repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
flynn/flynn
host/containerinit/init.go
changeState
func (c *ContainerInit) changeState(state State, err string, exitStatus int) { if err != "" { logger.Debug("changing state", "fn", "changeState", "state", state, "err", err) } else if exitStatus != -1 { logger.Debug("changing state", "fn", "changeState", "state", state, "exitStatus", exitStatus) } else { logger.Debug("changing state", "fn", "changeState", "state", state) } c.state = state c.error = err c.exitStatus = exitStatus c.streamsMtx.RLock() defer c.streamsMtx.RUnlock() for ch := range c.streams { ch <- StateChange{State: state, Error: err, ExitStatus: exitStatus} } }
go
func (c *ContainerInit) changeState(state State, err string, exitStatus int) { if err != "" { logger.Debug("changing state", "fn", "changeState", "state", state, "err", err) } else if exitStatus != -1 { logger.Debug("changing state", "fn", "changeState", "state", state, "exitStatus", exitStatus) } else { logger.Debug("changing state", "fn", "changeState", "state", state) } c.state = state c.error = err c.exitStatus = exitStatus c.streamsMtx.RLock() defer c.streamsMtx.RUnlock() for ch := range c.streams { ch <- StateChange{State: state, Error: err, ExitStatus: exitStatus} } }
[ "func", "(", "c", "*", "ContainerInit", ")", "changeState", "(", "state", "State", ",", "err", "string", ",", "exitStatus", "int", ")", "{", "if", "err", "!=", "\"\"", "{", "logger", ".", "Debug", "(", "\"changing state\"", ",", "\"fn\"", ",", "\"changeState\"", ",", "\"state\"", ",", "state", ",", "\"err\"", ",", "err", ")", "\n", "}", "else", "if", "exitStatus", "!=", "-", "1", "{", "logger", ".", "Debug", "(", "\"changing state\"", ",", "\"fn\"", ",", "\"changeState\"", ",", "\"state\"", ",", "state", ",", "\"exitStatus\"", ",", "exitStatus", ")", "\n", "}", "else", "{", "logger", ".", "Debug", "(", "\"changing state\"", ",", "\"fn\"", ",", "\"changeState\"", ",", "\"state\"", ",", "state", ")", "\n", "}", "\n", "c", ".", "state", "=", "state", "\n", "c", ".", "error", "=", "err", "\n", "c", ".", "exitStatus", "=", "exitStatus", "\n", "c", ".", "streamsMtx", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "streamsMtx", ".", "RUnlock", "(", ")", "\n", "for", "ch", ":=", "range", "c", ".", "streams", "{", "ch", "<-", "StateChange", "{", "State", ":", "state", ",", "Error", ":", "err", ",", "ExitStatus", ":", "exitStatus", "}", "\n", "}", "\n", "}" ]
// Caller must hold lock
[ "Caller", "must", "hold", "lock" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/containerinit/init.go#L314-L332
train
flynn/flynn
host/containerinit/init.go
debugStackPrinter
func debugStackPrinter(out io.Writer) { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR2) for range c { pprof.Lookup("goroutine").WriteTo(out, 1) } }
go
func debugStackPrinter(out io.Writer) { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR2) for range c { pprof.Lookup("goroutine").WriteTo(out, 1) } }
[ "func", "debugStackPrinter", "(", "out", "io", ".", "Writer", ")", "{", "c", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "c", ",", "syscall", ".", "SIGUSR2", ")", "\n", "for", "range", "c", "{", "pprof", ".", "Lookup", "(", "\"goroutine\"", ")", ".", "WriteTo", "(", "out", ",", "1", ")", "\n", "}", "\n", "}" ]
// print a full goroutine stack trace to the log fd on SIGUSR2
[ "print", "a", "full", "goroutine", "stack", "trace", "to", "the", "log", "fd", "on", "SIGUSR2" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/containerinit/init.go#L754-L760
train
flynn/flynn
host/containerinit/init.go
Main
func Main() { logR, logW, err := newSocketPair("log") if err != nil { os.Exit(70) } go debugStackPrinter(logW) config := &Config{} data, err := ioutil.ReadFile("/.containerconfig") if err != nil { os.Exit(70) } if err := json.Unmarshal(data, config); err != nil { os.Exit(70) } logger = log15.New("component", "containerinit") logger.SetHandler(log15.LvlFilterHandler(config.LogLevel, log15.StreamHandler(logW, log15.LogfmtFormat()))) // Propagate the plugin-specific container env variable config.Env["container"] = os.Getenv("container") if err := containerInitApp(config, logR); err != nil { os.Exit(70) } }
go
func Main() { logR, logW, err := newSocketPair("log") if err != nil { os.Exit(70) } go debugStackPrinter(logW) config := &Config{} data, err := ioutil.ReadFile("/.containerconfig") if err != nil { os.Exit(70) } if err := json.Unmarshal(data, config); err != nil { os.Exit(70) } logger = log15.New("component", "containerinit") logger.SetHandler(log15.LvlFilterHandler(config.LogLevel, log15.StreamHandler(logW, log15.LogfmtFormat()))) // Propagate the plugin-specific container env variable config.Env["container"] = os.Getenv("container") if err := containerInitApp(config, logR); err != nil { os.Exit(70) } }
[ "func", "Main", "(", ")", "{", "logR", ",", "logW", ",", "err", ":=", "newSocketPair", "(", "\"log\"", ")", "\n", "if", "err", "!=", "nil", "{", "os", ".", "Exit", "(", "70", ")", "\n", "}", "\n", "go", "debugStackPrinter", "(", "logW", ")", "\n", "config", ":=", "&", "Config", "{", "}", "\n", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "\"/.containerconfig\"", ")", "\n", "if", "err", "!=", "nil", "{", "os", ".", "Exit", "(", "70", ")", "\n", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "config", ")", ";", "err", "!=", "nil", "{", "os", ".", "Exit", "(", "70", ")", "\n", "}", "\n", "logger", "=", "log15", ".", "New", "(", "\"component\"", ",", "\"containerinit\"", ")", "\n", "logger", ".", "SetHandler", "(", "log15", ".", "LvlFilterHandler", "(", "config", ".", "LogLevel", ",", "log15", ".", "StreamHandler", "(", "logW", ",", "log15", ".", "LogfmtFormat", "(", ")", ")", ")", ")", "\n", "config", ".", "Env", "[", "\"container\"", "]", "=", "os", ".", "Getenv", "(", "\"container\"", ")", "\n", "if", "err", ":=", "containerInitApp", "(", "config", ",", "logR", ")", ";", "err", "!=", "nil", "{", "os", ".", "Exit", "(", "70", ")", "\n", "}", "\n", "}" ]
// This code is run INSIDE the container and is responsible for setting // up the environment before running the actual process
[ "This", "code", "is", "run", "INSIDE", "the", "container", "and", "is", "responsible", "for", "setting", "up", "the", "environment", "before", "running", "the", "actual", "process" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/containerinit/init.go#L764-L789
train
flynn/flynn
pkg/iptables/iptables.go
Exists
func Exists(args ...string) bool { if _, err := Raw(append([]string{"-C"}, args...)...); err != nil { return false } return true }
go
func Exists(args ...string) bool { if _, err := Raw(append([]string{"-C"}, args...)...); err != nil { return false } return true }
[ "func", "Exists", "(", "args", "...", "string", ")", "bool", "{", "if", "_", ",", "err", ":=", "Raw", "(", "append", "(", "[", "]", "string", "{", "\"-C\"", "}", ",", "args", "...", ")", "...", ")", ";", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Check if an existing rule exists
[ "Check", "if", "an", "existing", "rule", "exists" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/iptables/iptables.go#L66-L71
train
flynn/flynn
appliance/mongodb/cmd.go
NewCmd
func NewCmd(cmd *exec.Cmd) *Cmd { c := &Cmd{ Cmd: cmd, stopped: make(chan struct{}, 1), } c.stoppingValue.Store(false) c.Stdout = os.Stdout c.Stderr = os.Stderr return c }
go
func NewCmd(cmd *exec.Cmd) *Cmd { c := &Cmd{ Cmd: cmd, stopped: make(chan struct{}, 1), } c.stoppingValue.Store(false) c.Stdout = os.Stdout c.Stderr = os.Stderr return c }
[ "func", "NewCmd", "(", "cmd", "*", "exec", ".", "Cmd", ")", "*", "Cmd", "{", "c", ":=", "&", "Cmd", "{", "Cmd", ":", "cmd", ",", "stopped", ":", "make", "(", "chan", "struct", "{", "}", ",", "1", ")", ",", "}", "\n", "c", ".", "stoppingValue", ".", "Store", "(", "false", ")", "\n", "c", ".", "Stdout", "=", "os", ".", "Stdout", "\n", "c", ".", "Stderr", "=", "os", ".", "Stderr", "\n", "return", "c", "\n", "}" ]
// NewCmd returns a new instance of Cmd that wraps cmd.
[ "NewCmd", "returns", "a", "new", "instance", "of", "Cmd", "that", "wraps", "cmd", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L19-L28
train
flynn/flynn
appliance/mongodb/cmd.go
Start
func (cmd *Cmd) Start() error { if err := cmd.Cmd.Start(); err != nil { return err } go cmd.monitor() return nil }
go
func (cmd *Cmd) Start() error { if err := cmd.Cmd.Start(); err != nil { return err } go cmd.monitor() return nil }
[ "func", "(", "cmd", "*", "Cmd", ")", "Start", "(", ")", "error", "{", "if", "err", ":=", "cmd", ".", "Cmd", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "go", "cmd", ".", "monitor", "(", ")", "\n", "return", "nil", "\n", "}" ]
// Start executes the command.
[ "Start", "executes", "the", "command", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L31-L37
train
flynn/flynn
appliance/mongodb/cmd.go
Stop
func (cmd *Cmd) Stop() error { cmd.stoppingValue.Store(true) if err := cmd.Process.Signal(syscall.SIGKILL); err != nil { return err } return nil }
go
func (cmd *Cmd) Stop() error { cmd.stoppingValue.Store(true) if err := cmd.Process.Signal(syscall.SIGKILL); err != nil { return err } return nil }
[ "func", "(", "cmd", "*", "Cmd", ")", "Stop", "(", ")", "error", "{", "cmd", ".", "stoppingValue", ".", "Store", "(", "true", ")", "\n", "if", "err", ":=", "cmd", ".", "Process", ".", "Signal", "(", "syscall", ".", "SIGKILL", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Stop marks the command as expecting an exit and stops the underlying command.
[ "Stop", "marks", "the", "command", "as", "expecting", "an", "exit", "and", "stops", "the", "underlying", "command", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L40-L46
train
flynn/flynn
appliance/mongodb/cmd.go
monitor
func (cmd *Cmd) monitor() { err := cmd.Wait() if !cmd.stoppingValue.Load().(bool) { cmd.err = err } close(cmd.stopped) }
go
func (cmd *Cmd) monitor() { err := cmd.Wait() if !cmd.stoppingValue.Load().(bool) { cmd.err = err } close(cmd.stopped) }
[ "func", "(", "cmd", "*", "Cmd", ")", "monitor", "(", ")", "{", "err", ":=", "cmd", ".", "Wait", "(", ")", "\n", "if", "!", "cmd", ".", "stoppingValue", ".", "Load", "(", ")", ".", "(", "bool", ")", "{", "cmd", ".", "err", "=", "err", "\n", "}", "\n", "close", "(", "cmd", ".", "stopped", ")", "\n", "}" ]
// monitor checks for process exit and returns
[ "monitor", "checks", "for", "process", "exit", "and", "returns" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L56-L62
train
flynn/flynn
pkg/httpclient/json.go
Stream
func (c *Client) Stream(method, path string, in, out interface{}) (stream.Stream, error) { return c.StreamWithHeader(method, path, make(http.Header), in, out) }
go
func (c *Client) Stream(method, path string, in, out interface{}) (stream.Stream, error) { return c.StreamWithHeader(method, path, make(http.Header), in, out) }
[ "func", "(", "c", "*", "Client", ")", "Stream", "(", "method", ",", "path", "string", ",", "in", ",", "out", "interface", "{", "}", ")", "(", "stream", ".", "Stream", ",", "error", ")", "{", "return", "c", ".", "StreamWithHeader", "(", "method", ",", "path", ",", "make", "(", "http", ".", "Header", ")", ",", "in", ",", "out", ")", "\n", "}" ]
// Stream returns a stream.Stream for a specific method and path. in is an // optional json object to be sent to the server via the body, and out is a // required channel, to which the output will be streamed.
[ "Stream", "returns", "a", "stream", ".", "Stream", "for", "a", "specific", "method", "and", "path", ".", "in", "is", "an", "optional", "json", "object", "to", "be", "sent", "to", "the", "server", "via", "the", "body", "and", "out", "is", "a", "required", "channel", "to", "which", "the", "output", "will", "be", "streamed", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/httpclient/json.go#L222-L224
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextComponentName
func NewContextComponentName(ctx context.Context, componentName string) context.Context { return context.WithValue(ctx, ctxKeyComponent, componentName) }
go
func NewContextComponentName(ctx context.Context, componentName string) context.Context { return context.WithValue(ctx, ctxKeyComponent, componentName) }
[ "func", "NewContextComponentName", "(", "ctx", "context", ".", "Context", ",", "componentName", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyComponent", ",", "componentName", ")", "\n", "}" ]
// NewContextComponentName creates a new context that carries the provided // componentName value.
[ "NewContextComponentName", "creates", "a", "new", "context", "that", "carries", "the", "provided", "componentName", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L23-L25
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
ComponentNameFromContext
func ComponentNameFromContext(ctx context.Context) (componentName string, ok bool) { componentName, ok = ctx.Value(ctxKeyComponent).(string) return }
go
func ComponentNameFromContext(ctx context.Context) (componentName string, ok bool) { componentName, ok = ctx.Value(ctxKeyComponent).(string) return }
[ "func", "ComponentNameFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "componentName", "string", ",", "ok", "bool", ")", "{", "componentName", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyComponent", ")", ".", "(", "string", ")", "\n", "return", "\n", "}" ]
// ComponentNameFromContext extracts a component name from a context.
[ "ComponentNameFromContext", "extracts", "a", "component", "name", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L28-L31
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextLogger
func NewContextLogger(ctx context.Context, logger log.Logger) context.Context { return context.WithValue(ctx, ctxKeyLogger, logger) }
go
func NewContextLogger(ctx context.Context, logger log.Logger) context.Context { return context.WithValue(ctx, ctxKeyLogger, logger) }
[ "func", "NewContextLogger", "(", "ctx", "context", ".", "Context", ",", "logger", "log", ".", "Logger", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyLogger", ",", "logger", ")", "\n", "}" ]
// NewContextLogger creates a new context that carries the provided logger // value.
[ "NewContextLogger", "creates", "a", "new", "context", "that", "carries", "the", "provided", "logger", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L35-L37
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
LoggerFromContext
func LoggerFromContext(ctx context.Context) (logger log.Logger, ok bool) { logger, ok = ctx.Value(ctxKeyLogger).(log.Logger) return }
go
func LoggerFromContext(ctx context.Context) (logger log.Logger, ok bool) { logger, ok = ctx.Value(ctxKeyLogger).(log.Logger) return }
[ "func", "LoggerFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "logger", "log", ".", "Logger", ",", "ok", "bool", ")", "{", "logger", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyLogger", ")", ".", "(", "log", ".", "Logger", ")", "\n", "return", "\n", "}" ]
// LoggerFromContext extracts a logger from a context.
[ "LoggerFromContext", "extracts", "a", "logger", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L40-L43
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextParams
func NewContextParams(ctx context.Context, params httprouter.Params) context.Context { return context.WithValue(ctx, ctxKeyParams, params) }
go
func NewContextParams(ctx context.Context, params httprouter.Params) context.Context { return context.WithValue(ctx, ctxKeyParams, params) }
[ "func", "NewContextParams", "(", "ctx", "context", ".", "Context", ",", "params", "httprouter", ".", "Params", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyParams", ",", "params", ")", "\n", "}" ]
// NewContextParams creates a new context that carries the provided params // value.
[ "NewContextParams", "creates", "a", "new", "context", "that", "carries", "the", "provided", "params", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L47-L49
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
ParamsFromContext
func ParamsFromContext(ctx context.Context) (params httprouter.Params, ok bool) { params, ok = ctx.Value(ctxKeyParams).(httprouter.Params) return }
go
func ParamsFromContext(ctx context.Context) (params httprouter.Params, ok bool) { params, ok = ctx.Value(ctxKeyParams).(httprouter.Params) return }
[ "func", "ParamsFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "params", "httprouter", ".", "Params", ",", "ok", "bool", ")", "{", "params", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyParams", ")", ".", "(", "httprouter", ".", "Params", ")", "\n", "return", "\n", "}" ]
// ParamsFromContext extracts params from a context.
[ "ParamsFromContext", "extracts", "params", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L52-L55
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextRequestID
func NewContextRequestID(ctx context.Context, id string) context.Context { return context.WithValue(ctx, ctxKeyReqID, id) }
go
func NewContextRequestID(ctx context.Context, id string) context.Context { return context.WithValue(ctx, ctxKeyReqID, id) }
[ "func", "NewContextRequestID", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyReqID", ",", "id", ")", "\n", "}" ]
// NewContextRequestID creates a new context that carries the provided request // ID value.
[ "NewContextRequestID", "creates", "a", "new", "context", "that", "carries", "the", "provided", "request", "ID", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L59-L61
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
RequestIDFromContext
func RequestIDFromContext(ctx context.Context) (id string, ok bool) { id, ok = ctx.Value(ctxKeyReqID).(string) return }
go
func RequestIDFromContext(ctx context.Context) (id string, ok bool) { id, ok = ctx.Value(ctxKeyReqID).(string) return }
[ "func", "RequestIDFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "id", "string", ",", "ok", "bool", ")", "{", "id", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyReqID", ")", ".", "(", "string", ")", "\n", "return", "\n", "}" ]
// RequestIDFromContext extracts a request ID from a context.
[ "RequestIDFromContext", "extracts", "a", "request", "ID", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L64-L67
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextStartTime
func NewContextStartTime(ctx context.Context, start time.Time) context.Context { return context.WithValue(ctx, ctxKeyStartTime, start) }
go
func NewContextStartTime(ctx context.Context, start time.Time) context.Context { return context.WithValue(ctx, ctxKeyStartTime, start) }
[ "func", "NewContextStartTime", "(", "ctx", "context", ".", "Context", ",", "start", "time", ".", "Time", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyStartTime", ",", "start", ")", "\n", "}" ]
// NewContextStartTime creates a new context that carries the provided start // time.
[ "NewContextStartTime", "creates", "a", "new", "context", "that", "carries", "the", "provided", "start", "time", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L71-L73
train
flynn/flynn
pkg/ctxhelper/ctxhelper.go
StartTimeFromContext
func StartTimeFromContext(ctx context.Context) (start time.Time, ok bool) { start, ok = ctx.Value(ctxKeyStartTime).(time.Time) return }
go
func StartTimeFromContext(ctx context.Context) (start time.Time, ok bool) { start, ok = ctx.Value(ctxKeyStartTime).(time.Time) return }
[ "func", "StartTimeFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "start", "time", ".", "Time", ",", "ok", "bool", ")", "{", "start", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyStartTime", ")", ".", "(", "time", ".", "Time", ")", "\n", "return", "\n", "}" ]
// StartTimeFromContext extracts a start time from a context.
[ "StartTimeFromContext", "extracts", "a", "start", "time", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L76-L79
train
flynn/flynn
controller/sink.go
CreateSink
func (c *controllerAPI) CreateSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { var sink ct.Sink if err := httphelper.DecodeJSON(req, &sink); err != nil { respondWithError(w, err) return } if err := schema.Validate(&sink); err != nil { respondWithError(w, err) return } if err := c.sinkRepo.Add(&sink); err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, &sink) }
go
func (c *controllerAPI) CreateSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { var sink ct.Sink if err := httphelper.DecodeJSON(req, &sink); err != nil { respondWithError(w, err) return } if err := schema.Validate(&sink); err != nil { respondWithError(w, err) return } if err := c.sinkRepo.Add(&sink); err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, &sink) }
[ "func", "(", "c", "*", "controllerAPI", ")", "CreateSink", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "var", "sink", "ct", ".", "Sink", "\n", "if", "err", ":=", "httphelper", ".", "DecodeJSON", "(", "req", ",", "&", "sink", ")", ";", "err", "!=", "nil", "{", "respondWithError", "(", "w", ",", "err", ")", "\n", "return", "\n", "}", "\n", "if", "err", ":=", "schema", ".", "Validate", "(", "&", "sink", ")", ";", "err", "!=", "nil", "{", "respondWithError", "(", "w", ",", "err", ")", "\n", "return", "\n", "}", "\n", "if", "err", ":=", "c", ".", "sinkRepo", ".", "Add", "(", "&", "sink", ")", ";", "err", "!=", "nil", "{", "respondWithError", "(", "w", ",", "err", ")", "\n", "return", "\n", "}", "\n", "httphelper", ".", "JSON", "(", "w", ",", "200", ",", "&", "sink", ")", "\n", "}" ]
// Create a new sink
[ "Create", "a", "new", "sink" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/sink.go#L132-L149
train
flynn/flynn
controller/sink.go
GetSink
func (c *controllerAPI) GetSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sink, err := c.sinkRepo.Get(params.ByName("sink_id")) if err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, sink) }
go
func (c *controllerAPI) GetSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sink, err := c.sinkRepo.Get(params.ByName("sink_id")) if err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, sink) }
[ "func", "(", "c", "*", "controllerAPI", ")", "GetSink", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "params", ",", "_", ":=", "ctxhelper", ".", "ParamsFromContext", "(", "ctx", ")", "\n", "sink", ",", "err", ":=", "c", ".", "sinkRepo", ".", "Get", "(", "params", ".", "ByName", "(", "\"sink_id\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "respondWithError", "(", "w", ",", "err", ")", "\n", "return", "\n", "}", "\n", "httphelper", ".", "JSON", "(", "w", ",", "200", ",", "sink", ")", "\n", "}" ]
// Get a sink
[ "Get", "a", "sink" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/sink.go#L152-L162
train
flynn/flynn
controller/sink.go
DeleteSink
func (c *controllerAPI) DeleteSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sinkID := params.ByName("sink_id") sink, err := c.sinkRepo.Get(sinkID) if err != nil { respondWithError(w, err) return } if err = c.sinkRepo.Remove(sinkID); err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, sink) }
go
func (c *controllerAPI) DeleteSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sinkID := params.ByName("sink_id") sink, err := c.sinkRepo.Get(sinkID) if err != nil { respondWithError(w, err) return } if err = c.sinkRepo.Remove(sinkID); err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, sink) }
[ "func", "(", "c", "*", "controllerAPI", ")", "DeleteSink", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "params", ",", "_", ":=", "ctxhelper", ".", "ParamsFromContext", "(", "ctx", ")", "\n", "sinkID", ":=", "params", ".", "ByName", "(", "\"sink_id\"", ")", "\n", "sink", ",", "err", ":=", "c", ".", "sinkRepo", ".", "Get", "(", "sinkID", ")", "\n", "if", "err", "!=", "nil", "{", "respondWithError", "(", "w", ",", "err", ")", "\n", "return", "\n", "}", "\n", "if", "err", "=", "c", ".", "sinkRepo", ".", "Remove", "(", "sinkID", ")", ";", "err", "!=", "nil", "{", "respondWithError", "(", "w", ",", "err", ")", "\n", "return", "\n", "}", "\n", "httphelper", ".", "JSON", "(", "w", ",", "200", ",", "sink", ")", "\n", "}" ]
// Delete a sink
[ "Delete", "a", "sink" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/sink.go#L261-L277
train
flynn/flynn
util/release/types/manifest.go
Add
func (m *EC2Manifest) Add(version string, image *EC2Image) { versions := make(sortVersions, 0, len(m.Versions)+1) for _, v := range m.Versions { if v.version() == version { images := make([]*EC2Image, len(v.Images)) added := false for n, i := range v.Images { if i.Region == image.Region { // replace existing image images[n] = image added = true continue } images[n] = i } if !added { images = append(images, image) } v.Images = images return } versions = append(versions, v) } versions = append(versions, &EC2Version{ Version: version, Images: []*EC2Image{image}, }) sort.Sort(sort.Reverse(versions)) m.Versions = make([]*EC2Version, 0, maxVersions) for i := 0; i < len(versions) && i < maxVersions; i++ { m.Versions = append(m.Versions, versions[i].(*EC2Version)) } }
go
func (m *EC2Manifest) Add(version string, image *EC2Image) { versions := make(sortVersions, 0, len(m.Versions)+1) for _, v := range m.Versions { if v.version() == version { images := make([]*EC2Image, len(v.Images)) added := false for n, i := range v.Images { if i.Region == image.Region { // replace existing image images[n] = image added = true continue } images[n] = i } if !added { images = append(images, image) } v.Images = images return } versions = append(versions, v) } versions = append(versions, &EC2Version{ Version: version, Images: []*EC2Image{image}, }) sort.Sort(sort.Reverse(versions)) m.Versions = make([]*EC2Version, 0, maxVersions) for i := 0; i < len(versions) && i < maxVersions; i++ { m.Versions = append(m.Versions, versions[i].(*EC2Version)) } }
[ "func", "(", "m", "*", "EC2Manifest", ")", "Add", "(", "version", "string", ",", "image", "*", "EC2Image", ")", "{", "versions", ":=", "make", "(", "sortVersions", ",", "0", ",", "len", "(", "m", ".", "Versions", ")", "+", "1", ")", "\n", "for", "_", ",", "v", ":=", "range", "m", ".", "Versions", "{", "if", "v", ".", "version", "(", ")", "==", "version", "{", "images", ":=", "make", "(", "[", "]", "*", "EC2Image", ",", "len", "(", "v", ".", "Images", ")", ")", "\n", "added", ":=", "false", "\n", "for", "n", ",", "i", ":=", "range", "v", ".", "Images", "{", "if", "i", ".", "Region", "==", "image", ".", "Region", "{", "images", "[", "n", "]", "=", "image", "\n", "added", "=", "true", "\n", "continue", "\n", "}", "\n", "images", "[", "n", "]", "=", "i", "\n", "}", "\n", "if", "!", "added", "{", "images", "=", "append", "(", "images", ",", "image", ")", "\n", "}", "\n", "v", ".", "Images", "=", "images", "\n", "return", "\n", "}", "\n", "versions", "=", "append", "(", "versions", ",", "v", ")", "\n", "}", "\n", "versions", "=", "append", "(", "versions", ",", "&", "EC2Version", "{", "Version", ":", "version", ",", "Images", ":", "[", "]", "*", "EC2Image", "{", "image", "}", ",", "}", ")", "\n", "sort", ".", "Sort", "(", "sort", ".", "Reverse", "(", "versions", ")", ")", "\n", "m", ".", "Versions", "=", "make", "(", "[", "]", "*", "EC2Version", ",", "0", ",", "maxVersions", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "versions", ")", "&&", "i", "<", "maxVersions", ";", "i", "++", "{", "m", ".", "Versions", "=", "append", "(", "m", ".", "Versions", ",", "versions", "[", "i", "]", ".", "(", "*", "EC2Version", ")", ")", "\n", "}", "\n", "}" ]
// Add adds an image to the manifest. // // If the version is already in the manifest, the given image either // replaces any existing image with the same region, or is appended to // the existing list of images for that version. // // If the version is not already in the manifest a new version is added // containing the image. // // The number of versions in the manifest is capped at the value of maxVersions.
[ "Add", "adds", "an", "image", "to", "the", "manifest", ".", "If", "the", "version", "is", "already", "in", "the", "manifest", "the", "given", "image", "either", "replaces", "any", "existing", "image", "with", "the", "same", "region", "or", "is", "appended", "to", "the", "existing", "list", "of", "images", "for", "that", "version", ".", "If", "the", "version", "is", "not", "already", "in", "the", "manifest", "a", "new", "version", "is", "added", "containing", "the", "image", ".", "The", "number", "of", "versions", "in", "the", "manifest", "is", "capped", "at", "the", "value", "of", "maxVersions", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/util/release/types/manifest.go#L26-L58
train
flynn/flynn
util/release/types/manifest.go
Add
func (m *VagrantManifest) Add(version string, provider *VagrantProvider) { // strip the leading "v" from the version as Vagrant only supports // versions like X.Y.Z, see https://github.com/flynn/flynn/issues/2230 version = strings.TrimPrefix(version, "v") versions := make(sortVersions, 0, len(m.Versions)+1) for _, v := range m.Versions { if v.version() == version { providers := make([]*VagrantProvider, len(v.Providers)) added := false for i, p := range v.Providers { if p.Name == provider.Name { // replace existing provider providers[i] = provider added = true continue } providers[i] = p } if !added { providers = append(providers, provider) } v.Providers = providers return } versions = append(versions, v) } versions = append(versions, &VagrantVersion{ Version: version, Providers: []*VagrantProvider{provider}, }) sort.Sort(sort.Reverse(versions)) m.Versions = make([]*VagrantVersion, 0, maxVersions) for i := 0; i < len(versions) && i < maxVersions; i++ { m.Versions = append(m.Versions, versions[i].(*VagrantVersion)) } }
go
func (m *VagrantManifest) Add(version string, provider *VagrantProvider) { // strip the leading "v" from the version as Vagrant only supports // versions like X.Y.Z, see https://github.com/flynn/flynn/issues/2230 version = strings.TrimPrefix(version, "v") versions := make(sortVersions, 0, len(m.Versions)+1) for _, v := range m.Versions { if v.version() == version { providers := make([]*VagrantProvider, len(v.Providers)) added := false for i, p := range v.Providers { if p.Name == provider.Name { // replace existing provider providers[i] = provider added = true continue } providers[i] = p } if !added { providers = append(providers, provider) } v.Providers = providers return } versions = append(versions, v) } versions = append(versions, &VagrantVersion{ Version: version, Providers: []*VagrantProvider{provider}, }) sort.Sort(sort.Reverse(versions)) m.Versions = make([]*VagrantVersion, 0, maxVersions) for i := 0; i < len(versions) && i < maxVersions; i++ { m.Versions = append(m.Versions, versions[i].(*VagrantVersion)) } }
[ "func", "(", "m", "*", "VagrantManifest", ")", "Add", "(", "version", "string", ",", "provider", "*", "VagrantProvider", ")", "{", "version", "=", "strings", ".", "TrimPrefix", "(", "version", ",", "\"v\"", ")", "\n", "versions", ":=", "make", "(", "sortVersions", ",", "0", ",", "len", "(", "m", ".", "Versions", ")", "+", "1", ")", "\n", "for", "_", ",", "v", ":=", "range", "m", ".", "Versions", "{", "if", "v", ".", "version", "(", ")", "==", "version", "{", "providers", ":=", "make", "(", "[", "]", "*", "VagrantProvider", ",", "len", "(", "v", ".", "Providers", ")", ")", "\n", "added", ":=", "false", "\n", "for", "i", ",", "p", ":=", "range", "v", ".", "Providers", "{", "if", "p", ".", "Name", "==", "provider", ".", "Name", "{", "providers", "[", "i", "]", "=", "provider", "\n", "added", "=", "true", "\n", "continue", "\n", "}", "\n", "providers", "[", "i", "]", "=", "p", "\n", "}", "\n", "if", "!", "added", "{", "providers", "=", "append", "(", "providers", ",", "provider", ")", "\n", "}", "\n", "v", ".", "Providers", "=", "providers", "\n", "return", "\n", "}", "\n", "versions", "=", "append", "(", "versions", ",", "v", ")", "\n", "}", "\n", "versions", "=", "append", "(", "versions", ",", "&", "VagrantVersion", "{", "Version", ":", "version", ",", "Providers", ":", "[", "]", "*", "VagrantProvider", "{", "provider", "}", ",", "}", ")", "\n", "sort", ".", "Sort", "(", "sort", ".", "Reverse", "(", "versions", ")", ")", "\n", "m", ".", "Versions", "=", "make", "(", "[", "]", "*", "VagrantVersion", ",", "0", ",", "maxVersions", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "versions", ")", "&&", "i", "<", "maxVersions", ";", "i", "++", "{", "m", ".", "Versions", "=", "append", "(", "m", ".", "Versions", ",", "versions", "[", "i", "]", ".", "(", "*", "VagrantVersion", ")", ")", "\n", "}", "\n", "}" ]
// Add adds a provider to the manifest. // // If the version is already in the manifest, the given provider either // replaces any existing provider with the same name, or is appended to // the existing list of providers for that version. // // If the version is not already in the manifest a new version is added // containing the provider. // // The number of versions in the manifest is capped at the value of maxVersions.
[ "Add", "adds", "a", "provider", "to", "the", "manifest", ".", "If", "the", "version", "is", "already", "in", "the", "manifest", "the", "given", "provider", "either", "replaces", "any", "existing", "provider", "with", "the", "same", "name", "or", "is", "appended", "to", "the", "existing", "list", "of", "providers", "for", "that", "version", ".", "If", "the", "version", "is", "not", "already", "in", "the", "manifest", "a", "new", "version", "is", "added", "containing", "the", "provider", ".", "The", "number", "of", "versions", "in", "the", "manifest", "is", "capped", "at", "the", "value", "of", "maxVersions", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/util/release/types/manifest.go#L114-L150
train
flynn/flynn
pkg/mux/mux.go
New
func New(ln net.Listener) *Mux { return &Mux{ ln: ln, handlers: make(map[byte]*handler), Timeout: 30 * time.Second, LogOutput: os.Stderr, } }
go
func New(ln net.Listener) *Mux { return &Mux{ ln: ln, handlers: make(map[byte]*handler), Timeout: 30 * time.Second, LogOutput: os.Stderr, } }
[ "func", "New", "(", "ln", "net", ".", "Listener", ")", "*", "Mux", "{", "return", "&", "Mux", "{", "ln", ":", "ln", ",", "handlers", ":", "make", "(", "map", "[", "byte", "]", "*", "handler", ")", ",", "Timeout", ":", "30", "*", "time", ".", "Second", ",", "LogOutput", ":", "os", ".", "Stderr", ",", "}", "\n", "}" ]
// New returns a new instance of Mux.
[ "New", "returns", "a", "new", "instance", "of", "Mux", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L29-L36
train
flynn/flynn
pkg/mux/mux.go
Close
func (mux *Mux) Close() (err error) { mux.once.Do(func() { // Close underlying listener. if mux.ln != nil { err = mux.ln.Close() } // Wait for open connections to close and then close handlers. mux.wg.Wait() for _, h := range mux.handlers { h.Close() } }) return }
go
func (mux *Mux) Close() (err error) { mux.once.Do(func() { // Close underlying listener. if mux.ln != nil { err = mux.ln.Close() } // Wait for open connections to close and then close handlers. mux.wg.Wait() for _, h := range mux.handlers { h.Close() } }) return }
[ "func", "(", "mux", "*", "Mux", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "mux", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "if", "mux", ".", "ln", "!=", "nil", "{", "err", "=", "mux", ".", "ln", ".", "Close", "(", ")", "\n", "}", "\n", "mux", ".", "wg", ".", "Wait", "(", ")", "\n", "for", "_", ",", "h", ":=", "range", "mux", ".", "handlers", "{", "h", ".", "Close", "(", ")", "\n", "}", "\n", "}", ")", "\n", "return", "\n", "}" ]
// Close closes the underlying listener.
[ "Close", "closes", "the", "underlying", "listener", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L39-L53
train
flynn/flynn
pkg/mux/mux.go
Serve
func (mux *Mux) Serve() error { logger := log.New(mux.LogOutput, "", log.LstdFlags) for { // Handle incoming connections. Retry temporary errors. conn, err := mux.ln.Accept() if err, ok := err.(interface { Temporary() bool }); ok && err.Temporary() { logger.Printf("tcp.Mux: temporary error: %s", err) continue } // Other errors should close the muxer and wait for outstanding conns. if err != nil { mux.Close() return err } // Hand off connection to a separate goroutine. mux.wg.Add(1) go func(conn net.Conn) { defer mux.wg.Done() if err := mux.handleConn(conn); err != nil { conn.Close() logger.Printf("tcp.Mux: %s", err) } }(conn) } }
go
func (mux *Mux) Serve() error { logger := log.New(mux.LogOutput, "", log.LstdFlags) for { // Handle incoming connections. Retry temporary errors. conn, err := mux.ln.Accept() if err, ok := err.(interface { Temporary() bool }); ok && err.Temporary() { logger.Printf("tcp.Mux: temporary error: %s", err) continue } // Other errors should close the muxer and wait for outstanding conns. if err != nil { mux.Close() return err } // Hand off connection to a separate goroutine. mux.wg.Add(1) go func(conn net.Conn) { defer mux.wg.Done() if err := mux.handleConn(conn); err != nil { conn.Close() logger.Printf("tcp.Mux: %s", err) } }(conn) } }
[ "func", "(", "mux", "*", "Mux", ")", "Serve", "(", ")", "error", "{", "logger", ":=", "log", ".", "New", "(", "mux", ".", "LogOutput", ",", "\"\"", ",", "log", ".", "LstdFlags", ")", "\n", "for", "{", "conn", ",", "err", ":=", "mux", ".", "ln", ".", "Accept", "(", ")", "\n", "if", "err", ",", "ok", ":=", "err", ".", "(", "interface", "{", "Temporary", "(", ")", "bool", "\n", "}", ")", ";", "ok", "&&", "err", ".", "Temporary", "(", ")", "{", "logger", ".", "Printf", "(", "\"tcp.Mux: temporary error: %s\"", ",", "err", ")", "\n", "continue", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "mux", ".", "Close", "(", ")", "\n", "return", "err", "\n", "}", "\n", "mux", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", "conn", "net", ".", "Conn", ")", "{", "defer", "mux", ".", "wg", ".", "Done", "(", ")", "\n", "if", "err", ":=", "mux", ".", "handleConn", "(", "conn", ")", ";", "err", "!=", "nil", "{", "conn", ".", "Close", "(", ")", "\n", "logger", ".", "Printf", "(", "\"tcp.Mux: %s\"", ",", "err", ")", "\n", "}", "\n", "}", "(", "conn", ")", "\n", "}", "\n", "}" ]
// Serve handles connections from ln and multiplexes then across registered listener.
[ "Serve", "handles", "connections", "from", "ln", "and", "multiplexes", "then", "across", "registered", "listener", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L56-L85
train
flynn/flynn
pkg/mux/mux.go
Listen
func (mux *Mux) Listen(hdrs []byte) net.Listener { // Create new handler. h := mux.handler() // Register each header byte. for _, hdr := range hdrs { // Create a new listener and assign it. mux.handlers[hdr] = h } return h }
go
func (mux *Mux) Listen(hdrs []byte) net.Listener { // Create new handler. h := mux.handler() // Register each header byte. for _, hdr := range hdrs { // Create a new listener and assign it. mux.handlers[hdr] = h } return h }
[ "func", "(", "mux", "*", "Mux", ")", "Listen", "(", "hdrs", "[", "]", "byte", ")", "net", ".", "Listener", "{", "h", ":=", "mux", ".", "handler", "(", ")", "\n", "for", "_", ",", "hdr", ":=", "range", "hdrs", "{", "mux", ".", "handlers", "[", "hdr", "]", "=", "h", "\n", "}", "\n", "return", "h", "\n", "}" ]
// Listen returns a listener that receives connections from any byte in hdrs. // Re-registering hdr bytes will overwrite existing handlers.
[ "Listen", "returns", "a", "listener", "that", "receives", "connections", "from", "any", "byte", "in", "hdrs", ".", "Re", "-", "registering", "hdr", "bytes", "will", "overwrite", "existing", "handlers", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L122-L133
train
flynn/flynn
pkg/mux/mux.go
handler
func (mux *Mux) handler() *handler { return &handler{ mux: mux, c: make(chan net.Conn), } }
go
func (mux *Mux) handler() *handler { return &handler{ mux: mux, c: make(chan net.Conn), } }
[ "func", "(", "mux", "*", "Mux", ")", "handler", "(", ")", "*", "handler", "{", "return", "&", "handler", "{", "mux", ":", "mux", ",", "c", ":", "make", "(", "chan", "net", ".", "Conn", ")", ",", "}", "\n", "}" ]
// handler returns a new instance of handler.
[ "handler", "returns", "a", "new", "instance", "of", "handler", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L136-L141
train
flynn/flynn
pkg/mux/mux.go
Accept
func (h *handler) Accept() (c net.Conn, err error) { conn, ok := <-h.c if !ok { return nil, errors.New("network connection closed") } return conn, nil }
go
func (h *handler) Accept() (c net.Conn, err error) { conn, ok := <-h.c if !ok { return nil, errors.New("network connection closed") } return conn, nil }
[ "func", "(", "h", "*", "handler", ")", "Accept", "(", ")", "(", "c", "net", ".", "Conn", ",", "err", "error", ")", "{", "conn", ",", "ok", ":=", "<-", "h", ".", "c", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"network connection closed\"", ")", "\n", "}", "\n", "return", "conn", ",", "nil", "\n", "}" ]
// Accept waits for and returns the next connection.
[ "Accept", "waits", "for", "and", "returns", "the", "next", "connection", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L151-L157
train
flynn/flynn
pkg/mux/mux.go
Close
func (h *handler) Close() error { h.once.Do(func() { close(h.c) }) return nil }
go
func (h *handler) Close() error { h.once.Do(func() { close(h.c) }) return nil }
[ "func", "(", "h", "*", "handler", ")", "Close", "(", ")", "error", "{", "h", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "close", "(", "h", ".", "c", ")", "}", ")", "\n", "return", "nil", "\n", "}" ]
// Close closes the original listener.
[ "Close", "closes", "the", "original", "listener", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L160-L163
train
flynn/flynn
pkg/mux/mux.go
newBufConn
func newBufConn(conn net.Conn) *bufConn { return &bufConn{ conn: conn, r: bufio.NewReader(conn), } }
go
func newBufConn(conn net.Conn) *bufConn { return &bufConn{ conn: conn, r: bufio.NewReader(conn), } }
[ "func", "newBufConn", "(", "conn", "net", ".", "Conn", ")", "*", "bufConn", "{", "return", "&", "bufConn", "{", "conn", ":", "conn", ",", "r", ":", "bufio", ".", "NewReader", "(", "conn", ")", ",", "}", "\n", "}" ]
// newBufConn returns a new instance of bufConn.
[ "newBufConn", "returns", "a", "new", "instance", "of", "bufConn", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L175-L180
train
flynn/flynn
controller/worker/deployment/discoverd_meta.go
deployDiscoverdMeta
func (d *DeployJob) deployDiscoverdMeta() (err error) { log := d.logger.New("fn", "deployDiscoverdMeta") log.Info("starting discoverd-meta deployment") defer func() { if err != nil { // TODO: support rolling back err = ErrSkipRollback{err.Error()} } }() for typ, count := range d.Processes { proc := d.newRelease.Processes[typ] if proc.Service == "" { if err := d.scaleOneByOne(typ, log); err != nil { return err } continue } discDeploy, err := dd.NewDeployment(proc.Service) if err != nil { return err } if err := discDeploy.Create(d.ID); err != nil { return err } defer discDeploy.Close() for i := 0; i < count; i++ { if err := d.scaleNewFormationUpByOne(typ, log); err != nil { return err } if err := discDeploy.Wait(d.ID, d.timeout, log); err != nil { return err } if err := d.scaleOldFormationDownByOne(typ, log); err != nil { return err } } } return nil }
go
func (d *DeployJob) deployDiscoverdMeta() (err error) { log := d.logger.New("fn", "deployDiscoverdMeta") log.Info("starting discoverd-meta deployment") defer func() { if err != nil { // TODO: support rolling back err = ErrSkipRollback{err.Error()} } }() for typ, count := range d.Processes { proc := d.newRelease.Processes[typ] if proc.Service == "" { if err := d.scaleOneByOne(typ, log); err != nil { return err } continue } discDeploy, err := dd.NewDeployment(proc.Service) if err != nil { return err } if err := discDeploy.Create(d.ID); err != nil { return err } defer discDeploy.Close() for i := 0; i < count; i++ { if err := d.scaleNewFormationUpByOne(typ, log); err != nil { return err } if err := discDeploy.Wait(d.ID, d.timeout, log); err != nil { return err } if err := d.scaleOldFormationDownByOne(typ, log); err != nil { return err } } } return nil }
[ "func", "(", "d", "*", "DeployJob", ")", "deployDiscoverdMeta", "(", ")", "(", "err", "error", ")", "{", "log", ":=", "d", ".", "logger", ".", "New", "(", "\"fn\"", ",", "\"deployDiscoverdMeta\"", ")", "\n", "log", ".", "Info", "(", "\"starting discoverd-meta deployment\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "err", "=", "ErrSkipRollback", "{", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n", "}", "(", ")", "\n", "for", "typ", ",", "count", ":=", "range", "d", ".", "Processes", "{", "proc", ":=", "d", ".", "newRelease", ".", "Processes", "[", "typ", "]", "\n", "if", "proc", ".", "Service", "==", "\"\"", "{", "if", "err", ":=", "d", ".", "scaleOneByOne", "(", "typ", ",", "log", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "continue", "\n", "}", "\n", "discDeploy", ",", "err", ":=", "dd", ".", "NewDeployment", "(", "proc", ".", "Service", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "discDeploy", ".", "Create", "(", "d", ".", "ID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "discDeploy", ".", "Close", "(", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "count", ";", "i", "++", "{", "if", "err", ":=", "d", ".", "scaleNewFormationUpByOne", "(", "typ", ",", "log", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "discDeploy", ".", "Wait", "(", "d", ".", "ID", ",", "d", ".", "timeout", ",", "log", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "d", ".", "scaleOldFormationDownByOne", "(", "typ", ",", "log", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// deployDiscoverMeta does a one-by-one deployment but uses discoverd.Deployment // to wait for appropriate service metadata before stopping old jobs.
[ "deployDiscoverMeta", "does", "a", "one", "-", "by", "-", "one", "deployment", "but", "uses", "discoverd", ".", "Deployment", "to", "wait", "for", "appropriate", "service", "metadata", "before", "stopping", "old", "jobs", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/worker/deployment/discoverd_meta.go#L7-L50
train
flynn/flynn
logaggregator/client/client.go
NewWithHTTP
func NewWithHTTP(uri string, httpClient *http.Client) (*Client, error) { if uri == "" { uri = "http://logaggregator.discoverd" } u, err := url.Parse(uri) if err != nil { return nil, err } return newClient(u.String(), httpClient), nil }
go
func NewWithHTTP(uri string, httpClient *http.Client) (*Client, error) { if uri == "" { uri = "http://logaggregator.discoverd" } u, err := url.Parse(uri) if err != nil { return nil, err } return newClient(u.String(), httpClient), nil }
[ "func", "NewWithHTTP", "(", "uri", "string", ",", "httpClient", "*", "http", ".", "Client", ")", "(", "*", "Client", ",", "error", ")", "{", "if", "uri", "==", "\"\"", "{", "uri", "=", "\"http://logaggregator.discoverd\"", "\n", "}", "\n", "u", ",", "err", ":=", "url", ".", "Parse", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newClient", "(", "u", ".", "String", "(", ")", ",", "httpClient", ")", ",", "nil", "\n", "}" ]
// NewClient creates a new Client pointing at uri with the specified http client.
[ "NewClient", "creates", "a", "new", "Client", "pointing", "at", "uri", "with", "the", "specified", "http", "client", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/client/client.go#L42-L51
train
flynn/flynn
pkg/rpcplus/jsonrpc/client.go
NewClientCodec
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec { return &clientCodec{ dec: json.NewDecoder(conn), enc: json.NewEncoder(conn), c: conn, pending: make(map[uint64]string), } }
go
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec { return &clientCodec{ dec: json.NewDecoder(conn), enc: json.NewEncoder(conn), c: conn, pending: make(map[uint64]string), } }
[ "func", "NewClientCodec", "(", "conn", "io", ".", "ReadWriteCloser", ")", "rpc", ".", "ClientCodec", "{", "return", "&", "clientCodec", "{", "dec", ":", "json", ".", "NewDecoder", "(", "conn", ")", ",", "enc", ":", "json", ".", "NewEncoder", "(", "conn", ")", ",", "c", ":", "conn", ",", "pending", ":", "make", "(", "map", "[", "uint64", "]", "string", ")", ",", "}", "\n", "}" ]
// NewClientCodec returns a new rpc.ClientCodec using JSON-RPC on conn.
[ "NewClientCodec", "returns", "a", "new", "rpc", ".", "ClientCodec", "using", "JSON", "-", "RPC", "on", "conn", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/jsonrpc/client.go#L37-L44
train
flynn/flynn
pkg/rpcplus/jsonrpc/client.go
NewClient
func NewClient(conn io.ReadWriteCloser) *rpc.Client { return rpc.NewClientWithCodec(NewClientCodec(conn)) }
go
func NewClient(conn io.ReadWriteCloser) *rpc.Client { return rpc.NewClientWithCodec(NewClientCodec(conn)) }
[ "func", "NewClient", "(", "conn", "io", ".", "ReadWriteCloser", ")", "*", "rpc", ".", "Client", "{", "return", "rpc", ".", "NewClientWithCodec", "(", "NewClientCodec", "(", "conn", ")", ")", "\n", "}" ]
// NewClient returns a new rpc.Client to handle requests to the // set of services at the other end of the connection.
[ "NewClient", "returns", "a", "new", "rpc", ".", "Client", "to", "handle", "requests", "to", "the", "set", "of", "services", "at", "the", "other", "end", "of", "the", "connection", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/jsonrpc/client.go#L113-L115
train
flynn/flynn
controller/types/types.go
Critical
func (a *App) Critical() bool { v, ok := a.Meta["flynn-system-critical"] return ok && v == "true" }
go
func (a *App) Critical() bool { v, ok := a.Meta["flynn-system-critical"] return ok && v == "true" }
[ "func", "(", "a", "*", "App", ")", "Critical", "(", ")", "bool", "{", "v", ",", "ok", ":=", "a", ".", "Meta", "[", "\"flynn-system-critical\"", "]", "\n", "return", "ok", "&&", "v", "==", "\"true\"", "\n", "}" ]
// Critical apps cannot be completely scaled down by the scheduler
[ "Critical", "apps", "cannot", "be", "completely", "scaled", "down", "by", "the", "scheduler" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/types/types.go#L74-L77
train
flynn/flynn
pkg/syslog/rfc5424/message.go
NewMessage
func NewMessage(hdr *Header, msg []byte) *Message { var h Header if hdr != nil { h = *hdr } if h.Timestamp.IsZero() { h.Timestamp = time.Now().UTC() } if h.Version == 0 { h.Version = 1 } if msg != nil { m := make([]byte, len(msg)) copy(m, msg) msg = m } return &Message{Header: h, Msg: msg} }
go
func NewMessage(hdr *Header, msg []byte) *Message { var h Header if hdr != nil { h = *hdr } if h.Timestamp.IsZero() { h.Timestamp = time.Now().UTC() } if h.Version == 0 { h.Version = 1 } if msg != nil { m := make([]byte, len(msg)) copy(m, msg) msg = m } return &Message{Header: h, Msg: msg} }
[ "func", "NewMessage", "(", "hdr", "*", "Header", ",", "msg", "[", "]", "byte", ")", "*", "Message", "{", "var", "h", "Header", "\n", "if", "hdr", "!=", "nil", "{", "h", "=", "*", "hdr", "\n", "}", "\n", "if", "h", ".", "Timestamp", ".", "IsZero", "(", ")", "{", "h", ".", "Timestamp", "=", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", "\n", "}", "\n", "if", "h", ".", "Version", "==", "0", "{", "h", ".", "Version", "=", "1", "\n", "}", "\n", "if", "msg", "!=", "nil", "{", "m", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "msg", ")", ")", "\n", "copy", "(", "m", ",", "msg", ")", "\n", "msg", "=", "m", "\n", "}", "\n", "return", "&", "Message", "{", "Header", ":", "h", ",", "Msg", ":", "msg", "}", "\n", "}" ]
// NewMessage builds a new message from a copy of the header and message.
[ "NewMessage", "builds", "a", "new", "message", "from", "a", "copy", "of", "the", "header", "and", "message", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/syslog/rfc5424/message.go#L23-L44
train
flynn/flynn
controller/scheduler/host.go
StreamJobEventsTo
func (h *Host) StreamJobEventsTo(ch chan *host.Event) (map[string]host.ActiveJob, error) { log := h.logger.New("fn", "StreamJobEventsTo", "host.id", h.ID) var events chan *host.Event var stream stream.Stream connect := func() (err error) { log.Info("connecting job event stream") events = make(chan *host.Event) stream, err = h.client.StreamEvents("all", events) if err != nil { log.Error("error connecting job event stream", "err", err) } return } if err := connect(); err != nil { return nil, err } log.Info("getting active jobs") jobs, err := h.client.ListJobs() if err != nil { log.Error("error getting active jobs", "err", err) return nil, err } log.Info(fmt.Sprintf("got %d active job(s) for host %s", len(jobs), h.ID)) go func() { defer stream.Close() defer close(h.jobsDone) for { eventLoop: for { select { case event, ok := <-events: if !ok { break eventLoop } ch <- event // if the host is a FakeHostClient with TestEventHook // set, send on the channel to synchronize with tests if h, ok := h.client.(*testutils.FakeHostClient); ok && h.TestEventHook != nil { h.TestEventHook <- struct{}{} } case <-h.stop: return } } log.Warn("job event stream disconnected", "err", stream.Err()) // keep trying to reconnect, unless we are told to stop retryLoop: for { select { case <-h.stop: return default: } if err := connect(); err == nil { break retryLoop } time.Sleep(100 * time.Millisecond) } } }() return jobs, nil }
go
func (h *Host) StreamJobEventsTo(ch chan *host.Event) (map[string]host.ActiveJob, error) { log := h.logger.New("fn", "StreamJobEventsTo", "host.id", h.ID) var events chan *host.Event var stream stream.Stream connect := func() (err error) { log.Info("connecting job event stream") events = make(chan *host.Event) stream, err = h.client.StreamEvents("all", events) if err != nil { log.Error("error connecting job event stream", "err", err) } return } if err := connect(); err != nil { return nil, err } log.Info("getting active jobs") jobs, err := h.client.ListJobs() if err != nil { log.Error("error getting active jobs", "err", err) return nil, err } log.Info(fmt.Sprintf("got %d active job(s) for host %s", len(jobs), h.ID)) go func() { defer stream.Close() defer close(h.jobsDone) for { eventLoop: for { select { case event, ok := <-events: if !ok { break eventLoop } ch <- event // if the host is a FakeHostClient with TestEventHook // set, send on the channel to synchronize with tests if h, ok := h.client.(*testutils.FakeHostClient); ok && h.TestEventHook != nil { h.TestEventHook <- struct{}{} } case <-h.stop: return } } log.Warn("job event stream disconnected", "err", stream.Err()) // keep trying to reconnect, unless we are told to stop retryLoop: for { select { case <-h.stop: return default: } if err := connect(); err == nil { break retryLoop } time.Sleep(100 * time.Millisecond) } } }() return jobs, nil }
[ "func", "(", "h", "*", "Host", ")", "StreamJobEventsTo", "(", "ch", "chan", "*", "host", ".", "Event", ")", "(", "map", "[", "string", "]", "host", ".", "ActiveJob", ",", "error", ")", "{", "log", ":=", "h", ".", "logger", ".", "New", "(", "\"fn\"", ",", "\"StreamJobEventsTo\"", ",", "\"host.id\"", ",", "h", ".", "ID", ")", "\n", "var", "events", "chan", "*", "host", ".", "Event", "\n", "var", "stream", "stream", ".", "Stream", "\n", "connect", ":=", "func", "(", ")", "(", "err", "error", ")", "{", "log", ".", "Info", "(", "\"connecting job event stream\"", ")", "\n", "events", "=", "make", "(", "chan", "*", "host", ".", "Event", ")", "\n", "stream", ",", "err", "=", "h", ".", "client", ".", "StreamEvents", "(", "\"all\"", ",", "events", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", "\"error connecting job event stream\"", ",", "\"err\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "if", "err", ":=", "connect", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "log", ".", "Info", "(", "\"getting active jobs\"", ")", "\n", "jobs", ",", "err", ":=", "h", ".", "client", ".", "ListJobs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", "\"error getting active jobs\"", ",", "\"err\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "log", ".", "Info", "(", "fmt", ".", "Sprintf", "(", "\"got %d active job(s) for host %s\"", ",", "len", "(", "jobs", ")", ",", "h", ".", "ID", ")", ")", "\n", "go", "func", "(", ")", "{", "defer", "stream", ".", "Close", "(", ")", "\n", "defer", "close", "(", "h", ".", "jobsDone", ")", "\n", "for", "{", "eventLoop", ":", "for", "{", "select", "{", "case", "event", ",", "ok", ":=", "<-", "events", ":", "if", "!", "ok", "{", "break", "eventLoop", "\n", "}", "\n", "ch", "<-", "event", "\n", "if", "h", ",", "ok", ":=", "h", ".", "client", ".", "(", "*", "testutils", ".", "FakeHostClient", ")", ";", "ok", "&&", "h", ".", "TestEventHook", "!=", "nil", "{", "h", ".", "TestEventHook", "<-", "struct", "{", "}", "{", "}", "\n", "}", "\n", "case", "<-", "h", ".", "stop", ":", "return", "\n", "}", "\n", "}", "\n", "log", ".", "Warn", "(", "\"job event stream disconnected\"", ",", "\"err\"", ",", "stream", ".", "Err", "(", ")", ")", "\n", "retryLoop", ":", "for", "{", "select", "{", "case", "<-", "h", ".", "stop", ":", "return", "\n", "default", ":", "}", "\n", "if", "err", ":=", "connect", "(", ")", ";", "err", "==", "nil", "{", "break", "retryLoop", "\n", "}", "\n", "time", ".", "Sleep", "(", "100", "*", "time", ".", "Millisecond", ")", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n", "return", "jobs", ",", "nil", "\n", "}" ]
// StreamJobEventsTo streams all job events from the host to the given channel // in a goroutine, returning the current list of active jobs.
[ "StreamJobEventsTo", "streams", "all", "job", "events", "from", "the", "host", "to", "the", "given", "channel", "in", "a", "goroutine", "returning", "the", "current", "list", "of", "active", "jobs", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/host.go#L153-L219
train
flynn/flynn
logaggregator/snapshot/snapshot.go
WriteTo
func WriteTo(buffers [][]*rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) return writeTo(buffers, enc) }
go
func WriteTo(buffers [][]*rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) return writeTo(buffers, enc) }
[ "func", "WriteTo", "(", "buffers", "[", "]", "[", "]", "*", "rfc5424", ".", "Message", ",", "w", "io", ".", "Writer", ")", "error", "{", "enc", ":=", "gob", ".", "NewEncoder", "(", "w", ")", "\n", "return", "writeTo", "(", "buffers", ",", "enc", ")", "\n", "}" ]
// WriteTo writes a snapshot of the buffers to the writer. The partitioning of // messages is not retained. The writer is left open.
[ "WriteTo", "writes", "a", "snapshot", "of", "the", "buffers", "to", "the", "writer", ".", "The", "partitioning", "of", "messages", "is", "not", "retained", ".", "The", "writer", "is", "left", "open", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/snapshot/snapshot.go#L12-L15
train
flynn/flynn
logaggregator/snapshot/snapshot.go
StreamTo
func StreamTo(buffers [][]*rfc5424.Message, msgc <-chan *rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) if err := writeTo(buffers, enc); err != nil { return err } for msg := range msgc { if err := enc.Encode(msg); err != nil { return err } } return nil }
go
func StreamTo(buffers [][]*rfc5424.Message, msgc <-chan *rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) if err := writeTo(buffers, enc); err != nil { return err } for msg := range msgc { if err := enc.Encode(msg); err != nil { return err } } return nil }
[ "func", "StreamTo", "(", "buffers", "[", "]", "[", "]", "*", "rfc5424", ".", "Message", ",", "msgc", "<-", "chan", "*", "rfc5424", ".", "Message", ",", "w", "io", ".", "Writer", ")", "error", "{", "enc", ":=", "gob", ".", "NewEncoder", "(", "w", ")", "\n", "if", "err", ":=", "writeTo", "(", "buffers", ",", "enc", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "msg", ":=", "range", "msgc", "{", "if", "err", ":=", "enc", ".", "Encode", "(", "msg", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// StreamTo writes a snapshot of the buffers to the writer, then writes // messages from the channel to the writer. The writer is left open.
[ "StreamTo", "writes", "a", "snapshot", "of", "the", "buffers", "to", "the", "writer", "then", "writes", "messages", "from", "the", "channel", "to", "the", "writer", ".", "The", "writer", "is", "left", "open", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/snapshot/snapshot.go#L30-L42
train
flynn/flynn
logaggregator/snapshot/snapshot.go
NewScanner
func NewScanner(r io.Reader) *Scanner { return &Scanner{dec: gob.NewDecoder(r)} }
go
func NewScanner(r io.Reader) *Scanner { return &Scanner{dec: gob.NewDecoder(r)} }
[ "func", "NewScanner", "(", "r", "io", ".", "Reader", ")", "*", "Scanner", "{", "return", "&", "Scanner", "{", "dec", ":", "gob", ".", "NewDecoder", "(", "r", ")", "}", "\n", "}" ]
// NewScanner returns a new Scanner reading from r.
[ "NewScanner", "returns", "a", "new", "Scanner", "reading", "from", "r", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/snapshot/snapshot.go#L53-L55
train
flynn/flynn
appliance/redis/handler.go
healthStatus
func (h *Handler) healthStatus() status.Status { info, err := h.Process.Info() if err != nil || !info.Running { return status.Unhealthy } return status.Healthy }
go
func (h *Handler) healthStatus() status.Status { info, err := h.Process.Info() if err != nil || !info.Running { return status.Unhealthy } return status.Healthy }
[ "func", "(", "h", "*", "Handler", ")", "healthStatus", "(", ")", "status", ".", "Status", "{", "info", ",", "err", ":=", "h", ".", "Process", ".", "Info", "(", ")", "\n", "if", "err", "!=", "nil", "||", "!", "info", ".", "Running", "{", "return", "status", ".", "Unhealthy", "\n", "}", "\n", "return", "status", ".", "Healthy", "\n", "}" ]
// healthStatus returns whether the process is healthy or unhealthy.
[ "healthStatus", "returns", "whether", "the", "process", "is", "healthy", "or", "unhealthy", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/handler.go#L38-L44
train
flynn/flynn
discoverd/main.go
Promote
func (m *Main) Promote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Printf("attempting promotion") // Request the leader joins us to the cluster. m.logger.Println("requesting leader join us to cluster") targetLogIndex, err := discoverd.DefaultClient.RaftAddPeer(m.advertiseAddr) if err != nil { m.logger.Println("error requesting leader to join us to cluster:", err) return err } // Open the store. if m.store == nil { if err := m.openStore(); err != nil { return err } // Wait for leadership. if err := m.waitForLeader(60 * time.Second); err != nil { return err } // Wait for store to catchup for m.store.LastIndex() < targetLogIndex.LastIndex { m.logger.Println("Waiting for store to catchup, current:", m.store.LastIndex(), "target:", targetLogIndex.LastIndex) time.Sleep(100 * time.Millisecond) } } // Update the DNS server to use the local store. if m.dnsServer != nil { m.dnsServer.SetStore(m.store) } // Update the HTTP server to use the local store. m.handler.Store = m.store m.handler.Proxy.Store(false) m.logger.Println("promoted successfully") return nil }
go
func (m *Main) Promote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Printf("attempting promotion") // Request the leader joins us to the cluster. m.logger.Println("requesting leader join us to cluster") targetLogIndex, err := discoverd.DefaultClient.RaftAddPeer(m.advertiseAddr) if err != nil { m.logger.Println("error requesting leader to join us to cluster:", err) return err } // Open the store. if m.store == nil { if err := m.openStore(); err != nil { return err } // Wait for leadership. if err := m.waitForLeader(60 * time.Second); err != nil { return err } // Wait for store to catchup for m.store.LastIndex() < targetLogIndex.LastIndex { m.logger.Println("Waiting for store to catchup, current:", m.store.LastIndex(), "target:", targetLogIndex.LastIndex) time.Sleep(100 * time.Millisecond) } } // Update the DNS server to use the local store. if m.dnsServer != nil { m.dnsServer.SetStore(m.store) } // Update the HTTP server to use the local store. m.handler.Store = m.store m.handler.Proxy.Store(false) m.logger.Println("promoted successfully") return nil }
[ "func", "(", "m", "*", "Main", ")", "Promote", "(", ")", "error", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "m", ".", "logger", ".", "Printf", "(", "\"attempting promotion\"", ")", "\n", "m", ".", "logger", ".", "Println", "(", "\"requesting leader join us to cluster\"", ")", "\n", "targetLogIndex", ",", "err", ":=", "discoverd", ".", "DefaultClient", ".", "RaftAddPeer", "(", "m", ".", "advertiseAddr", ")", "\n", "if", "err", "!=", "nil", "{", "m", ".", "logger", ".", "Println", "(", "\"error requesting leader to join us to cluster:\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "if", "m", ".", "store", "==", "nil", "{", "if", "err", ":=", "m", ".", "openStore", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "m", ".", "waitForLeader", "(", "60", "*", "time", ".", "Second", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "m", ".", "store", ".", "LastIndex", "(", ")", "<", "targetLogIndex", ".", "LastIndex", "{", "m", ".", "logger", ".", "Println", "(", "\"Waiting for store to catchup, current:\"", ",", "m", ".", "store", ".", "LastIndex", "(", ")", ",", "\"target:\"", ",", "targetLogIndex", ".", "LastIndex", ")", "\n", "time", ".", "Sleep", "(", "100", "*", "time", ".", "Millisecond", ")", "\n", "}", "\n", "}", "\n", "if", "m", ".", "dnsServer", "!=", "nil", "{", "m", ".", "dnsServer", ".", "SetStore", "(", "m", ".", "store", ")", "\n", "}", "\n", "m", ".", "handler", ".", "Store", "=", "m", ".", "store", "\n", "m", ".", "handler", ".", "Proxy", ".", "Store", "(", "false", ")", "\n", "m", ".", "logger", ".", "Println", "(", "\"promoted successfully\"", ")", "\n", "return", "nil", "\n", "}" ]
// Join the consensus set, promoting ourselves from proxy to raft node.
[ "Join", "the", "consensus", "set", "promoting", "ourselves", "from", "proxy", "to", "raft", "node", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L289-L332
train
flynn/flynn
discoverd/main.go
Demote
func (m *Main) Demote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("demotion requested") var leaderAddr string if m.store != nil { leaderAddr := m.store.Leader() if leaderAddr == "" { return server.ErrNoKnownLeader } } else { leader, err := discoverd.DefaultClient.RaftLeader() if err != nil || (err == nil && leader.Host == "") { return fmt.Errorf("failed to get leader address from configured peers") } leaderAddr = leader.Host } // Update the dns server to use proxy store if m.dnsServer != nil { m.dnsServer.SetStore(&server.ProxyStore{Peers: m.peers}) } // Set handler into proxy mode m.handler.Proxy.Store(true) // If we fail from here on out we should attempt to rollback rollback := func() { if m.dnsServer != nil { m.dnsServer.SetStore(m.store) } m.handler.Proxy.Store(false) } // If we are the leader remove ourselves directly, // otherwise request the leader remove us from the peer set. if leaderAddr == m.advertiseAddr { if err := m.store.RemovePeer(m.advertiseAddr); err != nil { rollback() return err } } else { if err := discoverd.DefaultClient.RaftRemovePeer(m.advertiseAddr); err != nil { rollback() return err } } // Close the raft store. if m.store != nil { m.store.Close() m.store = nil } m.handler.Store = nil m.logger.Println("demoted successfully") return nil }
go
func (m *Main) Demote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("demotion requested") var leaderAddr string if m.store != nil { leaderAddr := m.store.Leader() if leaderAddr == "" { return server.ErrNoKnownLeader } } else { leader, err := discoverd.DefaultClient.RaftLeader() if err != nil || (err == nil && leader.Host == "") { return fmt.Errorf("failed to get leader address from configured peers") } leaderAddr = leader.Host } // Update the dns server to use proxy store if m.dnsServer != nil { m.dnsServer.SetStore(&server.ProxyStore{Peers: m.peers}) } // Set handler into proxy mode m.handler.Proxy.Store(true) // If we fail from here on out we should attempt to rollback rollback := func() { if m.dnsServer != nil { m.dnsServer.SetStore(m.store) } m.handler.Proxy.Store(false) } // If we are the leader remove ourselves directly, // otherwise request the leader remove us from the peer set. if leaderAddr == m.advertiseAddr { if err := m.store.RemovePeer(m.advertiseAddr); err != nil { rollback() return err } } else { if err := discoverd.DefaultClient.RaftRemovePeer(m.advertiseAddr); err != nil { rollback() return err } } // Close the raft store. if m.store != nil { m.store.Close() m.store = nil } m.handler.Store = nil m.logger.Println("demoted successfully") return nil }
[ "func", "(", "m", "*", "Main", ")", "Demote", "(", ")", "error", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "m", ".", "logger", ".", "Println", "(", "\"demotion requested\"", ")", "\n", "var", "leaderAddr", "string", "\n", "if", "m", ".", "store", "!=", "nil", "{", "leaderAddr", ":=", "m", ".", "store", ".", "Leader", "(", ")", "\n", "if", "leaderAddr", "==", "\"\"", "{", "return", "server", ".", "ErrNoKnownLeader", "\n", "}", "\n", "}", "else", "{", "leader", ",", "err", ":=", "discoverd", ".", "DefaultClient", ".", "RaftLeader", "(", ")", "\n", "if", "err", "!=", "nil", "||", "(", "err", "==", "nil", "&&", "leader", ".", "Host", "==", "\"\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"failed to get leader address from configured peers\"", ")", "\n", "}", "\n", "leaderAddr", "=", "leader", ".", "Host", "\n", "}", "\n", "if", "m", ".", "dnsServer", "!=", "nil", "{", "m", ".", "dnsServer", ".", "SetStore", "(", "&", "server", ".", "ProxyStore", "{", "Peers", ":", "m", ".", "peers", "}", ")", "\n", "}", "\n", "m", ".", "handler", ".", "Proxy", ".", "Store", "(", "true", ")", "\n", "rollback", ":=", "func", "(", ")", "{", "if", "m", ".", "dnsServer", "!=", "nil", "{", "m", ".", "dnsServer", ".", "SetStore", "(", "m", ".", "store", ")", "\n", "}", "\n", "m", ".", "handler", ".", "Proxy", ".", "Store", "(", "false", ")", "\n", "}", "\n", "if", "leaderAddr", "==", "m", ".", "advertiseAddr", "{", "if", "err", ":=", "m", ".", "store", ".", "RemovePeer", "(", "m", ".", "advertiseAddr", ")", ";", "err", "!=", "nil", "{", "rollback", "(", ")", "\n", "return", "err", "\n", "}", "\n", "}", "else", "{", "if", "err", ":=", "discoverd", ".", "DefaultClient", ".", "RaftRemovePeer", "(", "m", ".", "advertiseAddr", ")", ";", "err", "!=", "nil", "{", "rollback", "(", ")", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "if", "m", ".", "store", "!=", "nil", "{", "m", ".", "store", ".", "Close", "(", ")", "\n", "m", ".", "store", "=", "nil", "\n", "}", "\n", "m", ".", "handler", ".", "Store", "=", "nil", "\n", "m", ".", "logger", ".", "Println", "(", "\"demoted successfully\"", ")", "\n", "return", "nil", "\n", "}" ]
// Leave the consensus set, demoting ourselves to proxy from raft node.
[ "Leave", "the", "consensus", "set", "demoting", "ourselves", "to", "proxy", "from", "raft", "node", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L335-L394
train
flynn/flynn
discoverd/main.go
Close
func (m *Main) Close() (info dt.TargetLogIndex, err error) { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("discoverd shutting down") if m.httpServer != nil { // Disable keep alives so that persistent connections will close m.httpServer.SetKeepAlivesEnabled(false) } if m.dnsServer != nil { m.dnsServer.Close() m.dnsServer = nil } if m.ln != nil { m.ln.Close() m.ln = nil } if m.store != nil { info.LastIndex, err = m.store.Close() m.store = nil } return info, err }
go
func (m *Main) Close() (info dt.TargetLogIndex, err error) { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("discoverd shutting down") if m.httpServer != nil { // Disable keep alives so that persistent connections will close m.httpServer.SetKeepAlivesEnabled(false) } if m.dnsServer != nil { m.dnsServer.Close() m.dnsServer = nil } if m.ln != nil { m.ln.Close() m.ln = nil } if m.store != nil { info.LastIndex, err = m.store.Close() m.store = nil } return info, err }
[ "func", "(", "m", "*", "Main", ")", "Close", "(", ")", "(", "info", "dt", ".", "TargetLogIndex", ",", "err", "error", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "m", ".", "logger", ".", "Println", "(", "\"discoverd shutting down\"", ")", "\n", "if", "m", ".", "httpServer", "!=", "nil", "{", "m", ".", "httpServer", ".", "SetKeepAlivesEnabled", "(", "false", ")", "\n", "}", "\n", "if", "m", ".", "dnsServer", "!=", "nil", "{", "m", ".", "dnsServer", ".", "Close", "(", ")", "\n", "m", ".", "dnsServer", "=", "nil", "\n", "}", "\n", "if", "m", ".", "ln", "!=", "nil", "{", "m", ".", "ln", ".", "Close", "(", ")", "\n", "m", ".", "ln", "=", "nil", "\n", "}", "\n", "if", "m", ".", "store", "!=", "nil", "{", "info", ".", "LastIndex", ",", "err", "=", "m", ".", "store", ".", "Close", "(", ")", "\n", "m", ".", "store", "=", "nil", "\n", "}", "\n", "return", "info", ",", "err", "\n", "}" ]
// Close shuts down all open servers.
[ "Close", "shuts", "down", "all", "open", "servers", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L407-L428
train
flynn/flynn
discoverd/main.go
openStore
func (m *Main) openStore() error { // If the advertised address is not in the peer list then we should proxy. // Resolve advertised address. addr, err := net.ResolveTCPAddr("tcp", m.advertiseAddr) if err != nil { return err } // Listen via mux storeLn := m.mux.Listen([]byte{server.StoreHdr}) // Initialize store. s := server.NewStore(m.dataDir) s.Listener = storeLn s.Advertise = addr // Allow single node if there's no peers set. s.EnableSingleNode = len(m.peers) <= 1 // Open store. if err := s.Open(); err != nil { return err } m.store = s // If peers then set peer set. if len(m.peers) > 0 { if err := s.SetPeers(m.peers); err != nil { return fmt.Errorf("set peers: %s", err) } } return nil }
go
func (m *Main) openStore() error { // If the advertised address is not in the peer list then we should proxy. // Resolve advertised address. addr, err := net.ResolveTCPAddr("tcp", m.advertiseAddr) if err != nil { return err } // Listen via mux storeLn := m.mux.Listen([]byte{server.StoreHdr}) // Initialize store. s := server.NewStore(m.dataDir) s.Listener = storeLn s.Advertise = addr // Allow single node if there's no peers set. s.EnableSingleNode = len(m.peers) <= 1 // Open store. if err := s.Open(); err != nil { return err } m.store = s // If peers then set peer set. if len(m.peers) > 0 { if err := s.SetPeers(m.peers); err != nil { return fmt.Errorf("set peers: %s", err) } } return nil }
[ "func", "(", "m", "*", "Main", ")", "openStore", "(", ")", "error", "{", "addr", ",", "err", ":=", "net", ".", "ResolveTCPAddr", "(", "\"tcp\"", ",", "m", ".", "advertiseAddr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "storeLn", ":=", "m", ".", "mux", ".", "Listen", "(", "[", "]", "byte", "{", "server", ".", "StoreHdr", "}", ")", "\n", "s", ":=", "server", ".", "NewStore", "(", "m", ".", "dataDir", ")", "\n", "s", ".", "Listener", "=", "storeLn", "\n", "s", ".", "Advertise", "=", "addr", "\n", "s", ".", "EnableSingleNode", "=", "len", "(", "m", ".", "peers", ")", "<=", "1", "\n", "if", "err", ":=", "s", ".", "Open", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "m", ".", "store", "=", "s", "\n", "if", "len", "(", "m", ".", "peers", ")", ">", "0", "{", "if", "err", ":=", "s", ".", "SetPeers", "(", "m", ".", "peers", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"set peers: %s\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// openStore initializes and opens the store.
[ "openStore", "initializes", "and", "opens", "the", "store", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L431-L465
train
flynn/flynn
discoverd/main.go
openDNSServer
func (m *Main) openDNSServer(addr string, recursors []string) error { s := &server.DNSServer{ UDPAddr: addr, TCPAddr: addr, Recursors: recursors, } // If store is available then attach it. Otherwise use a proxy. if m.store != nil { s.SetStore(m.store) } else { s.SetStore(&server.ProxyStore{Peers: m.peers}) } if err := s.ListenAndServe(); err != nil { return err } m.dnsServer = s return nil }
go
func (m *Main) openDNSServer(addr string, recursors []string) error { s := &server.DNSServer{ UDPAddr: addr, TCPAddr: addr, Recursors: recursors, } // If store is available then attach it. Otherwise use a proxy. if m.store != nil { s.SetStore(m.store) } else { s.SetStore(&server.ProxyStore{Peers: m.peers}) } if err := s.ListenAndServe(); err != nil { return err } m.dnsServer = s return nil }
[ "func", "(", "m", "*", "Main", ")", "openDNSServer", "(", "addr", "string", ",", "recursors", "[", "]", "string", ")", "error", "{", "s", ":=", "&", "server", ".", "DNSServer", "{", "UDPAddr", ":", "addr", ",", "TCPAddr", ":", "addr", ",", "Recursors", ":", "recursors", ",", "}", "\n", "if", "m", ".", "store", "!=", "nil", "{", "s", ".", "SetStore", "(", "m", ".", "store", ")", "\n", "}", "else", "{", "s", ".", "SetStore", "(", "&", "server", ".", "ProxyStore", "{", "Peers", ":", "m", ".", "peers", "}", ")", "\n", "}", "\n", "if", "err", ":=", "s", ".", "ListenAndServe", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "m", ".", "dnsServer", "=", "s", "\n", "return", "nil", "\n", "}" ]
// openDNSServer initializes and opens the DNS server. // The store must already be open.
[ "openDNSServer", "initializes", "and", "opens", "the", "DNS", "server", ".", "The", "store", "must", "already", "be", "open", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L469-L488
train
flynn/flynn
discoverd/main.go
openHTTPServer
func (m *Main) openHTTPServer() error { h := server.NewHandler(false, m.peers) h.Main = m h.Peers = m.peers // If we have no store then start the handler in proxy mode if m.store == nil { h.Proxy.Store(true) } else { h.Store = m.store } m.handler = h m.httpServer = &http.Server{Handler: h} // Create listener via mux // HTTP listens to all methods: CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE. httpLn := m.mux.Listen([]byte{'C', 'D', 'G', 'H', 'O', 'P', 'T'}) go m.httpServer.Serve(httpLn) return nil }
go
func (m *Main) openHTTPServer() error { h := server.NewHandler(false, m.peers) h.Main = m h.Peers = m.peers // If we have no store then start the handler in proxy mode if m.store == nil { h.Proxy.Store(true) } else { h.Store = m.store } m.handler = h m.httpServer = &http.Server{Handler: h} // Create listener via mux // HTTP listens to all methods: CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE. httpLn := m.mux.Listen([]byte{'C', 'D', 'G', 'H', 'O', 'P', 'T'}) go m.httpServer.Serve(httpLn) return nil }
[ "func", "(", "m", "*", "Main", ")", "openHTTPServer", "(", ")", "error", "{", "h", ":=", "server", ".", "NewHandler", "(", "false", ",", "m", ".", "peers", ")", "\n", "h", ".", "Main", "=", "m", "\n", "h", ".", "Peers", "=", "m", ".", "peers", "\n", "if", "m", ".", "store", "==", "nil", "{", "h", ".", "Proxy", ".", "Store", "(", "true", ")", "\n", "}", "else", "{", "h", ".", "Store", "=", "m", ".", "store", "\n", "}", "\n", "m", ".", "handler", "=", "h", "\n", "m", ".", "httpServer", "=", "&", "http", ".", "Server", "{", "Handler", ":", "h", "}", "\n", "httpLn", ":=", "m", ".", "mux", ".", "Listen", "(", "[", "]", "byte", "{", "'C'", ",", "'D'", ",", "'G'", ",", "'H'", ",", "'O'", ",", "'P'", ",", "'T'", "}", ")", "\n", "go", "m", ".", "httpServer", ".", "Serve", "(", "httpLn", ")", "\n", "return", "nil", "\n", "}" ]
// openHTTPServer initializes and opens the HTTP server. // The store must already be open.
[ "openHTTPServer", "initializes", "and", "opens", "the", "HTTP", "server", ".", "The", "store", "must", "already", "be", "open", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L492-L510
train
flynn/flynn
discoverd/main.go
Notify
func (m *Main) Notify(notifyURL, dnsAddr string) { m.mu.Lock() m.status.URL = strings.Join(m.peers, ",") if dnsAddr != "" { m.status.DNS = dnsAddr } payload, _ := json.Marshal(m.status) m.mu.Unlock() res, err := http.Post(notifyURL, "application/json", bytes.NewReader(payload)) if err != nil { m.logger.Printf("failed to notify: %s", err) } else { res.Body.Close() } }
go
func (m *Main) Notify(notifyURL, dnsAddr string) { m.mu.Lock() m.status.URL = strings.Join(m.peers, ",") if dnsAddr != "" { m.status.DNS = dnsAddr } payload, _ := json.Marshal(m.status) m.mu.Unlock() res, err := http.Post(notifyURL, "application/json", bytes.NewReader(payload)) if err != nil { m.logger.Printf("failed to notify: %s", err) } else { res.Body.Close() } }
[ "func", "(", "m", "*", "Main", ")", "Notify", "(", "notifyURL", ",", "dnsAddr", "string", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "m", ".", "status", ".", "URL", "=", "strings", ".", "Join", "(", "m", ".", "peers", ",", "\",\"", ")", "\n", "if", "dnsAddr", "!=", "\"\"", "{", "m", ".", "status", ".", "DNS", "=", "dnsAddr", "\n", "}", "\n", "payload", ",", "_", ":=", "json", ".", "Marshal", "(", "m", ".", "status", ")", "\n", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "res", ",", "err", ":=", "http", ".", "Post", "(", "notifyURL", ",", "\"application/json\"", ",", "bytes", ".", "NewReader", "(", "payload", ")", ")", "\n", "if", "err", "!=", "nil", "{", "m", ".", "logger", ".", "Printf", "(", "\"failed to notify: %s\"", ",", "err", ")", "\n", "}", "else", "{", "res", ".", "Body", ".", "Close", "(", ")", "\n", "}", "\n", "}" ]
// Notify sends a POST to notifyURL to let it know that addr is accessible.
[ "Notify", "sends", "a", "POST", "to", "notifyURL", "to", "let", "it", "know", "that", "addr", "is", "accessible", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L513-L528
train
flynn/flynn
discoverd/main.go
MergeHostPort
func MergeHostPort(host, portAddr string) string { _, port, _ := net.SplitHostPort(portAddr) return net.JoinHostPort(host, port) }
go
func MergeHostPort(host, portAddr string) string { _, port, _ := net.SplitHostPort(portAddr) return net.JoinHostPort(host, port) }
[ "func", "MergeHostPort", "(", "host", ",", "portAddr", "string", ")", "string", "{", "_", ",", "port", ",", "_", ":=", "net", ".", "SplitHostPort", "(", "portAddr", ")", "\n", "return", "net", ".", "JoinHostPort", "(", "host", ",", "port", ")", "\n", "}" ]
// MergeHostPort joins host to the port in portAddr.
[ "MergeHostPort", "joins", "host", "to", "the", "port", "in", "portAddr", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L531-L534
train
flynn/flynn
discoverd/main.go
waitForLeader
func (m *Main) waitForLeader(timeout time.Duration) error { // Ignore leadership if we are a proxy. if m.store == nil { return nil } var timeoutCh <-chan time.Time if timeout != IndefiniteTimeout { timeoutCh = time.After(timeout) } for { select { case <-timeoutCh: return errors.New("timed out waiting for leader") case <-time.After(100 * time.Millisecond): if leader := m.store.Leader(); leader != "" { return nil } } } }
go
func (m *Main) waitForLeader(timeout time.Duration) error { // Ignore leadership if we are a proxy. if m.store == nil { return nil } var timeoutCh <-chan time.Time if timeout != IndefiniteTimeout { timeoutCh = time.After(timeout) } for { select { case <-timeoutCh: return errors.New("timed out waiting for leader") case <-time.After(100 * time.Millisecond): if leader := m.store.Leader(); leader != "" { return nil } } } }
[ "func", "(", "m", "*", "Main", ")", "waitForLeader", "(", "timeout", "time", ".", "Duration", ")", "error", "{", "if", "m", ".", "store", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "var", "timeoutCh", "<-", "chan", "time", ".", "Time", "\n", "if", "timeout", "!=", "IndefiniteTimeout", "{", "timeoutCh", "=", "time", ".", "After", "(", "timeout", ")", "\n", "}", "\n", "for", "{", "select", "{", "case", "<-", "timeoutCh", ":", "return", "errors", ".", "New", "(", "\"timed out waiting for leader\"", ")", "\n", "case", "<-", "time", ".", "After", "(", "100", "*", "time", ".", "Millisecond", ")", ":", "if", "leader", ":=", "m", ".", "store", ".", "Leader", "(", ")", ";", "leader", "!=", "\"\"", "{", "return", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// waitForLeader polls the store until a leader is found or a timeout occurs. // If timeout is -1 then wait indefinitely
[ "waitForLeader", "polls", "the", "store", "until", "a", "leader", "is", "found", "or", "a", "timeout", "occurs", ".", "If", "timeout", "is", "-", "1", "then", "wait", "indefinitely" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L538-L557
train
flynn/flynn
discoverd/main.go
TrimSpaceSlice
func TrimSpaceSlice(a []string) []string { other := make([]string, 0, len(a)) for _, s := range a { s = strings.TrimSpace(s) if s == "" { continue } other = append(other, s) } return other }
go
func TrimSpaceSlice(a []string) []string { other := make([]string, 0, len(a)) for _, s := range a { s = strings.TrimSpace(s) if s == "" { continue } other = append(other, s) } return other }
[ "func", "TrimSpaceSlice", "(", "a", "[", "]", "string", ")", "[", "]", "string", "{", "other", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "a", ")", ")", "\n", "for", "_", ",", "s", ":=", "range", "a", "{", "s", "=", "strings", ".", "TrimSpace", "(", "s", ")", "\n", "if", "s", "==", "\"\"", "{", "continue", "\n", "}", "\n", "other", "=", "append", "(", "other", ",", "s", ")", "\n", "}", "\n", "return", "other", "\n", "}" ]
// TrimSpaceSlice returns a new slice of trimmed strings. // Empty strings are removed entirely.
[ "TrimSpaceSlice", "returns", "a", "new", "slice", "of", "trimmed", "strings", ".", "Empty", "strings", "are", "removed", "entirely", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L612-L622
train
flynn/flynn
discoverd/main.go
SetPortSlice
func SetPortSlice(peers []string, addr string) ([]string, error) { // Retrieve the port from addr. _, port, err := net.SplitHostPort(addr) if err != nil { return nil, err } // Merge the port with the peer hosts into a new slice. other := make([]string, len(peers)) for i, peer := range peers { host, _, err := net.SplitHostPort(peer) if err != nil { return nil, err } other[i] = net.JoinHostPort(host, port) } return other, nil }
go
func SetPortSlice(peers []string, addr string) ([]string, error) { // Retrieve the port from addr. _, port, err := net.SplitHostPort(addr) if err != nil { return nil, err } // Merge the port with the peer hosts into a new slice. other := make([]string, len(peers)) for i, peer := range peers { host, _, err := net.SplitHostPort(peer) if err != nil { return nil, err } other[i] = net.JoinHostPort(host, port) } return other, nil }
[ "func", "SetPortSlice", "(", "peers", "[", "]", "string", ",", "addr", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "_", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "other", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "peers", ")", ")", "\n", "for", "i", ",", "peer", ":=", "range", "peers", "{", "host", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "peer", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "other", "[", "i", "]", "=", "net", ".", "JoinHostPort", "(", "host", ",", "port", ")", "\n", "}", "\n", "return", "other", ",", "nil", "\n", "}" ]
// SetPortSlice sets the ports for a slice of hosts.
[ "SetPortSlice", "sets", "the", "ports", "for", "a", "slice", "of", "hosts", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L625-L644
train
flynn/flynn
controller/client/v1/client.go
GetCACert
func (c *Client) GetCACert() ([]byte, error) { var cert bytes.Buffer res, err := c.RawReq("GET", "/ca-cert", nil, nil, nil) if err != nil { return nil, err } defer res.Body.Close() if _, err := io.Copy(&cert, res.Body); err != nil { return nil, err } return cert.Bytes(), nil }
go
func (c *Client) GetCACert() ([]byte, error) { var cert bytes.Buffer res, err := c.RawReq("GET", "/ca-cert", nil, nil, nil) if err != nil { return nil, err } defer res.Body.Close() if _, err := io.Copy(&cert, res.Body); err != nil { return nil, err } return cert.Bytes(), nil }
[ "func", "(", "c", "*", "Client", ")", "GetCACert", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "cert", "bytes", ".", "Buffer", "\n", "res", ",", "err", ":=", "c", ".", "RawReq", "(", "\"GET\"", ",", "\"/ca-cert\"", ",", "nil", ",", "nil", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "res", ".", "Body", ".", "Close", "(", ")", "\n", "if", "_", ",", "err", ":=", "io", ".", "Copy", "(", "&", "cert", ",", "res", ".", "Body", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "cert", ".", "Bytes", "(", ")", ",", "nil", "\n", "}" ]
// GetCACert returns the CA cert for the controller
[ "GetCACert", "returns", "the", "CA", "cert", "for", "the", "controller" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L112-L123
train
flynn/flynn
controller/client/v1/client.go
PutDomain
func (c *Client) PutDomain(dm *ct.DomainMigration) error { if dm.Domain == "" { return errors.New("controller: missing domain") } if dm.OldDomain == "" { return errors.New("controller: missing old domain") } return c.Put("/domain", dm, dm) }
go
func (c *Client) PutDomain(dm *ct.DomainMigration) error { if dm.Domain == "" { return errors.New("controller: missing domain") } if dm.OldDomain == "" { return errors.New("controller: missing old domain") } return c.Put("/domain", dm, dm) }
[ "func", "(", "c", "*", "Client", ")", "PutDomain", "(", "dm", "*", "ct", ".", "DomainMigration", ")", "error", "{", "if", "dm", ".", "Domain", "==", "\"\"", "{", "return", "errors", ".", "New", "(", "\"controller: missing domain\"", ")", "\n", "}", "\n", "if", "dm", ".", "OldDomain", "==", "\"\"", "{", "return", "errors", ".", "New", "(", "\"controller: missing old domain\"", ")", "\n", "}", "\n", "return", "c", ".", "Put", "(", "\"/domain\"", ",", "dm", ",", "dm", ")", "\n", "}" ]
// PutDomain migrates the cluster domain
[ "PutDomain", "migrates", "the", "cluster", "domain" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L137-L145
train
flynn/flynn
controller/client/v1/client.go
CreateArtifact
func (c *Client) CreateArtifact(artifact *ct.Artifact) error { return c.Post("/artifacts", artifact, artifact) }
go
func (c *Client) CreateArtifact(artifact *ct.Artifact) error { return c.Post("/artifacts", artifact, artifact) }
[ "func", "(", "c", "*", "Client", ")", "CreateArtifact", "(", "artifact", "*", "ct", ".", "Artifact", ")", "error", "{", "return", "c", ".", "Post", "(", "\"/artifacts\"", ",", "artifact", ",", "artifact", ")", "\n", "}" ]
// CreateArtifact creates a new artifact.
[ "CreateArtifact", "creates", "a", "new", "artifact", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L148-L150
train
flynn/flynn
controller/client/v1/client.go
CreateRelease
func (c *Client) CreateRelease(appID string, release *ct.Release) error { release.AppID = appID return c.Post("/releases", release, release) }
go
func (c *Client) CreateRelease(appID string, release *ct.Release) error { release.AppID = appID return c.Post("/releases", release, release) }
[ "func", "(", "c", "*", "Client", ")", "CreateRelease", "(", "appID", "string", ",", "release", "*", "ct", ".", "Release", ")", "error", "{", "release", ".", "AppID", "=", "appID", "\n", "return", "c", ".", "Post", "(", "\"/releases\"", ",", "release", ",", "release", ")", "\n", "}" ]
// CreateRelease creates a new release.
[ "CreateRelease", "creates", "a", "new", "release", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L153-L156
train
flynn/flynn
controller/client/v1/client.go
CreateApp
func (c *Client) CreateApp(app *ct.App) error { return c.Post("/apps", app, app) }
go
func (c *Client) CreateApp(app *ct.App) error { return c.Post("/apps", app, app) }
[ "func", "(", "c", "*", "Client", ")", "CreateApp", "(", "app", "*", "ct", ".", "App", ")", "error", "{", "return", "c", ".", "Post", "(", "\"/apps\"", ",", "app", ",", "app", ")", "\n", "}" ]
// CreateApp creates a new app.
[ "CreateApp", "creates", "a", "new", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L159-L161
train
flynn/flynn
controller/client/v1/client.go
UpdateApp
func (c *Client) UpdateApp(app *ct.App) error { if app.ID == "" { return errors.New("controller: missing id") } return c.Post(fmt.Sprintf("/apps/%s", app.ID), app, app) }
go
func (c *Client) UpdateApp(app *ct.App) error { if app.ID == "" { return errors.New("controller: missing id") } return c.Post(fmt.Sprintf("/apps/%s", app.ID), app, app) }
[ "func", "(", "c", "*", "Client", ")", "UpdateApp", "(", "app", "*", "ct", ".", "App", ")", "error", "{", "if", "app", ".", "ID", "==", "\"\"", "{", "return", "errors", ".", "New", "(", "\"controller: missing id\"", ")", "\n", "}", "\n", "return", "c", ".", "Post", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s\"", ",", "app", ".", "ID", ")", ",", "app", ",", "app", ")", "\n", "}" ]
// UpdateApp updates the meta and strategy using app.ID.
[ "UpdateApp", "updates", "the", "meta", "and", "strategy", "using", "app", ".", "ID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L164-L169
train
flynn/flynn
controller/client/v1/client.go
DeleteApp
func (c *Client) DeleteApp(appID string) (*ct.AppDeletion, error) { events := make(chan *ct.Event) stream, err := c.StreamEvents(ct.StreamEventsOptions{ AppID: appID, ObjectTypes: []ct.EventType{ct.EventTypeAppDeletion}, }, events) if err != nil { return nil, err } defer stream.Close() if err := c.Delete(fmt.Sprintf("/apps/%s", appID), nil); err != nil { return nil, err } select { case event, ok := <-events: if !ok { return nil, stream.Err() } var e ct.AppDeletionEvent if err := json.Unmarshal(event.Data, &e); err != nil { return nil, err } if e.Error != "" { return nil, errors.New(e.Error) } return e.AppDeletion, nil case <-time.After(60 * time.Second): return nil, errors.New("timed out waiting for app deletion") } }
go
func (c *Client) DeleteApp(appID string) (*ct.AppDeletion, error) { events := make(chan *ct.Event) stream, err := c.StreamEvents(ct.StreamEventsOptions{ AppID: appID, ObjectTypes: []ct.EventType{ct.EventTypeAppDeletion}, }, events) if err != nil { return nil, err } defer stream.Close() if err := c.Delete(fmt.Sprintf("/apps/%s", appID), nil); err != nil { return nil, err } select { case event, ok := <-events: if !ok { return nil, stream.Err() } var e ct.AppDeletionEvent if err := json.Unmarshal(event.Data, &e); err != nil { return nil, err } if e.Error != "" { return nil, errors.New(e.Error) } return e.AppDeletion, nil case <-time.After(60 * time.Second): return nil, errors.New("timed out waiting for app deletion") } }
[ "func", "(", "c", "*", "Client", ")", "DeleteApp", "(", "appID", "string", ")", "(", "*", "ct", ".", "AppDeletion", ",", "error", ")", "{", "events", ":=", "make", "(", "chan", "*", "ct", ".", "Event", ")", "\n", "stream", ",", "err", ":=", "c", ".", "StreamEvents", "(", "ct", ".", "StreamEventsOptions", "{", "AppID", ":", "appID", ",", "ObjectTypes", ":", "[", "]", "ct", ".", "EventType", "{", "ct", ".", "EventTypeAppDeletion", "}", ",", "}", ",", "events", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "stream", ".", "Close", "(", ")", "\n", "if", "err", ":=", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s\"", ",", "appID", ")", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "select", "{", "case", "event", ",", "ok", ":=", "<-", "events", ":", "if", "!", "ok", "{", "return", "nil", ",", "stream", ".", "Err", "(", ")", "\n", "}", "\n", "var", "e", "ct", ".", "AppDeletionEvent", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "event", ".", "Data", ",", "&", "e", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "e", ".", "Error", "!=", "\"\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "e", ".", "Error", ")", "\n", "}", "\n", "return", "e", ".", "AppDeletion", ",", "nil", "\n", "case", "<-", "time", ".", "After", "(", "60", "*", "time", ".", "Second", ")", ":", "return", "nil", ",", "errors", ".", "New", "(", "\"timed out waiting for app deletion\"", ")", "\n", "}", "\n", "}" ]
// DeleteApp deletes an app.
[ "DeleteApp", "deletes", "an", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L180-L211
train
flynn/flynn
controller/client/v1/client.go
CreateProvider
func (c *Client) CreateProvider(provider *ct.Provider) error { return c.Post("/providers", provider, provider) }
go
func (c *Client) CreateProvider(provider *ct.Provider) error { return c.Post("/providers", provider, provider) }
[ "func", "(", "c", "*", "Client", ")", "CreateProvider", "(", "provider", "*", "ct", ".", "Provider", ")", "error", "{", "return", "c", ".", "Post", "(", "\"/providers\"", ",", "provider", ",", "provider", ")", "\n", "}" ]
// CreateProvider creates a new provider.
[ "CreateProvider", "creates", "a", "new", "provider", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L214-L216
train
flynn/flynn
controller/client/v1/client.go
GetProvider
func (c *Client) GetProvider(providerID string) (*ct.Provider, error) { provider := &ct.Provider{} return provider, c.Get(fmt.Sprintf("/providers/%s", providerID), provider) }
go
func (c *Client) GetProvider(providerID string) (*ct.Provider, error) { provider := &ct.Provider{} return provider, c.Get(fmt.Sprintf("/providers/%s", providerID), provider) }
[ "func", "(", "c", "*", "Client", ")", "GetProvider", "(", "providerID", "string", ")", "(", "*", "ct", ".", "Provider", ",", "error", ")", "{", "provider", ":=", "&", "ct", ".", "Provider", "{", "}", "\n", "return", "provider", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s\"", ",", "providerID", ")", ",", "provider", ")", "\n", "}" ]
// GetProvider returns the provider identified by providerID.
[ "GetProvider", "returns", "the", "provider", "identified", "by", "providerID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L219-L222
train
flynn/flynn
controller/client/v1/client.go
ProvisionResource
func (c *Client) ProvisionResource(req *ct.ResourceReq) (*ct.Resource, error) { if req.ProviderID == "" { return nil, errors.New("controller: missing provider id") } res := &ct.Resource{} err := c.Post(fmt.Sprintf("/providers/%s/resources", req.ProviderID), req, res) return res, err }
go
func (c *Client) ProvisionResource(req *ct.ResourceReq) (*ct.Resource, error) { if req.ProviderID == "" { return nil, errors.New("controller: missing provider id") } res := &ct.Resource{} err := c.Post(fmt.Sprintf("/providers/%s/resources", req.ProviderID), req, res) return res, err }
[ "func", "(", "c", "*", "Client", ")", "ProvisionResource", "(", "req", "*", "ct", ".", "ResourceReq", ")", "(", "*", "ct", ".", "Resource", ",", "error", ")", "{", "if", "req", ".", "ProviderID", "==", "\"\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"controller: missing provider id\"", ")", "\n", "}", "\n", "res", ":=", "&", "ct", ".", "Resource", "{", "}", "\n", "err", ":=", "c", ".", "Post", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s/resources\"", ",", "req", ".", "ProviderID", ")", ",", "req", ",", "res", ")", "\n", "return", "res", ",", "err", "\n", "}" ]
// ProvisionResource uses a provider to provision a new resource for the // application. Returns details about the resource.
[ "ProvisionResource", "uses", "a", "provider", "to", "provision", "a", "new", "resource", "for", "the", "application", ".", "Returns", "details", "about", "the", "resource", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L226-L233
train
flynn/flynn
controller/client/v1/client.go
GetResource
func (c *Client) GetResource(providerID, resourceID string) (*ct.Resource, error) { res := &ct.Resource{} err := c.Get(fmt.Sprintf("/providers/%s/resources/%s", providerID, resourceID), res) return res, err }
go
func (c *Client) GetResource(providerID, resourceID string) (*ct.Resource, error) { res := &ct.Resource{} err := c.Get(fmt.Sprintf("/providers/%s/resources/%s", providerID, resourceID), res) return res, err }
[ "func", "(", "c", "*", "Client", ")", "GetResource", "(", "providerID", ",", "resourceID", "string", ")", "(", "*", "ct", ".", "Resource", ",", "error", ")", "{", "res", ":=", "&", "ct", ".", "Resource", "{", "}", "\n", "err", ":=", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s/resources/%s\"", ",", "providerID", ",", "resourceID", ")", ",", "res", ")", "\n", "return", "res", ",", "err", "\n", "}" ]
// GetResource returns the resource identified by resourceID under providerID.
[ "GetResource", "returns", "the", "resource", "identified", "by", "resourceID", "under", "providerID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L236-L240
train
flynn/flynn
controller/client/v1/client.go
ResourceListAll
func (c *Client) ResourceListAll() ([]*ct.Resource, error) { var resources []*ct.Resource return resources, c.Get("/resources", &resources) }
go
func (c *Client) ResourceListAll() ([]*ct.Resource, error) { var resources []*ct.Resource return resources, c.Get("/resources", &resources) }
[ "func", "(", "c", "*", "Client", ")", "ResourceListAll", "(", ")", "(", "[", "]", "*", "ct", ".", "Resource", ",", "error", ")", "{", "var", "resources", "[", "]", "*", "ct", ".", "Resource", "\n", "return", "resources", ",", "c", ".", "Get", "(", "\"/resources\"", ",", "&", "resources", ")", "\n", "}" ]
// ResourceListAll returns all resources.
[ "ResourceListAll", "returns", "all", "resources", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L243-L246
train
flynn/flynn
controller/client/v1/client.go
ResourceList
func (c *Client) ResourceList(providerID string) ([]*ct.Resource, error) { var resources []*ct.Resource return resources, c.Get(fmt.Sprintf("/providers/%s/resources", providerID), &resources) }
go
func (c *Client) ResourceList(providerID string) ([]*ct.Resource, error) { var resources []*ct.Resource return resources, c.Get(fmt.Sprintf("/providers/%s/resources", providerID), &resources) }
[ "func", "(", "c", "*", "Client", ")", "ResourceList", "(", "providerID", "string", ")", "(", "[", "]", "*", "ct", ".", "Resource", ",", "error", ")", "{", "var", "resources", "[", "]", "*", "ct", ".", "Resource", "\n", "return", "resources", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s/resources\"", ",", "providerID", ")", ",", "&", "resources", ")", "\n", "}" ]
// ResourceList returns all resources under providerID.
[ "ResourceList", "returns", "all", "resources", "under", "providerID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L249-L252
train
flynn/flynn
controller/client/v1/client.go
AddResourceApp
func (c *Client) AddResourceApp(providerID, resourceID, appID string) (*ct.Resource, error) { var resource *ct.Resource return resource, c.Put(fmt.Sprintf("/providers/%s/resources/%s/apps/%s", providerID, resourceID, appID), nil, &resource) }
go
func (c *Client) AddResourceApp(providerID, resourceID, appID string) (*ct.Resource, error) { var resource *ct.Resource return resource, c.Put(fmt.Sprintf("/providers/%s/resources/%s/apps/%s", providerID, resourceID, appID), nil, &resource) }
[ "func", "(", "c", "*", "Client", ")", "AddResourceApp", "(", "providerID", ",", "resourceID", ",", "appID", "string", ")", "(", "*", "ct", ".", "Resource", ",", "error", ")", "{", "var", "resource", "*", "ct", ".", "Resource", "\n", "return", "resource", ",", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s/resources/%s/apps/%s\"", ",", "providerID", ",", "resourceID", ",", "appID", ")", ",", "nil", ",", "&", "resource", ")", "\n", "}" ]
// AddResourceApp adds appID to the resource identified by resourceID and returns the resource
[ "AddResourceApp", "adds", "appID", "to", "the", "resource", "identified", "by", "resourceID", "and", "returns", "the", "resource" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L255-L258
train
flynn/flynn
controller/client/v1/client.go
DeleteResourceApp
func (c *Client) DeleteResourceApp(providerID, resourceID, appID string) (*ct.Resource, error) { var resource *ct.Resource return resource, c.Delete(fmt.Sprintf("/providers/%s/resources/%s/apps/%s", providerID, resourceID, appID), &resource) }
go
func (c *Client) DeleteResourceApp(providerID, resourceID, appID string) (*ct.Resource, error) { var resource *ct.Resource return resource, c.Delete(fmt.Sprintf("/providers/%s/resources/%s/apps/%s", providerID, resourceID, appID), &resource) }
[ "func", "(", "c", "*", "Client", ")", "DeleteResourceApp", "(", "providerID", ",", "resourceID", ",", "appID", "string", ")", "(", "*", "ct", ".", "Resource", ",", "error", ")", "{", "var", "resource", "*", "ct", ".", "Resource", "\n", "return", "resource", ",", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s/resources/%s/apps/%s\"", ",", "providerID", ",", "resourceID", ",", "appID", ")", ",", "&", "resource", ")", "\n", "}" ]
// DeleteResourceApp removes appID from the resource identified by resourceID and returns the resource
[ "DeleteResourceApp", "removes", "appID", "from", "the", "resource", "identified", "by", "resourceID", "and", "returns", "the", "resource" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L261-L264
train
flynn/flynn
controller/client/v1/client.go
AppResourceList
func (c *Client) AppResourceList(appID string) ([]*ct.Resource, error) { var resources []*ct.Resource return resources, c.Get(fmt.Sprintf("/apps/%s/resources", appID), &resources) }
go
func (c *Client) AppResourceList(appID string) ([]*ct.Resource, error) { var resources []*ct.Resource return resources, c.Get(fmt.Sprintf("/apps/%s/resources", appID), &resources) }
[ "func", "(", "c", "*", "Client", ")", "AppResourceList", "(", "appID", "string", ")", "(", "[", "]", "*", "ct", ".", "Resource", ",", "error", ")", "{", "var", "resources", "[", "]", "*", "ct", ".", "Resource", "\n", "return", "resources", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/resources\"", ",", "appID", ")", ",", "&", "resources", ")", "\n", "}" ]
// AppResourceList returns a list of all resources under appID.
[ "AppResourceList", "returns", "a", "list", "of", "all", "resources", "under", "appID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L267-L270
train
flynn/flynn
controller/client/v1/client.go
PutResource
func (c *Client) PutResource(resource *ct.Resource) error { if resource.ID == "" || resource.ProviderID == "" { return errors.New("controller: missing id and/or provider id") } return c.Put(fmt.Sprintf("/providers/%s/resources/%s", resource.ProviderID, resource.ID), resource, resource) }
go
func (c *Client) PutResource(resource *ct.Resource) error { if resource.ID == "" || resource.ProviderID == "" { return errors.New("controller: missing id and/or provider id") } return c.Put(fmt.Sprintf("/providers/%s/resources/%s", resource.ProviderID, resource.ID), resource, resource) }
[ "func", "(", "c", "*", "Client", ")", "PutResource", "(", "resource", "*", "ct", ".", "Resource", ")", "error", "{", "if", "resource", ".", "ID", "==", "\"\"", "||", "resource", ".", "ProviderID", "==", "\"\"", "{", "return", "errors", ".", "New", "(", "\"controller: missing id and/or provider id\"", ")", "\n", "}", "\n", "return", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s/resources/%s\"", ",", "resource", ".", "ProviderID", ",", "resource", ".", "ID", ")", ",", "resource", ",", "resource", ")", "\n", "}" ]
// PutResource updates a resource.
[ "PutResource", "updates", "a", "resource", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L273-L278
train
flynn/flynn
controller/client/v1/client.go
DeleteResource
func (c *Client) DeleteResource(providerID, resourceID string) (*ct.Resource, error) { res := &ct.Resource{} err := c.Delete(fmt.Sprintf("/providers/%s/resources/%s", providerID, resourceID), res) return res, err }
go
func (c *Client) DeleteResource(providerID, resourceID string) (*ct.Resource, error) { res := &ct.Resource{} err := c.Delete(fmt.Sprintf("/providers/%s/resources/%s", providerID, resourceID), res) return res, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteResource", "(", "providerID", ",", "resourceID", "string", ")", "(", "*", "ct", ".", "Resource", ",", "error", ")", "{", "res", ":=", "&", "ct", ".", "Resource", "{", "}", "\n", "err", ":=", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"/providers/%s/resources/%s\"", ",", "providerID", ",", "resourceID", ")", ",", "res", ")", "\n", "return", "res", ",", "err", "\n", "}" ]
// DeleteResource deprovisions and deletes the resource identified by resourceID under providerID.
[ "DeleteResource", "deprovisions", "and", "deletes", "the", "resource", "identified", "by", "resourceID", "under", "providerID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L281-L285
train
flynn/flynn
controller/client/v1/client.go
PutFormation
func (c *Client) PutFormation(formation *ct.Formation) error { if formation.AppID == "" || formation.ReleaseID == "" { return errors.New("controller: missing app id and/or release id") } return c.Put(fmt.Sprintf("/apps/%s/formations/%s", formation.AppID, formation.ReleaseID), formation, formation) }
go
func (c *Client) PutFormation(formation *ct.Formation) error { if formation.AppID == "" || formation.ReleaseID == "" { return errors.New("controller: missing app id and/or release id") } return c.Put(fmt.Sprintf("/apps/%s/formations/%s", formation.AppID, formation.ReleaseID), formation, formation) }
[ "func", "(", "c", "*", "Client", ")", "PutFormation", "(", "formation", "*", "ct", ".", "Formation", ")", "error", "{", "if", "formation", ".", "AppID", "==", "\"\"", "||", "formation", ".", "ReleaseID", "==", "\"\"", "{", "return", "errors", ".", "New", "(", "\"controller: missing app id and/or release id\"", ")", "\n", "}", "\n", "return", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/formations/%s\"", ",", "formation", ".", "AppID", ",", "formation", ".", "ReleaseID", ")", ",", "formation", ",", "formation", ")", "\n", "}" ]
// PutFormation updates an existing formation.
[ "PutFormation", "updates", "an", "existing", "formation", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L389-L394
train
flynn/flynn
controller/client/v1/client.go
PutJob
func (c *Client) PutJob(job *ct.Job) error { if job.UUID == "" || job.AppID == "" { return errors.New("controller: missing job uuid and/or app id") } return c.Put(fmt.Sprintf("/apps/%s/jobs/%s", job.AppID, job.UUID), job, job) }
go
func (c *Client) PutJob(job *ct.Job) error { if job.UUID == "" || job.AppID == "" { return errors.New("controller: missing job uuid and/or app id") } return c.Put(fmt.Sprintf("/apps/%s/jobs/%s", job.AppID, job.UUID), job, job) }
[ "func", "(", "c", "*", "Client", ")", "PutJob", "(", "job", "*", "ct", ".", "Job", ")", "error", "{", "if", "job", ".", "UUID", "==", "\"\"", "||", "job", ".", "AppID", "==", "\"\"", "{", "return", "errors", ".", "New", "(", "\"controller: missing job uuid and/or app id\"", ")", "\n", "}", "\n", "return", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/jobs/%s\"", ",", "job", ".", "AppID", ",", "job", ".", "UUID", ")", ",", "job", ",", "job", ")", "\n", "}" ]
// PutJob updates an existing job.
[ "PutJob", "updates", "an", "existing", "job", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L397-L402
train
flynn/flynn
controller/client/v1/client.go
DeleteJob
func (c *Client) DeleteJob(appID, jobID string) error { return c.Delete(fmt.Sprintf("/apps/%s/jobs/%s", appID, jobID), nil) }
go
func (c *Client) DeleteJob(appID, jobID string) error { return c.Delete(fmt.Sprintf("/apps/%s/jobs/%s", appID, jobID), nil) }
[ "func", "(", "c", "*", "Client", ")", "DeleteJob", "(", "appID", ",", "jobID", "string", ")", "error", "{", "return", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/jobs/%s\"", ",", "appID", ",", "jobID", ")", ",", "nil", ")", "\n", "}" ]
// DeleteJob kills a specific job id under the specified app.
[ "DeleteJob", "kills", "a", "specific", "job", "id", "under", "the", "specified", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L405-L407
train
flynn/flynn
controller/client/v1/client.go
SetAppRelease
func (c *Client) SetAppRelease(appID, releaseID string) error { return c.Put(fmt.Sprintf("/apps/%s/release", appID), &ct.Release{ID: releaseID}, nil) }
go
func (c *Client) SetAppRelease(appID, releaseID string) error { return c.Put(fmt.Sprintf("/apps/%s/release", appID), &ct.Release{ID: releaseID}, nil) }
[ "func", "(", "c", "*", "Client", ")", "SetAppRelease", "(", "appID", ",", "releaseID", "string", ")", "error", "{", "return", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/release\"", ",", "appID", ")", ",", "&", "ct", ".", "Release", "{", "ID", ":", "releaseID", "}", ",", "nil", ")", "\n", "}" ]
// SetAppRelease sets the specified release as the current release for an app.
[ "SetAppRelease", "sets", "the", "specified", "release", "as", "the", "current", "release", "for", "an", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L410-L412
train
flynn/flynn
controller/client/v1/client.go
GetAppRelease
func (c *Client) GetAppRelease(appID string) (*ct.Release, error) { release := &ct.Release{} return release, c.Get(fmt.Sprintf("/apps/%s/release", appID), release) }
go
func (c *Client) GetAppRelease(appID string) (*ct.Release, error) { release := &ct.Release{} return release, c.Get(fmt.Sprintf("/apps/%s/release", appID), release) }
[ "func", "(", "c", "*", "Client", ")", "GetAppRelease", "(", "appID", "string", ")", "(", "*", "ct", ".", "Release", ",", "error", ")", "{", "release", ":=", "&", "ct", ".", "Release", "{", "}", "\n", "return", "release", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/release\"", ",", "appID", ")", ",", "release", ")", "\n", "}" ]
// GetAppRelease returns the current release of an app.
[ "GetAppRelease", "returns", "the", "current", "release", "of", "an", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L415-L418
train
flynn/flynn
controller/client/v1/client.go
RouteList
func (c *Client) RouteList(appID string) ([]*router.Route, error) { var routes []*router.Route return routes, c.Get(fmt.Sprintf("/apps/%s/routes", appID), &routes) }
go
func (c *Client) RouteList(appID string) ([]*router.Route, error) { var routes []*router.Route return routes, c.Get(fmt.Sprintf("/apps/%s/routes", appID), &routes) }
[ "func", "(", "c", "*", "Client", ")", "RouteList", "(", "appID", "string", ")", "(", "[", "]", "*", "router", ".", "Route", ",", "error", ")", "{", "var", "routes", "[", "]", "*", "router", ".", "Route", "\n", "return", "routes", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/routes\"", ",", "appID", ")", ",", "&", "routes", ")", "\n", "}" ]
// RouteList returns all routes for an app.
[ "RouteList", "returns", "all", "routes", "for", "an", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L421-L424
train
flynn/flynn
controller/client/v1/client.go
GetRoute
func (c *Client) GetRoute(appID string, routeID string) (*router.Route, error) { route := &router.Route{} return route, c.Get(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), route) }
go
func (c *Client) GetRoute(appID string, routeID string) (*router.Route, error) { route := &router.Route{} return route, c.Get(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), route) }
[ "func", "(", "c", "*", "Client", ")", "GetRoute", "(", "appID", "string", ",", "routeID", "string", ")", "(", "*", "router", ".", "Route", ",", "error", ")", "{", "route", ":=", "&", "router", ".", "Route", "{", "}", "\n", "return", "route", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/routes/%s\"", ",", "appID", ",", "routeID", ")", ",", "route", ")", "\n", "}" ]
// GetRoute returns details for the routeID under the specified app.
[ "GetRoute", "returns", "details", "for", "the", "routeID", "under", "the", "specified", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L427-L430
train
flynn/flynn
controller/client/v1/client.go
CreateRoute
func (c *Client) CreateRoute(appID string, route *router.Route) error { return c.Post(fmt.Sprintf("/apps/%s/routes", appID), route, route) }
go
func (c *Client) CreateRoute(appID string, route *router.Route) error { return c.Post(fmt.Sprintf("/apps/%s/routes", appID), route, route) }
[ "func", "(", "c", "*", "Client", ")", "CreateRoute", "(", "appID", "string", ",", "route", "*", "router", ".", "Route", ")", "error", "{", "return", "c", ".", "Post", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/routes\"", ",", "appID", ")", ",", "route", ",", "route", ")", "\n", "}" ]
// CreateRoute creates a new route for the specified app.
[ "CreateRoute", "creates", "a", "new", "route", "for", "the", "specified", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L433-L435
train
flynn/flynn
controller/client/v1/client.go
UpdateRoute
func (c *Client) UpdateRoute(appID string, routeID string, route *router.Route) error { return c.Put(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), route, route) }
go
func (c *Client) UpdateRoute(appID string, routeID string, route *router.Route) error { return c.Put(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), route, route) }
[ "func", "(", "c", "*", "Client", ")", "UpdateRoute", "(", "appID", "string", ",", "routeID", "string", ",", "route", "*", "router", ".", "Route", ")", "error", "{", "return", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/routes/%s\"", ",", "appID", ",", "routeID", ")", ",", "route", ",", "route", ")", "\n", "}" ]
// UpdateRoute updates details for the routeID under the specified app.
[ "UpdateRoute", "updates", "details", "for", "the", "routeID", "under", "the", "specified", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L438-L440
train
flynn/flynn
controller/client/v1/client.go
DeleteRoute
func (c *Client) DeleteRoute(appID string, routeID string) error { return c.Delete(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), nil) }
go
func (c *Client) DeleteRoute(appID string, routeID string) error { return c.Delete(fmt.Sprintf("/apps/%s/routes/%s", appID, routeID), nil) }
[ "func", "(", "c", "*", "Client", ")", "DeleteRoute", "(", "appID", "string", ",", "routeID", "string", ")", "error", "{", "return", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/routes/%s\"", ",", "appID", ",", "routeID", ")", ",", "nil", ")", "\n", "}" ]
// DeleteRoute deletes a route under the specified app.
[ "DeleteRoute", "deletes", "a", "route", "under", "the", "specified", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L443-L445
train
flynn/flynn
controller/client/v1/client.go
GetFormation
func (c *Client) GetFormation(appID, releaseID string) (*ct.Formation, error) { formation := &ct.Formation{} return formation, c.Get(fmt.Sprintf("/apps/%s/formations/%s", appID, releaseID), formation) }
go
func (c *Client) GetFormation(appID, releaseID string) (*ct.Formation, error) { formation := &ct.Formation{} return formation, c.Get(fmt.Sprintf("/apps/%s/formations/%s", appID, releaseID), formation) }
[ "func", "(", "c", "*", "Client", ")", "GetFormation", "(", "appID", ",", "releaseID", "string", ")", "(", "*", "ct", ".", "Formation", ",", "error", ")", "{", "formation", ":=", "&", "ct", ".", "Formation", "{", "}", "\n", "return", "formation", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/formations/%s\"", ",", "appID", ",", "releaseID", ")", ",", "formation", ")", "\n", "}" ]
// GetFormation returns details for the specified formation under app and // release.
[ "GetFormation", "returns", "details", "for", "the", "specified", "formation", "under", "app", "and", "release", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L449-L452
train
flynn/flynn
controller/client/v1/client.go
GetExpandedFormation
func (c *Client) GetExpandedFormation(appID, releaseID string) (*ct.ExpandedFormation, error) { formation := &ct.ExpandedFormation{} return formation, c.Get(fmt.Sprintf("/apps/%s/formations/%s?expand=true", appID, releaseID), formation) }
go
func (c *Client) GetExpandedFormation(appID, releaseID string) (*ct.ExpandedFormation, error) { formation := &ct.ExpandedFormation{} return formation, c.Get(fmt.Sprintf("/apps/%s/formations/%s?expand=true", appID, releaseID), formation) }
[ "func", "(", "c", "*", "Client", ")", "GetExpandedFormation", "(", "appID", ",", "releaseID", "string", ")", "(", "*", "ct", ".", "ExpandedFormation", ",", "error", ")", "{", "formation", ":=", "&", "ct", ".", "ExpandedFormation", "{", "}", "\n", "return", "formation", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/formations/%s?expand=true\"", ",", "appID", ",", "releaseID", ")", ",", "formation", ")", "\n", "}" ]
// GetExpandedFormation returns expanded details for the specified formation // under app and release.
[ "GetExpandedFormation", "returns", "expanded", "details", "for", "the", "specified", "formation", "under", "app", "and", "release", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L456-L459
train
flynn/flynn
controller/client/v1/client.go
FormationList
func (c *Client) FormationList(appID string) ([]*ct.Formation, error) { var formations []*ct.Formation return formations, c.Get(fmt.Sprintf("/apps/%s/formations", appID), &formations) }
go
func (c *Client) FormationList(appID string) ([]*ct.Formation, error) { var formations []*ct.Formation return formations, c.Get(fmt.Sprintf("/apps/%s/formations", appID), &formations) }
[ "func", "(", "c", "*", "Client", ")", "FormationList", "(", "appID", "string", ")", "(", "[", "]", "*", "ct", ".", "Formation", ",", "error", ")", "{", "var", "formations", "[", "]", "*", "ct", ".", "Formation", "\n", "return", "formations", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/formations\"", ",", "appID", ")", ",", "&", "formations", ")", "\n", "}" ]
// FormationList returns a list of all formations under appID.
[ "FormationList", "returns", "a", "list", "of", "all", "formations", "under", "appID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L462-L465
train
flynn/flynn
controller/client/v1/client.go
DeleteFormation
func (c *Client) DeleteFormation(appID, releaseID string) error { return c.Delete(fmt.Sprintf("/apps/%s/formations/%s", appID, releaseID), nil) }
go
func (c *Client) DeleteFormation(appID, releaseID string) error { return c.Delete(fmt.Sprintf("/apps/%s/formations/%s", appID, releaseID), nil) }
[ "func", "(", "c", "*", "Client", ")", "DeleteFormation", "(", "appID", ",", "releaseID", "string", ")", "error", "{", "return", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/formations/%s\"", ",", "appID", ",", "releaseID", ")", ",", "nil", ")", "\n", "}" ]
// DeleteFormation deletes the formation matching appID and releaseID.
[ "DeleteFormation", "deletes", "the", "formation", "matching", "appID", "and", "releaseID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L475-L477
train
flynn/flynn
controller/client/v1/client.go
GetRelease
func (c *Client) GetRelease(releaseID string) (*ct.Release, error) { release := &ct.Release{} return release, c.Get(fmt.Sprintf("/releases/%s", releaseID), release) }
go
func (c *Client) GetRelease(releaseID string) (*ct.Release, error) { release := &ct.Release{} return release, c.Get(fmt.Sprintf("/releases/%s", releaseID), release) }
[ "func", "(", "c", "*", "Client", ")", "GetRelease", "(", "releaseID", "string", ")", "(", "*", "ct", ".", "Release", ",", "error", ")", "{", "release", ":=", "&", "ct", ".", "Release", "{", "}", "\n", "return", "release", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/releases/%s\"", ",", "releaseID", ")", ",", "release", ")", "\n", "}" ]
// GetRelease returns details for the specified release.
[ "GetRelease", "returns", "details", "for", "the", "specified", "release", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L480-L483
train
flynn/flynn
controller/client/v1/client.go
GetArtifact
func (c *Client) GetArtifact(artifactID string) (*ct.Artifact, error) { artifact := &ct.Artifact{} return artifact, c.Get(fmt.Sprintf("/artifacts/%s", artifactID), artifact) }
go
func (c *Client) GetArtifact(artifactID string) (*ct.Artifact, error) { artifact := &ct.Artifact{} return artifact, c.Get(fmt.Sprintf("/artifacts/%s", artifactID), artifact) }
[ "func", "(", "c", "*", "Client", ")", "GetArtifact", "(", "artifactID", "string", ")", "(", "*", "ct", ".", "Artifact", ",", "error", ")", "{", "artifact", ":=", "&", "ct", ".", "Artifact", "{", "}", "\n", "return", "artifact", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/artifacts/%s\"", ",", "artifactID", ")", ",", "artifact", ")", "\n", "}" ]
// GetArtifact returns details for the specified artifact.
[ "GetArtifact", "returns", "details", "for", "the", "specified", "artifact", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L486-L489
train
flynn/flynn
controller/client/v1/client.go
GetApp
func (c *Client) GetApp(appID string) (*ct.App, error) { app := &ct.App{} return app, c.Get(fmt.Sprintf("/apps/%s", appID), app) }
go
func (c *Client) GetApp(appID string) (*ct.App, error) { app := &ct.App{} return app, c.Get(fmt.Sprintf("/apps/%s", appID), app) }
[ "func", "(", "c", "*", "Client", ")", "GetApp", "(", "appID", "string", ")", "(", "*", "ct", ".", "App", ",", "error", ")", "{", "app", ":=", "&", "ct", ".", "App", "{", "}", "\n", "return", "app", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s\"", ",", "appID", ")", ",", "app", ")", "\n", "}" ]
// GetApp returns details for the specified app.
[ "GetApp", "returns", "details", "for", "the", "specified", "app", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L492-L495
train
flynn/flynn
controller/client/v1/client.go
GetAppLog
func (c *Client) GetAppLog(appID string, opts *logagg.LogOpts) (io.ReadCloser, error) { path := fmt.Sprintf("/apps/%s/log", appID) if opts != nil { if encodedQuery := opts.EncodedQuery(); encodedQuery != "" { path = fmt.Sprintf("%s?%s", path, encodedQuery) } } res, err := c.RawReq("GET", path, nil, nil, nil) if err != nil { return nil, err } return res.Body, nil }
go
func (c *Client) GetAppLog(appID string, opts *logagg.LogOpts) (io.ReadCloser, error) { path := fmt.Sprintf("/apps/%s/log", appID) if opts != nil { if encodedQuery := opts.EncodedQuery(); encodedQuery != "" { path = fmt.Sprintf("%s?%s", path, encodedQuery) } } res, err := c.RawReq("GET", path, nil, nil, nil) if err != nil { return nil, err } return res.Body, nil }
[ "func", "(", "c", "*", "Client", ")", "GetAppLog", "(", "appID", "string", ",", "opts", "*", "logagg", ".", "LogOpts", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "path", ":=", "fmt", ".", "Sprintf", "(", "\"/apps/%s/log\"", ",", "appID", ")", "\n", "if", "opts", "!=", "nil", "{", "if", "encodedQuery", ":=", "opts", ".", "EncodedQuery", "(", ")", ";", "encodedQuery", "!=", "\"\"", "{", "path", "=", "fmt", ".", "Sprintf", "(", "\"%s?%s\"", ",", "path", ",", "encodedQuery", ")", "\n", "}", "\n", "}", "\n", "res", ",", "err", ":=", "c", ".", "RawReq", "(", "\"GET\"", ",", "path", ",", "nil", ",", "nil", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "res", ".", "Body", ",", "nil", "\n", "}" ]
// GetAppLog returns a ReadCloser log stream of the app with ID appID. If lines // is zero or above, the number of lines returned will be capped at that value. // Otherwise, all available logs are returned. If follow is true, new log lines // are streamed after the buffered log.
[ "GetAppLog", "returns", "a", "ReadCloser", "log", "stream", "of", "the", "app", "with", "ID", "appID", ".", "If", "lines", "is", "zero", "or", "above", "the", "number", "of", "lines", "returned", "will", "be", "capped", "at", "that", "value", ".", "Otherwise", "all", "available", "logs", "are", "returned", ".", "If", "follow", "is", "true", "new", "log", "lines", "are", "streamed", "after", "the", "buffered", "log", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L501-L513
train
flynn/flynn
controller/client/v1/client.go
StreamAppLog
func (c *Client) StreamAppLog(appID string, opts *logagg.LogOpts, output chan<- *ct.SSELogChunk) (stream.Stream, error) { path := fmt.Sprintf("/apps/%s/log", appID) if opts != nil { if encodedQuery := opts.EncodedQuery(); encodedQuery != "" { path = fmt.Sprintf("%s?%s", path, encodedQuery) } } return c.Stream("GET", path, nil, output) }
go
func (c *Client) StreamAppLog(appID string, opts *logagg.LogOpts, output chan<- *ct.SSELogChunk) (stream.Stream, error) { path := fmt.Sprintf("/apps/%s/log", appID) if opts != nil { if encodedQuery := opts.EncodedQuery(); encodedQuery != "" { path = fmt.Sprintf("%s?%s", path, encodedQuery) } } return c.Stream("GET", path, nil, output) }
[ "func", "(", "c", "*", "Client", ")", "StreamAppLog", "(", "appID", "string", ",", "opts", "*", "logagg", ".", "LogOpts", ",", "output", "chan", "<-", "*", "ct", ".", "SSELogChunk", ")", "(", "stream", ".", "Stream", ",", "error", ")", "{", "path", ":=", "fmt", ".", "Sprintf", "(", "\"/apps/%s/log\"", ",", "appID", ")", "\n", "if", "opts", "!=", "nil", "{", "if", "encodedQuery", ":=", "opts", ".", "EncodedQuery", "(", ")", ";", "encodedQuery", "!=", "\"\"", "{", "path", "=", "fmt", ".", "Sprintf", "(", "\"%s?%s\"", ",", "path", ",", "encodedQuery", ")", "\n", "}", "\n", "}", "\n", "return", "c", ".", "Stream", "(", "\"GET\"", ",", "path", ",", "nil", ",", "output", ")", "\n", "}" ]
// StreamAppLog is the same as GetAppLog but returns log lines via an SSE stream
[ "StreamAppLog", "is", "the", "same", "as", "GetAppLog", "but", "returns", "log", "lines", "via", "an", "SSE", "stream" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L516-L524
train
flynn/flynn
controller/client/v1/client.go
GetDeployment
func (c *Client) GetDeployment(deploymentID string) (*ct.Deployment, error) { res := &ct.Deployment{} return res, c.Get(fmt.Sprintf("/deployments/%s", deploymentID), res) }
go
func (c *Client) GetDeployment(deploymentID string) (*ct.Deployment, error) { res := &ct.Deployment{} return res, c.Get(fmt.Sprintf("/deployments/%s", deploymentID), res) }
[ "func", "(", "c", "*", "Client", ")", "GetDeployment", "(", "deploymentID", "string", ")", "(", "*", "ct", ".", "Deployment", ",", "error", ")", "{", "res", ":=", "&", "ct", ".", "Deployment", "{", "}", "\n", "return", "res", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/deployments/%s\"", ",", "deploymentID", ")", ",", "res", ")", "\n", "}" ]
// GetDeployment returns a deployment queued on the deployer.
[ "GetDeployment", "returns", "a", "deployment", "queued", "on", "the", "deployer", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L527-L530
train
flynn/flynn
controller/client/v1/client.go
DeploymentList
func (c *Client) DeploymentList(appID string) ([]*ct.Deployment, error) { var deployments []*ct.Deployment return deployments, c.Get(fmt.Sprintf("/apps/%s/deployments", appID), &deployments) }
go
func (c *Client) DeploymentList(appID string) ([]*ct.Deployment, error) { var deployments []*ct.Deployment return deployments, c.Get(fmt.Sprintf("/apps/%s/deployments", appID), &deployments) }
[ "func", "(", "c", "*", "Client", ")", "DeploymentList", "(", "appID", "string", ")", "(", "[", "]", "*", "ct", ".", "Deployment", ",", "error", ")", "{", "var", "deployments", "[", "]", "*", "ct", ".", "Deployment", "\n", "return", "deployments", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/deployments\"", ",", "appID", ")", ",", "&", "deployments", ")", "\n", "}" ]
// DeploymentList returns a list of all deployments.
[ "DeploymentList", "returns", "a", "list", "of", "all", "deployments", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L538-L541
train
flynn/flynn
controller/client/v1/client.go
StreamJobEvents
func (c *Client) StreamJobEvents(appID string, output chan *ct.Job) (stream.Stream, error) { appEvents := make(chan *ct.Event) go convertEvents(appEvents, output) return c.StreamEvents(ct.StreamEventsOptions{ AppID: appID, ObjectTypes: []ct.EventType{ct.EventTypeJob}, }, appEvents) }
go
func (c *Client) StreamJobEvents(appID string, output chan *ct.Job) (stream.Stream, error) { appEvents := make(chan *ct.Event) go convertEvents(appEvents, output) return c.StreamEvents(ct.StreamEventsOptions{ AppID: appID, ObjectTypes: []ct.EventType{ct.EventTypeJob}, }, appEvents) }
[ "func", "(", "c", "*", "Client", ")", "StreamJobEvents", "(", "appID", "string", ",", "output", "chan", "*", "ct", ".", "Job", ")", "(", "stream", ".", "Stream", ",", "error", ")", "{", "appEvents", ":=", "make", "(", "chan", "*", "ct", ".", "Event", ")", "\n", "go", "convertEvents", "(", "appEvents", ",", "output", ")", "\n", "return", "c", ".", "StreamEvents", "(", "ct", ".", "StreamEventsOptions", "{", "AppID", ":", "appID", ",", "ObjectTypes", ":", "[", "]", "ct", ".", "EventType", "{", "ct", ".", "EventTypeJob", "}", ",", "}", ",", "appEvents", ")", "\n", "}" ]
// StreamJobEvents streams job events to the output channel.
[ "StreamJobEvents", "streams", "job", "events", "to", "the", "output", "channel", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L611-L618
train
flynn/flynn
controller/client/v1/client.go
RunJobAttached
func (c *Client) RunJobAttached(appID string, job *ct.NewJob) (httpclient.ReadWriteCloser, error) { return c.Hijack("POST", fmt.Sprintf("/apps/%s/jobs", appID), http.Header{"Upgrade": {"flynn-attach/0"}}, job) }
go
func (c *Client) RunJobAttached(appID string, job *ct.NewJob) (httpclient.ReadWriteCloser, error) { return c.Hijack("POST", fmt.Sprintf("/apps/%s/jobs", appID), http.Header{"Upgrade": {"flynn-attach/0"}}, job) }
[ "func", "(", "c", "*", "Client", ")", "RunJobAttached", "(", "appID", "string", ",", "job", "*", "ct", ".", "NewJob", ")", "(", "httpclient", ".", "ReadWriteCloser", ",", "error", ")", "{", "return", "c", ".", "Hijack", "(", "\"POST\"", ",", "fmt", ".", "Sprintf", "(", "\"/apps/%s/jobs\"", ",", "appID", ")", ",", "http", ".", "Header", "{", "\"Upgrade\"", ":", "{", "\"flynn-attach/0\"", "}", "}", ",", "job", ")", "\n", "}" ]
// RunJobAttached runs a new job under the specified app, attaching to the job // and returning a ReadWriteCloser stream, which can then be used for // communicating with the job.
[ "RunJobAttached", "runs", "a", "new", "job", "under", "the", "specified", "app", "attaching", "to", "the", "job", "and", "returning", "a", "ReadWriteCloser", "stream", "which", "can", "then", "be", "used", "for", "communicating", "with", "the", "job", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L724-L726
train
flynn/flynn
controller/client/v1/client.go
RunJobDetached
func (c *Client) RunJobDetached(appID string, req *ct.NewJob) (*ct.Job, error) { job := &ct.Job{} return job, c.Post(fmt.Sprintf("/apps/%s/jobs", appID), req, job) }
go
func (c *Client) RunJobDetached(appID string, req *ct.NewJob) (*ct.Job, error) { job := &ct.Job{} return job, c.Post(fmt.Sprintf("/apps/%s/jobs", appID), req, job) }
[ "func", "(", "c", "*", "Client", ")", "RunJobDetached", "(", "appID", "string", ",", "req", "*", "ct", ".", "NewJob", ")", "(", "*", "ct", ".", "Job", ",", "error", ")", "{", "job", ":=", "&", "ct", ".", "Job", "{", "}", "\n", "return", "job", ",", "c", ".", "Post", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/jobs\"", ",", "appID", ")", ",", "req", ",", "job", ")", "\n", "}" ]
// RunJobDetached runs a new job under the specified app, returning the job's // details.
[ "RunJobDetached", "runs", "a", "new", "job", "under", "the", "specified", "app", "returning", "the", "job", "s", "details", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L730-L733
train
flynn/flynn
controller/client/v1/client.go
GetJob
func (c *Client) GetJob(appID, jobID string) (*ct.Job, error) { job := &ct.Job{} return job, c.Get(fmt.Sprintf("/apps/%s/jobs/%s", appID, jobID), job) }
go
func (c *Client) GetJob(appID, jobID string) (*ct.Job, error) { job := &ct.Job{} return job, c.Get(fmt.Sprintf("/apps/%s/jobs/%s", appID, jobID), job) }
[ "func", "(", "c", "*", "Client", ")", "GetJob", "(", "appID", ",", "jobID", "string", ")", "(", "*", "ct", ".", "Job", ",", "error", ")", "{", "job", ":=", "&", "ct", ".", "Job", "{", "}", "\n", "return", "job", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/jobs/%s\"", ",", "appID", ",", "jobID", ")", ",", "job", ")", "\n", "}" ]
// GetJob returns a Job for the given app and job ID
[ "GetJob", "returns", "a", "Job", "for", "the", "given", "app", "and", "job", "ID" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L736-L739
train
flynn/flynn
controller/client/v1/client.go
JobList
func (c *Client) JobList(appID string) ([]*ct.Job, error) { var jobs []*ct.Job return jobs, c.Get(fmt.Sprintf("/apps/%s/jobs", appID), &jobs) }
go
func (c *Client) JobList(appID string) ([]*ct.Job, error) { var jobs []*ct.Job return jobs, c.Get(fmt.Sprintf("/apps/%s/jobs", appID), &jobs) }
[ "func", "(", "c", "*", "Client", ")", "JobList", "(", "appID", "string", ")", "(", "[", "]", "*", "ct", ".", "Job", ",", "error", ")", "{", "var", "jobs", "[", "]", "*", "ct", ".", "Job", "\n", "return", "jobs", ",", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"/apps/%s/jobs\"", ",", "appID", ")", ",", "&", "jobs", ")", "\n", "}" ]
// JobList returns a list of all jobs.
[ "JobList", "returns", "a", "list", "of", "all", "jobs", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L742-L745
train
flynn/flynn
controller/client/v1/client.go
JobListActive
func (c *Client) JobListActive() ([]*ct.Job, error) { var jobs []*ct.Job return jobs, c.Get("/active-jobs", &jobs) }
go
func (c *Client) JobListActive() ([]*ct.Job, error) { var jobs []*ct.Job return jobs, c.Get("/active-jobs", &jobs) }
[ "func", "(", "c", "*", "Client", ")", "JobListActive", "(", ")", "(", "[", "]", "*", "ct", ".", "Job", ",", "error", ")", "{", "var", "jobs", "[", "]", "*", "ct", ".", "Job", "\n", "return", "jobs", ",", "c", ".", "Get", "(", "\"/active-jobs\"", ",", "&", "jobs", ")", "\n", "}" ]
// JobListActive returns a list of all active jobs.
[ "JobListActive", "returns", "a", "list", "of", "all", "active", "jobs", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L748-L751
train
flynn/flynn
controller/client/v1/client.go
AppList
func (c *Client) AppList() ([]*ct.App, error) { var apps []*ct.App return apps, c.Get("/apps", &apps) }
go
func (c *Client) AppList() ([]*ct.App, error) { var apps []*ct.App return apps, c.Get("/apps", &apps) }
[ "func", "(", "c", "*", "Client", ")", "AppList", "(", ")", "(", "[", "]", "*", "ct", ".", "App", ",", "error", ")", "{", "var", "apps", "[", "]", "*", "ct", ".", "App", "\n", "return", "apps", ",", "c", ".", "Get", "(", "\"/apps\"", ",", "&", "apps", ")", "\n", "}" ]
// AppList returns a list of all apps.
[ "AppList", "returns", "a", "list", "of", "all", "apps", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/v1/client.go#L754-L757
train