id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
27,600 | flynn/flynn | pkg/cluster/attach.go | NewAttachClient | func NewAttachClient(conn io.ReadWriteCloser) AttachClient {
return &attachClient{conn: conn, w: bufio.NewWriter(conn)}
} | go | func NewAttachClient(conn io.ReadWriteCloser) AttachClient {
return &attachClient{conn: conn, w: bufio.NewWriter(conn)}
} | [
"func",
"NewAttachClient",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
")",
"AttachClient",
"{",
"return",
"&",
"attachClient",
"{",
"conn",
":",
"conn",
",",
"w",
":",
"bufio",
".",
"NewWriter",
"(",
"conn",
")",
"}",
"\n",
"}"
] | // NewAttachClient wraps conn in an implementation of AttachClient. | [
"NewAttachClient",
"wraps",
"conn",
"in",
"an",
"implementation",
"of",
"AttachClient",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/attach.go#L88-L90 |
27,601 | flynn/flynn | pkg/pinned/pinned.go | Dial | func (c *Config) Dial(network, addr string) (net.Conn, error) {
var conf tls.Config
if c.Config != nil {
conf = *c.Config
}
conf.InsecureSkipVerify = true
cn, err := dialer.Retry.Dial(network, addr)
if err != nil {
return nil, err
}
conn := Conn{
Conn: tls.Client(cn, &conf),
Wire: cn,
}
if conf.Ser... | go | func (c *Config) Dial(network, addr string) (net.Conn, error) {
var conf tls.Config
if c.Config != nil {
conf = *c.Config
}
conf.InsecureSkipVerify = true
cn, err := dialer.Retry.Dial(network, addr)
if err != nil {
return nil, err
}
conn := Conn{
Conn: tls.Client(cn, &conf),
Wire: cn,
}
if conf.Ser... | [
"func",
"(",
"c",
"*",
"Config",
")",
"Dial",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"var",
"conf",
"tls",
".",
"Config",
"\n",
"if",
"c",
".",
"Config",
"!=",
"nil",
"{",
"conf",
"=",
"*",
... | // Dial establishes a TLS connection to addr and checks the peer leaf
// certificate against the configured pin. The underlying type of the returned
// net.Conn is a Conn. | [
"Dial",
"establishes",
"a",
"TLS",
"connection",
"to",
"addr",
"and",
"checks",
"the",
"peer",
"leaf",
"certificate",
"against",
"the",
"configured",
"pin",
".",
"The",
"underlying",
"type",
"of",
"the",
"returned",
"net",
".",
"Conn",
"is",
"a",
"Conn",
"... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/pinned/pinned.go#L36-L74 |
27,602 | flynn/flynn | pkg/pinned/pinned.go | CloseWrite | func (c Conn) CloseWrite() error {
if cw, ok := c.Wire.(interface {
CloseWrite() error
}); ok {
return cw.CloseWrite()
}
return errors.New("pinned: underlying connection does not support CloseWrite")
} | go | func (c Conn) CloseWrite() error {
if cw, ok := c.Wire.(interface {
CloseWrite() error
}); ok {
return cw.CloseWrite()
}
return errors.New("pinned: underlying connection does not support CloseWrite")
} | [
"func",
"(",
"c",
"Conn",
")",
"CloseWrite",
"(",
")",
"error",
"{",
"if",
"cw",
",",
"ok",
":=",
"c",
".",
"Wire",
".",
"(",
"interface",
"{",
"CloseWrite",
"(",
")",
"error",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"cw",
".",
"CloseWrite",
... | // CloseWrite shuts down the writing side of the connection. | [
"CloseWrite",
"shuts",
"down",
"the",
"writing",
"side",
"of",
"the",
"connection",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/pinned/pinned.go#L86-L93 |
27,603 | flynn/flynn | discoverd/client/client.go | currentPin | func (c *Client) currentPin() (string, string) {
c.mu.RLock()
defer c.mu.RUnlock()
return c.leader, c.pinned
} | go | func (c *Client) currentPin() (string, string) {
c.mu.RLock()
defer c.mu.RUnlock()
return c.leader, c.pinned
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"currentPin",
"(",
")",
"(",
"string",
",",
"string",
")",
"{",
"c",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"c",
".",
"leader",
",",
"c... | // Retrieves current pin value | [
"Retrieves",
"current",
"pin",
"value"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/client/client.go#L132-L136 |
27,604 | flynn/flynn | discoverd/client/client.go | updatePin | func (c *Client) updatePin(new string) {
c.mu.Lock()
defer c.mu.Unlock()
c.pinned = new
} | go | func (c *Client) updatePin(new string) {
c.mu.Lock()
defer c.mu.Unlock()
c.pinned = new
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"updatePin",
"(",
"new",
"string",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"pinned",
"=",
"new",
"\n",
"}"
] | // Update the currently pinned server | [
"Update",
"the",
"currently",
"pinned",
"server"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/client/client.go#L139-L143 |
27,605 | flynn/flynn | discoverd/client/client.go | updateServers | func (c *Client) updateServers(servers []string, idx uint64) {
c.mu.Lock()
defer c.mu.Unlock()
// If the new index isn't greater than the current index then ignore
// changes to the peer list. Prevents out of order request handling
// nuking a more recent version of the peer list.
if idx < c.idx {
return
}
c... | go | func (c *Client) updateServers(servers []string, idx uint64) {
c.mu.Lock()
defer c.mu.Unlock()
// If the new index isn't greater than the current index then ignore
// changes to the peer list. Prevents out of order request handling
// nuking a more recent version of the peer list.
if idx < c.idx {
return
}
c... | [
"func",
"(",
"c",
"*",
"Client",
")",
"updateServers",
"(",
"servers",
"[",
"]",
"string",
",",
"idx",
"uint64",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// If the new index i... | // Updates the list of peers | [
"Updates",
"the",
"list",
"of",
"peers"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/client/client.go#L146-L179 |
27,606 | flynn/flynn | pkg/keepalive/reuseport.go | ReusableListen | func ReusableListen(proto, addr string) (net.Listener, error) {
backlogOnce.Do(func() {
backlog = maxListenerBacklog()
})
saddr, typ, err := sockaddr(proto, addr)
if err != nil {
return nil, err
}
fd, err := syscall.Socket(typ, syscall.SOCK_STREAM, syscall.IPPROTO_TCP)
if err != nil {
return nil, err
}
... | go | func ReusableListen(proto, addr string) (net.Listener, error) {
backlogOnce.Do(func() {
backlog = maxListenerBacklog()
})
saddr, typ, err := sockaddr(proto, addr)
if err != nil {
return nil, err
}
fd, err := syscall.Socket(typ, syscall.SOCK_STREAM, syscall.IPPROTO_TCP)
if err != nil {
return nil, err
}
... | [
"func",
"ReusableListen",
"(",
"proto",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"backlogOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"backlog",
"=",
"maxListenerBacklog",
"(",
")",
"\n",
"}",
")",
"\n\n",
"sa... | // ReusableListen returns a TCP listener with SO_REUSEPORT and keepalives
// enabled. | [
"ReusableListen",
"returns",
"a",
"TCP",
"listener",
"with",
"SO_REUSEPORT",
"and",
"keepalives",
"enabled",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/keepalive/reuseport.go#L19-L58 |
27,607 | flynn/flynn | router/client/client.go | NewWithAddr | func NewWithAddr(addr string) Client {
c := newRouterClient()
c.URL = fmt.Sprintf("http://%s", addr)
return c
} | go | func NewWithAddr(addr string) Client {
c := newRouterClient()
c.URL = fmt.Sprintf("http://%s", addr)
return c
} | [
"func",
"NewWithAddr",
"(",
"addr",
"string",
")",
"Client",
"{",
"c",
":=",
"newRouterClient",
"(",
")",
"\n",
"c",
".",
"URL",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"addr",
")",
"\n",
"return",
"c",
"\n",
"}"
] | // NewWithAddr uses addr as the specified API url and returns a client. | [
"NewWithAddr",
"uses",
"addr",
"as",
"the",
"specified",
"API",
"url",
"and",
"returns",
"a",
"client",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/client/client.go#L46-L50 |
27,608 | flynn/flynn | appliance/redis/process.go | NewProcess | func NewProcess() *Process {
p := &Process{
Port: DefaultPort,
BinDir: DefaultBinDir,
DataDir: DefaultDataDir,
Password: DefaultPassword,
OpTimeout: DefaultOpTimeout,
ReplTimeout: DefaultReplTimeout,
Logger: log15.New("app", "redis"),
}
p.stopping.Store(false)
return p
} | go | func NewProcess() *Process {
p := &Process{
Port: DefaultPort,
BinDir: DefaultBinDir,
DataDir: DefaultDataDir,
Password: DefaultPassword,
OpTimeout: DefaultOpTimeout,
ReplTimeout: DefaultReplTimeout,
Logger: log15.New("app", "redis"),
}
p.stopping.Store(false)
return p
} | [
"func",
"NewProcess",
"(",
")",
"*",
"Process",
"{",
"p",
":=",
"&",
"Process",
"{",
"Port",
":",
"DefaultPort",
",",
"BinDir",
":",
"DefaultBinDir",
",",
"DataDir",
":",
"DefaultDataDir",
",",
"Password",
":",
"DefaultPassword",
",",
"OpTimeout",
":",
"De... | // NewProcess returns a new instance of Process with defaults. | [
"NewProcess",
"returns",
"a",
"new",
"instance",
"of",
"Process",
"with",
"defaults",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L70-L82 |
27,609 | flynn/flynn | appliance/redis/process.go | Start | func (p *Process) Start() error {
p.mtx.Lock()
defer p.mtx.Unlock()
// Valdiate that process is not already running and that we have a config.
if p.running {
return ErrRunning
}
return p.start()
} | go | func (p *Process) Start() error {
p.mtx.Lock()
defer p.mtx.Unlock()
// Valdiate that process is not already running and that we have a config.
if p.running {
return ErrRunning
}
return p.start()
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"Start",
"(",
")",
"error",
"{",
"p",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"// Valdiate that process is not already running and that we have a config.",
"if... | // Start begins the process.
// Returns an error if the process is already running. | [
"Start",
"begins",
"the",
"process",
".",
"Returns",
"an",
"error",
"if",
"the",
"process",
"is",
"already",
"running",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L89-L98 |
27,610 | flynn/flynn | appliance/redis/process.go | Stop | func (p *Process) Stop() error {
p.mtx.Lock()
defer p.mtx.Unlock()
if !p.running {
return ErrStopped
}
return p.stop()
} | go | func (p *Process) Stop() error {
p.mtx.Lock()
defer p.mtx.Unlock()
if !p.running {
return ErrStopped
}
return p.stop()
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"Stop",
"(",
")",
"error",
"{",
"p",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"!",
"p",
".",
"running",
"{",
"return",
"ErrStopped",
"\n",
... | // Stop attempts to gracefully stop the process. If the process cannot be
// stopped gracefully then it is forcefully stopped. Returns an error if the
// process is already stopped. | [
"Stop",
"attempts",
"to",
"gracefully",
"stop",
"the",
"process",
".",
"If",
"the",
"process",
"cannot",
"be",
"stopped",
"gracefully",
"then",
"it",
"is",
"forcefully",
"stopped",
".",
"Returns",
"an",
"error",
"if",
"the",
"process",
"is",
"already",
"stop... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L142-L150 |
27,611 | flynn/flynn | appliance/redis/process.go | monitorCmd | func (p *Process) monitorCmd(cmd *exec.Cmd, stopped chan struct{}) {
err := cmd.Wait()
if !p.stopping.Load().(bool) {
p.Logger.Error("unexpectedly exit", "err", err)
shutdown.ExitWithCode(1)
}
close(stopped)
} | go | func (p *Process) monitorCmd(cmd *exec.Cmd, stopped chan struct{}) {
err := cmd.Wait()
if !p.stopping.Load().(bool) {
p.Logger.Error("unexpectedly exit", "err", err)
shutdown.ExitWithCode(1)
}
close(stopped)
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"monitorCmd",
"(",
"cmd",
"*",
"exec",
".",
"Cmd",
",",
"stopped",
"chan",
"struct",
"{",
"}",
")",
"{",
"err",
":=",
"cmd",
".",
"Wait",
"(",
")",
"\n",
"if",
"!",
"p",
".",
"stopping",
".",
"Load",
"(",
... | // monitorCmd waits for cmd to finish and reports an error if it was unexpected.
// Also closes the stopped channel to notify other listeners that it has finished. | [
"monitorCmd",
"waits",
"for",
"cmd",
"to",
"finish",
"and",
"reports",
"an",
"error",
"if",
"it",
"was",
"unexpected",
".",
"Also",
"closes",
"the",
"stopped",
"channel",
"to",
"notify",
"other",
"listeners",
"that",
"it",
"has",
"finished",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L179-L186 |
27,612 | flynn/flynn | appliance/redis/process.go | writeConfig | func (p *Process) writeConfig() error {
logger := p.Logger.New("fn", "writeConfig")
logger.Info("writing")
// Create parent directory if it doesn't exist.
if err := os.MkdirAll(filepath.Dir(p.ConfigPath()), 0777); err != nil {
logger.Error("cannot create config parent directory", "err", err)
return err
}
f,... | go | func (p *Process) writeConfig() error {
logger := p.Logger.New("fn", "writeConfig")
logger.Info("writing")
// Create parent directory if it doesn't exist.
if err := os.MkdirAll(filepath.Dir(p.ConfigPath()), 0777); err != nil {
logger.Error("cannot create config parent directory", "err", err)
return err
}
f,... | [
"func",
"(",
"p",
"*",
"Process",
")",
"writeConfig",
"(",
")",
"error",
"{",
"logger",
":=",
"p",
".",
"Logger",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"// Create parent direct... | // writeConfig generates a new redis.conf at the config path. | [
"writeConfig",
"generates",
"a",
"new",
"redis",
".",
"conf",
"at",
"the",
"config",
"path",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L189-L212 |
27,613 | flynn/flynn | appliance/redis/process.go | Info | func (p *Process) Info() (*ProcessInfo, error) {
p.mtx.Lock()
defer p.mtx.Unlock()
return &ProcessInfo{Running: p.running}, nil
} | go | func (p *Process) Info() (*ProcessInfo, error) {
p.mtx.Lock()
defer p.mtx.Unlock()
return &ProcessInfo{Running: p.running}, nil
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"Info",
"(",
")",
"(",
"*",
"ProcessInfo",
",",
"error",
")",
"{",
"p",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"&",
"ProcessInfo",
"{",
... | // Info returns information about the process. | [
"Info",
"returns",
"information",
"about",
"the",
"process",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L215-L219 |
27,614 | flynn/flynn | appliance/redis/process.go | ping | func (p *Process) ping(addr string, timeout time.Duration) error {
// Default to local process if addr not specified.
if addr == "" {
addr = fmt.Sprintf("localhost:%s", p.Port)
}
logger := p.Logger.New("fn", "ping", "addr", addr, "timeout", timeout)
logger.Info("sending")
timer := time.NewTimer(timeout)
defe... | go | func (p *Process) ping(addr string, timeout time.Duration) error {
// Default to local process if addr not specified.
if addr == "" {
addr = fmt.Sprintf("localhost:%s", p.Port)
}
logger := p.Logger.New("fn", "ping", "addr", addr, "timeout", timeout)
logger.Info("sending")
timer := time.NewTimer(timeout)
defe... | [
"func",
"(",
"p",
"*",
"Process",
")",
"ping",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"// Default to local process if addr not specified.",
"if",
"addr",
"==",
"\"",
"\"",
"{",
"addr",
"=",
"fmt",
".",
"Sprintf",
... | // ping executes a PING command against addr until timeout occurs. | [
"ping",
"executes",
"a",
"PING",
"command",
"against",
"addr",
"until",
"timeout",
"occurs",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L227-L277 |
27,615 | flynn/flynn | appliance/redis/process.go | pingWait | func (p *Process) pingWait(addr string, timeout time.Duration) error {
// Default to local process if addr not specified.
if addr == "" {
addr = fmt.Sprintf("localhost:%s", p.Port)
}
logger := p.Logger.New("fn", "pingWait", "addr", addr, "timeout", timeout)
ticker := time.NewTicker(checkInterval)
defer ticker... | go | func (p *Process) pingWait(addr string, timeout time.Duration) error {
// Default to local process if addr not specified.
if addr == "" {
addr = fmt.Sprintf("localhost:%s", p.Port)
}
logger := p.Logger.New("fn", "pingWait", "addr", addr, "timeout", timeout)
ticker := time.NewTicker(checkInterval)
defer ticker... | [
"func",
"(",
"p",
"*",
"Process",
")",
"pingWait",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"// Default to local process if addr not specified.",
"if",
"addr",
"==",
"\"",
"\"",
"{",
"addr",
"=",
"fmt",
".",
"Sprintf... | // pingWait continually pings a server until successful response or timeout. | [
"pingWait",
"continually",
"pings",
"a",
"server",
"until",
"successful",
"response",
"or",
"timeout",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L280-L308 |
27,616 | flynn/flynn | appliance/redis/process.go | Restore | func (p *Process) Restore(r io.Reader) error {
p.mtx.Lock()
defer p.mtx.Unlock()
logger := p.Logger.New("fn", "Restore")
logger.Info("begin restore")
// Stop if running.
if p.running {
logger.Info("stopping process")
if err := p.stop(); err != nil {
logger.Error("error stopping process", "err", err)
r... | go | func (p *Process) Restore(r io.Reader) error {
p.mtx.Lock()
defer p.mtx.Unlock()
logger := p.Logger.New("fn", "Restore")
logger.Info("begin restore")
// Stop if running.
if p.running {
logger.Info("stopping process")
if err := p.stop(); err != nil {
logger.Error("error stopping process", "err", err)
r... | [
"func",
"(",
"p",
"*",
"Process",
")",
"Restore",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"p",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"logger",
":=",
"p",
".",
"Logger",
"... | // Restore stops the process, copies an RDB from r, and restarts the process.
// Redis automatically handles recovery when there's a dump.rdb file present. | [
"Restore",
"stops",
"the",
"process",
"copies",
"an",
"RDB",
"from",
"r",
"and",
"restarts",
"the",
"process",
".",
"Redis",
"automatically",
"handles",
"recovery",
"when",
"there",
"s",
"a",
"dump",
".",
"rdb",
"file",
"present",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L312-L358 |
27,617 | flynn/flynn | appliance/redis/process.go | RedisInfo | func (p *Process) RedisInfo(addr string, timeout time.Duration) (*RedisInfo, error) {
// Default to local process if addr not specified.
if addr == "" {
addr = fmt.Sprintf("localhost:%s", p.Port)
}
logger := p.Logger.New("fn", "replInfo", "addr", addr)
logger.Info("sending INFO")
// Connect to the redis serve... | go | func (p *Process) RedisInfo(addr string, timeout time.Duration) (*RedisInfo, error) {
// Default to local process if addr not specified.
if addr == "" {
addr = fmt.Sprintf("localhost:%s", p.Port)
}
logger := p.Logger.New("fn", "replInfo", "addr", addr)
logger.Info("sending INFO")
// Connect to the redis serve... | [
"func",
"(",
"p",
"*",
"Process",
")",
"RedisInfo",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"RedisInfo",
",",
"error",
")",
"{",
"// Default to local process if addr not specified.",
"if",
"addr",
"==",
"\"",
"\"",
"{",... | // RedisInfo executes an INFO command against a Redis server and returns the results. | [
"RedisInfo",
"executes",
"an",
"INFO",
"command",
"against",
"a",
"Redis",
"server",
"and",
"returns",
"the",
"results",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L361-L405 |
27,618 | flynn/flynn | appliance/redis/process.go | ParseRedisInfo | func ParseRedisInfo(s string) (*RedisInfo, error) {
var info RedisInfo
scanner := bufio.NewScanner(strings.NewReader(s))
for scanner.Scan() {
line := scanner.Text()
// Skip blank lines & comment lines
if strings.HasPrefix(line, "#") || line == "" {
continue
}
// Split into key/value.
a := strings.S... | go | func ParseRedisInfo(s string) (*RedisInfo, error) {
var info RedisInfo
scanner := bufio.NewScanner(strings.NewReader(s))
for scanner.Scan() {
line := scanner.Text()
// Skip blank lines & comment lines
if strings.HasPrefix(line, "#") || line == "" {
continue
}
// Split into key/value.
a := strings.S... | [
"func",
"ParseRedisInfo",
"(",
"s",
"string",
")",
"(",
"*",
"RedisInfo",
",",
"error",
")",
"{",
"var",
"info",
"RedisInfo",
"\n\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"strings",
".",
"NewReader",
"(",
"s",
")",
")",
"\n",
"for",
"scann... | // ParseRedisInfo parses the response from an INFO command. | [
"ParseRedisInfo",
"parses",
"the",
"response",
"from",
"an",
"INFO",
"command",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L426-L474 |
27,619 | flynn/flynn | appliance/redis/process.go | atoi | func atoi(s string) int {
i, _ := strconv.Atoi(s)
return i
} | go | func atoi(s string) int {
i, _ := strconv.Atoi(s)
return i
} | [
"func",
"atoi",
"(",
"s",
"string",
")",
"int",
"{",
"i",
",",
"_",
":=",
"strconv",
".",
"Atoi",
"(",
"s",
")",
"\n",
"return",
"i",
"\n",
"}"
] | // atoi returns the parsed integer value of s. Returns zero if a parse error occurs. | [
"atoi",
"returns",
"the",
"parsed",
"integer",
"value",
"of",
"s",
".",
"Returns",
"zero",
"if",
"a",
"parse",
"error",
"occurs",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/process.go#L490-L493 |
27,620 | flynn/flynn | gitreceive/receiver/flynn-receive.go | needsDefaultScale | func needsDefaultScale(appID, prevReleaseID string, procs map[string]ct.ProcessType, client controller.Client) bool {
if _, ok := procs["web"]; !ok {
return false
}
if prevReleaseID == "" {
return true
}
_, err := client.GetFormation(appID, prevReleaseID)
return err == controller.ErrNotFound
} | go | func needsDefaultScale(appID, prevReleaseID string, procs map[string]ct.ProcessType, client controller.Client) bool {
if _, ok := procs["web"]; !ok {
return false
}
if prevReleaseID == "" {
return true
}
_, err := client.GetFormation(appID, prevReleaseID)
return err == controller.ErrNotFound
} | [
"func",
"needsDefaultScale",
"(",
"appID",
",",
"prevReleaseID",
"string",
",",
"procs",
"map",
"[",
"string",
"]",
"ct",
".",
"ProcessType",
",",
"client",
"controller",
".",
"Client",
")",
"bool",
"{",
"if",
"_",
",",
"ok",
":=",
"procs",
"[",
"\"",
... | // needsDefaultScale indicates whether a release needs a default scale based on
// whether it has a web process type and either has no previous release or no
// previous scale. | [
"needsDefaultScale",
"indicates",
"whether",
"a",
"release",
"needs",
"a",
"default",
"scale",
"based",
"on",
"whether",
"it",
"has",
"a",
"web",
"process",
"type",
"and",
"either",
"has",
"no",
"previous",
"release",
"or",
"no",
"previous",
"scale",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/gitreceive/receiver/flynn-receive.go#L269-L278 |
27,621 | flynn/flynn | host/update.go | setEnv | func setEnv(cmd *exec.Cmd, envs map[string]string) {
env := os.Environ()
cmd.Env = make([]string, 0, len(env)+len(envs))
outer:
for _, e := range env {
for k := range envs {
if strings.HasPrefix(e, k+"=") {
continue outer
}
}
cmd.Env = append(cmd.Env, e)
}
for k, v := range envs {
cmd.Env = appen... | go | func setEnv(cmd *exec.Cmd, envs map[string]string) {
env := os.Environ()
cmd.Env = make([]string, 0, len(env)+len(envs))
outer:
for _, e := range env {
for k := range envs {
if strings.HasPrefix(e, k+"=") {
continue outer
}
}
cmd.Env = append(cmd.Env, e)
}
for k, v := range envs {
cmd.Env = appen... | [
"func",
"setEnv",
"(",
"cmd",
"*",
"exec",
".",
"Cmd",
",",
"envs",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"env",
":=",
"os",
".",
"Environ",
"(",
")",
"\n",
"cmd",
".",
"Env",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len... | // setEnv sets the given environment variables for the command, ensuring they
// are only set once. | [
"setEnv",
"sets",
"the",
"given",
"environment",
"variables",
"for",
"the",
"command",
"ensuring",
"they",
"are",
"only",
"set",
"once",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/update.go#L183-L198 |
27,622 | flynn/flynn | host/update.go | Resume | func (c *Child) Resume(buffers host.LogBuffers) error {
if buffers == nil {
buffers = host.LogBuffers{}
}
data, err := json.Marshal(buffers)
if err != nil {
return err
}
if _, err := syscall.Write(c.sock, append(ControlMsgResume, data...)); err != nil {
return err
}
msg := make([]byte, len(ControlMsgOK))
... | go | func (c *Child) Resume(buffers host.LogBuffers) error {
if buffers == nil {
buffers = host.LogBuffers{}
}
data, err := json.Marshal(buffers)
if err != nil {
return err
}
if _, err := syscall.Write(c.sock, append(ControlMsgResume, data...)); err != nil {
return err
}
msg := make([]byte, len(ControlMsgOK))
... | [
"func",
"(",
"c",
"*",
"Child",
")",
"Resume",
"(",
"buffers",
"host",
".",
"LogBuffers",
")",
"error",
"{",
"if",
"buffers",
"==",
"nil",
"{",
"buffers",
"=",
"host",
".",
"LogBuffers",
"{",
"}",
"\n",
"}",
"\n",
"data",
",",
"err",
":=",
"json",
... | // Resume writes ControlMsgResume to the control socket and waits for a
// ControlMsgOK response | [
"Resume",
"writes",
"ControlMsgResume",
"to",
"the",
"control",
"socket",
"and",
"waits",
"for",
"a",
"ControlMsgOK",
"response"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/update.go#L216-L235 |
27,623 | flynn/flynn | pkg/cluster/client.go | Host | func (c *Client) Host(id string) (*Host, error) {
hosts, err := c.Hosts()
if err != nil {
return nil, err
}
for _, h := range hosts {
if h.ID() == id {
return h, nil
}
}
return nil, fmt.Errorf("cluster: unknown host %q", id)
} | go | func (c *Client) Host(id string) (*Host, error) {
hosts, err := c.Hosts()
if err != nil {
return nil, err
}
for _, h := range hosts {
if h.ID() == id {
return h, nil
}
}
return nil, fmt.Errorf("cluster: unknown host %q", id)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Host",
"(",
"id",
"string",
")",
"(",
"*",
"Host",
",",
"error",
")",
"{",
"hosts",
",",
"err",
":=",
"c",
".",
"Hosts",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // Host returns the host identified by id. | [
"Host",
"returns",
"the",
"host",
"identified",
"by",
"id",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/client.go#L54-L65 |
27,624 | flynn/flynn | pkg/cluster/client.go | Hosts | func (c *Client) Hosts() ([]*Host, error) {
insts, err := c.s.Instances()
if err != nil {
return nil, err
}
hosts := make([]*Host, len(insts))
for i, inst := range insts {
hosts[i] = NewHost(
inst.Meta["id"],
inst.Addr,
c.h,
HostTagsFromMeta(inst.Meta),
)
}
return hosts, nil
} | go | func (c *Client) Hosts() ([]*Host, error) {
insts, err := c.s.Instances()
if err != nil {
return nil, err
}
hosts := make([]*Host, len(insts))
for i, inst := range insts {
hosts[i] = NewHost(
inst.Meta["id"],
inst.Addr,
c.h,
HostTagsFromMeta(inst.Meta),
)
}
return hosts, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Hosts",
"(",
")",
"(",
"[",
"]",
"*",
"Host",
",",
"error",
")",
"{",
"insts",
",",
"err",
":=",
"c",
".",
"s",
".",
"Instances",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"e... | // Hosts returns a list of hosts in the cluster. | [
"Hosts",
"returns",
"a",
"list",
"of",
"hosts",
"in",
"the",
"cluster",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/client.go#L68-L83 |
27,625 | flynn/flynn | host/types/types.go | Merge | func (x ContainerConfig) Merge(y ContainerConfig) ContainerConfig {
x.TTY = x.TTY || y.TTY
x.Stdin = x.Stdin || y.Stdin
x.Data = x.Data || y.Data
if y.Args != nil {
x.Args = y.Args
}
env := make(map[string]string, len(x.Env)+len(y.Env))
for k, v := range x.Env {
env[k] = v
}
for k, v := range y.Env {
env... | go | func (x ContainerConfig) Merge(y ContainerConfig) ContainerConfig {
x.TTY = x.TTY || y.TTY
x.Stdin = x.Stdin || y.Stdin
x.Data = x.Data || y.Data
if y.Args != nil {
x.Args = y.Args
}
env := make(map[string]string, len(x.Env)+len(y.Env))
for k, v := range x.Env {
env[k] = v
}
for k, v := range y.Env {
env... | [
"func",
"(",
"x",
"ContainerConfig",
")",
"Merge",
"(",
"y",
"ContainerConfig",
")",
"ContainerConfig",
"{",
"x",
".",
"TTY",
"=",
"x",
".",
"TTY",
"||",
"y",
".",
"TTY",
"\n",
"x",
".",
"Stdin",
"=",
"x",
".",
"Stdin",
"||",
"y",
".",
"Stdin",
"... | // Apply 'y' to 'x', returning a new structure. 'y' trumps. | [
"Apply",
"y",
"to",
"x",
"returning",
"a",
"new",
"structure",
".",
"y",
"trumps",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/types/types.go#L122-L161 |
27,626 | flynn/flynn | pkg/cliutil/json.go | DecodeJSONArg | func DecodeJSONArg(name string, v interface{}) error {
var src io.Reader = os.Stdin
if name != "-" && name != "" {
f, err := os.Open(name)
if err != nil {
return err
}
defer f.Close()
src = f
}
return json.NewDecoder(src).Decode(v)
} | go | func DecodeJSONArg(name string, v interface{}) error {
var src io.Reader = os.Stdin
if name != "-" && name != "" {
f, err := os.Open(name)
if err != nil {
return err
}
defer f.Close()
src = f
}
return json.NewDecoder(src).Decode(v)
} | [
"func",
"DecodeJSONArg",
"(",
"name",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"src",
"io",
".",
"Reader",
"=",
"os",
".",
"Stdin",
"\n",
"if",
"name",
"!=",
"\"",
"\"",
"&&",
"name",
"!=",
"\"",
"\"",
"{",
"f",
",",
... | // DecodeJSONArg decodes JSON into v from a file named name, if name is empty or
// "-", stdin is used. | [
"DecodeJSONArg",
"decodes",
"JSON",
"into",
"v",
"from",
"a",
"file",
"named",
"name",
"if",
"name",
"is",
"empty",
"or",
"-",
"stdin",
"is",
"used",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cliutil/json.go#L11-L22 |
27,627 | flynn/flynn | host/volume/manager/manager.go | LockDB | func (m *Manager) LockDB() error {
m.dbMtx.RLock()
if m.db == nil {
m.dbMtx.RUnlock()
return ErrDBClosed
}
return nil
} | go | func (m *Manager) LockDB() error {
m.dbMtx.RLock()
if m.db == nil {
m.dbMtx.RUnlock()
return ErrDBClosed
}
return nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"LockDB",
"(",
")",
"error",
"{",
"m",
".",
"dbMtx",
".",
"RLock",
"(",
")",
"\n",
"if",
"m",
".",
"db",
"==",
"nil",
"{",
"m",
".",
"dbMtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ErrDBClosed",
"\n",
... | // LockDB acquires a read lock on the DB mutex so that it cannot be closed
// until the caller has finished performing actions which will lead to changes
// being persisted to the DB.
//
// For example, creating a volume first delegates to the provider to create the
// volume and then persists to the DB, but if the DB ... | [
"LockDB",
"acquires",
"a",
"read",
"lock",
"on",
"the",
"DB",
"mutex",
"so",
"that",
"it",
"cannot",
"be",
"closed",
"until",
"the",
"caller",
"has",
"finished",
"performing",
"actions",
"which",
"will",
"lead",
"to",
"changes",
"being",
"persisted",
"to",
... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/volume/manager/manager.go#L126-L133 |
27,628 | flynn/flynn | host/volume/manager/manager.go | persistVolume | func (m *Manager) persistVolume(tx *bolt.Tx, vol volume.Volume) error {
// Save the general volume info
volumesBucket := tx.Bucket([]byte("volumes"))
id := vol.Info().ID
k := []byte(id)
_, volExists := m.volumes[id]
if !volExists {
volumesBucket.Delete(k)
} else {
b, err := json.Marshal(vol.Info())
if err ... | go | func (m *Manager) persistVolume(tx *bolt.Tx, vol volume.Volume) error {
// Save the general volume info
volumesBucket := tx.Bucket([]byte("volumes"))
id := vol.Info().ID
k := []byte(id)
_, volExists := m.volumes[id]
if !volExists {
volumesBucket.Delete(k)
} else {
b, err := json.Marshal(vol.Info())
if err ... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"persistVolume",
"(",
"tx",
"*",
"bolt",
".",
"Tx",
",",
"vol",
"volume",
".",
"Volume",
")",
"error",
"{",
"// Save the general volume info",
"volumesBucket",
":=",
"tx",
".",
"Bucket",
"(",
"[",
"]",
"byte",
"(",
... | // Called to sync changes to disk when a volume is updated | [
"Called",
"to",
"sync",
"changes",
"to",
"disk",
"when",
"a",
"volume",
"is",
"updated"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/volume/manager/manager.go#L488-L526 |
27,629 | flynn/flynn | flannel/backend/vxlan/device.go | setAddr4 | func setAddr4(link *netlink.Vxlan, ipn *net.IPNet) error {
addrs, err := netlink.AddrList(link, syscall.AF_INET)
if err != nil {
return err
}
addr := netlink.Addr{IPNet: ipn}
existing := false
for _, old := range addrs {
if old.IPNet.String() == addr.IPNet.String() {
existing = true
continue
}
if e... | go | func setAddr4(link *netlink.Vxlan, ipn *net.IPNet) error {
addrs, err := netlink.AddrList(link, syscall.AF_INET)
if err != nil {
return err
}
addr := netlink.Addr{IPNet: ipn}
existing := false
for _, old := range addrs {
if old.IPNet.String() == addr.IPNet.String() {
existing = true
continue
}
if e... | [
"func",
"setAddr4",
"(",
"link",
"*",
"netlink",
".",
"Vxlan",
",",
"ipn",
"*",
"net",
".",
"IPNet",
")",
"error",
"{",
"addrs",
",",
"err",
":=",
"netlink",
".",
"AddrList",
"(",
"link",
",",
"syscall",
".",
"AF_INET",
")",
"\n",
"if",
"err",
"!="... | // sets IP4 addr on link removing any existing ones first | [
"sets",
"IP4",
"addr",
"on",
"link",
"removing",
"any",
"existing",
"ones",
"first"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/flannel/backend/vxlan/device.go#L231-L256 |
27,630 | flynn/flynn | pkg/syslog/rfc5424/parser.go | Parse | func Parse(buf []byte) (*Message, error) {
msg := &Message{}
return msg, parse(buf, msg)
} | go | func Parse(buf []byte) (*Message, error) {
msg := &Message{}
return msg, parse(buf, msg)
} | [
"func",
"Parse",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"msg",
":=",
"&",
"Message",
"{",
"}",
"\n",
"return",
"msg",
",",
"parse",
"(",
"buf",
",",
"msg",
")",
"\n",
"}"
] | // Parse parses RFC5424 syslog messages into a Message. | [
"Parse",
"parses",
"RFC5424",
"syslog",
"messages",
"into",
"a",
"Message",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/syslog/rfc5424/parser.go#L10-L13 |
27,631 | flynn/flynn | logaggregator/buffer/buffer.go | Add | func (b *Buffer) Add(m *rfc5424.Message) error {
b.mu.Lock()
defer b.mu.Unlock()
if b.length == -1 {
return errors.New("buffer closed")
}
if b.head == nil {
b.head = &message{Message: *m}
b.tail = b.head
} else {
// iterate from newest to oldest through messages to find position
// to insert new messag... | go | func (b *Buffer) Add(m *rfc5424.Message) error {
b.mu.Lock()
defer b.mu.Unlock()
if b.length == -1 {
return errors.New("buffer closed")
}
if b.head == nil {
b.head = &message{Message: *m}
b.tail = b.head
} else {
// iterate from newest to oldest through messages to find position
// to insert new messag... | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Add",
"(",
"m",
"*",
"rfc5424",
".",
"Message",
")",
"error",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"length",
"==",
... | // Add adds an element to the Buffer. If the Buffer is already full, it removes
// an existing message. | [
"Add",
"adds",
"an",
"element",
"to",
"the",
"Buffer",
".",
"If",
"the",
"Buffer",
"is",
"already",
"full",
"it",
"removes",
"an",
"existing",
"message",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/buffer/buffer.go#L50-L108 |
27,632 | flynn/flynn | logaggregator/buffer/buffer.go | Read | func (b *Buffer) Read() []*rfc5424.Message {
b.mu.RLock()
defer b.mu.RUnlock()
return b.read()
} | go | func (b *Buffer) Read() []*rfc5424.Message {
b.mu.RLock()
defer b.mu.RUnlock()
return b.read()
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Read",
"(",
")",
"[",
"]",
"*",
"rfc5424",
".",
"Message",
"{",
"b",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"b",
".",
"read",
"(",
"... | // Read returns a copied slice with the contents of the Buffer. It does not
// modify the underlying buffer in any way. You are free to modify the
// returned slice without affecting Buffer, though modifying the individual
// elements in the result will also modify those elements in the Buffer. | [
"Read",
"returns",
"a",
"copied",
"slice",
"with",
"the",
"contents",
"of",
"the",
"Buffer",
".",
"It",
"does",
"not",
"modify",
"the",
"underlying",
"buffer",
"in",
"any",
"way",
".",
"You",
"are",
"free",
"to",
"modify",
"the",
"returned",
"slice",
"wi... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/buffer/buffer.go#L124-L128 |
27,633 | flynn/flynn | logaggregator/buffer/buffer.go | ReadAndSubscribe | func (b *Buffer) ReadAndSubscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) []*rfc5424.Message {
b.mu.RLock()
defer b.mu.RUnlock()
b.subscribe(msgc, donec)
return b.read()
} | go | func (b *Buffer) ReadAndSubscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) []*rfc5424.Message {
b.mu.RLock()
defer b.mu.RUnlock()
b.subscribe(msgc, donec)
return b.read()
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"ReadAndSubscribe",
"(",
"msgc",
"chan",
"<-",
"*",
"rfc5424",
".",
"Message",
",",
"donec",
"<-",
"chan",
"struct",
"{",
"}",
")",
"[",
"]",
"*",
"rfc5424",
".",
"Message",
"{",
"b",
".",
"mu",
".",
"RLock",
... | // ReadAndSubscribe returns all buffered messages just like Read, and also
// returns a channel that will stream new messages as they arrive. | [
"ReadAndSubscribe",
"returns",
"all",
"buffered",
"messages",
"just",
"like",
"Read",
"and",
"also",
"returns",
"a",
"channel",
"that",
"will",
"stream",
"new",
"messages",
"as",
"they",
"arrive",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/buffer/buffer.go#L132-L138 |
27,634 | flynn/flynn | logaggregator/buffer/buffer.go | Subscribe | func (b *Buffer) Subscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) {
b.mu.RLock()
defer b.mu.RUnlock()
b.subscribe(msgc, donec)
} | go | func (b *Buffer) Subscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) {
b.mu.RLock()
defer b.mu.RUnlock()
b.subscribe(msgc, donec)
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Subscribe",
"(",
"msgc",
"chan",
"<-",
"*",
"rfc5424",
".",
"Message",
",",
"donec",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"b",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
... | // Subscribe returns a channel that sends all future messages added to the
// Buffer. The returned channel is buffered, and any attempts to send new
// messages to the channel will drop messages if the channel is full.
//
// The caller closes the donec channel to stop receiving messages. | [
"Subscribe",
"returns",
"a",
"channel",
"that",
"sends",
"all",
"future",
"messages",
"added",
"to",
"the",
"Buffer",
".",
"The",
"returned",
"channel",
"is",
"buffered",
"and",
"any",
"attempts",
"to",
"send",
"new",
"messages",
"to",
"the",
"channel",
"wil... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/buffer/buffer.go#L145-L150 |
27,635 | flynn/flynn | logaggregator/buffer/buffer.go | read | func (b *Buffer) read() []*rfc5424.Message {
if b.length == -1 {
return nil
}
buf := make([]*rfc5424.Message, 0, b.length)
msg := b.head
for msg != nil {
buf = append(buf, &msg.Message)
msg = msg.next
}
return buf
} | go | func (b *Buffer) read() []*rfc5424.Message {
if b.length == -1 {
return nil
}
buf := make([]*rfc5424.Message, 0, b.length)
msg := b.head
for msg != nil {
buf = append(buf, &msg.Message)
msg = msg.next
}
return buf
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"read",
"(",
")",
"[",
"]",
"*",
"rfc5424",
".",
"Message",
"{",
"if",
"b",
".",
"length",
"==",
"-",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"*",
"rfc5424",
".",... | // _read expects b.mu to already be locked | [
"_read",
"expects",
"b",
".",
"mu",
"to",
"already",
"be",
"locked"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/buffer/buffer.go#L153-L165 |
27,636 | flynn/flynn | logaggregator/buffer/buffer.go | subscribe | func (b *Buffer) subscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) {
b.subs[msgc] = struct{}{}
go func() {
select {
case <-donec:
case <-b.donec:
}
b.mu.Lock()
defer b.mu.Unlock()
delete(b.subs, msgc)
close(msgc)
}()
} | go | func (b *Buffer) subscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) {
b.subs[msgc] = struct{}{}
go func() {
select {
case <-donec:
case <-b.donec:
}
b.mu.Lock()
defer b.mu.Unlock()
delete(b.subs, msgc)
close(msgc)
}()
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"subscribe",
"(",
"msgc",
"chan",
"<-",
"*",
"rfc5424",
".",
"Message",
",",
"donec",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"b",
".",
"subs",
"[",
"msgc",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n\n... | // _subscribe assumes b.mu is already locked | [
"_subscribe",
"assumes",
"b",
".",
"mu",
"is",
"already",
"locked"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/buffer/buffer.go#L168-L183 |
27,637 | flynn/flynn | controller/client/client.go | NewClient | func NewClient(uri, key string) (Client, error) {
return NewClientWithHTTP(uri, key, httphelper.RetryClient)
} | go | func NewClient(uri, key string) (Client, error) {
return NewClientWithHTTP(uri, key, httphelper.RetryClient)
} | [
"func",
"NewClient",
"(",
"uri",
",",
"key",
"string",
")",
"(",
"Client",
",",
"error",
")",
"{",
"return",
"NewClientWithHTTP",
"(",
"uri",
",",
"key",
",",
"httphelper",
".",
"RetryClient",
")",
"\n",
"}"
] | // NewClient creates a new Client pointing at uri and using key for
// authentication. | [
"NewClient",
"creates",
"a",
"new",
"Client",
"pointing",
"at",
"uri",
"and",
"using",
"key",
"for",
"authentication",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/client.go#L130-L132 |
27,638 | flynn/flynn | controller/client/client.go | NewClientWithConfig | func NewClientWithConfig(uri, key string, config Config) (Client, error) {
if config.Pin == nil {
return NewClient(uri, key)
}
d := &pinned.Config{Pin: config.Pin}
if config.Domain != "" {
d.Config = &tls.Config{ServerName: config.Domain}
}
httpClient := &http.Client{Transport: &http.Transport{DialTLS: d.Dial... | go | func NewClientWithConfig(uri, key string, config Config) (Client, error) {
if config.Pin == nil {
return NewClient(uri, key)
}
d := &pinned.Config{Pin: config.Pin}
if config.Domain != "" {
d.Config = &tls.Config{ServerName: config.Domain}
}
httpClient := &http.Client{Transport: &http.Transport{DialTLS: d.Dial... | [
"func",
"NewClientWithConfig",
"(",
"uri",
",",
"key",
"string",
",",
"config",
"Config",
")",
"(",
"Client",
",",
"error",
")",
"{",
"if",
"config",
".",
"Pin",
"==",
"nil",
"{",
"return",
"NewClient",
"(",
"uri",
",",
"key",
")",
"\n",
"}",
"\n",
... | // NewClientWithConfig acts like NewClient, but supports custom configuration. | [
"NewClientWithConfig",
"acts",
"like",
"NewClient",
"but",
"supports",
"custom",
"configuration",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/client/client.go#L146-L159 |
27,639 | flynn/flynn | pkg/rpcplus/jsonrpc/server.go | NewServerCodec | func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec {
return &serverCodec{
dec: json.NewDecoder(conn),
enc: json.NewEncoder(conn),
c: conn,
pending: make(map[uint64]*json.RawMessage),
}
} | go | func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec {
return &serverCodec{
dec: json.NewDecoder(conn),
enc: json.NewEncoder(conn),
c: conn,
pending: make(map[uint64]*json.RawMessage),
}
} | [
"func",
"NewServerCodec",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
")",
"rpc",
".",
"ServerCodec",
"{",
"return",
"&",
"serverCodec",
"{",
"dec",
":",
"json",
".",
"NewDecoder",
"(",
"conn",
")",
",",
"enc",
":",
"json",
".",
"NewEncoder",
"(",
"conn",... | // NewServerCodec returns a new rpc.ServerCodec using JSON-RPC on conn. | [
"NewServerCodec",
"returns",
"a",
"new",
"rpc",
".",
"ServerCodec",
"using",
"JSON",
"-",
"RPC",
"on",
"conn",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/jsonrpc/server.go#L36-L43 |
27,640 | flynn/flynn | pkg/rpcplus/jsonrpc/server.go | ServeConnWithContext | func ServeConnWithContext(conn io.ReadWriteCloser, context interface{}) {
rpc.ServeCodecWithContext(NewServerCodec(conn), context)
} | go | func ServeConnWithContext(conn io.ReadWriteCloser, context interface{}) {
rpc.ServeCodecWithContext(NewServerCodec(conn), context)
} | [
"func",
"ServeConnWithContext",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
",",
"context",
"interface",
"{",
"}",
")",
"{",
"rpc",
".",
"ServeCodecWithContext",
"(",
"NewServerCodec",
"(",
"conn",
")",
",",
"context",
")",
"\n",
"}"
] | // ServeConnWithContext is like ServeConn but it allows to pass a
// connection context to the RPC methods. | [
"ServeConnWithContext",
"is",
"like",
"ServeConn",
"but",
"it",
"allows",
"to",
"pass",
"a",
"connection",
"context",
"to",
"the",
"RPC",
"methods",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/jsonrpc/server.go#L142-L144 |
27,641 | flynn/flynn | host/state.go | CloseDB | func (s *State) CloseDB() error {
s.dbCond.L.Lock()
defer s.dbCond.L.Unlock()
if s.stateDB == nil {
return nil
}
for s.dbUsers > 0 {
s.dbCond.Wait()
}
if err := s.stateDB.Close(); err != nil {
return err
}
s.stateDB = nil
return nil
} | go | func (s *State) CloseDB() error {
s.dbCond.L.Lock()
defer s.dbCond.L.Unlock()
if s.stateDB == nil {
return nil
}
for s.dbUsers > 0 {
s.dbCond.Wait()
}
if err := s.stateDB.Close(); err != nil {
return err
}
s.stateDB = nil
return nil
} | [
"func",
"(",
"s",
"*",
"State",
")",
"CloseDB",
"(",
")",
"error",
"{",
"s",
".",
"dbCond",
".",
"L",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"dbCond",
".",
"L",
".",
"Unlock",
"(",
")",
"\n",
"if",
"s",
".",
"stateDB",
"==",
"nil",
... | // CloseDB closes the persistence DB, waiting for the state to be fully
// released first. | [
"CloseDB",
"closes",
"the",
"persistence",
"DB",
"waiting",
"for",
"the",
"state",
"to",
"be",
"fully",
"released",
"first",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/state.go#L199-L213 |
27,642 | flynn/flynn | host/state.go | Acquire | func (s *State) Acquire() error {
s.dbCond.L.Lock()
defer s.dbCond.L.Unlock()
if s.stateDB == nil {
return ErrDBClosed
}
s.dbUsers++
return nil
} | go | func (s *State) Acquire() error {
s.dbCond.L.Lock()
defer s.dbCond.L.Unlock()
if s.stateDB == nil {
return ErrDBClosed
}
s.dbUsers++
return nil
} | [
"func",
"(",
"s",
"*",
"State",
")",
"Acquire",
"(",
")",
"error",
"{",
"s",
".",
"dbCond",
".",
"L",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"dbCond",
".",
"L",
".",
"Unlock",
"(",
")",
"\n",
"if",
"s",
".",
"stateDB",
"==",
"nil",
... | // Acquire acquires the state for use by incrementing s.dbUsers, which prevents
// the state DB being closed until the caller has finished performing actions
// which will lead to changes being persisted to the DB.
//
// For example, running a job starts the job and then persists the change of
// state, but if the DB i... | [
"Acquire",
"acquires",
"the",
"state",
"for",
"use",
"by",
"incrementing",
"s",
".",
"dbUsers",
"which",
"prevents",
"the",
"state",
"DB",
"being",
"closed",
"until",
"the",
"caller",
"has",
"finished",
"performing",
"actions",
"which",
"will",
"lead",
"to",
... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/state.go#L227-L235 |
27,643 | flynn/flynn | host/state.go | Release | func (s *State) Release() {
s.dbCond.L.Lock()
defer s.dbCond.L.Unlock()
s.dbUsers--
if s.dbUsers == 0 {
s.dbCond.Broadcast()
}
} | go | func (s *State) Release() {
s.dbCond.L.Lock()
defer s.dbCond.L.Unlock()
s.dbUsers--
if s.dbUsers == 0 {
s.dbCond.Broadcast()
}
} | [
"func",
"(",
"s",
"*",
"State",
")",
"Release",
"(",
")",
"{",
"s",
".",
"dbCond",
".",
"L",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"dbCond",
".",
"L",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"dbUsers",
"--",
"\n",
"if",
"s",
".",... | // Release releases the state by decrementing s.dbUsers, broadcasting the
// condition variable if no users are left to wake CloseDB. | [
"Release",
"releases",
"the",
"state",
"by",
"decrementing",
"s",
".",
"dbUsers",
"broadcasting",
"the",
"condition",
"variable",
"if",
"no",
"users",
"are",
"left",
"to",
"wake",
"CloseDB",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/state.go#L239-L246 |
27,644 | flynn/flynn | controller/utils/utils.go | GetEntrypoint | func GetEntrypoint(artifacts []*ct.Artifact, typ string) *ct.ImageEntrypoint {
for i := len(artifacts) - 1; i >= 0; i-- {
artifact := artifacts[i]
if artifact.Type != ct.ArtifactTypeFlynn {
continue
}
if e, ok := artifact.Manifest().Entrypoints[typ]; ok {
return e
}
}
for i := len(artifacts) - 1; i >... | go | func GetEntrypoint(artifacts []*ct.Artifact, typ string) *ct.ImageEntrypoint {
for i := len(artifacts) - 1; i >= 0; i-- {
artifact := artifacts[i]
if artifact.Type != ct.ArtifactTypeFlynn {
continue
}
if e, ok := artifact.Manifest().Entrypoints[typ]; ok {
return e
}
}
for i := len(artifacts) - 1; i >... | [
"func",
"GetEntrypoint",
"(",
"artifacts",
"[",
"]",
"*",
"ct",
".",
"Artifact",
",",
"typ",
"string",
")",
"*",
"ct",
".",
"ImageEntrypoint",
"{",
"for",
"i",
":=",
"len",
"(",
"artifacts",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{"... | // GetEntrypoint returns an image entrypoint for a process type from a list of
// artifacts, first iterating through them and returning any entrypoint having
// the exact type, then iterating through them and returning the artifact's
// default entrypoint if it has one.
//
// The artifacts are traversed in reverse orde... | [
"GetEntrypoint",
"returns",
"an",
"image",
"entrypoint",
"for",
"a",
"process",
"type",
"from",
"a",
"list",
"of",
"artifacts",
"first",
"iterating",
"through",
"them",
"and",
"returning",
"any",
"entrypoint",
"having",
"the",
"exact",
"type",
"then",
"iterating... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/utils/utils.go#L106-L126 |
27,645 | flynn/flynn | controller/utils/utils.go | SetupMountspecs | func SetupMountspecs(job *host.Job, artifacts []*ct.Artifact) {
for _, artifact := range artifacts {
if artifact.Type != ct.ArtifactTypeFlynn {
continue
}
if len(artifact.Manifest().Rootfs) != 1 {
continue
}
rootfs := artifact.Manifest().Rootfs[0]
for _, layer := range rootfs.Layers {
if layer.Typ... | go | func SetupMountspecs(job *host.Job, artifacts []*ct.Artifact) {
for _, artifact := range artifacts {
if artifact.Type != ct.ArtifactTypeFlynn {
continue
}
if len(artifact.Manifest().Rootfs) != 1 {
continue
}
rootfs := artifact.Manifest().Rootfs[0]
for _, layer := range rootfs.Layers {
if layer.Typ... | [
"func",
"SetupMountspecs",
"(",
"job",
"*",
"host",
".",
"Job",
",",
"artifacts",
"[",
"]",
"*",
"ct",
".",
"Artifact",
")",
"{",
"for",
"_",
",",
"artifact",
":=",
"range",
"artifacts",
"{",
"if",
"artifact",
".",
"Type",
"!=",
"ct",
".",
"ArtifactT... | // SetupMountspecs populates job.Mountspecs using the layers from a list of
// Flynn image artifacts, expecting each artifact to have a single rootfs entry
// containing squashfs layers | [
"SetupMountspecs",
"populates",
"job",
".",
"Mountspecs",
"using",
"the",
"layers",
"from",
"a",
"list",
"of",
"Flynn",
"image",
"artifacts",
"expecting",
"each",
"artifact",
"to",
"have",
"a",
"single",
"rootfs",
"entry",
"containing",
"squashfs",
"layers"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/utils/utils.go#L131-L154 |
27,646 | flynn/flynn | controller/scheduler/formation.go | IsScaleDownOf | func (p Processes) IsScaleDownOf(proc Processes) bool {
for typ, count := range p {
if count <= -proc[typ] {
return true
}
}
return false
} | go | func (p Processes) IsScaleDownOf(proc Processes) bool {
for typ, count := range p {
if count <= -proc[typ] {
return true
}
}
return false
} | [
"func",
"(",
"p",
"Processes",
")",
"IsScaleDownOf",
"(",
"proc",
"Processes",
")",
"bool",
"{",
"for",
"typ",
",",
"count",
":=",
"range",
"p",
"{",
"if",
"count",
"<=",
"-",
"proc",
"[",
"typ",
"]",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
... | // IsScaleDownOf returns whether a diff is the complete scale down of any
// process types in the given processes | [
"IsScaleDownOf",
"returns",
"whether",
"a",
"diff",
"is",
"the",
"complete",
"scale",
"down",
"of",
"any",
"process",
"types",
"in",
"the",
"given",
"processes"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/formation.go#L59-L66 |
27,647 | flynn/flynn | controller/scheduler/formation.go | RectifyOmni | func (f *Formation) RectifyOmni(hostCount int) bool {
changed := false
for typ, proc := range f.Release.Processes {
if proc.Omni && f.Processes != nil && f.Processes[typ] > 0 {
count := f.OriginalProcesses[typ] * hostCount
if f.Processes[typ] != count {
f.Processes[typ] = count
changed = true
}
}... | go | func (f *Formation) RectifyOmni(hostCount int) bool {
changed := false
for typ, proc := range f.Release.Processes {
if proc.Omni && f.Processes != nil && f.Processes[typ] > 0 {
count := f.OriginalProcesses[typ] * hostCount
if f.Processes[typ] != count {
f.Processes[typ] = count
changed = true
}
}... | [
"func",
"(",
"f",
"*",
"Formation",
")",
"RectifyOmni",
"(",
"hostCount",
"int",
")",
"bool",
"{",
"changed",
":=",
"false",
"\n",
"for",
"typ",
",",
"proc",
":=",
"range",
"f",
".",
"Release",
".",
"Processes",
"{",
"if",
"proc",
".",
"Omni",
"&&",
... | // RectifyOmni updates the process counts for omni jobs by multiplying them by
// the host count, returning whether or not any counts have changed | [
"RectifyOmni",
"updates",
"the",
"process",
"counts",
"for",
"omni",
"jobs",
"by",
"multiplying",
"them",
"by",
"the",
"host",
"count",
"returning",
"whether",
"or",
"not",
"any",
"counts",
"have",
"changed"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/formation.go#L90-L102 |
27,648 | flynn/flynn | controller/scheduler/formation.go | Diff | func (f *Formation) Diff(running Processes) Processes {
return Processes(f.Processes).Diff(running)
} | go | func (f *Formation) Diff(running Processes) Processes {
return Processes(f.Processes).Diff(running)
} | [
"func",
"(",
"f",
"*",
"Formation",
")",
"Diff",
"(",
"running",
"Processes",
")",
"Processes",
"{",
"return",
"Processes",
"(",
"f",
".",
"Processes",
")",
".",
"Diff",
"(",
"running",
")",
"\n",
"}"
] | // Diff returns the diff between the given running processes and what is
// expected to be running for the formation | [
"Diff",
"returns",
"the",
"diff",
"between",
"the",
"given",
"running",
"processes",
"and",
"what",
"is",
"expected",
"to",
"be",
"running",
"for",
"the",
"formation"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/formation.go#L124-L126 |
27,649 | flynn/flynn | host/cli/download.go | updateTUFClient | func updateTUFClient(client *tuf.Client) error {
_, err := client.Update()
if err == nil || tuf.IsLatestSnapshot(err) {
return nil
}
if err == tuf.ErrNoRootKeys {
if err := client.Init(tufconfig.RootKeys, len(tufconfig.RootKeys)); err != nil {
return err
}
return updateTUFClient(client)
}
return err
} | go | func updateTUFClient(client *tuf.Client) error {
_, err := client.Update()
if err == nil || tuf.IsLatestSnapshot(err) {
return nil
}
if err == tuf.ErrNoRootKeys {
if err := client.Init(tufconfig.RootKeys, len(tufconfig.RootKeys)); err != nil {
return err
}
return updateTUFClient(client)
}
return err
} | [
"func",
"updateTUFClient",
"(",
"client",
"*",
"tuf",
".",
"Client",
")",
"error",
"{",
"_",
",",
"err",
":=",
"client",
".",
"Update",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"||",
"tuf",
".",
"IsLatestSnapshot",
"(",
"err",
")",
"{",
"return",
... | // updateTUFClient updates the given client, initializing and re-running the
// update if ErrNoRootKeys is returned. | [
"updateTUFClient",
"updates",
"the",
"given",
"client",
"initializing",
"and",
"re",
"-",
"running",
"the",
"update",
"if",
"ErrNoRootKeys",
"is",
"returned",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/cli/download.go#L146-L158 |
27,650 | flynn/flynn | controller/scheduler/job.go | Tags | func (j *Job) Tags() map[string]string {
if j.Formation == nil {
return nil
}
return j.Formation.Tags[j.Type]
} | go | func (j *Job) Tags() map[string]string {
if j.Formation == nil {
return nil
}
return j.Formation.Tags[j.Type]
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Tags",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"if",
"j",
".",
"Formation",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"j",
".",
"Formation",
".",
"Tags",
"[",
"j",
".",
"Type",... | // Tags returns the tags for the job's process type from the formation | [
"Tags",
"returns",
"the",
"tags",
"for",
"the",
"job",
"s",
"process",
"type",
"from",
"the",
"formation"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/job.go#L115-L120 |
27,651 | flynn/flynn | controller/scheduler/job.go | TagsMatchHost | func (j *Job) TagsMatchHost(host *Host) bool {
for k, v := range j.Tags() {
if w, ok := host.Tags[k]; !ok || v != w {
return false
}
}
return true
} | go | func (j *Job) TagsMatchHost(host *Host) bool {
for k, v := range j.Tags() {
if w, ok := host.Tags[k]; !ok || v != w {
return false
}
}
return true
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"TagsMatchHost",
"(",
"host",
"*",
"Host",
")",
"bool",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"j",
".",
"Tags",
"(",
")",
"{",
"if",
"w",
",",
"ok",
":=",
"host",
".",
"Tags",
"[",
"k",
"]",
";",
"!",
... | // TagsMatchHost checks whether all of the job's tags match the corresponding
// host's tags | [
"TagsMatchHost",
"checks",
"whether",
"all",
"of",
"the",
"job",
"s",
"tags",
"match",
"the",
"corresponding",
"host",
"s",
"tags"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/job.go#L124-L131 |
27,652 | flynn/flynn | controller/scheduler/job.go | WithFormationAndType | func (j Jobs) WithFormationAndType(f *Formation, typ string) sortJobs {
jobs := make(sortJobs, 0, len(j))
for _, job := range j {
if job.Formation == f && job.Type == typ {
jobs = append(jobs, job)
}
}
jobs.Sort()
return jobs
} | go | func (j Jobs) WithFormationAndType(f *Formation, typ string) sortJobs {
jobs := make(sortJobs, 0, len(j))
for _, job := range j {
if job.Formation == f && job.Type == typ {
jobs = append(jobs, job)
}
}
jobs.Sort()
return jobs
} | [
"func",
"(",
"j",
"Jobs",
")",
"WithFormationAndType",
"(",
"f",
"*",
"Formation",
",",
"typ",
"string",
")",
"sortJobs",
"{",
"jobs",
":=",
"make",
"(",
"sortJobs",
",",
"0",
",",
"len",
"(",
"j",
")",
")",
"\n",
"for",
"_",
",",
"job",
":=",
"r... | // WithFormationAndType returns a list of jobs which belong to the given
// formation and have the given type, ordered with the most recently started
// job first | [
"WithFormationAndType",
"returns",
"a",
"list",
"of",
"jobs",
"which",
"belong",
"to",
"the",
"given",
"formation",
"and",
"have",
"the",
"given",
"type",
"ordered",
"with",
"the",
"most",
"recently",
"started",
"job",
"first"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/job.go#L211-L220 |
27,653 | flynn/flynn | host/logmux/logmux.go | Follow | func (m *Mux) Follow(r io.ReadCloser, buffer string, msgID logagg.MsgID, config *Config) *LogStream {
hdr := &rfc5424.Header{
Hostname: []byte(config.HostID),
AppName: []byte(config.AppID),
MsgID: []byte(msgID),
}
if config.JobType != "" {
hdr.ProcID = []byte(config.JobType + "." + config.JobID)
} else ... | go | func (m *Mux) Follow(r io.ReadCloser, buffer string, msgID logagg.MsgID, config *Config) *LogStream {
hdr := &rfc5424.Header{
Hostname: []byte(config.HostID),
AppName: []byte(config.AppID),
MsgID: []byte(msgID),
}
if config.JobType != "" {
hdr.ProcID = []byte(config.JobType + "." + config.JobID)
} else ... | [
"func",
"(",
"m",
"*",
"Mux",
")",
"Follow",
"(",
"r",
"io",
".",
"ReadCloser",
",",
"buffer",
"string",
",",
"msgID",
"logagg",
".",
"MsgID",
",",
"config",
"*",
"Config",
")",
"*",
"LogStream",
"{",
"hdr",
":=",
"&",
"rfc5424",
".",
"Header",
"{"... | // Follow starts a goroutine that reads log lines from the reader into the mux.
// It runs until the reader is closed or an error occurs. If an error occurs,
// the reader may still be open. | [
"Follow",
"starts",
"a",
"goroutine",
"that",
"reads",
"log",
"lines",
"from",
"the",
"reader",
"into",
"the",
"mux",
".",
"It",
"runs",
"until",
"the",
"reader",
"is",
"closed",
"or",
"an",
"error",
"occurs",
".",
"If",
"an",
"error",
"occurs",
"the",
... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/logmux/logmux.go#L286-L333 |
27,654 | flynn/flynn | host/logmux/logmux.go | jobDoneCh | func (m *Mux) jobDoneCh(jobID string, stop <-chan struct{}) <-chan struct{} {
ch := make(chan struct{})
go func() {
defer close(ch)
var started chan struct{}
m.jobsMtx.Lock()
// check if there is already a WaitGroup
wg, ok := m.jobWaits[jobID]
if !ok {
// if not, check if there is a channel to be notif... | go | func (m *Mux) jobDoneCh(jobID string, stop <-chan struct{}) <-chan struct{} {
ch := make(chan struct{})
go func() {
defer close(ch)
var started chan struct{}
m.jobsMtx.Lock()
// check if there is already a WaitGroup
wg, ok := m.jobWaits[jobID]
if !ok {
// if not, check if there is a channel to be notif... | [
"func",
"(",
"m",
"*",
"Mux",
")",
"jobDoneCh",
"(",
"jobID",
"string",
",",
"stop",
"<-",
"chan",
"struct",
"{",
"}",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"ch",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"go",
"func",
"("... | // jobDoneCh returns a channel that is closed when all of the streams we are
// following from the job have been closed. It will never unblock if the job has
// already finished. | [
"jobDoneCh",
"returns",
"a",
"channel",
"that",
"is",
"closed",
"when",
"all",
"of",
"the",
"streams",
"we",
"are",
"following",
"from",
"the",
"job",
"have",
"been",
"closed",
".",
"It",
"will",
"never",
"unblock",
"if",
"the",
"job",
"has",
"already",
... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/logmux/logmux.go#L407-L448 |
27,655 | flynn/flynn | host/logmux/logmux.go | logFiles | func (m *Mux) logFiles(app string) (map[string][]string, error) {
files, err := ioutil.ReadDir(m.logDir)
if err != nil {
return nil, err
}
res := make(map[string][]string)
for _, f := range files {
n := f.Name()
if f.IsDir() || !strings.HasSuffix(n, ".log") || !appIDPrefixPattern.MatchString(n) || !strings.... | go | func (m *Mux) logFiles(app string) (map[string][]string, error) {
files, err := ioutil.ReadDir(m.logDir)
if err != nil {
return nil, err
}
res := make(map[string][]string)
for _, f := range files {
n := f.Name()
if f.IsDir() || !strings.HasSuffix(n, ".log") || !appIDPrefixPattern.MatchString(n) || !strings.... | [
"func",
"(",
"m",
"*",
"Mux",
")",
"logFiles",
"(",
"app",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"m",
".",
"logDir",
")",
"\n",
"if",... | // logFiles returns a list of app IDs and the list of log file names associated
// with them, from oldest to newest. There is always at least one file, the
// current log for the app. | [
"logFiles",
"returns",
"a",
"list",
"of",
"app",
"IDs",
"and",
"the",
"list",
"of",
"log",
"file",
"names",
"associated",
"with",
"them",
"from",
"oldest",
"to",
"newest",
".",
"There",
"is",
"always",
"at",
"least",
"one",
"file",
"the",
"current",
"log... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/logmux/logmux.go#L620-L637 |
27,656 | flynn/flynn | host/logmux/logmux.go | Release | func (l *appLog) Release() {
l.mtx.Lock()
defer l.mtx.Unlock()
l.refs--
if l.refs == 0 {
// we're the last user, clean it up
l.l.Close()
l.m.appLogsMtx.Lock()
delete(l.m.appLogs, l.appID)
l.m.appLogsMtx.Unlock()
}
} | go | func (l *appLog) Release() {
l.mtx.Lock()
defer l.mtx.Unlock()
l.refs--
if l.refs == 0 {
// we're the last user, clean it up
l.l.Close()
l.m.appLogsMtx.Lock()
delete(l.m.appLogs, l.appID)
l.m.appLogsMtx.Unlock()
}
} | [
"func",
"(",
"l",
"*",
"appLog",
")",
"Release",
"(",
")",
"{",
"l",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"refs",
"--",
"\n",
"if",
"l",
".",
"refs",
"==",
"0",
"{",
"... | // Release releases the app log, when the last job releases an app log, it is
// closed. | [
"Release",
"releases",
"the",
"app",
"log",
"when",
"the",
"last",
"job",
"releases",
"an",
"app",
"log",
"it",
"is",
"closed",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/logmux/logmux.go#L684-L695 |
27,657 | flynn/flynn | router/tree.go | Insert | func (n *node) Insert(path string, backend *httpRoute) {
cur := n
for part, i := slice(path, 0); ; part, i = slice(path, i) {
if part != "" {
child, _ := cur.children[part]
if child == nil {
// insert node if it doesn't exist
child = &node{children: make(map[string]*node, 0)}
cur.children[part] = ... | go | func (n *node) Insert(path string, backend *httpRoute) {
cur := n
for part, i := slice(path, 0); ; part, i = slice(path, i) {
if part != "" {
child, _ := cur.children[part]
if child == nil {
// insert node if it doesn't exist
child = &node{children: make(map[string]*node, 0)}
cur.children[part] = ... | [
"func",
"(",
"n",
"*",
"node",
")",
"Insert",
"(",
"path",
"string",
",",
"backend",
"*",
"httpRoute",
")",
"{",
"cur",
":=",
"n",
"\n",
"for",
"part",
",",
"i",
":=",
"slice",
"(",
"path",
",",
"0",
")",
";",
";",
"part",
",",
"i",
"=",
"sli... | // insert a new route into the tree, replacing entry if it exists | [
"insert",
"a",
"new",
"route",
"into",
"the",
"tree",
"replacing",
"entry",
"if",
"it",
"exists"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/tree.go#L20-L37 |
27,658 | flynn/flynn | router/tree.go | Lookup | func (n *node) Lookup(path string) *httpRoute {
cur := n
prev := n
for part, i := slice(path, 0); ; part, i = slice(path, i) {
if part != "" {
cur = cur.children[part]
if cur == nil {
// can't progress any deeper, return last backend we saw
return prev.backend
}
if cur.backend != nil {
prev... | go | func (n *node) Lookup(path string) *httpRoute {
cur := n
prev := n
for part, i := slice(path, 0); ; part, i = slice(path, i) {
if part != "" {
cur = cur.children[part]
if cur == nil {
// can't progress any deeper, return last backend we saw
return prev.backend
}
if cur.backend != nil {
prev... | [
"func",
"(",
"n",
"*",
"node",
")",
"Lookup",
"(",
"path",
"string",
")",
"*",
"httpRoute",
"{",
"cur",
":=",
"n",
"\n",
"prev",
":=",
"n",
"\n",
"for",
"part",
",",
"i",
":=",
"slice",
"(",
"path",
",",
"0",
")",
";",
";",
"part",
",",
"i",
... | // lookup returns the best match for a given path | [
"lookup",
"returns",
"the",
"best",
"match",
"for",
"a",
"given",
"path"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/tree.go#L40-L62 |
27,659 | flynn/flynn | router/tree.go | slice | func slice(path string, start int) (segment string, next int) {
if len(path) == 0 || start < 0 || start >= len(path) {
return "", -1
}
end := strings.IndexRune(path[start:], '/')
if end == -1 {
return path[start:], -1
}
if path[start:start+end] == "/" {
return "", start + end + 1
}
return path[start : sta... | go | func slice(path string, start int) (segment string, next int) {
if len(path) == 0 || start < 0 || start >= len(path) {
return "", -1
}
end := strings.IndexRune(path[start:], '/')
if end == -1 {
return path[start:], -1
}
if path[start:start+end] == "/" {
return "", start + end + 1
}
return path[start : sta... | [
"func",
"slice",
"(",
"path",
"string",
",",
"start",
"int",
")",
"(",
"segment",
"string",
",",
"next",
"int",
")",
"{",
"if",
"len",
"(",
"path",
")",
"==",
"0",
"||",
"start",
"<",
"0",
"||",
"start",
">=",
"len",
"(",
"path",
")",
"{",
"ret... | // slices string into path segments performing 0 heap allocation | [
"slices",
"string",
"into",
"path",
"segments",
"performing",
"0",
"heap",
"allocation"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/tree.go#L99-L111 |
27,660 | flynn/flynn | controller/events.go | Notify | func (e *EventSubscriber) Notify(event *ct.Event) {
if len(e.objectTypes) > 0 {
foundType := false
for _, typ := range e.objectTypes {
if typ == string(event.ObjectType) {
foundType = true
break
}
}
if !foundType {
return
}
}
if e.objectID != "" && e.objectID != event.ObjectID {
return
... | go | func (e *EventSubscriber) Notify(event *ct.Event) {
if len(e.objectTypes) > 0 {
foundType := false
for _, typ := range e.objectTypes {
if typ == string(event.ObjectType) {
foundType = true
break
}
}
if !foundType {
return
}
}
if e.objectID != "" && e.objectID != event.ObjectID {
return
... | [
"func",
"(",
"e",
"*",
"EventSubscriber",
")",
"Notify",
"(",
"event",
"*",
"ct",
".",
"Event",
")",
"{",
"if",
"len",
"(",
"e",
".",
"objectTypes",
")",
">",
"0",
"{",
"foundType",
":=",
"false",
"\n",
"for",
"_",
",",
"typ",
":=",
"range",
"e",... | // Notify filters the event based on it's type and objectID and then pushes
// it to the event queue. | [
"Notify",
"filters",
"the",
"event",
"based",
"on",
"it",
"s",
"type",
"and",
"objectID",
"and",
"then",
"pushes",
"it",
"to",
"the",
"event",
"queue",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L328-L350 |
27,661 | flynn/flynn | controller/events.go | loop | func (e *EventSubscriber) loop() {
defer close(e.Events)
for {
select {
case <-e.stop:
return
case event := <-e.queue:
e.Events <- event
}
}
} | go | func (e *EventSubscriber) loop() {
defer close(e.Events)
for {
select {
case <-e.stop:
return
case event := <-e.queue:
e.Events <- event
}
}
} | [
"func",
"(",
"e",
"*",
"EventSubscriber",
")",
"loop",
"(",
")",
"{",
"defer",
"close",
"(",
"e",
".",
"Events",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"e",
".",
"stop",
":",
"return",
"\n",
"case",
"event",
":=",
"<-",
"e",
".",
"... | // loop pops events off the queue and sends them to the Events channel. | [
"loop",
"pops",
"events",
"off",
"the",
"queue",
"and",
"sends",
"them",
"to",
"the",
"Events",
"channel",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L353-L363 |
27,662 | flynn/flynn | controller/events.go | Close | func (e *EventSubscriber) Close() {
e.l.Unsubscribe(e)
e.stopOnce.Do(func() { close(e.stop) })
} | go | func (e *EventSubscriber) Close() {
e.l.Unsubscribe(e)
e.stopOnce.Do(func() { close(e.stop) })
} | [
"func",
"(",
"e",
"*",
"EventSubscriber",
")",
"Close",
"(",
")",
"{",
"e",
".",
"l",
".",
"Unsubscribe",
"(",
"e",
")",
"\n",
"e",
".",
"stopOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"e",
".",
"stop",
")",
"}",
")",
"\n",
... | // Close unsubscribes from the EventListener and stops the loop. | [
"Close",
"unsubscribes",
"from",
"the",
"EventListener",
"and",
"stops",
"the",
"loop",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L366-L369 |
27,663 | flynn/flynn | controller/events.go | CloseWithError | func (e *EventSubscriber) CloseWithError(err error) {
e.errOnce.Do(func() { e.Err = err })
e.Close()
} | go | func (e *EventSubscriber) CloseWithError(err error) {
e.errOnce.Do(func() { e.Err = err })
e.Close()
} | [
"func",
"(",
"e",
"*",
"EventSubscriber",
")",
"CloseWithError",
"(",
"err",
"error",
")",
"{",
"e",
".",
"errOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"e",
".",
"Err",
"=",
"err",
"}",
")",
"\n",
"e",
".",
"Close",
"(",
")",
"\n",
"}"
] | // CloseWithError sets the Err field and then closes the subscriber. | [
"CloseWithError",
"sets",
"the",
"Err",
"field",
"and",
"then",
"closes",
"the",
"subscriber",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L372-L375 |
27,664 | flynn/flynn | controller/events.go | Subscribe | func (e *EventListener) Subscribe(appID string, objectTypes []string, objectID string) (*EventSubscriber, error) {
e.subMtx.Lock()
defer e.subMtx.Unlock()
if e.IsClosed() {
return nil, errors.New("event listener closed")
}
s := &EventSubscriber{
Events: make(chan *ct.Event),
l: e,
queue: ... | go | func (e *EventListener) Subscribe(appID string, objectTypes []string, objectID string) (*EventSubscriber, error) {
e.subMtx.Lock()
defer e.subMtx.Unlock()
if e.IsClosed() {
return nil, errors.New("event listener closed")
}
s := &EventSubscriber{
Events: make(chan *ct.Event),
l: e,
queue: ... | [
"func",
"(",
"e",
"*",
"EventListener",
")",
"Subscribe",
"(",
"appID",
"string",
",",
"objectTypes",
"[",
"]",
"string",
",",
"objectID",
"string",
")",
"(",
"*",
"EventSubscriber",
",",
"error",
")",
"{",
"e",
".",
"subMtx",
".",
"Lock",
"(",
")",
... | // Subscribe creates and returns an EventSubscriber for the given app, type and object.
// Using an empty string for appID subscribes to all apps | [
"Subscribe",
"creates",
"and",
"returns",
"an",
"EventSubscriber",
"for",
"the",
"given",
"app",
"type",
"and",
"object",
".",
"Using",
"an",
"empty",
"string",
"for",
"appID",
"subscribes",
"to",
"all",
"apps"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L400-L421 |
27,665 | flynn/flynn | controller/events.go | Unsubscribe | func (e *EventListener) Unsubscribe(s *EventSubscriber) {
e.subMtx.Lock()
defer e.subMtx.Unlock()
if subs, ok := e.subscribers[s.appID]; ok {
delete(subs, s)
if len(subs) == 0 {
delete(e.subscribers, s.appID)
}
}
} | go | func (e *EventListener) Unsubscribe(s *EventSubscriber) {
e.subMtx.Lock()
defer e.subMtx.Unlock()
if subs, ok := e.subscribers[s.appID]; ok {
delete(subs, s)
if len(subs) == 0 {
delete(e.subscribers, s.appID)
}
}
} | [
"func",
"(",
"e",
"*",
"EventListener",
")",
"Unsubscribe",
"(",
"s",
"*",
"EventSubscriber",
")",
"{",
"e",
".",
"subMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"subMtx",
".",
"Unlock",
"(",
")",
"\n",
"if",
"subs",
",",
"ok",
":=",
"e... | // Unsubscribe unsubscribes the given subscriber. | [
"Unsubscribe",
"unsubscribes",
"the",
"given",
"subscriber",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L424-L433 |
27,666 | flynn/flynn | controller/events.go | Listen | func (e *EventListener) Listen() error {
log := logger.New("fn", "EventListener.Listen")
listener, err := e.eventRepo.db.Listen("events", log)
if err != nil {
e.CloseWithError(err)
return err
}
go func() {
for {
select {
case n, ok := <-listener.Notify:
if !ok {
e.CloseWithError(listener.Err)
... | go | func (e *EventListener) Listen() error {
log := logger.New("fn", "EventListener.Listen")
listener, err := e.eventRepo.db.Listen("events", log)
if err != nil {
e.CloseWithError(err)
return err
}
go func() {
for {
select {
case n, ok := <-listener.Notify:
if !ok {
e.CloseWithError(listener.Err)
... | [
"func",
"(",
"e",
"*",
"EventListener",
")",
"Listen",
"(",
")",
"error",
"{",
"log",
":=",
"logger",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"listener",
",",
"err",
":=",
"e",
".",
"eventRepo",
".",
"db",
".",
"Listen",
"(",
"... | // Listen creates a postgres listener for events and starts a goroutine to
// forward the events to subscribers. | [
"Listen",
"creates",
"a",
"postgres",
"listener",
"for",
"events",
"and",
"starts",
"a",
"goroutine",
"to",
"forward",
"the",
"events",
"to",
"subscribers",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L437-L475 |
27,667 | flynn/flynn | controller/events.go | Notify | func (e *EventListener) Notify(event *ct.Event) {
e.subMtx.RLock()
defer e.subMtx.RUnlock()
if subs, ok := e.subscribers[event.AppID]; ok {
for sub := range subs {
sub.Notify(event)
}
}
if event.AppID != "" {
// Ensure subscribers not filtering by app get the event
if subs, ok := e.subscribers[""]; ok {... | go | func (e *EventListener) Notify(event *ct.Event) {
e.subMtx.RLock()
defer e.subMtx.RUnlock()
if subs, ok := e.subscribers[event.AppID]; ok {
for sub := range subs {
sub.Notify(event)
}
}
if event.AppID != "" {
// Ensure subscribers not filtering by app get the event
if subs, ok := e.subscribers[""]; ok {... | [
"func",
"(",
"e",
"*",
"EventListener",
")",
"Notify",
"(",
"event",
"*",
"ct",
".",
"Event",
")",
"{",
"e",
".",
"subMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"subMtx",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"subs",
",",
"ok",
":="... | // Notify notifies all sbscribers of the given event. | [
"Notify",
"notifies",
"all",
"sbscribers",
"of",
"the",
"given",
"event",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L478-L494 |
27,668 | flynn/flynn | controller/events.go | IsClosed | func (e *EventListener) IsClosed() bool {
e.closedMtx.RLock()
defer e.closedMtx.RUnlock()
return e.closed
} | go | func (e *EventListener) IsClosed() bool {
e.closedMtx.RLock()
defer e.closedMtx.RUnlock()
return e.closed
} | [
"func",
"(",
"e",
"*",
"EventListener",
")",
"IsClosed",
"(",
")",
"bool",
"{",
"e",
".",
"closedMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"closedMtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"closed",
"\n",
"}"
] | // IsClosed returns whether or not the listener is closed. | [
"IsClosed",
"returns",
"whether",
"or",
"not",
"the",
"listener",
"is",
"closed",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L497-L501 |
27,669 | flynn/flynn | controller/events.go | CloseWithError | func (e *EventListener) CloseWithError(err error) {
e.closedMtx.Lock()
if e.closed {
e.closedMtx.Unlock()
return
}
e.closed = true
e.closedMtx.Unlock()
e.subMtx.RLock()
defer e.subMtx.RUnlock()
subscribers := e.subscribers
for _, subs := range subscribers {
for sub := range subs {
go sub.CloseWithErr... | go | func (e *EventListener) CloseWithError(err error) {
e.closedMtx.Lock()
if e.closed {
e.closedMtx.Unlock()
return
}
e.closed = true
e.closedMtx.Unlock()
e.subMtx.RLock()
defer e.subMtx.RUnlock()
subscribers := e.subscribers
for _, subs := range subscribers {
for sub := range subs {
go sub.CloseWithErr... | [
"func",
"(",
"e",
"*",
"EventListener",
")",
"CloseWithError",
"(",
"err",
"error",
")",
"{",
"e",
".",
"closedMtx",
".",
"Lock",
"(",
")",
"\n",
"if",
"e",
".",
"closed",
"{",
"e",
".",
"closedMtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
... | // CloseWithError marks the listener as closed and closes all subscribers
// with the given error. | [
"CloseWithError",
"marks",
"the",
"listener",
"as",
"closed",
"and",
"closes",
"all",
"subscribers",
"with",
"the",
"given",
"error",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/events.go#L505-L523 |
27,670 | flynn/flynn | pkg/rpcplus/server.go | prepareMethod | func prepareMethod(method reflect.Method) *methodType {
mtype := method.Type
mname := method.Name
var replyType, argType, contextType reflect.Type
stream := false
// Method must be exported.
if method.PkgPath != "" {
return nil
}
switch mtype.NumIn() {
case 3:
// normal method
argType = mtype.In(1)
r... | go | func prepareMethod(method reflect.Method) *methodType {
mtype := method.Type
mname := method.Name
var replyType, argType, contextType reflect.Type
stream := false
// Method must be exported.
if method.PkgPath != "" {
return nil
}
switch mtype.NumIn() {
case 3:
// normal method
argType = mtype.In(1)
r... | [
"func",
"prepareMethod",
"(",
"method",
"reflect",
".",
"Method",
")",
"*",
"methodType",
"{",
"mtype",
":=",
"method",
".",
"Type",
"\n",
"mname",
":=",
"method",
".",
"Name",
"\n",
"var",
"replyType",
",",
"argType",
",",
"contextType",
"reflect",
".",
... | // prepareMethod returns a methodType for the provided method or nil
// in case if the method was unsuitable. | [
"prepareMethod",
"returns",
"a",
"methodType",
"for",
"the",
"provided",
"method",
"or",
"nil",
"in",
"case",
"if",
"the",
"method",
"was",
"unsuitable",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/server.go#L261-L320 |
27,671 | flynn/flynn | pkg/rpcplus/server.go | ServeConnWithContext | func (server *Server) ServeConnWithContext(conn io.ReadWriteCloser, context interface{}) {
buf := bufio.NewWriter(conn)
srv := &gobServerCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(buf), buf}
server.ServeCodecWithContext(srv, context)
} | go | func (server *Server) ServeConnWithContext(conn io.ReadWriteCloser, context interface{}) {
buf := bufio.NewWriter(conn)
srv := &gobServerCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(buf), buf}
server.ServeCodecWithContext(srv, context)
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"ServeConnWithContext",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
",",
"context",
"interface",
"{",
"}",
")",
"{",
"buf",
":=",
"bufio",
".",
"NewWriter",
"(",
"conn",
")",
"\n",
"srv",
":=",
"&",
"gobServerCod... | // ServeConnWithContext is like ServeConn but makes it possible to
// pass a connection context to the RPC methods. | [
"ServeConnWithContext",
"is",
"like",
"ServeConn",
"but",
"makes",
"it",
"possible",
"to",
"pass",
"a",
"connection",
"context",
"to",
"the",
"RPC",
"methods",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/server.go#L538-L542 |
27,672 | flynn/flynn | pkg/rpcplus/server.go | ServeCodecWithContext | func (server *Server) ServeCodecWithContext(codec ServerCodec, context interface{}) {
sending := new(sync.Mutex)
eof := make(chan struct{})
stopChans := make(map[uint64]chan struct{})
var stopChansMtx sync.Mutex
var contextVal reflect.Value
if context != nil {
contextVal = reflect.ValueOf(context)
} else {
... | go | func (server *Server) ServeCodecWithContext(codec ServerCodec, context interface{}) {
sending := new(sync.Mutex)
eof := make(chan struct{})
stopChans := make(map[uint64]chan struct{})
var stopChansMtx sync.Mutex
var contextVal reflect.Value
if context != nil {
contextVal = reflect.ValueOf(context)
} else {
... | [
"func",
"(",
"server",
"*",
"Server",
")",
"ServeCodecWithContext",
"(",
"codec",
"ServerCodec",
",",
"context",
"interface",
"{",
"}",
")",
"{",
"sending",
":=",
"new",
"(",
"sync",
".",
"Mutex",
")",
"\n",
"eof",
":=",
"make",
"(",
"chan",
"struct",
... | // ServeCodecWithContext is like ServeCodec but it makes it possible
// to pass a connection context to the RPC methods. | [
"ServeCodecWithContext",
"is",
"like",
"ServeCodec",
"but",
"it",
"makes",
"it",
"possible",
"to",
"pass",
"a",
"connection",
"context",
"to",
"the",
"RPC",
"methods",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/server.go#L552-L620 |
27,673 | flynn/flynn | pkg/rpcplus/server.go | Accept | func (server *Server) Accept(lis net.Listener) {
for {
conn, err := lis.Accept()
if err != nil {
log.Fatal("rpc.Serve: accept:", err.Error()) // TODO(r): exit?
}
go server.ServeConn(conn)
}
} | go | func (server *Server) Accept(lis net.Listener) {
for {
conn, err := lis.Accept()
if err != nil {
log.Fatal("rpc.Serve: accept:", err.Error()) // TODO(r): exit?
}
go server.ServeConn(conn)
}
} | [
"func",
"(",
"server",
"*",
"Server",
")",
"Accept",
"(",
"lis",
"net",
".",
"Listener",
")",
"{",
"for",
"{",
"conn",
",",
"err",
":=",
"lis",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"\"",
"\"",
... | // Accept accepts connections on the listener and serves requests
// for each incoming connection. Accept blocks; the caller typically
// invokes it in a go statement. | [
"Accept",
"accepts",
"connections",
"on",
"the",
"listener",
"and",
"serves",
"requests",
"for",
"each",
"incoming",
"connection",
".",
"Accept",
"blocks",
";",
"the",
"caller",
"typically",
"invokes",
"it",
"in",
"a",
"go",
"statement",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/server.go#L742-L750 |
27,674 | flynn/flynn | pkg/rpcplus/server.go | ServeHTTP | func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if req.Method != "CONNECT" {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusMethodNotAllowed)
io.WriteString(w, "405 must CONNECT\n")
return
}
conn, _, err := w.(http.Hijacker).Hijack()
if err !... | go | func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if req.Method != "CONNECT" {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusMethodNotAllowed)
io.WriteString(w, "405 must CONNECT\n")
return
}
conn, _, err := w.(http.Hijacker).Hijack()
if err !... | [
"func",
"(",
"server",
"*",
"Server",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"req",
".",
"Method",
"!=",
"\"",
"\"",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
... | // ServeHTTP implements an http.Handler that answers RPC requests. | [
"ServeHTTP",
"implements",
"an",
"http",
".",
"Handler",
"that",
"answers",
"RPC",
"requests",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/server.go#L812-L826 |
27,675 | flynn/flynn | appliance/mariadb/process.go | Backup | func (p *Process) Backup() (io.ReadCloser, error) {
r := &backupReadCloser{}
cmd := exec.Command(
filepath.Join(p.BinDir, "innobackupex"),
"--defaults-file="+p.ConfigPath(),
"--host=127.0.0.1",
"--port="+p.Port,
"--user=flynn",
"--password="+p.Password,
"--socket=",
"--stream=xbstream",
".",
)
cm... | go | func (p *Process) Backup() (io.ReadCloser, error) {
r := &backupReadCloser{}
cmd := exec.Command(
filepath.Join(p.BinDir, "innobackupex"),
"--defaults-file="+p.ConfigPath(),
"--host=127.0.0.1",
"--port="+p.Port,
"--user=flynn",
"--password="+p.Password,
"--socket=",
"--stream=xbstream",
".",
)
cm... | [
"func",
"(",
"p",
"*",
"Process",
")",
"Backup",
"(",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"r",
":=",
"&",
"backupReadCloser",
"{",
"}",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"filepath",
".",
"Join",
"(",
"p",
".... | // Backup returns a reader for streaming a backup in xbstream format. | [
"Backup",
"returns",
"a",
"reader",
"for",
"streaming",
"a",
"backup",
"in",
"xbstream",
"format",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L289-L320 |
27,676 | flynn/flynn | appliance/mariadb/process.go | Restore | func (p *Process) Restore(r io.Reader) (*BackupInfo, error) {
if err := p.writeConfig(configData{}); err != nil {
return nil, err
}
if err := p.unpackXbstream(r); err != nil {
return nil, err
}
backupInfo, err := p.extractBackupInfo()
if err != nil {
return nil, err
}
if err := p.restoreApplyLog(); err !=... | go | func (p *Process) Restore(r io.Reader) (*BackupInfo, error) {
if err := p.writeConfig(configData{}); err != nil {
return nil, err
}
if err := p.unpackXbstream(r); err != nil {
return nil, err
}
backupInfo, err := p.extractBackupInfo()
if err != nil {
return nil, err
}
if err := p.restoreApplyLog(); err !=... | [
"func",
"(",
"p",
"*",
"Process",
")",
"Restore",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"BackupInfo",
",",
"error",
")",
"{",
"if",
"err",
":=",
"p",
".",
"writeConfig",
"(",
"configData",
"{",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"r... | // Restore restores the database from an xbstream backup. | [
"Restore",
"restores",
"the",
"database",
"from",
"an",
"xbstream",
"backup",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L341-L356 |
27,677 | flynn/flynn | appliance/mariadb/process.go | DSN | func (p *Process) DSN() *DSN {
return &DSN{
Host: "127.0.0.1:" + p.Port,
User: "flynn",
Password: p.Password,
Timeout: p.OpTimeout,
}
} | go | func (p *Process) DSN() *DSN {
return &DSN{
Host: "127.0.0.1:" + p.Port,
User: "flynn",
Password: p.Password,
Timeout: p.OpTimeout,
}
} | [
"func",
"(",
"p",
"*",
"Process",
")",
"DSN",
"(",
")",
"*",
"DSN",
"{",
"return",
"&",
"DSN",
"{",
"Host",
":",
"\"",
"\"",
"+",
"p",
".",
"Port",
",",
"User",
":",
"\"",
"\"",
",",
"Password",
":",
"p",
".",
"Password",
",",
"Timeout",
":",... | // DSN returns the data source name for connecting to the local process as the "flynn" user. | [
"DSN",
"returns",
"the",
"data",
"source",
"name",
"for",
"connecting",
"to",
"the",
"local",
"process",
"as",
"the",
"flynn",
"user",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L890-L897 |
27,678 | flynn/flynn | appliance/mariadb/process.go | nodeXLogPosition | func (p *Process) nodeXLogPosition(dsn *DSN) (xlog.Position, error) {
db, err := sql.Open("mysql", dsn.String())
if err != nil {
return p.XLog().Zero(), err
}
defer db.Close()
var gtid string
if err := db.QueryRow(`SELECT @@gtid_current_pos`).Scan(>id); err != nil {
return p.XLog().Zero(), err
}
return x... | go | func (p *Process) nodeXLogPosition(dsn *DSN) (xlog.Position, error) {
db, err := sql.Open("mysql", dsn.String())
if err != nil {
return p.XLog().Zero(), err
}
defer db.Close()
var gtid string
if err := db.QueryRow(`SELECT @@gtid_current_pos`).Scan(>id); err != nil {
return p.XLog().Zero(), err
}
return x... | [
"func",
"(",
"p",
"*",
"Process",
")",
"nodeXLogPosition",
"(",
"dsn",
"*",
"DSN",
")",
"(",
"xlog",
".",
"Position",
",",
"error",
")",
"{",
"db",
",",
"err",
":=",
"sql",
".",
"Open",
"(",
"\"",
"\"",
",",
"dsn",
".",
"String",
"(",
")",
")",... | // XLogPosition returns the current XLogPosition of node specified by DSN. | [
"XLogPosition",
"returns",
"the",
"current",
"XLogPosition",
"of",
"node",
"specified",
"by",
"DSN",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L904-L917 |
27,679 | flynn/flynn | appliance/mariadb/process.go | installDB | func (p *Process) installDB() error {
logger := p.Logger.New("fn", "installDB", "data_dir", p.DataDir)
logger.Debug("starting installDB")
// Ignore errors, since the db could be already initialized
p.runCmd(exec.Command(
filepath.Join(p.BinDir, "mysql_install_db"),
"--defaults-extra-file="+p.ConfigPath(),
))
... | go | func (p *Process) installDB() error {
logger := p.Logger.New("fn", "installDB", "data_dir", p.DataDir)
logger.Debug("starting installDB")
// Ignore errors, since the db could be already initialized
p.runCmd(exec.Command(
filepath.Join(p.BinDir, "mysql_install_db"),
"--defaults-extra-file="+p.ConfigPath(),
))
... | [
"func",
"(",
"p",
"*",
"Process",
")",
"installDB",
"(",
")",
"error",
"{",
"logger",
":=",
"p",
".",
"Logger",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"p",
".",
"DataDir",
")",
"\n",
"logger",
".",
"Debug",
"(",
"... | // installDB initializes the data directory for a new database. | [
"installDB",
"initializes",
"the",
"data",
"directory",
"for",
"a",
"new",
"database",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L920-L931 |
27,680 | flynn/flynn | appliance/mariadb/process.go | Close | func (r *backupReadCloser) Close() error {
defer r.stdout.Close()
if err := r.cmd.Wait(); err != nil {
return err
}
// Verify that innobackupex prints "completed OK!" at the end of STDERR.
if !strings.HasSuffix(strings.TrimSpace(r.stderr.String()), "completed OK!") {
r.stderr.WriteTo(os.Stderr)
return erro... | go | func (r *backupReadCloser) Close() error {
defer r.stdout.Close()
if err := r.cmd.Wait(); err != nil {
return err
}
// Verify that innobackupex prints "completed OK!" at the end of STDERR.
if !strings.HasSuffix(strings.TrimSpace(r.stderr.String()), "completed OK!") {
r.stderr.WriteTo(os.Stderr)
return erro... | [
"func",
"(",
"r",
"*",
"backupReadCloser",
")",
"Close",
"(",
")",
"error",
"{",
"defer",
"r",
".",
"stdout",
".",
"Close",
"(",
")",
"\n\n",
"if",
"err",
":=",
"r",
".",
"cmd",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"er... | // Close waits for the backup command to finish and verifies that the backup completed successfully. | [
"Close",
"waits",
"for",
"the",
"backup",
"command",
"to",
"finish",
"and",
"verifies",
"that",
"the",
"backup",
"completed",
"successfully",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L1002-L1016 |
27,681 | flynn/flynn | appliance/mariadb/process.go | Read | func (r *backupReadCloser) Read(p []byte) (n int, err error) {
return r.stdout.Read(p)
} | go | func (r *backupReadCloser) Read(p []byte) (n int, err error) {
return r.stdout.Read(p)
} | [
"func",
"(",
"r",
"*",
"backupReadCloser",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"r",
".",
"stdout",
".",
"Read",
"(",
"p",
")",
"\n",
"}"
] | // Read reads n bytes of backup data into p. | [
"Read",
"reads",
"n",
"bytes",
"of",
"backup",
"data",
"into",
"p",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/process.go#L1019-L1021 |
27,682 | flynn/flynn | host/libcontainer_backend.go | discoverdDial | func (l *LibcontainerBackend) discoverdDial(network, addr string) (net.Conn, error) {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, err
}
if strings.HasSuffix(host, ".discoverd") {
// ensure discoverd is configured
<-l.discoverdConfigured
// lookup the service and pick a random address... | go | func (l *LibcontainerBackend) discoverdDial(network, addr string) (net.Conn, error) {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, err
}
if strings.HasSuffix(host, ".discoverd") {
// ensure discoverd is configured
<-l.discoverdConfigured
// lookup the service and pick a random address... | [
"func",
"(",
"l",
"*",
"LibcontainerBackend",
")",
"discoverdDial",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"host",
",",
"_",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
")",
"\n",
... | // discoverdDial is a discoverd aware dialer which resolves a discoverd host to
// an address using the configured discoverd client as the host is likely not
// using discoverd to resolve DNS queries | [
"discoverdDial",
"is",
"a",
"discoverd",
"aware",
"dialer",
"which",
"resolves",
"a",
"discoverd",
"host",
"to",
"an",
"address",
"using",
"the",
"configured",
"discoverd",
"client",
"as",
"the",
"host",
"is",
"likely",
"not",
"using",
"discoverd",
"to",
"reso... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/libcontainer_backend.go#L940-L959 |
27,683 | flynn/flynn | router/data_store.go | NewPostgresDataStore | func NewPostgresDataStore(routeType string, pgx *pgx.ConnPool) *pgDataStore {
tableName := ""
switch routeType {
case routeTypeHTTP:
tableName = tableNameHTTP
case routeTypeTCP:
tableName = tableNameTCP
default:
panic(fmt.Sprintf("unknown routeType: %q", routeType))
}
return &pgDataStore{
pgx: pgx,... | go | func NewPostgresDataStore(routeType string, pgx *pgx.ConnPool) *pgDataStore {
tableName := ""
switch routeType {
case routeTypeHTTP:
tableName = tableNameHTTP
case routeTypeTCP:
tableName = tableNameTCP
default:
panic(fmt.Sprintf("unknown routeType: %q", routeType))
}
return &pgDataStore{
pgx: pgx,... | [
"func",
"NewPostgresDataStore",
"(",
"routeType",
"string",
",",
"pgx",
"*",
"pgx",
".",
"ConnPool",
")",
"*",
"pgDataStore",
"{",
"tableName",
":=",
"\"",
"\"",
"\n",
"switch",
"routeType",
"{",
"case",
"routeTypeHTTP",
":",
"tableName",
"=",
"tableNameHTTP",... | // NewPostgresDataStore returns a DataStore that stores route information in a
// Postgres database. It uses pg_notify and a listener connection to watch for
// route changes. | [
"NewPostgresDataStore",
"returns",
"a",
"DataStore",
"that",
"stores",
"route",
"information",
"in",
"a",
"Postgres",
"database",
".",
"It",
"uses",
"pg_notify",
"and",
"a",
"listener",
"connection",
"to",
"watch",
"for",
"route",
"changes",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/data_store.go#L69-L84 |
27,684 | flynn/flynn | updater/updater.go | updateImageIDs | func updateImageIDs(env map[string]string) bool {
updated := false
for prefix, newID := range map[string]string{
"REDIS": redisImage.ID,
"SLUGBUILDER": slugBuilder.ID,
"SLUGRUNNER": slugRunner.ID,
} {
idKey := prefix + "_IMAGE_ID"
if id, ok := env[idKey]; ok && id != newID {
env[idKey] = newID
... | go | func updateImageIDs(env map[string]string) bool {
updated := false
for prefix, newID := range map[string]string{
"REDIS": redisImage.ID,
"SLUGBUILDER": slugBuilder.ID,
"SLUGRUNNER": slugRunner.ID,
} {
idKey := prefix + "_IMAGE_ID"
if id, ok := env[idKey]; ok && id != newID {
env[idKey] = newID
... | [
"func",
"updateImageIDs",
"(",
"env",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"updated",
":=",
"false",
"\n",
"for",
"prefix",
",",
"newID",
":=",
"range",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"redisImage",
".",
"... | // updateImageIDs updates REDIS_IMAGE_ID, SLUGBUILDER_IMAGE_ID and
// SLUGRUNNER_IMAGE_ID if they are set and have an old ID, and also
// replaces the legacy REDIS_IMAGE_URI, SLUGBUILDER_IMAGE_URI and
// SLUGRUNNER_IMAGE_URI | [
"updateImageIDs",
"updates",
"REDIS_IMAGE_ID",
"SLUGBUILDER_IMAGE_ID",
"and",
"SLUGRUNNER_IMAGE_ID",
"if",
"they",
"are",
"set",
"and",
"have",
"an",
"old",
"ID",
"and",
"also",
"replaces",
"the",
"legacy",
"REDIS_IMAGE_URI",
"SLUGBUILDER_IMAGE_URI",
"and",
"SLUGRUNNER_... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/updater/updater.go#L253-L274 |
27,685 | flynn/flynn | appliance/postgresql/pgxlog/pgxlog.go | Increment | func (p PgXLog) Increment(pos xlog.Position, increment int) (xlog.Position, error) {
parts, err := parse(pos)
if err != nil {
return "", err
}
return makePosition(parts[0], parts[1]+increment), nil
} | go | func (p PgXLog) Increment(pos xlog.Position, increment int) (xlog.Position, error) {
parts, err := parse(pos)
if err != nil {
return "", err
}
return makePosition(parts[0], parts[1]+increment), nil
} | [
"func",
"(",
"p",
"PgXLog",
")",
"Increment",
"(",
"pos",
"xlog",
".",
"Position",
",",
"increment",
"int",
")",
"(",
"xlog",
".",
"Position",
",",
"error",
")",
"{",
"parts",
",",
"err",
":=",
"parse",
"(",
"pos",
")",
"\n",
"if",
"err",
"!=",
"... | // Increment increments an xlog position by the given number. | [
"Increment",
"increments",
"an",
"xlog",
"position",
"by",
"the",
"given",
"number",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/postgresql/pgxlog/pgxlog.go#L53-L59 |
27,686 | flynn/flynn | appliance/postgresql/pgxlog/pgxlog.go | parse | func parse(xlog xlog.Position) (res [2]int, err error) {
parts := strings.SplitN(string(xlog), "/", 2)
if len(parts) != 2 {
err = fmt.Errorf("malformed xlog position %q", xlog)
return
}
res[0], err = parseHex(parts[0])
if err != nil {
return
}
res[1], err = parseHex(parts[1])
return
} | go | func parse(xlog xlog.Position) (res [2]int, err error) {
parts := strings.SplitN(string(xlog), "/", 2)
if len(parts) != 2 {
err = fmt.Errorf("malformed xlog position %q", xlog)
return
}
res[0], err = parseHex(parts[0])
if err != nil {
return
}
res[1], err = parseHex(parts[1])
return
} | [
"func",
"parse",
"(",
"xlog",
"xlog",
".",
"Position",
")",
"(",
"res",
"[",
"2",
"]",
"int",
",",
"err",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"xlog",
")",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
... | // parse takes an xlog position emitted by postgres and returns an array of two
// integers representing the filepart and offset components of the xlog
// position. This is an internal representation that should not be exposed
// outside of this package. | [
"parse",
"takes",
"an",
"xlog",
"position",
"emitted",
"by",
"postgres",
"and",
"returns",
"an",
"array",
"of",
"two",
"integers",
"representing",
"the",
"filepart",
"and",
"offset",
"components",
"of",
"the",
"xlog",
"position",
".",
"This",
"is",
"an",
"in... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/postgresql/pgxlog/pgxlog.go#L86-L100 |
27,687 | flynn/flynn | appliance/postgresql/pgxlog/pgxlog.go | makePosition | func makePosition(filepart int, offset int) xlog.Position {
return xlog.Position(fmt.Sprintf("%X/%08X", filepart, offset))
} | go | func makePosition(filepart int, offset int) xlog.Position {
return xlog.Position(fmt.Sprintf("%X/%08X", filepart, offset))
} | [
"func",
"makePosition",
"(",
"filepart",
"int",
",",
"offset",
"int",
")",
"xlog",
".",
"Position",
"{",
"return",
"xlog",
".",
"Position",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"filepart",
",",
"offset",
")",
")",
"\n",
"}"
] | // MakePosition constructs an xlog position string from a numeric file part and
// offset. | [
"MakePosition",
"constructs",
"an",
"xlog",
"position",
"string",
"from",
"a",
"numeric",
"file",
"part",
"and",
"offset",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/postgresql/pgxlog/pgxlog.go#L104-L106 |
27,688 | flynn/flynn | host/logmux/sink.go | parseProcID | func parseProcID(procID []byte) (string, string) {
procTypeID := strings.SplitN(string(procID), ".", 2)
if len(procTypeID) == 2 {
return procTypeID[1], procTypeID[0]
}
return procTypeID[0], ""
} | go | func parseProcID(procID []byte) (string, string) {
procTypeID := strings.SplitN(string(procID), ".", 2)
if len(procTypeID) == 2 {
return procTypeID[1], procTypeID[0]
}
return procTypeID[0], ""
} | [
"func",
"parseProcID",
"(",
"procID",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"string",
")",
"{",
"procTypeID",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"procID",
")",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"procTypeI... | // Parses JobID and ProcType from header ProcID field
// Always returns JobID, returns ProcType if available | [
"Parses",
"JobID",
"and",
"ProcType",
"from",
"header",
"ProcID",
"field",
"Always",
"returns",
"JobID",
"returns",
"ProcType",
"if",
"available"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/logmux/sink.go#L571-L577 |
27,689 | flynn/flynn | pkg/sirenia/scale/scale.go | CheckScale | func CheckScale(app, controllerKey, procName string, logger log15.Logger) (bool, error) {
logger = logger.New("fn", "CheckScale")
// Connect to controller.
logger.Info("connecting to controller")
client, err := controller.NewClient("", controllerKey)
if err != nil {
logger.Error("controller client error", "err",... | go | func CheckScale(app, controllerKey, procName string, logger log15.Logger) (bool, error) {
logger = logger.New("fn", "CheckScale")
// Connect to controller.
logger.Info("connecting to controller")
client, err := controller.NewClient("", controllerKey)
if err != nil {
logger.Error("controller client error", "err",... | [
"func",
"CheckScale",
"(",
"app",
",",
"controllerKey",
",",
"procName",
"string",
",",
"logger",
"log15",
".",
"Logger",
")",
"(",
"bool",
",",
"error",
")",
"{",
"logger",
"=",
"logger",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"/... | // CheckScale examines sirenia cluster formation to check if cluster
// has been scaled up yet.
// Returns true if scaled, false if not. | [
"CheckScale",
"examines",
"sirenia",
"cluster",
"formation",
"to",
"check",
"if",
"cluster",
"has",
"been",
"scaled",
"up",
"yet",
".",
"Returns",
"true",
"if",
"scaled",
"false",
"if",
"not",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/scale/scale.go#L103-L142 |
27,690 | RichardKnop/machinery | v1/worker.go | Launch | func (worker *Worker) Launch() error {
errorsChan := make(chan error)
worker.LaunchAsync(errorsChan)
return <-errorsChan
} | go | func (worker *Worker) Launch() error {
errorsChan := make(chan error)
worker.LaunchAsync(errorsChan)
return <-errorsChan
} | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"Launch",
"(",
")",
"error",
"{",
"errorsChan",
":=",
"make",
"(",
"chan",
"error",
")",
"\n\n",
"worker",
".",
"LaunchAsync",
"(",
"errorsChan",
")",
"\n\n",
"return",
"<-",
"errorsChan",
"\n",
"}"
] | // Launch starts a new worker process. The worker subscribes
// to the default queue and processes incoming registered tasks | [
"Launch",
"starts",
"a",
"new",
"worker",
"process",
".",
"The",
"worker",
"subscribes",
"to",
"the",
"default",
"queue",
"and",
"processes",
"incoming",
"registered",
"tasks"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L32-L38 |
27,691 | RichardKnop/machinery | v1/worker.go | LaunchAsync | func (worker *Worker) LaunchAsync(errorsChan chan<- error) {
cnf := worker.server.GetConfig()
broker := worker.server.GetBroker()
// Log some useful information about worker configuration
log.INFO.Printf("Launching a worker with the following settings:")
log.INFO.Printf("- Broker: %s", cnf.Broker)
if worker.Queu... | go | func (worker *Worker) LaunchAsync(errorsChan chan<- error) {
cnf := worker.server.GetConfig()
broker := worker.server.GetBroker()
// Log some useful information about worker configuration
log.INFO.Printf("Launching a worker with the following settings:")
log.INFO.Printf("- Broker: %s", cnf.Broker)
if worker.Queu... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"LaunchAsync",
"(",
"errorsChan",
"chan",
"<-",
"error",
")",
"{",
"cnf",
":=",
"worker",
".",
"server",
".",
"GetConfig",
"(",
")",
"\n",
"broker",
":=",
"worker",
".",
"server",
".",
"GetBroker",
"(",
")",
... | // LaunchAsync is a non blocking version of Launch | [
"LaunchAsync",
"is",
"a",
"non",
"blocking",
"version",
"of",
"Launch"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L41-L107 |
27,692 | RichardKnop/machinery | v1/worker.go | taskRetry | func (worker *Worker) taskRetry(signature *tasks.Signature) error {
// Update task state to RETRY
if err := worker.server.GetBackend().SetStateRetry(signature); err != nil {
return fmt.Errorf("Set state to 'retry' for task %s returned error: %s", signature.UUID, err)
}
// Decrement the retry counter, when it rea... | go | func (worker *Worker) taskRetry(signature *tasks.Signature) error {
// Update task state to RETRY
if err := worker.server.GetBackend().SetStateRetry(signature); err != nil {
return fmt.Errorf("Set state to 'retry' for task %s returned error: %s", signature.UUID, err)
}
// Decrement the retry counter, when it rea... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"taskRetry",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
")",
"error",
"{",
"// Update task state to RETRY",
"if",
"err",
":=",
"worker",
".",
"server",
".",
"GetBackend",
"(",
")",
".",
"SetStateRetry",
"(",
... | // retryTask decrements RetryCount counter and republishes the task to the queue | [
"retryTask",
"decrements",
"RetryCount",
"counter",
"and",
"republishes",
"the",
"task",
"to",
"the",
"queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L191-L212 |
27,693 | RichardKnop/machinery | v1/worker.go | taskSucceeded | func (worker *Worker) taskSucceeded(signature *tasks.Signature, taskResults []*tasks.TaskResult) error {
// Update task state to SUCCESS
if err := worker.server.GetBackend().SetStateSuccess(signature, taskResults); err != nil {
return fmt.Errorf("Set state to 'success' for task %s returned error: %s", signature.UUI... | go | func (worker *Worker) taskSucceeded(signature *tasks.Signature, taskResults []*tasks.TaskResult) error {
// Update task state to SUCCESS
if err := worker.server.GetBackend().SetStateSuccess(signature, taskResults); err != nil {
return fmt.Errorf("Set state to 'success' for task %s returned error: %s", signature.UUI... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"taskSucceeded",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
",",
"taskResults",
"[",
"]",
"*",
"tasks",
".",
"TaskResult",
")",
"error",
"{",
"// Update task state to SUCCESS",
"if",
"err",
":=",
"worker",
".... | // taskSucceeded updates the task state and triggers success callbacks or a
// chord callback if this was the last task of a group with a chord callback | [
"taskSucceeded",
"updates",
"the",
"task",
"state",
"and",
"triggers",
"success",
"callbacks",
"or",
"a",
"chord",
"callback",
"if",
"this",
"was",
"the",
"last",
"task",
"of",
"a",
"group",
"with",
"a",
"chord",
"callback"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L234-L339 |
27,694 | RichardKnop/machinery | v1/worker.go | taskFailed | func (worker *Worker) taskFailed(signature *tasks.Signature, taskErr error) error {
// Update task state to FAILURE
if err := worker.server.GetBackend().SetStateFailure(signature, taskErr.Error()); err != nil {
return fmt.Errorf("Set state to 'failure' for task %s returned error: %s", signature.UUID, err)
}
if w... | go | func (worker *Worker) taskFailed(signature *tasks.Signature, taskErr error) error {
// Update task state to FAILURE
if err := worker.server.GetBackend().SetStateFailure(signature, taskErr.Error()); err != nil {
return fmt.Errorf("Set state to 'failure' for task %s returned error: %s", signature.UUID, err)
}
if w... | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"taskFailed",
"(",
"signature",
"*",
"tasks",
".",
"Signature",
",",
"taskErr",
"error",
")",
"error",
"{",
"// Update task state to FAILURE",
"if",
"err",
":=",
"worker",
".",
"server",
".",
"GetBackend",
"(",
")",... | // taskFailed updates the task state and triggers error callbacks | [
"taskFailed",
"updates",
"the",
"task",
"state",
"and",
"triggers",
"error",
"callbacks"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L342-L366 |
27,695 | RichardKnop/machinery | v1/worker.go | hasAMQPBackend | func (worker *Worker) hasAMQPBackend() bool {
_, ok := worker.server.GetBackend().(*amqp.Backend)
return ok
} | go | func (worker *Worker) hasAMQPBackend() bool {
_, ok := worker.server.GetBackend().(*amqp.Backend)
return ok
} | [
"func",
"(",
"worker",
"*",
"Worker",
")",
"hasAMQPBackend",
"(",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"worker",
".",
"server",
".",
"GetBackend",
"(",
")",
".",
"(",
"*",
"amqp",
".",
"Backend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // Returns true if the worker uses AMQP backend | [
"Returns",
"true",
"if",
"the",
"worker",
"uses",
"AMQP",
"backend"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/worker.go#L369-L372 |
27,696 | RichardKnop/machinery | v1/common/amqp.go | Connect | func (ac *AMQPConnector) Connect(url string, tlsConfig *tls.Config, exchange, exchangeType, queueName string, queueDurable, queueDelete bool, queueBindingKey string, exchangeDeclareArgs, queueDeclareArgs, queueBindingArgs amqp.Table) (*amqp.Connection, *amqp.Channel, amqp.Queue, <-chan amqp.Confirmation, <-chan *amqp.E... | go | func (ac *AMQPConnector) Connect(url string, tlsConfig *tls.Config, exchange, exchangeType, queueName string, queueDurable, queueDelete bool, queueBindingKey string, exchangeDeclareArgs, queueDeclareArgs, queueBindingArgs amqp.Table) (*amqp.Connection, *amqp.Channel, amqp.Queue, <-chan amqp.Confirmation, <-chan *amqp.E... | [
"func",
"(",
"ac",
"*",
"AMQPConnector",
")",
"Connect",
"(",
"url",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
",",
"exchange",
",",
"exchangeType",
",",
"queueName",
"string",
",",
"queueDurable",
",",
"queueDelete",
"bool",
",",
"queueBindingK... | // Connect opens a connection to RabbitMQ, declares an exchange, opens a channel,
// declares and binds the queue and enables publish notifications | [
"Connect",
"opens",
"a",
"connection",
"to",
"RabbitMQ",
"declares",
"an",
"exchange",
"opens",
"a",
"channel",
"declares",
"and",
"binds",
"the",
"queue",
"and",
"enables",
"publish",
"notifications"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L15-L70 |
27,697 | RichardKnop/machinery | v1/common/amqp.go | DeleteQueue | func (ac *AMQPConnector) DeleteQueue(channel *amqp.Channel, queueName string) error {
// First return value is number of messages removed
_, err := channel.QueueDelete(
queueName, // name
false, // ifUnused
false, // ifEmpty
false, // noWait
)
return err
} | go | func (ac *AMQPConnector) DeleteQueue(channel *amqp.Channel, queueName string) error {
// First return value is number of messages removed
_, err := channel.QueueDelete(
queueName, // name
false, // ifUnused
false, // ifEmpty
false, // noWait
)
return err
} | [
"func",
"(",
"ac",
"*",
"AMQPConnector",
")",
"DeleteQueue",
"(",
"channel",
"*",
"amqp",
".",
"Channel",
",",
"queueName",
"string",
")",
"error",
"{",
"// First return value is number of messages removed",
"_",
",",
"err",
":=",
"channel",
".",
"QueueDelete",
... | // DeleteQueue deletes a queue by name | [
"DeleteQueue",
"deletes",
"a",
"queue",
"by",
"name"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L73-L83 |
27,698 | RichardKnop/machinery | v1/common/amqp.go | InspectQueue | func (*AMQPConnector) InspectQueue(channel *amqp.Channel, queueName string) (*amqp.Queue, error) {
queueState, err := channel.QueueInspect(queueName)
if err != nil {
return nil, fmt.Errorf("Queue inspect error: %s", err)
}
return &queueState, nil
} | go | func (*AMQPConnector) InspectQueue(channel *amqp.Channel, queueName string) (*amqp.Queue, error) {
queueState, err := channel.QueueInspect(queueName)
if err != nil {
return nil, fmt.Errorf("Queue inspect error: %s", err)
}
return &queueState, nil
} | [
"func",
"(",
"*",
"AMQPConnector",
")",
"InspectQueue",
"(",
"channel",
"*",
"amqp",
".",
"Channel",
",",
"queueName",
"string",
")",
"(",
"*",
"amqp",
".",
"Queue",
",",
"error",
")",
"{",
"queueState",
",",
"err",
":=",
"channel",
".",
"QueueInspect",
... | // InspectQueue provides information about a specific queue | [
"InspectQueue",
"provides",
"information",
"about",
"a",
"specific",
"queue"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L86-L93 |
27,699 | RichardKnop/machinery | v1/common/amqp.go | Open | func (ac *AMQPConnector) Open(url string, tlsConfig *tls.Config) (*amqp.Connection, *amqp.Channel, error) {
// Connect
// From amqp docs: DialTLS will use the provided tls.Config when it encounters an amqps:// scheme
// and will dial a plain connection when it encounters an amqp:// scheme.
conn, err := amqp.DialTLS... | go | func (ac *AMQPConnector) Open(url string, tlsConfig *tls.Config) (*amqp.Connection, *amqp.Channel, error) {
// Connect
// From amqp docs: DialTLS will use the provided tls.Config when it encounters an amqps:// scheme
// and will dial a plain connection when it encounters an amqp:// scheme.
conn, err := amqp.DialTLS... | [
"func",
"(",
"ac",
"*",
"AMQPConnector",
")",
"Open",
"(",
"url",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"(",
"*",
"amqp",
".",
"Connection",
",",
"*",
"amqp",
".",
"Channel",
",",
"error",
")",
"{",
"// Connect",
"// From amqp doc... | // Open new RabbitMQ connection | [
"Open",
"new",
"RabbitMQ",
"connection"
] | 07418869e268a380aea5b9aefbb0b9f5bb715a12 | https://github.com/RichardKnop/machinery/blob/07418869e268a380aea5b9aefbb0b9f5bb715a12/v1/common/amqp.go#L96-L112 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.