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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
flynn/flynn
controller/scheduler/scheduler.go
findVolume
func (s *Scheduler) findVolume(job *Job, req *ct.VolumeReq) *Volume { for _, vol := range s.volumes { // skip destroyed or decommissioned volumes if vol.GetState() == ct.VolumeStateDestroyed || vol.DecommissionedAt != nil { continue } // skip if the app, release, type or path do not match if vol.AppID !=...
go
func (s *Scheduler) findVolume(job *Job, req *ct.VolumeReq) *Volume { for _, vol := range s.volumes { // skip destroyed or decommissioned volumes if vol.GetState() == ct.VolumeStateDestroyed || vol.DecommissionedAt != nil { continue } // skip if the app, release, type or path do not match if vol.AppID !=...
[ "func", "(", "s", "*", "Scheduler", ")", "findVolume", "(", "job", "*", "Job", ",", "req", "*", "ct", ".", "VolumeReq", ")", "*", "Volume", "{", "for", "_", ",", "vol", ":=", "range", "s", ".", "volumes", "{", "// skip destroyed or decommissioned volumes...
// findVolume looks for an existing, unassigned volume which matches the given // job's app, release and type, and the volume request's path
[ "findVolume", "looks", "for", "an", "existing", "unassigned", "volume", "which", "matches", "the", "given", "job", "s", "app", "release", "and", "type", "and", "the", "volume", "request", "s", "path" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/scheduler.go#L1040-L1076
train
flynn/flynn
controller/scheduler/scheduler.go
activeFormationCount
func (s *Scheduler) activeFormationCount(appID string) int { activeReleases := make(map[string]struct{}) for _, job := range s.jobs { if job.IsRunning() && job.IsInApp(appID) { activeReleases[job.Formation.Release.ID] = struct{}{} } } return len(activeReleases) }
go
func (s *Scheduler) activeFormationCount(appID string) int { activeReleases := make(map[string]struct{}) for _, job := range s.jobs { if job.IsRunning() && job.IsInApp(appID) { activeReleases[job.Formation.Release.ID] = struct{}{} } } return len(activeReleases) }
[ "func", "(", "s", "*", "Scheduler", ")", "activeFormationCount", "(", "appID", "string", ")", "int", "{", "activeReleases", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "for", "_", ",", "job", ":=", "range", "s", ".", ...
// activeFormationCount returns the number of formations which have running // jobs for the given app
[ "activeFormationCount", "returns", "the", "number", "of", "formations", "which", "have", "running", "jobs", "for", "the", "given", "app" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/scheduler.go#L1537-L1545
train
flynn/flynn
controller/scheduler/scheduler.go
findJobToStop
func (s *Scheduler) findJobToStop(f *Formation, typ string) (*Job, error) { var found *Job for _, job := range s.jobs.WithFormationAndType(f, typ) { switch job.State { case JobStatePending: return job, nil case JobStateStarting, JobStateRunning: // if the job is on a host which is shutting down, // ret...
go
func (s *Scheduler) findJobToStop(f *Formation, typ string) (*Job, error) { var found *Job for _, job := range s.jobs.WithFormationAndType(f, typ) { switch job.State { case JobStatePending: return job, nil case JobStateStarting, JobStateRunning: // if the job is on a host which is shutting down, // ret...
[ "func", "(", "s", "*", "Scheduler", ")", "findJobToStop", "(", "f", "*", "Formation", ",", "typ", "string", ")", "(", "*", "Job", ",", "error", ")", "{", "var", "found", "*", "Job", "\n", "for", "_", ",", "job", ":=", "range", "s", ".", "jobs", ...
// findJobToStop finds a job from the given formation and type which should be // stopped, choosing pending jobs if present, and the most recently started job // otherwise
[ "findJobToStop", "finds", "a", "job", "from", "the", "given", "formation", "and", "type", "which", "should", "be", "stopped", "choosing", "pending", "jobs", "if", "present", "and", "the", "most", "recently", "started", "job", "otherwise" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/scheduler.go#L2478-L2508
train
flynn/flynn
appliance/redis/cmd/flynn-redis/main.go
readID
func (m *Main) readID(path string) (string, error) { buf, err := ioutil.ReadFile(path) if err != nil && !os.IsNotExist(err) { return "", fmt.Errorf("error reading instance ID: %s", err) } // If the ID exists then return it immediately. id := string(buf) if id != "" { return id, nil } // Generate a new ID ...
go
func (m *Main) readID(path string) (string, error) { buf, err := ioutil.ReadFile(path) if err != nil && !os.IsNotExist(err) { return "", fmt.Errorf("error reading instance ID: %s", err) } // If the ID exists then return it immediately. id := string(buf) if id != "" { return id, nil } // Generate a new ID ...
[ "func", "(", "m", "*", "Main", ")", "readID", "(", "path", "string", ")", "(", "string", ",", "error", ")", "{", "buf", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", "IsNotE...
// readID reads the instance id from path. // If the file instance id doesn't exist then a random ID is generated.
[ "readID", "reads", "the", "instance", "id", "from", "path", ".", "If", "the", "file", "instance", "id", "doesn", "t", "exist", "then", "a", "random", "ID", "is", "generated", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/cmd/flynn-redis/main.go#L195-L213
train
flynn/flynn
host/fixer/fixer.go
FindAppReleaseJobs
func (f *ClusterFixer) FindAppReleaseJobs(app, typ string) []map[string]*host.Job { var sortReleases ReleasesByCreate releases := make(map[string]map[string]*host.ActiveJob) // map of releaseID -> hostID -> job ordered // connect to each host, list jobs, find distinct releases for _, h := range f.hosts { jobs, er...
go
func (f *ClusterFixer) FindAppReleaseJobs(app, typ string) []map[string]*host.Job { var sortReleases ReleasesByCreate releases := make(map[string]map[string]*host.ActiveJob) // map of releaseID -> hostID -> job ordered // connect to each host, list jobs, find distinct releases for _, h := range f.hosts { jobs, er...
[ "func", "(", "f", "*", "ClusterFixer", ")", "FindAppReleaseJobs", "(", "app", ",", "typ", "string", ")", "[", "]", "map", "[", "string", "]", "*", "host", ".", "Job", "{", "var", "sortReleases", "ReleasesByCreate", "\n", "releases", ":=", "make", "(", ...
// FindAppReleaseJobs returns a slice with one map of host id to job for each // known release of the given app and type, most recent first
[ "FindAppReleaseJobs", "returns", "a", "slice", "with", "one", "map", "of", "host", "id", "to", "job", "for", "each", "known", "release", "of", "the", "given", "app", "and", "type", "most", "recent", "first" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/fixer/fixer.go#L220-L260
train
flynn/flynn
pkg/cors/cors.go
IsOriginAllowed
func (o *Options) IsOriginAllowed(origin string, req *http.Request) (allowed bool) { if o.ShouldAllowOrigin != nil { return o.ShouldAllowOrigin(origin, req) } for _, pattern := range allowOriginPatterns { allowed, _ = regexp.MatchString(pattern, origin) if allowed { return } } return }
go
func (o *Options) IsOriginAllowed(origin string, req *http.Request) (allowed bool) { if o.ShouldAllowOrigin != nil { return o.ShouldAllowOrigin(origin, req) } for _, pattern := range allowOriginPatterns { allowed, _ = regexp.MatchString(pattern, origin) if allowed { return } } return }
[ "func", "(", "o", "*", "Options", ")", "IsOriginAllowed", "(", "origin", "string", ",", "req", "*", "http", ".", "Request", ")", "(", "allowed", "bool", ")", "{", "if", "o", ".", "ShouldAllowOrigin", "!=", "nil", "{", "return", "o", ".", "ShouldAllowOr...
// Looks up if the origin matches one of the patterns // generated from Options.AllowOrigins patterns.
[ "Looks", "up", "if", "the", "origin", "matches", "one", "of", "the", "patterns", "generated", "from", "Options", ".", "AllowOrigins", "patterns", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cors/cors.go#L106-L117
train
flynn/flynn
pkg/cors/cors.go
Handler
func (o *Options) Handler(next http.Handler) http.HandlerFunc { // Allow default headers if nothing is specified. if len(o.AllowHeaders) == 0 { o.AllowHeaders = defaultAllowHeaders } for _, origin := range o.AllowOrigins { pattern := regexp.QuoteMeta(origin) pattern = strings.Replace(pattern, "\\*", ".*", -1...
go
func (o *Options) Handler(next http.Handler) http.HandlerFunc { // Allow default headers if nothing is specified. if len(o.AllowHeaders) == 0 { o.AllowHeaders = defaultAllowHeaders } for _, origin := range o.AllowOrigins { pattern := regexp.QuoteMeta(origin) pattern = strings.Replace(pattern, "\\*", ".*", -1...
[ "func", "(", "o", "*", "Options", ")", "Handler", "(", "next", "http", ".", "Handler", ")", "http", ".", "HandlerFunc", "{", "// Allow default headers if nothing is specified.", "if", "len", "(", "o", ".", "AllowHeaders", ")", "==", "0", "{", "o", ".", "Al...
// Allows CORS for requests those match the provided options.
[ "Allows", "CORS", "for", "requests", "those", "match", "the", "provided", "options", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cors/cors.go#L120-L145
train
flynn/flynn
appliance/postgresql/process.go
initDB
func (p *Process) initDB() error { log := p.log.New("fn", "initDB", "dir", p.dataDir) log.Debug("starting initDB") // ignore errors, since the db could be already initialized // TODO(titanous): check errors when this is not the case _ = p.runCmd(exec.Command( p.binPath("initdb"), "--pgdata", p.dataDir, "--u...
go
func (p *Process) initDB() error { log := p.log.New("fn", "initDB", "dir", p.dataDir) log.Debug("starting initDB") // ignore errors, since the db could be already initialized // TODO(titanous): check errors when this is not the case _ = p.runCmd(exec.Command( p.binPath("initdb"), "--pgdata", p.dataDir, "--u...
[ "func", "(", "p", "*", "Process", ")", "initDB", "(", ")", "error", "{", "log", ":=", "p", ".", "log", ".", "New", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "p", ".", "dataDir", ")", "\n", "log", ".", "Debug", "(", "\"", "\"",...
// initDB initializes the postgres data directory for a new dDB. This can fail // if the db has already been initialized, which is not a fatal error. // // This method should only be called by the primary of a shard. Standbys will // not need to initialize, as they will restore from an already running primary.
[ "initDB", "initializes", "the", "postgres", "data", "directory", "for", "a", "new", "dDB", ".", "This", "can", "fail", "if", "the", "db", "has", "already", "been", "initialized", "which", "is", "not", "a", "fatal", "error", ".", "This", "method", "should",...
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/postgresql/process.go#L809-L824
train
flynn/flynn
host/downloader/downloader.go
DownloadConfig
func (d *Downloader) DownloadConfig(dir string) (map[string]string, error) { if err := os.MkdirAll(dir, 0755); err != nil { return nil, fmt.Errorf("error creating config dir: %s", err) } paths := make(map[string]string, len(config)) for _, conf := range config { path, err := d.downloadGzippedFile(conf, dir, fal...
go
func (d *Downloader) DownloadConfig(dir string) (map[string]string, error) { if err := os.MkdirAll(dir, 0755); err != nil { return nil, fmt.Errorf("error creating config dir: %s", err) } paths := make(map[string]string, len(config)) for _, conf := range config { path, err := d.downloadGzippedFile(conf, dir, fal...
[ "func", "(", "d", "*", "Downloader", ")", "DownloadConfig", "(", "dir", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "dir", ",", "0755", ")", ";", "err", "!=", "ni...
// DownloadConfig downloads the Flynn config files using the tuf client to the // given dir.
[ "DownloadConfig", "downloads", "the", "Flynn", "config", "files", "using", "the", "tuf", "client", "to", "the", "given", "dir", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/downloader/downloader.go#L69-L82
train
flynn/flynn
pkg/cluster/utils.go
ExtractHostID
func ExtractHostID(id string) (string, error) { ids := strings.SplitN(id, "-", 2) if len(ids) != 2 || ids[0] == "" || ids[1] == "" { return "", errors.New("invalid ID") } return ids[0], nil }
go
func ExtractHostID(id string) (string, error) { ids := strings.SplitN(id, "-", 2) if len(ids) != 2 || ids[0] == "" || ids[1] == "" { return "", errors.New("invalid ID") } return ids[0], nil }
[ "func", "ExtractHostID", "(", "id", "string", ")", "(", "string", ",", "error", ")", "{", "ids", ":=", "strings", ".", "SplitN", "(", "id", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "ids", ")", "!=", "2", "||", "ids", "[", "0", ...
// ExtractHostID returns the host ID component of a job ID, returning an error // if the given ID is invalid.
[ "ExtractHostID", "returns", "the", "host", "ID", "component", "of", "a", "job", "ID", "returning", "an", "error", "if", "the", "given", "ID", "is", "invalid", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/utils.go#L12-L18
train
flynn/flynn
pkg/cluster/utils.go
GenerateJobID
func GenerateJobID(hostID, uuid string) string { if uuid == "" { uuid = random.UUID() } return hostID + "-" + uuid }
go
func GenerateJobID(hostID, uuid string) string { if uuid == "" { uuid = random.UUID() } return hostID + "-" + uuid }
[ "func", "GenerateJobID", "(", "hostID", ",", "uuid", "string", ")", "string", "{", "if", "uuid", "==", "\"", "\"", "{", "uuid", "=", "random", ".", "UUID", "(", ")", "\n", "}", "\n", "return", "hostID", "+", "\"", "\"", "+", "uuid", "\n", "}" ]
// GenerateJobID returns a random job identifier, prefixed with the given host ID.
[ "GenerateJobID", "returns", "a", "random", "job", "identifier", "prefixed", "with", "the", "given", "host", "ID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/utils.go#L31-L36
train
flynn/flynn
appliance/mongodb/process.go
waitForSync
func (p *Process) waitForSync(downstream *discoverd.Instance) { p.Logger.Debug("waiting for downstream sync") stopCh := make(chan struct{}) doneCh := make(chan struct{}) var once sync.Once p.cancelSyncWait = func() { once.Do(func() { close(stopCh); <-doneCh }) } go p.waitForSyncInner(downstream, stopCh, don...
go
func (p *Process) waitForSync(downstream *discoverd.Instance) { p.Logger.Debug("waiting for downstream sync") stopCh := make(chan struct{}) doneCh := make(chan struct{}) var once sync.Once p.cancelSyncWait = func() { once.Do(func() { close(stopCh); <-doneCh }) } go p.waitForSyncInner(downstream, stopCh, don...
[ "func", "(", "p", "*", "Process", ")", "waitForSync", "(", "downstream", "*", "discoverd", ".", "Instance", ")", "{", "p", ".", "Logger", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "stopCh", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n"...
// waitForSync waits for downstream sync in goroutine
[ "waitForSync", "waits", "for", "downstream", "sync", "in", "goroutine" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/process.go#L853-L865
train
flynn/flynn
appliance/mongodb/process.go
DialInfo
func (p *Process) DialInfo() *mgo.DialInfo { localhost := net.JoinHostPort("localhost", p.Port) info := &mgo.DialInfo{ Addrs: []string{localhost}, Timeout: 5 * time.Second, Direct: true, } if p.securityEnabled() { info.Addrs = []string{p.addr()} info.Database = "admin" info.Username = "flynn" info...
go
func (p *Process) DialInfo() *mgo.DialInfo { localhost := net.JoinHostPort("localhost", p.Port) info := &mgo.DialInfo{ Addrs: []string{localhost}, Timeout: 5 * time.Second, Direct: true, } if p.securityEnabled() { info.Addrs = []string{p.addr()} info.Database = "admin" info.Username = "flynn" info...
[ "func", "(", "p", "*", "Process", ")", "DialInfo", "(", ")", "*", "mgo", ".", "DialInfo", "{", "localhost", ":=", "net", ".", "JoinHostPort", "(", "\"", "\"", ",", "p", ".", "Port", ")", "\n", "info", ":=", "&", "mgo", ".", "DialInfo", "{", "Addr...
// DialInfo returns dial info for connecting to the local process as the "flynn" user.
[ "DialInfo", "returns", "dial", "info", "for", "connecting", "to", "the", "local", "process", "as", "the", "flynn", "user", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/process.go#L868-L883
train
flynn/flynn
router/proxyproto/protocol.go
Read
func (p *conn) Read(b []byte) (int, error) { var err error p.initOnce.Do(func() { err = p.checkPrefix() }) if err != nil { return 0, err } if p.connBuf != nil { n := copy(b, p.connBuf) p.connBuf = p.connBuf[n:] if len(p.connBuf) == 0 { p.connBuf = nil } if len(b) == n { return n, nil } readN,...
go
func (p *conn) Read(b []byte) (int, error) { var err error p.initOnce.Do(func() { err = p.checkPrefix() }) if err != nil { return 0, err } if p.connBuf != nil { n := copy(b, p.connBuf) p.connBuf = p.connBuf[n:] if len(p.connBuf) == 0 { p.connBuf = nil } if len(b) == n { return n, nil } readN,...
[ "func", "(", "p", "*", "conn", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "var", "err", "error", "\n", "p", ".", "initOnce", ".", "Do", "(", "func", "(", ")", "{", "err", "=", "p", ".", "checkPrefix", ...
// Read checks for the PROXY protocol header when doing the initial scan. If // there is an error parsing the header, it is returned and the socket is // closed.
[ "Read", "checks", "for", "the", "PROXY", "protocol", "header", "when", "doing", "the", "initial", "scan", ".", "If", "there", "is", "an", "error", "parsing", "the", "header", "it", "is", "returned", "and", "the", "socket", "is", "closed", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/proxyproto/protocol.go#L55-L74
train
flynn/flynn
logaggregator/aggregator.go
NewAggregator
func NewAggregator() *Aggregator { a := &Aggregator{ buffers: make(map[string]*buffer.Buffer), msgc: make(chan *rfc5424.Message, 1000), pausec: make(chan struct{}), } go a.run() return a }
go
func NewAggregator() *Aggregator { a := &Aggregator{ buffers: make(map[string]*buffer.Buffer), msgc: make(chan *rfc5424.Message, 1000), pausec: make(chan struct{}), } go a.run() return a }
[ "func", "NewAggregator", "(", ")", "*", "Aggregator", "{", "a", ":=", "&", "Aggregator", "{", "buffers", ":", "make", "(", "map", "[", "string", "]", "*", "buffer", ".", "Buffer", ")", ",", "msgc", ":", "make", "(", "chan", "*", "rfc5424", ".", "Me...
// NewAggregator creates a new running Aggregator.
[ "NewAggregator", "creates", "a", "new", "running", "Aggregator", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/aggregator.go#L22-L30
train
flynn/flynn
logaggregator/aggregator.go
Read
func (a *Aggregator) Read(id string) []*rfc5424.Message { return a.getBuffer(id).Read() }
go
func (a *Aggregator) Read(id string) []*rfc5424.Message { return a.getBuffer(id).Read() }
[ "func", "(", "a", "*", "Aggregator", ")", "Read", "(", "id", "string", ")", "[", "]", "*", "rfc5424", ".", "Message", "{", "return", "a", ".", "getBuffer", "(", "id", ")", ".", "Read", "(", ")", "\n", "}" ]
// Read returns the buffered messages for id.
[ "Read", "returns", "the", "buffered", "messages", "for", "id", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/aggregator.go#L49-L51
train
flynn/flynn
logaggregator/aggregator.go
ReadAll
func (a *Aggregator) ReadAll() [][]*rfc5424.Message { // TODO(benburkert): restructure Aggregator & ring.Buffer to avoid nested locks a.bmu.Lock() defer a.bmu.Unlock() buffers := make([][]*rfc5424.Message, 0, len(a.buffers)) for _, buf := range a.buffers { buffers = append(buffers, buf.Read()) } return buffe...
go
func (a *Aggregator) ReadAll() [][]*rfc5424.Message { // TODO(benburkert): restructure Aggregator & ring.Buffer to avoid nested locks a.bmu.Lock() defer a.bmu.Unlock() buffers := make([][]*rfc5424.Message, 0, len(a.buffers)) for _, buf := range a.buffers { buffers = append(buffers, buf.Read()) } return buffe...
[ "func", "(", "a", "*", "Aggregator", ")", "ReadAll", "(", ")", "[", "]", "[", "]", "*", "rfc5424", ".", "Message", "{", "// TODO(benburkert): restructure Aggregator & ring.Buffer to avoid nested locks", "a", ".", "bmu", ".", "Lock", "(", ")", "\n", "defer", "a...
// ReadAll returns all buffered messages.
[ "ReadAll", "returns", "all", "buffered", "messages", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/aggregator.go#L54-L65
train
flynn/flynn
logaggregator/aggregator.go
ReadAndSubscribe
func (a *Aggregator) ReadAndSubscribe(id string, msgc chan<- *rfc5424.Message, donec <-chan struct{}) []*rfc5424.Message { return a.getBuffer(id).ReadAndSubscribe(msgc, donec) }
go
func (a *Aggregator) ReadAndSubscribe(id string, msgc chan<- *rfc5424.Message, donec <-chan struct{}) []*rfc5424.Message { return a.getBuffer(id).ReadAndSubscribe(msgc, donec) }
[ "func", "(", "a", "*", "Aggregator", ")", "ReadAndSubscribe", "(", "id", "string", ",", "msgc", "chan", "<-", "*", "rfc5424", ".", "Message", ",", "donec", "<-", "chan", "struct", "{", "}", ")", "[", "]", "*", "rfc5424", ".", "Message", "{", "return"...
// Read returns the buffered messages and adds a subscriber channel for id.
[ "Read", "returns", "the", "buffered", "messages", "and", "adds", "a", "subscriber", "channel", "for", "id", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/aggregator.go#L68-L70
train
flynn/flynn
logaggregator/aggregator.go
Reset
func (a *Aggregator) Reset() { a.bmu.Lock() defer a.bmu.Unlock() for k, buf := range a.buffers { buf.Close() delete(a.buffers, k) } }
go
func (a *Aggregator) Reset() { a.bmu.Lock() defer a.bmu.Unlock() for k, buf := range a.buffers { buf.Close() delete(a.buffers, k) } }
[ "func", "(", "a", "*", "Aggregator", ")", "Reset", "(", ")", "{", "a", ".", "bmu", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "bmu", ".", "Unlock", "(", ")", "\n\n", "for", "k", ",", "buf", ":=", "range", "a", ".", "buffers", "{", "buf",...
// Reset clears all buffered data and closes subscribers.
[ "Reset", "clears", "all", "buffered", "data", "and", "closes", "subscribers", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/aggregator.go#L73-L81
train
flynn/flynn
logaggregator/aggregator.go
Subscribe
func (a *Aggregator) Subscribe(id string, msgc chan<- *rfc5424.Message, donec <-chan struct{}) { a.getBuffer(id).Subscribe(msgc, donec) }
go
func (a *Aggregator) Subscribe(id string, msgc chan<- *rfc5424.Message, donec <-chan struct{}) { a.getBuffer(id).Subscribe(msgc, donec) }
[ "func", "(", "a", "*", "Aggregator", ")", "Subscribe", "(", "id", "string", ",", "msgc", "chan", "<-", "*", "rfc5424", ".", "Message", ",", "donec", "<-", "chan", "struct", "{", "}", ")", "{", "a", ".", "getBuffer", "(", "id", ")", ".", "Subscribe"...
// Read adds a subscriber channel for id.
[ "Read", "adds", "a", "subscriber", "channel", "for", "id", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/aggregator.go#L91-L93
train
flynn/flynn
gitreceive/server.go
pktLine
func pktLine(w io.Writer, s string) error { _, err := fmt.Fprintf(w, "%04x%s", len(s)+4, s) return err }
go
func pktLine(w io.Writer, s string) error { _, err := fmt.Fprintf(w, "%04x%s", len(s)+4, s) return err }
[ "func", "pktLine", "(", "w", "io", ".", "Writer", ",", "s", "string", ")", "error", "{", "_", ",", "err", ":=", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\"", ",", "len", "(", "s", ")", "+", "4", ",", "s", ")", "\n", "return", "err", "\n...
// Git HTTP line protocol functions
[ "Git", "HTTP", "line", "protocol", "functions" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/gitreceive/server.go#L268-L271
train
flynn/flynn
appliance/redis/cmd/flynn-redis-api/main.go
NewHandler
func NewHandler() *Handler { h := &Handler{ router: httprouter.New(), Logger: log15.New(), } h.router.POST("/clusters", h.servePostCluster) h.router.DELETE("/clusters", h.serveDeleteCluster) h.router.GET("/ping", h.serveGetPing) return h }
go
func NewHandler() *Handler { h := &Handler{ router: httprouter.New(), Logger: log15.New(), } h.router.POST("/clusters", h.servePostCluster) h.router.DELETE("/clusters", h.serveDeleteCluster) h.router.GET("/ping", h.serveGetPing) return h }
[ "func", "NewHandler", "(", ")", "*", "Handler", "{", "h", ":=", "&", "Handler", "{", "router", ":", "httprouter", ".", "New", "(", ")", ",", "Logger", ":", "log15", ".", "New", "(", ")", ",", "}", "\n", "h", ".", "router", ".", "POST", "(", "\"...
// NewAPIHandler returns a new instance of APIHandler.
[ "NewAPIHandler", "returns", "a", "new", "instance", "of", "APIHandler", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/cmd/flynn-redis-api/main.go#L169-L178
train
flynn/flynn
pkg/cluster/host.go
NewHost
func NewHost(id string, addr string, h *http.Client, tags map[string]string) *Host { if h == nil { h = http.DefaultClient } if !strings.HasPrefix(addr, "http") { addr = "http://" + addr } return &Host{ id: id, tags: tags, c: &httpclient.Client{ ErrNotFound: ErrNotFound, URL: addr, HTTP...
go
func NewHost(id string, addr string, h *http.Client, tags map[string]string) *Host { if h == nil { h = http.DefaultClient } if !strings.HasPrefix(addr, "http") { addr = "http://" + addr } return &Host{ id: id, tags: tags, c: &httpclient.Client{ ErrNotFound: ErrNotFound, URL: addr, HTTP...
[ "func", "NewHost", "(", "id", "string", ",", "addr", "string", ",", "h", "*", "http", ".", "Client", ",", "tags", "map", "[", "string", "]", "string", ")", "*", "Host", "{", "if", "h", "==", "nil", "{", "h", "=", "http", ".", "DefaultClient", "\n...
// NewHost creates a new Host that uses client to communicate with it. // addr is used by Attach.
[ "NewHost", "creates", "a", "new", "Host", "that", "uses", "client", "to", "communicate", "with", "it", ".", "addr", "is", "used", "by", "Attach", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L30-L46
train
flynn/flynn
pkg/cluster/host.go
ListJobs
func (c *Host) ListJobs() (map[string]host.ActiveJob, error) { var jobs map[string]host.ActiveJob err := c.c.Get("/host/jobs", &jobs) return jobs, err }
go
func (c *Host) ListJobs() (map[string]host.ActiveJob, error) { var jobs map[string]host.ActiveJob err := c.c.Get("/host/jobs", &jobs) return jobs, err }
[ "func", "(", "c", "*", "Host", ")", "ListJobs", "(", ")", "(", "map", "[", "string", "]", "host", ".", "ActiveJob", ",", "error", ")", "{", "var", "jobs", "map", "[", "string", "]", "host", ".", "ActiveJob", "\n", "err", ":=", "c", ".", "c", "....
// ListJobs lists all jobs on the host.
[ "ListJobs", "lists", "all", "jobs", "on", "the", "host", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L93-L97
train
flynn/flynn
pkg/cluster/host.go
AddJob
func (c *Host) AddJob(job *host.Job) error { return c.c.Put(fmt.Sprintf("/host/jobs/%s", job.ID), job, nil) }
go
func (c *Host) AddJob(job *host.Job) error { return c.c.Put(fmt.Sprintf("/host/jobs/%s", job.ID), job, nil) }
[ "func", "(", "c", "*", "Host", ")", "AddJob", "(", "job", "*", "host", ".", "Job", ")", "error", "{", "return", "c", ".", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "job", ".", "ID", ")", ",", "job", ",", "nil", ")",...
// AddJob runs a job on the host.
[ "AddJob", "runs", "a", "job", "on", "the", "host", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L107-L109
train
flynn/flynn
pkg/cluster/host.go
GetJob
func (c *Host) GetJob(id string) (*host.ActiveJob, error) { var res host.ActiveJob err := c.c.Get(fmt.Sprintf("/host/jobs/%s", id), &res) return &res, err }
go
func (c *Host) GetJob(id string) (*host.ActiveJob, error) { var res host.ActiveJob err := c.c.Get(fmt.Sprintf("/host/jobs/%s", id), &res) return &res, err }
[ "func", "(", "c", "*", "Host", ")", "GetJob", "(", "id", "string", ")", "(", "*", "host", ".", "ActiveJob", ",", "error", ")", "{", "var", "res", "host", ".", "ActiveJob", "\n", "err", ":=", "c", ".", "c", ".", "Get", "(", "fmt", ".", "Sprintf"...
// GetJob retrieves job details by ID.
[ "GetJob", "retrieves", "job", "details", "by", "ID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L112-L116
train
flynn/flynn
pkg/cluster/host.go
StopJob
func (c *Host) StopJob(id string) error { return c.c.Delete(fmt.Sprintf("/host/jobs/%s", id)) }
go
func (c *Host) StopJob(id string) error { return c.c.Delete(fmt.Sprintf("/host/jobs/%s", id)) }
[ "func", "(", "c", "*", "Host", ")", "StopJob", "(", "id", "string", ")", "error", "{", "return", "c", ".", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ")", ")", "\n", "}" ]
// StopJob stops a running job.
[ "StopJob", "stops", "a", "running", "job", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L119-L121
train
flynn/flynn
pkg/cluster/host.go
SignalJob
func (c *Host) SignalJob(id string, sig int) error { return c.c.Put(fmt.Sprintf("/host/jobs/%s/signal/%d", id, sig), nil, nil) }
go
func (c *Host) SignalJob(id string, sig int) error { return c.c.Put(fmt.Sprintf("/host/jobs/%s/signal/%d", id, sig), nil, nil) }
[ "func", "(", "c", "*", "Host", ")", "SignalJob", "(", "id", "string", ",", "sig", "int", ")", "error", "{", "return", "c", ".", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ",", "sig", ")", ",", "nil", ",", "nil", ...
// SignalJob sends a signal to a running job.
[ "SignalJob", "sends", "a", "signal", "to", "a", "running", "job", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L124-L126
train
flynn/flynn
pkg/cluster/host.go
DiscoverdDeregisterJob
func (c *Host) DiscoverdDeregisterJob(id string) error { return c.c.Put(fmt.Sprintf("/host/jobs/%s/discoverd-deregister", id), nil, nil) }
go
func (c *Host) DiscoverdDeregisterJob(id string) error { return c.c.Put(fmt.Sprintf("/host/jobs/%s/discoverd-deregister", id), nil, nil) }
[ "func", "(", "c", "*", "Host", ")", "DiscoverdDeregisterJob", "(", "id", "string", ")", "error", "{", "return", "c", ".", "c", ".", "Put", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ")", ",", "nil", ",", "nil", ")", "\n", "}" ]
// DiscoverdDeregisterJob requests a job to deregister from service discovery.
[ "DiscoverdDeregisterJob", "requests", "a", "job", "to", "deregister", "from", "service", "discovery", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L129-L131
train
flynn/flynn
pkg/cluster/host.go
StreamEvents
func (c *Host) StreamEvents(id string, ch chan *host.Event) (stream.Stream, error) { r := fmt.Sprintf("/host/jobs/%s", id) if id == "all" { r = "/host/jobs" } return c.c.ResumingStream("GET", r, ch) }
go
func (c *Host) StreamEvents(id string, ch chan *host.Event) (stream.Stream, error) { r := fmt.Sprintf("/host/jobs/%s", id) if id == "all" { r = "/host/jobs" } return c.c.ResumingStream("GET", r, ch) }
[ "func", "(", "c", "*", "Host", ")", "StreamEvents", "(", "id", "string", ",", "ch", "chan", "*", "host", ".", "Event", ")", "(", "stream", ".", "Stream", ",", "error", ")", "{", "r", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ")",...
// StreamEvents about job state changes to ch. id may be "all" or a single // job ID.
[ "StreamEvents", "about", "job", "state", "changes", "to", "ch", ".", "id", "may", "be", "all", "or", "a", "single", "job", "ID", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L135-L141
train
flynn/flynn
pkg/cluster/host.go
CreateVolume
func (c *Host) CreateVolume(providerId string, info *volume.Info) error { return c.c.Post(fmt.Sprintf("/storage/providers/%s/volumes", providerId), info, info) }
go
func (c *Host) CreateVolume(providerId string, info *volume.Info) error { return c.c.Post(fmt.Sprintf("/storage/providers/%s/volumes", providerId), info, info) }
[ "func", "(", "c", "*", "Host", ")", "CreateVolume", "(", "providerId", "string", ",", "info", "*", "volume", ".", "Info", ")", "error", "{", "return", "c", ".", "c", ".", "Post", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "providerId", ")", ...
// CreateVolume a new volume with the given configuration. // When in doubt, use a providerId of "default".
[ "CreateVolume", "a", "new", "volume", "with", "the", "given", "configuration", ".", "When", "in", "doubt", "use", "a", "providerId", "of", "default", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L145-L147
train
flynn/flynn
pkg/cluster/host.go
GetVolume
func (c *Host) GetVolume(volumeID string) (*volume.Info, error) { var volume volume.Info return &volume, c.c.Get(fmt.Sprintf("/storage/volumes/%s", volumeID), &volume) }
go
func (c *Host) GetVolume(volumeID string) (*volume.Info, error) { var volume volume.Info return &volume, c.c.Get(fmt.Sprintf("/storage/volumes/%s", volumeID), &volume) }
[ "func", "(", "c", "*", "Host", ")", "GetVolume", "(", "volumeID", "string", ")", "(", "*", "volume", ".", "Info", ",", "error", ")", "{", "var", "volume", "volume", ".", "Info", "\n", "return", "&", "volume", ",", "c", ".", "c", ".", "Get", "(", ...
// GetVolume gets a volume by ID
[ "GetVolume", "gets", "a", "volume", "by", "ID" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L150-L153
train
flynn/flynn
pkg/cluster/host.go
ListVolumes
func (c *Host) ListVolumes() ([]*volume.Info, error) { var volumes []*volume.Info return volumes, c.c.Get("/storage/volumes", &volumes) }
go
func (c *Host) ListVolumes() ([]*volume.Info, error) { var volumes []*volume.Info return volumes, c.c.Get("/storage/volumes", &volumes) }
[ "func", "(", "c", "*", "Host", ")", "ListVolumes", "(", ")", "(", "[", "]", "*", "volume", ".", "Info", ",", "error", ")", "{", "var", "volumes", "[", "]", "*", "volume", ".", "Info", "\n", "return", "volumes", ",", "c", ".", "c", ".", "Get", ...
// ListVolume returns a list of volume IDs
[ "ListVolume", "returns", "a", "list", "of", "volume", "IDs" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L156-L159
train
flynn/flynn
pkg/cluster/host.go
StreamVolumes
func (c *Host) StreamVolumes(ch chan *volume.Event) (stream.Stream, error) { return c.c.ResumingStream("GET", "/storage/volumes", ch) }
go
func (c *Host) StreamVolumes(ch chan *volume.Event) (stream.Stream, error) { return c.c.ResumingStream("GET", "/storage/volumes", ch) }
[ "func", "(", "c", "*", "Host", ")", "StreamVolumes", "(", "ch", "chan", "*", "volume", ".", "Event", ")", "(", "stream", ".", "Stream", ",", "error", ")", "{", "return", "c", ".", "c", ".", "ResumingStream", "(", "\"", "\"", ",", "\"", "\"", ",",...
// StreamVolumes streams volume events to the given channel
[ "StreamVolumes", "streams", "volume", "events", "to", "the", "given", "channel" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L162-L164
train
flynn/flynn
pkg/cluster/host.go
DestroyVolume
func (c *Host) DestroyVolume(volumeID string) error { return c.c.Delete(fmt.Sprintf("/storage/volumes/%s", volumeID)) }
go
func (c *Host) DestroyVolume(volumeID string) error { return c.c.Delete(fmt.Sprintf("/storage/volumes/%s", volumeID)) }
[ "func", "(", "c", "*", "Host", ")", "DestroyVolume", "(", "volumeID", "string", ")", "error", "{", "return", "c", ".", "c", ".", "Delete", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volumeID", ")", ")", "\n", "}" ]
// DestroyVolume deletes a volume by ID
[ "DestroyVolume", "deletes", "a", "volume", "by", "ID" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L167-L169
train
flynn/flynn
pkg/cluster/host.go
CreateSnapshot
func (c *Host) CreateSnapshot(volumeID string) (*volume.Info, error) { var res volume.Info err := c.c.Put(fmt.Sprintf("/storage/volumes/%s/snapshot", volumeID), nil, &res) return &res, err }
go
func (c *Host) CreateSnapshot(volumeID string) (*volume.Info, error) { var res volume.Info err := c.c.Put(fmt.Sprintf("/storage/volumes/%s/snapshot", volumeID), nil, &res) return &res, err }
[ "func", "(", "c", "*", "Host", ")", "CreateSnapshot", "(", "volumeID", "string", ")", "(", "*", "volume", ".", "Info", ",", "error", ")", "{", "var", "res", "volume", ".", "Info", "\n", "err", ":=", "c", ".", "c", ".", "Put", "(", "fmt", ".", "...
// Create snapshot creates a snapshot of a volume on a host.
[ "Create", "snapshot", "creates", "a", "snapshot", "of", "a", "volume", "on", "a", "host", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L172-L176
train
flynn/flynn
pkg/cluster/host.go
PullSnapshot
func (c *Host) PullSnapshot(receiveVolID string, sourceHostID string, sourceSnapID string) (*volume.Info, error) { var res volume.Info pull := volume.PullCoordinate{ HostID: sourceHostID, SnapshotID: sourceSnapID, } err := c.c.Post(fmt.Sprintf("/storage/volumes/%s/pull_snapshot", receiveVolID), pull, &res) ...
go
func (c *Host) PullSnapshot(receiveVolID string, sourceHostID string, sourceSnapID string) (*volume.Info, error) { var res volume.Info pull := volume.PullCoordinate{ HostID: sourceHostID, SnapshotID: sourceSnapID, } err := c.c.Post(fmt.Sprintf("/storage/volumes/%s/pull_snapshot", receiveVolID), pull, &res) ...
[ "func", "(", "c", "*", "Host", ")", "PullSnapshot", "(", "receiveVolID", "string", ",", "sourceHostID", "string", ",", "sourceSnapID", "string", ")", "(", "*", "volume", ".", "Info", ",", "error", ")", "{", "var", "res", "volume", ".", "Info", "\n", "p...
// PullSnapshot requests the host pull a snapshot from another host onto one of // its volumes. Returns the info for the new snapshot.
[ "PullSnapshot", "requests", "the", "host", "pull", "a", "snapshot", "from", "another", "host", "onto", "one", "of", "its", "volumes", ".", "Returns", "the", "info", "for", "the", "new", "snapshot", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L180-L188
train
flynn/flynn
pkg/cluster/host.go
PullImages
func (c *Host) PullImages(repository, configDir, version string, tufDB io.Reader, ch chan *ct.ImagePullInfo) (stream.Stream, error) { header := http.Header{"Content-Type": {"application/octet-stream"}} query := make(url.Values) query.Set("repository", repository) query.Set("config-dir", configDir) query.Set("versi...
go
func (c *Host) PullImages(repository, configDir, version string, tufDB io.Reader, ch chan *ct.ImagePullInfo) (stream.Stream, error) { header := http.Header{"Content-Type": {"application/octet-stream"}} query := make(url.Values) query.Set("repository", repository) query.Set("config-dir", configDir) query.Set("versi...
[ "func", "(", "c", "*", "Host", ")", "PullImages", "(", "repository", ",", "configDir", ",", "version", "string", ",", "tufDB", "io", ".", "Reader", ",", "ch", "chan", "*", "ct", ".", "ImagePullInfo", ")", "(", "stream", ".", "Stream", ",", "error", "...
// PullImages pulls images from a TUF repository using the local TUF file in tufDB
[ "PullImages", "pulls", "images", "from", "a", "TUF", "repository", "using", "the", "local", "TUF", "file", "in", "tufDB" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L204-L212
train
flynn/flynn
pkg/cluster/host.go
PullBinariesAndConfig
func (c *Host) PullBinariesAndConfig(repository, binDir, configDir, version string, tufDB io.Reader) (map[string]string, error) { query := make(url.Values) query.Set("repository", repository) query.Set("bin-dir", binDir) query.Set("config-dir", configDir) query.Set("version", version) path := "/host/pull/binaries...
go
func (c *Host) PullBinariesAndConfig(repository, binDir, configDir, version string, tufDB io.Reader) (map[string]string, error) { query := make(url.Values) query.Set("repository", repository) query.Set("bin-dir", binDir) query.Set("config-dir", configDir) query.Set("version", version) path := "/host/pull/binaries...
[ "func", "(", "c", "*", "Host", ")", "PullBinariesAndConfig", "(", "repository", ",", "binDir", ",", "configDir", ",", "version", "string", ",", "tufDB", "io", ".", "Reader", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "query"...
// PullBinariesAndConfig pulls binaries and config from a TUF repository using the local TUF file in tufDB
[ "PullBinariesAndConfig", "pulls", "binaries", "and", "config", "from", "a", "TUF", "repository", "using", "the", "local", "TUF", "file", "in", "tufDB" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/host.go#L215-L224
train
flynn/flynn
discoverd/server/handler.go
proxyWhitelisted
func proxyWhitelisted(r *http.Request) bool { for _, url := range []string{"/raft/promote", "/raft/demote", "/shutdown"} { if strings.HasPrefix(r.URL.Path, url) { return true } } return false }
go
func proxyWhitelisted(r *http.Request) bool { for _, url := range []string{"/raft/promote", "/raft/demote", "/shutdown"} { if strings.HasPrefix(r.URL.Path, url) { return true } } return false }
[ "func", "proxyWhitelisted", "(", "r", "*", "http", ".", "Request", ")", "bool", "{", "for", "_", ",", "url", ":=", "range", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "{", "if", "strings", ".", "HasPrefix", "(", ...
// Whitelisted endpoints won't be proxied.
[ "Whitelisted", "endpoints", "won", "t", "be", "proxied", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L115-L122
train
flynn/flynn
discoverd/server/handler.go
servePutService
func (h *Handler) servePutService(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve the path parameter. service := params.ByName("service") if err := ValidServiceName(service); err != nil { hh.ValidationError(w, "", err.Error()) return } // Read config from the request. config :...
go
func (h *Handler) servePutService(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve the path parameter. service := params.ByName("service") if err := ValidServiceName(service); err != nil { hh.ValidationError(w, "", err.Error()) return } // Read config from the request. config :...
[ "func", "(", "h", "*", "Handler", ")", "servePutService", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Retrieve the path parameter.", "service", ":=", "params", ".",...
// servePutService creates a service.
[ "servePutService", "creates", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L151-L177
train
flynn/flynn
discoverd/server/handler.go
serveDeleteService
func (h *Handler) serveDeleteService(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve the path parameter. service := params.ByName("service") if err := ValidServiceName(service); err != nil { hh.ValidationError(w, "", err.Error()) return } // Delete from the store. if err := h....
go
func (h *Handler) serveDeleteService(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve the path parameter. service := params.ByName("service") if err := ValidServiceName(service); err != nil { hh.ValidationError(w, "", err.Error()) return } // Delete from the store. if err := h....
[ "func", "(", "h", "*", "Handler", ")", "serveDeleteService", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Retrieve the path parameter.", "service", ":=", "params", "...
// serveDeleteService removes a service from the store by name.
[ "serveDeleteService", "removes", "a", "service", "from", "the", "store", "by", "name", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L180-L199
train
flynn/flynn
discoverd/server/handler.go
serveGetService
func (h *Handler) serveGetService(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // This should only return a stream if the Accept header is // text/event-stream (and return a 406 otherwise), but we // always return a stream due to Go's http.Client not // maintaining headers through a redirect....
go
func (h *Handler) serveGetService(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // This should only return a stream if the Accept header is // text/event-stream (and return a 406 otherwise), but we // always return a stream due to Go's http.Client not // maintaining headers through a redirect....
[ "func", "(", "h", "*", "Handler", ")", "serveGetService", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// This should only return a stream if the Accept header is", "// text/...
// serveGetService streams service events to the client.
[ "serveGetService", "streams", "service", "events", "to", "the", "client", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L202-L210
train
flynn/flynn
discoverd/server/handler.go
servePutServiceMeta
func (h *Handler) servePutServiceMeta(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Read the metadata from the request. meta := &discoverd.ServiceMeta{} if err := hh.DecodeJSON(r, meta); err != nil { hh.Error(w, err) return } // Update the meta in the store. if err := h.Store.SetServ...
go
func (h *Handler) servePutServiceMeta(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Read the metadata from the request. meta := &discoverd.ServiceMeta{} if err := hh.DecodeJSON(r, meta); err != nil { hh.Error(w, err) return } // Update the meta in the store. if err := h.Store.SetServ...
[ "func", "(", "h", "*", "Handler", ")", "servePutServiceMeta", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Read the metadata from the request.", "meta", ":=", "&", "...
// serveServiceMeta sets the metadata for a service.
[ "serveServiceMeta", "sets", "the", "metadata", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L213-L235
train
flynn/flynn
discoverd/server/handler.go
serveGetServiceMeta
func (h *Handler) serveGetServiceMeta(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Read path parameter. service := params.ByName("service") // Read meta from the store. meta := h.Store.ServiceMeta(service) if meta == nil { hh.ObjectNotFoundError(w, "service meta not found") return }...
go
func (h *Handler) serveGetServiceMeta(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Read path parameter. service := params.ByName("service") // Read meta from the store. meta := h.Store.ServiceMeta(service) if meta == nil { hh.ObjectNotFoundError(w, "service meta not found") return }...
[ "func", "(", "h", "*", "Handler", ")", "serveGetServiceMeta", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Read path parameter.", "service", ":=", "params", ".", "...
// serveGetServiceMeta returns the metadata for a service.
[ "serveGetServiceMeta", "returns", "the", "metadata", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L238-L251
train
flynn/flynn
discoverd/server/handler.go
servePutInstance
func (h *Handler) servePutInstance(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Read path parameter. service := params.ByName("service") // Read instance from request. inst := &discoverd.Instance{} if err := json.NewDecoder(r.Body).Decode(inst); err != nil { hh.Error(w, err) return ...
go
func (h *Handler) servePutInstance(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Read path parameter. service := params.ByName("service") // Read instance from request. inst := &discoverd.Instance{} if err := json.NewDecoder(r.Body).Decode(inst); err != nil { hh.Error(w, err) return ...
[ "func", "(", "h", "*", "Handler", ")", "servePutInstance", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Read path parameter.", "service", ":=", "params", ".", "ByN...
// servePutInstance adds an instance to a service.
[ "servePutInstance", "adds", "an", "instance", "to", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L254-L282
train
flynn/flynn
discoverd/server/handler.go
serveDeleteInstance
func (h *Handler) serveDeleteInstance(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve path parameters. service := params.ByName("service") instanceID := params.ByName("instance_id") // Remove instance from the store. if err := h.Store.RemoveInstance(service, instanceID); err == Err...
go
func (h *Handler) serveDeleteInstance(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve path parameters. service := params.ByName("service") instanceID := params.ByName("instance_id") // Remove instance from the store. if err := h.Store.RemoveInstance(service, instanceID); err == Err...
[ "func", "(", "h", "*", "Handler", ")", "serveDeleteInstance", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Retrieve path parameters.", "service", ":=", "params", "."...
// serveDeleteInstance removes an instance from the store by name.
[ "serveDeleteInstance", "removes", "an", "instance", "from", "the", "store", "by", "name", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L285-L301
train
flynn/flynn
discoverd/server/handler.go
serveGetInstances
func (h *Handler) serveGetInstances(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // If the client is requesting a stream, then handle as a stream. if strings.Contains(r.Header.Get("Accept"), "text/event-stream") { h.serveStream(w, params, discoverd.EventKindUp|discoverd.EventKindUpdate|discov...
go
func (h *Handler) serveGetInstances(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // If the client is requesting a stream, then handle as a stream. if strings.Contains(r.Header.Get("Accept"), "text/event-stream") { h.serveStream(w, params, discoverd.EventKindUp|discoverd.EventKindUpdate|discov...
[ "func", "(", "h", "*", "Handler", ")", "serveGetInstances", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// If the client is requesting a stream, then handle as a stream.", "...
// serveGetInstances returns a list of all instances for a service.
[ "serveGetInstances", "returns", "a", "list", "of", "all", "instances", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L304-L323
train
flynn/flynn
discoverd/server/handler.go
servePutLeader
func (h *Handler) servePutLeader(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve path parameters. service := params.ByName("service") // Check if the service allows manual leader election. config := h.Store.Config(service) if config == nil || config.LeaderType != discoverd.LeaderTy...
go
func (h *Handler) servePutLeader(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Retrieve path parameters. service := params.ByName("service") // Check if the service allows manual leader election. config := h.Store.Config(service) if config == nil || config.LeaderType != discoverd.LeaderTy...
[ "func", "(", "h", "*", "Handler", ")", "servePutLeader", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Retrieve path parameters.", "service", ":=", "params", ".", "...
// servePutLeader sets the leader for a service.
[ "servePutLeader", "sets", "the", "leader", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L326-L352
train
flynn/flynn
discoverd/server/handler.go
serveGetLeader
func (h *Handler) serveGetLeader(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Process as a stream if that's what the client wants. if strings.Contains(r.Header.Get("Accept"), "text/event-stream") { h.serveStream(w, params, discoverd.EventKindLeader) return } // Otherwise retrieve the ...
go
func (h *Handler) serveGetLeader(w http.ResponseWriter, r *http.Request, params httprouter.Params) { // Process as a stream if that's what the client wants. if strings.Contains(r.Header.Get("Accept"), "text/event-stream") { h.serveStream(w, params, discoverd.EventKindLeader) return } // Otherwise retrieve the ...
[ "func", "(", "h", "*", "Handler", ")", "serveGetLeader", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "// Process as a stream if that's what the client wants.", "if", "strin...
// serveGetLeader returns the current leader for a service.
[ "serveGetLeader", "returns", "the", "current", "leader", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L355-L375
train
flynn/flynn
discoverd/server/handler.go
servePromote
func (h *Handler) servePromote(w http.ResponseWriter, r *http.Request, params httprouter.Params) { if err := h.Main.Promote(); err != nil { hh.Error(w, err) return } }
go
func (h *Handler) servePromote(w http.ResponseWriter, r *http.Request, params httprouter.Params) { if err := h.Main.Promote(); err != nil { hh.Error(w, err) return } }
[ "func", "(", "h", "*", "Handler", ")", "servePromote", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "if", "err", ":=", "h", ".", "Main", ".", "Promote", "(", "...
// servePromote attempts to promote this discoverd peer to a raft peer
[ "servePromote", "attempts", "to", "promote", "this", "discoverd", "peer", "to", "a", "raft", "peer" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L397-L402
train
flynn/flynn
discoverd/server/handler.go
serveDemote
func (h *Handler) serveDemote(w http.ResponseWriter, r *http.Request, params httprouter.Params) { if err := h.Main.Demote(); err != nil { hh.Error(w, err) return } }
go
func (h *Handler) serveDemote(w http.ResponseWriter, r *http.Request, params httprouter.Params) { if err := h.Main.Demote(); err != nil { hh.Error(w, err) return } }
[ "func", "(", "h", "*", "Handler", ")", "serveDemote", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "if", "err", ":=", "h", ".", "Main", ".", "Demote", "(", ")"...
// serveDemote attempts to demote this peer from a raft peer to a proxy
[ "serveDemote", "attempts", "to", "demote", "this", "peer", "from", "a", "raft", "peer", "to", "a", "proxy" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L405-L410
train
flynn/flynn
discoverd/server/handler.go
serveStream
func (h *Handler) serveStream(w http.ResponseWriter, params httprouter.Params, kind discoverd.EventKind) { // Create a buffered channel to receive events. ch := make(chan *discoverd.Event, StreamBufferSize) // Subscribe to events on the store. service := params.ByName("service") stream := h.Store.Subscribe(servic...
go
func (h *Handler) serveStream(w http.ResponseWriter, params httprouter.Params, kind discoverd.EventKind) { // Create a buffered channel to receive events. ch := make(chan *discoverd.Event, StreamBufferSize) // Subscribe to events on the store. service := params.ByName("service") stream := h.Store.Subscribe(servic...
[ "func", "(", "h", "*", "Handler", ")", "serveStream", "(", "w", "http", ".", "ResponseWriter", ",", "params", "httprouter", ".", "Params", ",", "kind", "discoverd", ".", "EventKind", ")", "{", "// Create a buffered channel to receive events.", "ch", ":=", "make"...
// serveStream creates a subscription and streams out events in SSE format.
[ "serveStream", "creates", "a", "subscription", "and", "streams", "out", "events", "in", "SSE", "format", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L413-L431
train
flynn/flynn
discoverd/server/handler.go
serveGetRaftLeader
func (h *Handler) serveGetRaftLeader(w http.ResponseWriter, r *http.Request, params httprouter.Params) { leader := h.Store.Leader() if leader == "" { hh.ServiceUnavailableError(w, ErrNoKnownLeader.Error()) return } hh.JSON(w, 200, dt.RaftLeader{Host: h.Store.Leader()}) }
go
func (h *Handler) serveGetRaftLeader(w http.ResponseWriter, r *http.Request, params httprouter.Params) { leader := h.Store.Leader() if leader == "" { hh.ServiceUnavailableError(w, ErrNoKnownLeader.Error()) return } hh.JSON(w, 200, dt.RaftLeader{Host: h.Store.Leader()}) }
[ "func", "(", "h", "*", "Handler", ")", "serveGetRaftLeader", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "leader", ":=", "h", ".", "Store", ".", "Leader", "(", ...
// serveGetRaftLeader returns the current raft leader.
[ "serveGetRaftLeader", "returns", "the", "current", "raft", "leader", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L434-L442
train
flynn/flynn
discoverd/server/handler.go
serveGetRaftPeers
func (h *Handler) serveGetRaftPeers(w http.ResponseWriter, r *http.Request, params httprouter.Params) { peers, err := h.Store.GetPeers() if err != nil { hh.Error(w, err) } hh.JSON(w, 200, peers) }
go
func (h *Handler) serveGetRaftPeers(w http.ResponseWriter, r *http.Request, params httprouter.Params) { peers, err := h.Store.GetPeers() if err != nil { hh.Error(w, err) } hh.JSON(w, 200, peers) }
[ "func", "(", "h", "*", "Handler", ")", "serveGetRaftPeers", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "peers", ",", "err", ":=", "h", ".", "Store", ".", "GetP...
// serveGetRaftPeers returns the current raft peers.
[ "serveGetRaftPeers", "returns", "the", "current", "raft", "peers", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L445-L452
train
flynn/flynn
discoverd/server/handler.go
servePutRaftPeer
func (h *Handler) servePutRaftPeer(w http.ResponseWriter, r *http.Request, params httprouter.Params) { peer := params.ByName("peer") if err := h.Store.AddPeer(peer); err == ErrNotLeader { h.redirectToLeader(w, r) return } else if err != nil { hh.Error(w, err) return } var targetLogIndex dt.TargetLogIndex ...
go
func (h *Handler) servePutRaftPeer(w http.ResponseWriter, r *http.Request, params httprouter.Params) { peer := params.ByName("peer") if err := h.Store.AddPeer(peer); err == ErrNotLeader { h.redirectToLeader(w, r) return } else if err != nil { hh.Error(w, err) return } var targetLogIndex dt.TargetLogIndex ...
[ "func", "(", "h", "*", "Handler", ")", "servePutRaftPeer", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "peer", ":=", "params", ".", "ByName", "(", "\"", "\"", "...
// servePutRaftNodes joins a peer to the store cluster.
[ "servePutRaftNodes", "joins", "a", "peer", "to", "the", "store", "cluster", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L455-L467
train
flynn/flynn
discoverd/server/handler.go
serveDeleteRaftPeer
func (h *Handler) serveDeleteRaftPeer(w http.ResponseWriter, r *http.Request, params httprouter.Params) { peer := params.ByName("peer") if err := h.Store.RemovePeer(peer); err == ErrNotLeader { h.redirectToLeader(w, r) return } else if err != nil { hh.Error(w, err) return } }
go
func (h *Handler) serveDeleteRaftPeer(w http.ResponseWriter, r *http.Request, params httprouter.Params) { peer := params.ByName("peer") if err := h.Store.RemovePeer(peer); err == ErrNotLeader { h.redirectToLeader(w, r) return } else if err != nil { hh.Error(w, err) return } }
[ "func", "(", "h", "*", "Handler", ")", "serveDeleteRaftPeer", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "{", "peer", ":=", "params", ".", "ByName", "(", "\"", "\"", ...
// serveDeleteRaftNodes removes a peer to the store cluster.
[ "serveDeleteRaftNodes", "removes", "a", "peer", "to", "the", "store", "cluster", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L470-L479
train
flynn/flynn
discoverd/server/handler.go
redirectToLeader
func (h *Handler) redirectToLeader(w http.ResponseWriter, r *http.Request) { // Find the current leader. leader := h.Store.Leader() if leader == "" { hh.ServiceUnavailableError(w, ErrNoKnownLeader.Error()) return } redirectToHost(w, r, leader) }
go
func (h *Handler) redirectToLeader(w http.ResponseWriter, r *http.Request) { // Find the current leader. leader := h.Store.Leader() if leader == "" { hh.ServiceUnavailableError(w, ErrNoKnownLeader.Error()) return } redirectToHost(w, r, leader) }
[ "func", "(", "h", "*", "Handler", ")", "redirectToLeader", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "// Find the current leader.", "leader", ":=", "h", ".", "Store", ".", "Leader", "(", ")", "\n", "if", ...
// redirectToLeader redirects the request to the current known leader.
[ "redirectToLeader", "redirects", "the", "request", "to", "the", "current", "known", "leader", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/handler.go#L482-L491
train
flynn/flynn
discoverd/server/store.go
NewStore
func NewStore(path string) *Store { return &Store{ path: path, data: newRaftData(), subscribers: make(map[string]*list.List), leaderCh: make(chan bool), heartbeats: make(map[instanceKey]time.Time), closing: make(chan struct{}), HeartbeatTimeout: 1000 * time.Millisecond, ElectionTim...
go
func NewStore(path string) *Store { return &Store{ path: path, data: newRaftData(), subscribers: make(map[string]*list.List), leaderCh: make(chan bool), heartbeats: make(map[instanceKey]time.Time), closing: make(chan struct{}), HeartbeatTimeout: 1000 * time.Millisecond, ElectionTim...
[ "func", "NewStore", "(", "path", "string", ")", "*", "Store", "{", "return", "&", "Store", "{", "path", ":", "path", ",", "data", ":", "newRaftData", "(", ")", ",", "subscribers", ":", "make", "(", "map", "[", "string", "]", "*", "list", ".", "List...
// NewStore returns an instance of Store.
[ "NewStore", "returns", "an", "instance", "of", "Store", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L115-L137
train
flynn/flynn
discoverd/server/store.go
Open
func (s *Store) Open() error { s.mu.Lock() defer s.mu.Unlock() // Set up logging. s.logger = log.New(s.LogOutput, "[discoverd] ", log.LstdFlags) // Require listener & advertise address. if s.Listener == nil { return ErrListenerRequired } else if s.Advertise == nil { return ErrAdvertiseRequired } // Crea...
go
func (s *Store) Open() error { s.mu.Lock() defer s.mu.Unlock() // Set up logging. s.logger = log.New(s.LogOutput, "[discoverd] ", log.LstdFlags) // Require listener & advertise address. if s.Listener == nil { return ErrListenerRequired } else if s.Advertise == nil { return ErrAdvertiseRequired } // Crea...
[ "func", "(", "s", "*", "Store", ")", "Open", "(", ")", "error", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "// Set up logging.", "s", ".", "logger", "=", "log", ".", "New", "(", ...
// Open starts the raft consensus and opens the store.
[ "Open", "starts", "the", "raft", "consensus", "and", "opens", "the", "store", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L143-L228
train
flynn/flynn
discoverd/server/store.go
Close
func (s *Store) Close() (lastIdx uint64, err error) { // Notify goroutines of closing and wait until they finish. close(s.closing) s.wg.Wait() s.mu.Lock() defer s.mu.Unlock() for _, l := range s.subscribers { for el := l.Front(); el != nil; el = el.Next() { go el.Value.(*subscription).Close() } } if s.r...
go
func (s *Store) Close() (lastIdx uint64, err error) { // Notify goroutines of closing and wait until they finish. close(s.closing) s.wg.Wait() s.mu.Lock() defer s.mu.Unlock() for _, l := range s.subscribers { for el := l.Front(); el != nil; el = el.Next() { go el.Value.(*subscription).Close() } } if s.r...
[ "func", "(", "s", "*", "Store", ")", "Close", "(", ")", "(", "lastIdx", "uint64", ",", "err", "error", ")", "{", "// Notify goroutines of closing and wait until they finish.", "close", "(", "s", ".", "closing", ")", "\n", "s", ".", "wg", ".", "Wait", "(", ...
// Close shuts down the transport and store.
[ "Close", "shuts", "down", "the", "transport", "and", "store", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L244-L271
train
flynn/flynn
discoverd/server/store.go
Leader
func (s *Store) Leader() string { if s.raft == nil { return "" } return s.raft.Leader() }
go
func (s *Store) Leader() string { if s.raft == nil { return "" } return s.raft.Leader() }
[ "func", "(", "s", "*", "Store", ")", "Leader", "(", ")", "string", "{", "if", "s", ".", "raft", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "s", ".", "raft", ".", "Leader", "(", ")", "\n", "}" ]
// Leader returns the host of the current leader. Returns empty string if there is no leader. // Panic if called before store is opened.
[ "Leader", "returns", "the", "host", "of", "the", "current", "leader", ".", "Returns", "empty", "string", "if", "there", "is", "no", "leader", ".", "Panic", "if", "called", "before", "store", "is", "opened", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L275-L280
train
flynn/flynn
discoverd/server/store.go
monitorLeaderCh
func (s *Store) monitorLeaderCh() { defer s.wg.Done() incoming := s.raft.LeaderCh() for { select { case <-s.closing: return case isLeader, ok := <-incoming: // Update leader time and clear heartbeats. s.mu.Lock() if isLeader { s.leaderTime = time.Now() } else { s.leaderTime = time.Time{...
go
func (s *Store) monitorLeaderCh() { defer s.wg.Done() incoming := s.raft.LeaderCh() for { select { case <-s.closing: return case isLeader, ok := <-incoming: // Update leader time and clear heartbeats. s.mu.Lock() if isLeader { s.leaderTime = time.Now() } else { s.leaderTime = time.Time{...
[ "func", "(", "s", "*", "Store", ")", "monitorLeaderCh", "(", ")", "{", "defer", "s", ".", "wg", ".", "Done", "(", ")", "\n\n", "incoming", ":=", "s", ".", "raft", ".", "LeaderCh", "(", ")", "\n", "for", "{", "select", "{", "case", "<-", "s", "....
// monitors the raft leader channel, updates the leader time, and resends to a local channel.
[ "monitors", "the", "raft", "leader", "channel", "updates", "the", "leader", "time", "and", "resends", "to", "a", "local", "channel", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L283-L315
train
flynn/flynn
discoverd/server/store.go
LeaderCh
func (s *Store) LeaderCh() <-chan bool { if s.raft == nil { ch := make(chan bool, 1) ch <- true return ch } return s.leaderCh }
go
func (s *Store) LeaderCh() <-chan bool { if s.raft == nil { ch := make(chan bool, 1) ch <- true return ch } return s.leaderCh }
[ "func", "(", "s", "*", "Store", ")", "LeaderCh", "(", ")", "<-", "chan", "bool", "{", "if", "s", ".", "raft", "==", "nil", "{", "ch", ":=", "make", "(", "chan", "bool", ",", "1", ")", "\n", "ch", "<-", "true", "\n", "return", "ch", "\n", "}",...
// LeaderCh returns a channel that signals leadership change. // Panic if called before store is opened.
[ "LeaderCh", "returns", "a", "channel", "that", "signals", "leadership", "change", ".", "Panic", "if", "called", "before", "store", "is", "opened", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L319-L326
train
flynn/flynn
discoverd/server/store.go
AddPeer
func (s *Store) AddPeer(peer string) error { err := s.raft.AddPeer(peer).Error() if err == raft.ErrNotLeader { err = ErrNotLeader } else if err == raft.ErrKnownPeer { return nil } return err }
go
func (s *Store) AddPeer(peer string) error { err := s.raft.AddPeer(peer).Error() if err == raft.ErrNotLeader { err = ErrNotLeader } else if err == raft.ErrKnownPeer { return nil } return err }
[ "func", "(", "s", "*", "Store", ")", "AddPeer", "(", "peer", "string", ")", "error", "{", "err", ":=", "s", ".", "raft", ".", "AddPeer", "(", "peer", ")", ".", "Error", "(", ")", "\n", "if", "err", "==", "raft", ".", "ErrNotLeader", "{", "err", ...
// AddPeer adds a peer to the raft cluster. Panic if store is not open yet.
[ "AddPeer", "adds", "a", "peer", "to", "the", "raft", "cluster", ".", "Panic", "if", "store", "is", "not", "open", "yet", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L332-L340
train
flynn/flynn
discoverd/server/store.go
RemovePeer
func (s *Store) RemovePeer(peer string) error { err := s.raft.RemovePeer(peer).Error() if err == raft.ErrNotLeader { err = ErrNotLeader } else if err == raft.ErrUnknownPeer { return nil } return err }
go
func (s *Store) RemovePeer(peer string) error { err := s.raft.RemovePeer(peer).Error() if err == raft.ErrNotLeader { err = ErrNotLeader } else if err == raft.ErrUnknownPeer { return nil } return err }
[ "func", "(", "s", "*", "Store", ")", "RemovePeer", "(", "peer", "string", ")", "error", "{", "err", ":=", "s", ".", "raft", ".", "RemovePeer", "(", "peer", ")", ".", "Error", "(", ")", "\n", "if", "err", "==", "raft", ".", "ErrNotLeader", "{", "e...
// RemovePeer removes a peer from the raft cluster. Panic if store is not open yet.
[ "RemovePeer", "removes", "a", "peer", "from", "the", "raft", "cluster", ".", "Panic", "if", "store", "is", "not", "open", "yet", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L343-L351
train
flynn/flynn
discoverd/server/store.go
SetPeers
func (s *Store) SetPeers(peers []string) error { return s.raft.SetPeers(peers).Error() }
go
func (s *Store) SetPeers(peers []string) error { return s.raft.SetPeers(peers).Error() }
[ "func", "(", "s", "*", "Store", ")", "SetPeers", "(", "peers", "[", "]", "string", ")", "error", "{", "return", "s", ".", "raft", ".", "SetPeers", "(", "peers", ")", ".", "Error", "(", ")", "\n", "}" ]
// SetPeers sets a list of peers in the raft cluster. Panic if store is not open yet.
[ "SetPeers", "sets", "a", "list", "of", "peers", "in", "the", "raft", "cluster", ".", "Panic", "if", "store", "is", "not", "open", "yet", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L359-L361
train
flynn/flynn
discoverd/server/store.go
ServiceNames
func (s *Store) ServiceNames() []string { s.mu.RLock() defer s.mu.RUnlock() var a []string for name := range s.data.Services { a = append(a, name) } sort.Strings(a) return a }
go
func (s *Store) ServiceNames() []string { s.mu.RLock() defer s.mu.RUnlock() var a []string for name := range s.data.Services { a = append(a, name) } sort.Strings(a) return a }
[ "func", "(", "s", "*", "Store", ")", "ServiceNames", "(", ")", "[", "]", "string", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "var", "a", "[", "]", "string", "\n", "for", "nam...
// ServiceNames returns a sorted list of existing service names.
[ "ServiceNames", "returns", "a", "sorted", "list", "of", "existing", "service", "names", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L364-L375
train
flynn/flynn
discoverd/server/store.go
AddService
func (s *Store) AddService(service string, config *discoverd.ServiceConfig) error { if config == nil { config = DefaultServiceConfig } // Serialize command. cmd, err := json.Marshal(&addServiceCommand{ Service: service, Config: config, }) if err != nil { return err } if _, err := s.raftApply(addServi...
go
func (s *Store) AddService(service string, config *discoverd.ServiceConfig) error { if config == nil { config = DefaultServiceConfig } // Serialize command. cmd, err := json.Marshal(&addServiceCommand{ Service: service, Config: config, }) if err != nil { return err } if _, err := s.raftApply(addServi...
[ "func", "(", "s", "*", "Store", ")", "AddService", "(", "service", "string", ",", "config", "*", "discoverd", ".", "ServiceConfig", ")", "error", "{", "if", "config", "==", "nil", "{", "config", "=", "DefaultServiceConfig", "\n", "}", "\n\n", "// Serialize...
// AddService creates a service with a configuration. // Returns an error if the service already exists.
[ "AddService", "creates", "a", "service", "with", "a", "configuration", ".", "Returns", "an", "error", "if", "the", "service", "already", "exists", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L379-L397
train
flynn/flynn
discoverd/server/store.go
Config
func (s *Store) Config(service string) *discoverd.ServiceConfig { s.mu.RLock() defer s.mu.RUnlock() return s.data.Services[service] }
go
func (s *Store) Config(service string) *discoverd.ServiceConfig { s.mu.RLock() defer s.mu.RUnlock() return s.data.Services[service] }
[ "func", "(", "s", "*", "Store", ")", "Config", "(", "service", "string", ")", "*", "discoverd", ".", "ServiceConfig", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", ...
// Config returns the configuration for service.
[ "Config", "returns", "the", "configuration", "for", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L417-L421
train
flynn/flynn
discoverd/server/store.go
RemoveService
func (s *Store) RemoveService(service string) error { // Serialize command. cmd, err := json.Marshal(&removeServiceCommand{Service: service}) if err != nil { return err } if _, err := s.raftApply(removeServiceCommandType, cmd); err != nil { return err } return nil }
go
func (s *Store) RemoveService(service string) error { // Serialize command. cmd, err := json.Marshal(&removeServiceCommand{Service: service}) if err != nil { return err } if _, err := s.raftApply(removeServiceCommandType, cmd); err != nil { return err } return nil }
[ "func", "(", "s", "*", "Store", ")", "RemoveService", "(", "service", "string", ")", "error", "{", "// Serialize command.", "cmd", ",", "err", ":=", "json", ".", "Marshal", "(", "&", "removeServiceCommand", "{", "Service", ":", "service", "}", ")", "\n", ...
// RemoveService deletes the service from the store.
[ "RemoveService", "deletes", "the", "service", "from", "the", "store", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L424-L435
train
flynn/flynn
discoverd/server/store.go
Instances
func (s *Store) Instances(service string) ([]*discoverd.Instance, error) { s.mu.Lock() defer s.mu.Unlock() return s.instances(service), nil }
go
func (s *Store) Instances(service string) ([]*discoverd.Instance, error) { s.mu.Lock() defer s.mu.Unlock() return s.instances(service), nil }
[ "func", "(", "s", "*", "Store", ")", "Instances", "(", "service", "string", ")", "(", "[", "]", "*", "discoverd", ".", "Instance", ",", "error", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(",...
// Instances returns a list of instances for service.
[ "Instances", "returns", "a", "list", "of", "instances", "for", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L467-L471
train
flynn/flynn
discoverd/server/store.go
ServiceMeta
func (s *Store) ServiceMeta(service string) *discoverd.ServiceMeta { s.mu.Lock() defer s.mu.Unlock() return s.serviceMeta(service) }
go
func (s *Store) ServiceMeta(service string) *discoverd.ServiceMeta { s.mu.Lock() defer s.mu.Unlock() return s.serviceMeta(service) }
[ "func", "(", "s", "*", "Store", ")", "ServiceMeta", "(", "service", "string", ")", "*", "discoverd", ".", "ServiceMeta", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "s", ".",...
// ServiceMeta returns the meta data for a service.
[ "ServiceMeta", "returns", "the", "meta", "data", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L620-L624
train
flynn/flynn
discoverd/server/store.go
SetServiceLeader
func (s *Store) SetServiceLeader(service, id string) error { // Serialize command. cmd, err := json.Marshal(&setLeaderCommand{ Service: service, ID: id, }) if err != nil { return err } if _, err := s.raftApply(setLeaderCommandType, cmd); err != nil { return err } return nil }
go
func (s *Store) SetServiceLeader(service, id string) error { // Serialize command. cmd, err := json.Marshal(&setLeaderCommand{ Service: service, ID: id, }) if err != nil { return err } if _, err := s.raftApply(setLeaderCommandType, cmd); err != nil { return err } return nil }
[ "func", "(", "s", "*", "Store", ")", "SetServiceLeader", "(", "service", ",", "id", "string", ")", "error", "{", "// Serialize command.", "cmd", ",", "err", ":=", "json", ".", "Marshal", "(", "&", "setLeaderCommand", "{", "Service", ":", "service", ",", ...
// SetServiceLeader manually sets the leader for a service.
[ "SetServiceLeader", "manually", "sets", "the", "leader", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L709-L723
train
flynn/flynn
discoverd/server/store.go
invalidateServiceLeader
func (s *Store) invalidateServiceLeader(service string) { // Retrieve service config. c := s.data.Services[service] // Ignore if there is no config or the leader is manually elected. if c == nil || c.LeaderType == discoverd.LeaderTypeManual { return } // Retrieve current leader ID. prevLeaderID := s.data.Lea...
go
func (s *Store) invalidateServiceLeader(service string) { // Retrieve service config. c := s.data.Services[service] // Ignore if there is no config or the leader is manually elected. if c == nil || c.LeaderType == discoverd.LeaderTypeManual { return } // Retrieve current leader ID. prevLeaderID := s.data.Lea...
[ "func", "(", "s", "*", "Store", ")", "invalidateServiceLeader", "(", "service", "string", ")", "{", "// Retrieve service config.", "c", ":=", "s", ".", "data", ".", "Services", "[", "service", "]", "\n\n", "// Ignore if there is no config or the leader is manually ele...
// invalidateServiceLeader updates the current leader of service.
[ "invalidateServiceLeader", "updates", "the", "current", "leader", "of", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L769-L811
train
flynn/flynn
discoverd/server/store.go
expirer
func (s *Store) expirer() { defer s.wg.Done() ticker := time.NewTicker(s.ExpiryCheckInterval) defer ticker.Stop() for { // Wait for next check or for close signal. select { case <-s.closing: return case <-ticker.C: } // Check all instances for expiration. if err := s.EnforceExpiry(); err != nil ...
go
func (s *Store) expirer() { defer s.wg.Done() ticker := time.NewTicker(s.ExpiryCheckInterval) defer ticker.Stop() for { // Wait for next check or for close signal. select { case <-s.closing: return case <-ticker.C: } // Check all instances for expiration. if err := s.EnforceExpiry(); err != nil ...
[ "func", "(", "s", "*", "Store", ")", "expirer", "(", ")", "{", "defer", "s", ".", "wg", ".", "Done", "(", ")", "\n\n", "ticker", ":=", "time", ".", "NewTicker", "(", "s", ".", "ExpiryCheckInterval", ")", "\n", "defer", "ticker", ".", "Stop", "(", ...
// expirer runs in a separate goroutine and checks for instance expiration.
[ "expirer", "runs", "in", "a", "separate", "goroutine", "and", "checks", "for", "instance", "expiration", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L814-L833
train
flynn/flynn
discoverd/server/store.go
EnforceExpiry
func (s *Store) EnforceExpiry() error { var cmd []byte if err := func() error { s.mu.Lock() defer s.mu.Unlock() // Ignore if this store is not the leader and hasn't been for at least 2 TTLs intervals. if !s.IsLeader() { return raft.ErrNotLeader } else if s.leaderTime.IsZero() || time.Since(s.leaderTime)...
go
func (s *Store) EnforceExpiry() error { var cmd []byte if err := func() error { s.mu.Lock() defer s.mu.Unlock() // Ignore if this store is not the leader and hasn't been for at least 2 TTLs intervals. if !s.IsLeader() { return raft.ErrNotLeader } else if s.leaderTime.IsZero() || time.Since(s.leaderTime)...
[ "func", "(", "s", "*", "Store", ")", "EnforceExpiry", "(", ")", "error", "{", "var", "cmd", "[", "]", "byte", "\n", "if", "err", ":=", "func", "(", ")", "error", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", ...
// EnforceExpiry checks all instances for expiration and issues an expiration command, if necessary. // This function returns raft.ErrNotLeader if this store is not the current leader.
[ "EnforceExpiry", "checks", "all", "instances", "for", "expiration", "and", "issues", "an", "expiration", "command", "if", "necessary", ".", "This", "function", "returns", "raft", ".", "ErrNotLeader", "if", "this", "store", "is", "not", "the", "current", "leader"...
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L837-L902
train
flynn/flynn
discoverd/server/store.go
raftApply
func (s *Store) raftApply(typ byte, cmd []byte) (uint64, error) { s.mu.RLock() if s.raft == nil { s.mu.RUnlock() return 0, ErrShutdown } s.mu.RUnlock() // Join the command type and data into one message. buf := append([]byte{typ}, cmd...) // Apply to raft and receive an ApplyFuture back. f := s.raft.Apply...
go
func (s *Store) raftApply(typ byte, cmd []byte) (uint64, error) { s.mu.RLock() if s.raft == nil { s.mu.RUnlock() return 0, ErrShutdown } s.mu.RUnlock() // Join the command type and data into one message. buf := append([]byte{typ}, cmd...) // Apply to raft and receive an ApplyFuture back. f := s.raft.Apply...
[ "func", "(", "s", "*", "Store", ")", "raftApply", "(", "typ", "byte", ",", "cmd", "[", "]", "byte", ")", "(", "uint64", ",", "error", ")", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "if", "s", ".", "raft", "==", "nil", "{", "s", "."...
// raftApply joins typ and cmd and applies it to raft. // This call blocks until the apply completes and returns the error.
[ "raftApply", "joins", "typ", "and", "cmd", "and", "applies", "it", "to", "raft", ".", "This", "call", "blocks", "until", "the", "apply", "completes", "and", "returns", "the", "error", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L949-L971
train
flynn/flynn
discoverd/server/store.go
Snapshot
func (s *Store) Snapshot() (raft.FSMSnapshot, error) { s.mu.Lock() defer s.mu.Unlock() buf, err := json.Marshal(s.data) if err != nil { return nil, err } return &raftSnapshot{data: buf}, nil }
go
func (s *Store) Snapshot() (raft.FSMSnapshot, error) { s.mu.Lock() defer s.mu.Unlock() buf, err := json.Marshal(s.data) if err != nil { return nil, err } return &raftSnapshot{data: buf}, nil }
[ "func", "(", "s", "*", "Store", ")", "Snapshot", "(", ")", "(", "raft", ".", "FSMSnapshot", ",", "error", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "buf", ",", "err", ":="...
// Snapshot implements raft.FSM.
[ "Snapshot", "implements", "raft", ".", "FSM", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1007-L1016
train
flynn/flynn
discoverd/server/store.go
Restore
func (s *Store) Restore(r io.ReadCloser) error { s.mu.Lock() defer s.mu.Unlock() data := &raftData{} if err := json.NewDecoder(r).Decode(data); err != nil { return err } s.data = data return nil }
go
func (s *Store) Restore(r io.ReadCloser) error { s.mu.Lock() defer s.mu.Unlock() data := &raftData{} if err := json.NewDecoder(r).Decode(data); err != nil { return err } s.data = data return nil }
[ "func", "(", "s", "*", "Store", ")", "Restore", "(", "r", "io", ".", "ReadCloser", ")", "error", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "data", ":=", "&", "raftData", "{", "...
// Restore implements raft.FSM.
[ "Restore", "implements", "raft", ".", "FSM", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1019-L1029
train
flynn/flynn
discoverd/server/store.go
Subscribe
func (s *Store) Subscribe(service string, sendCurrent bool, kinds discoverd.EventKind, ch chan *discoverd.Event) stream.Stream { s.mu.Lock() defer s.mu.Unlock() // Create service subscription list if it doesn't exist yet. if _, ok := s.subscribers[service]; !ok { s.subscribers[service] = list.New() } // Creat...
go
func (s *Store) Subscribe(service string, sendCurrent bool, kinds discoverd.EventKind, ch chan *discoverd.Event) stream.Stream { s.mu.Lock() defer s.mu.Unlock() // Create service subscription list if it doesn't exist yet. if _, ok := s.subscribers[service]; !ok { s.subscribers[service] = list.New() } // Creat...
[ "func", "(", "s", "*", "Store", ")", "Subscribe", "(", "service", "string", ",", "sendCurrent", "bool", ",", "kinds", "discoverd", ".", "EventKind", ",", "ch", "chan", "*", "discoverd", ".", "Event", ")", "stream", ".", "Stream", "{", "s", ".", "mu", ...
// Subscribe creates a subscription to events on a given service.
[ "Subscribe", "creates", "a", "subscription", "to", "events", "on", "a", "given", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1032-L1089
train
flynn/flynn
discoverd/server/store.go
broadcast
func (s *Store) broadcast(event *discoverd.Event) { logBroadcast(event) // Retrieve list of subscribers for the service. l, ok := s.subscribers[event.Service] if !ok { return } // Iterate over each subscriber in the list. for el := l.Front(); el != nil; el = el.Next() { sub := el.Value.(*subscription) ...
go
func (s *Store) broadcast(event *discoverd.Event) { logBroadcast(event) // Retrieve list of subscribers for the service. l, ok := s.subscribers[event.Service] if !ok { return } // Iterate over each subscriber in the list. for el := l.Front(); el != nil; el = el.Next() { sub := el.Value.(*subscription) ...
[ "func", "(", "s", "*", "Store", ")", "broadcast", "(", "event", "*", "discoverd", ".", "Event", ")", "{", "logBroadcast", "(", "event", ")", "\n\n", "// Retrieve list of subscribers for the service.", "l", ",", "ok", ":=", "s", ".", "subscribers", "[", "even...
// broadcast sends an event to all subscribers. // Requires the mu lock to be obtained.
[ "broadcast", "sends", "an", "event", "to", "all", "subscribers", ".", "Requires", "the", "mu", "lock", "to", "be", "obtained", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1093-L1121
train
flynn/flynn
discoverd/server/store.go
Persist
func (ss *raftSnapshot) Persist(sink raft.SnapshotSink) error { // Write data to sink. if _, err := sink.Write(ss.data); err != nil { sink.Cancel() return err } // Close and exit. return sink.Close() }
go
func (ss *raftSnapshot) Persist(sink raft.SnapshotSink) error { // Write data to sink. if _, err := sink.Write(ss.data); err != nil { sink.Cancel() return err } // Close and exit. return sink.Close() }
[ "func", "(", "ss", "*", "raftSnapshot", ")", "Persist", "(", "sink", "raft", ".", "SnapshotSink", ")", "error", "{", "// Write data to sink.", "if", "_", ",", "err", ":=", "sink", ".", "Write", "(", "ss", ".", "data", ")", ";", "err", "!=", "nil", "{...
// Persist writes the snapshot to the sink.
[ "Persist", "writes", "the", "snapshot", "to", "the", "sink", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1148-L1157
train
flynn/flynn
discoverd/server/store.go
ServiceInstances
func (d *raftData) ServiceInstances(service string) []*discoverd.Instance { a := make([]*discoverd.Instance, 0, len(d.Instances[service])) for _, i := range d.Instances[service] { a = append(a, i) } sort.Sort(instanceSlice(a)) return a }
go
func (d *raftData) ServiceInstances(service string) []*discoverd.Instance { a := make([]*discoverd.Instance, 0, len(d.Instances[service])) for _, i := range d.Instances[service] { a = append(a, i) } sort.Sort(instanceSlice(a)) return a }
[ "func", "(", "d", "*", "raftData", ")", "ServiceInstances", "(", "service", "string", ")", "[", "]", "*", "discoverd", ".", "Instance", "{", "a", ":=", "make", "(", "[", "]", "*", "discoverd", ".", "Instance", ",", "0", ",", "len", "(", "d", ".", ...
// ServiceInstances returns the instances of a service in sorted order.
[ "ServiceInstances", "returns", "the", "instances", "of", "a", "service", "in", "sorted", "order", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1245-L1253
train
flynn/flynn
discoverd/server/store.go
ValidServiceName
func ValidServiceName(service string) error { // Blank service names are not allowed. if service == "" { return ErrUnsetService } // Service names must consist of the characters [a-z0-9-] for _, r := range service { if (r < 'a' || r > 'z') && (r < '0' || r > '9') && r != '-' { return ErrInvalidService } ...
go
func ValidServiceName(service string) error { // Blank service names are not allowed. if service == "" { return ErrUnsetService } // Service names must consist of the characters [a-z0-9-] for _, r := range service { if (r < 'a' || r > 'z') && (r < '0' || r > '9') && r != '-' { return ErrInvalidService } ...
[ "func", "ValidServiceName", "(", "service", "string", ")", "error", "{", "// Blank service names are not allowed.", "if", "service", "==", "\"", "\"", "{", "return", "ErrUnsetService", "\n", "}", "\n\n", "// Service names must consist of the characters [a-z0-9-]", "for", ...
// ValidServiceName returns nil if service is valid. Otherwise returns an error.
[ "ValidServiceName", "returns", "nil", "if", "service", "is", "valid", ".", "Otherwise", "returns", "an", "error", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1328-L1342
train
flynn/flynn
discoverd/server/store.go
Instances
func (s *ProxyStore) Instances(service string) ([]*discoverd.Instance, error) { host := s.Peers[rand.Intn(len(s.Peers))] client := discoverd.NewClientWithURL("http://" + host) return client.Service(service).Instances() }
go
func (s *ProxyStore) Instances(service string) ([]*discoverd.Instance, error) { host := s.Peers[rand.Intn(len(s.Peers))] client := discoverd.NewClientWithURL("http://" + host) return client.Service(service).Instances() }
[ "func", "(", "s", "*", "ProxyStore", ")", "Instances", "(", "service", "string", ")", "(", "[", "]", "*", "discoverd", ".", "Instance", ",", "error", ")", "{", "host", ":=", "s", ".", "Peers", "[", "rand", ".", "Intn", "(", "len", "(", "s", ".", ...
// Instances returns a list of instances for a service.
[ "Instances", "returns", "a", "list", "of", "instances", "for", "a", "service", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1351-L1355
train
flynn/flynn
discoverd/server/store.go
newRaftLayer
func newRaftLayer(ln net.Listener, addr net.Addr) *raftLayer { return &raftLayer{ ln: ln, addr: addr, } }
go
func newRaftLayer(ln net.Listener, addr net.Addr) *raftLayer { return &raftLayer{ ln: ln, addr: addr, } }
[ "func", "newRaftLayer", "(", "ln", "net", ".", "Listener", ",", "addr", "net", ".", "Addr", ")", "*", "raftLayer", "{", "return", "&", "raftLayer", "{", "ln", ":", "ln", ",", "addr", ":", "addr", ",", "}", "\n", "}" ]
// newRaftLayer returns a new instance of raftLayer.
[ "newRaftLayer", "returns", "a", "new", "instance", "of", "raftLayer", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/server/store.go#L1374-L1379
train
flynn/flynn
pkg/rpcplus/client.go
CloseStream
func (c *Call) CloseStream() error { if !c.Stream { return errors.New("rpc: cannot close non-stream request") } <-c.sent c.client.sending.Lock() defer c.client.sending.Unlock() c.client.mutex.Lock() if c.client.shutdown { c.client.mutex.Unlock() return ErrShutdown } c.client.mutex.Unlock() c.client.re...
go
func (c *Call) CloseStream() error { if !c.Stream { return errors.New("rpc: cannot close non-stream request") } <-c.sent c.client.sending.Lock() defer c.client.sending.Unlock() c.client.mutex.Lock() if c.client.shutdown { c.client.mutex.Unlock() return ErrShutdown } c.client.mutex.Unlock() c.client.re...
[ "func", "(", "c", "*", "Call", ")", "CloseStream", "(", ")", "error", "{", "if", "!", "c", ".", "Stream", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "<-", "c", ".", "sent", "\n", "c", ".", "client", ".", "send...
// CloseStream closes the associated stream
[ "CloseStream", "closes", "the", "associated", "stream" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/client.go#L45-L63
train
flynn/flynn
pkg/rpcplus/client.go
NewClient
func NewClient(conn io.ReadWriteCloser) *Client { encBuf := bufio.NewWriter(conn) client := &gobClientCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(encBuf), encBuf} return NewClientWithCodec(client) }
go
func NewClient(conn io.ReadWriteCloser) *Client { encBuf := bufio.NewWriter(conn) client := &gobClientCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(encBuf), encBuf} return NewClientWithCodec(client) }
[ "func", "NewClient", "(", "conn", "io", ".", "ReadWriteCloser", ")", "*", "Client", "{", "encBuf", ":=", "bufio", ".", "NewWriter", "(", "conn", ")", "\n", "client", ":=", "&", "gobClientCodec", "{", "conn", ",", "gob", ".", "NewDecoder", "(", "conn", ...
// NewClient returns a new Client to handle requests to the // set of services at the other end of the connection. // It adds a buffer to the write side of the connection so // the header and payload are sent as a unit.
[ "NewClient", "returns", "a", "new", "Client", "to", "handle", "requests", "to", "the", "set", "of", "services", "at", "the", "other", "end", "of", "the", "connection", ".", "It", "adds", "a", "buffer", "to", "the", "write", "side", "of", "the", "connecti...
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/client.go#L243-L247
train
flynn/flynn
pkg/rpcplus/client.go
DialHTTP
func DialHTTP(network, address string) (*Client, error) { return DialHTTPPath(network, address, DefaultRPCPath, nil) }
go
func DialHTTP(network, address string) (*Client, error) { return DialHTTPPath(network, address, DefaultRPCPath, nil) }
[ "func", "DialHTTP", "(", "network", ",", "address", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "DialHTTPPath", "(", "network", ",", "address", ",", "DefaultRPCPath", ",", "nil", ")", "\n", "}" ]
// DialHTTP connects to an HTTP RPC server at the specified network address // listening on the default HTTP RPC path.
[ "DialHTTP", "connects", "to", "an", "HTTP", "RPC", "server", "at", "the", "specified", "network", "address", "listening", "on", "the", "default", "HTTP", "RPC", "path", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/client.go#L291-L293
train
flynn/flynn
pkg/rpcplus/client.go
DialHTTPPath
func DialHTTPPath(network, address, path string, dial DialFunc) (*Client, error) { if dial == nil { dial = net.Dial } var err error conn, err := dial(network, address) if err != nil { return nil, err } client, err := NewHTTPClient(conn, path, nil) if err != nil { conn.Close() return nil, &net.OpError{ ...
go
func DialHTTPPath(network, address, path string, dial DialFunc) (*Client, error) { if dial == nil { dial = net.Dial } var err error conn, err := dial(network, address) if err != nil { return nil, err } client, err := NewHTTPClient(conn, path, nil) if err != nil { conn.Close() return nil, &net.OpError{ ...
[ "func", "DialHTTPPath", "(", "network", ",", "address", ",", "path", "string", ",", "dial", "DialFunc", ")", "(", "*", "Client", ",", "error", ")", "{", "if", "dial", "==", "nil", "{", "dial", "=", "net", ".", "Dial", "\n", "}", "\n", "var", "err",...
// DialHTTPPath connects to an HTTP RPC server // at the specified network address and path.
[ "DialHTTPPath", "connects", "to", "an", "HTTP", "RPC", "server", "at", "the", "specified", "network", "address", "and", "path", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/client.go#L299-L319
train
flynn/flynn
pkg/rpcplus/client.go
Dial
func Dial(network, address string) (*Client, error) { conn, err := net.Dial(network, address) if err != nil { return nil, err } return NewClient(conn), nil }
go
func Dial(network, address string) (*Client, error) { conn, err := net.Dial(network, address) if err != nil { return nil, err } return NewClient(conn), nil }
[ "func", "Dial", "(", "network", ",", "address", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "conn", ",", "err", ":=", "net", ".", "Dial", "(", "network", ",", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",...
// Dial connects to an RPC server at the specified network address.
[ "Dial", "connects", "to", "an", "RPC", "server", "at", "the", "specified", "network", "address", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/client.go#L344-L350
train
flynn/flynn
pkg/rpcplus/client.go
StreamGo
func (client *Client) StreamGo(serviceMethod string, args interface{}, replyStream interface{}) *Call { // first check the replyStream object is a stream of pointers to a data structure typ := reflect.TypeOf(replyStream) // FIXME: check the direction of the channel, maybe? if typ.Kind() != reflect.Chan || typ.Elem(...
go
func (client *Client) StreamGo(serviceMethod string, args interface{}, replyStream interface{}) *Call { // first check the replyStream object is a stream of pointers to a data structure typ := reflect.TypeOf(replyStream) // FIXME: check the direction of the channel, maybe? if typ.Kind() != reflect.Chan || typ.Elem(...
[ "func", "(", "client", "*", "Client", ")", "StreamGo", "(", "serviceMethod", "string", ",", "args", "interface", "{", "}", ",", "replyStream", "interface", "{", "}", ")", "*", "Call", "{", "// first check the replyStream object is a stream of pointers to a data struct...
// Go invokes the streaming function asynchronously. It returns the Call structure representing // the invocation.
[ "Go", "invokes", "the", "streaming", "function", "asynchronously", ".", "It", "returns", "the", "Call", "structure", "representing", "the", "invocation", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/client.go#L390-L408
train
flynn/flynn
appliance/mariadb/dsn.go
String
func (dsn *DSN) String() string { u := url.URL{ Host: fmt.Sprintf("tcp(%s)", dsn.Host), Path: "/" + dsn.Database, RawQuery: url.Values{ "timeout": {dsn.Timeout.String()}, }.Encode(), } // Set password, if available. if dsn.Password == "" { u.User = url.User(dsn.User) } else { u.User = url.UserPassw...
go
func (dsn *DSN) String() string { u := url.URL{ Host: fmt.Sprintf("tcp(%s)", dsn.Host), Path: "/" + dsn.Database, RawQuery: url.Values{ "timeout": {dsn.Timeout.String()}, }.Encode(), } // Set password, if available. if dsn.Password == "" { u.User = url.User(dsn.User) } else { u.User = url.UserPassw...
[ "func", "(", "dsn", "*", "DSN", ")", "String", "(", ")", "string", "{", "u", ":=", "url", ".", "URL", "{", "Host", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "dsn", ".", "Host", ")", ",", "Path", ":", "\"", "\"", "+", "dsn", ".", "Da...
// String encodes dsn to a URL string format.
[ "String", "encodes", "dsn", "to", "a", "URL", "string", "format", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mariadb/dsn.go#L20-L38
train
flynn/flynn
flannel/main.go
pingLeases
func pingLeases(leases []subnet.SubnetLease) error { const workers = 5 const timeout = 1 * time.Second if len(leases) == 0 { return nil } work := make(chan subnet.SubnetLease) results := make(chan bool, workers) client := http.Client{Timeout: timeout} var wg sync.WaitGroup wg.Add(workers) for i := 0; i <...
go
func pingLeases(leases []subnet.SubnetLease) error { const workers = 5 const timeout = 1 * time.Second if len(leases) == 0 { return nil } work := make(chan subnet.SubnetLease) results := make(chan bool, workers) client := http.Client{Timeout: timeout} var wg sync.WaitGroup wg.Add(workers) for i := 0; i <...
[ "func", "pingLeases", "(", "leases", "[", "]", "subnet", ".", "SubnetLease", ")", "error", "{", "const", "workers", "=", "5", "\n", "const", "timeout", "=", "1", "*", "time", ".", "Second", "\n\n", "if", "len", "(", "leases", ")", "==", "0", "{", "...
// ping neighbor leases five at a time, timeout 1 second, returning as soon as // one returns success.
[ "ping", "neighbor", "leases", "five", "at", "a", "time", "timeout", "1", "second", "returning", "as", "soon", "as", "one", "returns", "success", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/flannel/main.go#L235-L286
train
flynn/flynn
controller/schema.go
migrateProcessData
func migrateProcessData(tx *postgres.DBTx) error { type Release struct { ID string // use map[string]interface{} for process types so we can just // update Volumes and Data and leave other fields untouched Processes map[string]map[string]interface{} } var releases []Release rows, err := tx.Query("SELECT r...
go
func migrateProcessData(tx *postgres.DBTx) error { type Release struct { ID string // use map[string]interface{} for process types so we can just // update Volumes and Data and leave other fields untouched Processes map[string]map[string]interface{} } var releases []Release rows, err := tx.Query("SELECT r...
[ "func", "migrateProcessData", "(", "tx", "*", "postgres", ".", "DBTx", ")", "error", "{", "type", "Release", "struct", "{", "ID", "string", "\n\n", "// use map[string]interface{} for process types so we can just", "// update Volumes and Data and leave other fields untouched", ...
// migrateProcessData populates ProcessType.Volumes if ProcessType.Data is set
[ "migrateProcessData", "populates", "ProcessType", ".", "Volumes", "if", "ProcessType", ".", "Data", "is", "set" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/schema.go#L636-L687
train
flynn/flynn
router/proxy/transport.go
Finalize
func (r *RequestTrace) Finalize(backend *router.Backend) { r.mtx.Lock() r.final = true r.Backend = backend r.mtx.Unlock() }
go
func (r *RequestTrace) Finalize(backend *router.Backend) { r.mtx.Lock() r.final = true r.Backend = backend r.mtx.Unlock() }
[ "func", "(", "r", "*", "RequestTrace", ")", "Finalize", "(", "backend", "*", "router", ".", "Backend", ")", "{", "r", ".", "mtx", ".", "Lock", "(", ")", "\n", "r", ".", "final", "=", "true", "\n", "r", ".", "Backend", "=", "backend", "\n", "r", ...
// Finalize safely finalizes the trace for read access.
[ "Finalize", "safely", "finalizes", "the", "trace", "for", "read", "access", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/proxy/transport.go#L272-L277
train
flynn/flynn
router/proxy/transport.go
traceRequest
func traceRequest(req *http.Request) (*http.Request, *RequestTrace) { trace := &RequestTrace{} ct := &httptrace.ClientTrace{ GetConn: func(hostPort string) { trace.mtx.Lock() defer trace.mtx.Unlock() if trace.final { return } trace.ConnectStart = time.Now() }, GotConn: func(info httptrace.Got...
go
func traceRequest(req *http.Request) (*http.Request, *RequestTrace) { trace := &RequestTrace{} ct := &httptrace.ClientTrace{ GetConn: func(hostPort string) { trace.mtx.Lock() defer trace.mtx.Unlock() if trace.final { return } trace.ConnectStart = time.Now() }, GotConn: func(info httptrace.Got...
[ "func", "traceRequest", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Request", ",", "*", "RequestTrace", ")", "{", "trace", ":=", "&", "RequestTrace", "{", "}", "\n", "ct", ":=", "&", "httptrace", ".", "ClientTrace", "{", "Ge...
// traceRequest sets up request tracing and returns the modified // request.
[ "traceRequest", "sets", "up", "request", "tracing", "and", "returns", "the", "modified", "request", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/proxy/transport.go#L281-L329
train
flynn/flynn
controller/worker/deployment/context.go
execWithRetries
func (c *context) execWithRetries(query string, args ...interface{}) error { return execAttempts.Run(func() error { return c.db.Exec(query, args...) }) }
go
func (c *context) execWithRetries(query string, args ...interface{}) error { return execAttempts.Run(func() error { return c.db.Exec(query, args...) }) }
[ "func", "(", "c", "*", "context", ")", "execWithRetries", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "execAttempts", ".", "Run", "(", "func", "(", ")", "error", "{", "return", "c", ".", "db", ".", ...
// Retry db queries in case postgres has been deployed
[ "Retry", "db", "queries", "in", "case", "postgres", "has", "been", "deployed" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/worker/deployment/context.go#L180-L184
train
flynn/flynn
pkg/mauth/compare/compare.go
UnmarshalBinary
func UnmarshalBinary(b []byte) (interface{}, error) { if len(b) < 1 { return nil, fmt.Errorf("compare: buffer to unmarshal is zero-length") } switch Type(b[0]) { case TypeFalse, TypeTrue: v := new(Bool) return *v, v.UnmarshalBinary(b) case TypeIntegers: v := new(Integers) return *v, v.UnmarshalBinary(b) ...
go
func UnmarshalBinary(b []byte) (interface{}, error) { if len(b) < 1 { return nil, fmt.Errorf("compare: buffer to unmarshal is zero-length") } switch Type(b[0]) { case TypeFalse, TypeTrue: v := new(Bool) return *v, v.UnmarshalBinary(b) case TypeIntegers: v := new(Integers) return *v, v.UnmarshalBinary(b) ...
[ "func", "UnmarshalBinary", "(", "b", "[", "]", "byte", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "len", "(", "b", ")", "<", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "swi...
// comparisons are encoded as a single type byte followed by zero or more bytes // that are specific to the comparison type. // // UINT8 - type // UINT8 0..n - bytes
[ "comparisons", "are", "encoded", "as", "a", "single", "type", "byte", "followed", "by", "zero", "or", "more", "bytes", "that", "are", "specific", "to", "the", "comparison", "type", ".", "UINT8", "-", "type", "UINT8", "0", "..", "n", "-", "bytes" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mauth/compare/compare.go#L29-L52
train