id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
27,500 | 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 |
27,501 | 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 |
27,502 | 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 |
27,503 | 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 |
27,504 | 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 |
27,505 | 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 |
27,506 | 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 |
27,507 | 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 |
27,508 | 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 |
27,509 | 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 |
27,510 | 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 |
27,511 | 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 |
27,512 | 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 |
27,513 | 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 |
27,514 | 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 |
27,515 | 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 |
27,516 | 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 |
27,517 | 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 |
27,518 | 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 |
27,519 | 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 |
27,520 | 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 |
27,521 | 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 |
27,522 | 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 |
27,523 | 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 |
27,524 | 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 |
27,525 | 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 |
27,526 | 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 |
27,527 | 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 |
27,528 | 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 |
27,529 | 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 |
27,530 | 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 |
27,531 | 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 |
27,532 | 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 |
27,533 | 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 |
27,534 | 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 |
27,535 | 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 |
27,536 | 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 |
27,537 | 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 |
27,538 | 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 |
27,539 | 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 |
27,540 | 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 |
27,541 | 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 |
27,542 | 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 |
27,543 | 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 |
27,544 | 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 |
27,545 | 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 |
27,546 | 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 |
27,547 | 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 |
27,548 | 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 |
27,549 | 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 |
27,550 | 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 |
27,551 | 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 |
27,552 | 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 |
27,553 | 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 |
27,554 | 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 |
27,555 | 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 |
27,556 | 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 |
27,557 | 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 |
27,558 | 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 |
27,559 | 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 |
27,560 | 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 |
27,561 | 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 |
27,562 | 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 |
27,563 | 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 |
27,564 | 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 |
27,565 | 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 |
27,566 | 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 |
27,567 | 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 |
27,568 | 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 |
27,569 | 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 |
27,570 | 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 |
27,571 | 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 |
27,572 | 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 |
27,573 | 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 |
27,574 | 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 |
27,575 | 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 |
27,576 | flynn/flynn | pkg/syslog/rfc6587/rfc6587.go | Bytes | func Bytes(m *rfc5424.Message) []byte {
msg := m.Bytes()
return bytes.Join([][]byte{[]byte(strconv.Itoa(len(msg))), msg}, []byte{' '})
} | go | func Bytes(m *rfc5424.Message) []byte {
msg := m.Bytes()
return bytes.Join([][]byte{[]byte(strconv.Itoa(len(msg))), msg}, []byte{' '})
} | [
"func",
"Bytes",
"(",
"m",
"*",
"rfc5424",
".",
"Message",
")",
"[",
"]",
"byte",
"{",
"msg",
":=",
"m",
".",
"Bytes",
"(",
")",
"\n",
"return",
"bytes",
".",
"Join",
"(",
"[",
"]",
"[",
"]",
"byte",
"{",
"[",
"]",
"byte",
"(",
"strconv",
"."... | // Bytes returns the RFC6587-framed bytes of an RFC5424 syslog Message,
// including length prefix. | [
"Bytes",
"returns",
"the",
"RFC6587",
"-",
"framed",
"bytes",
"of",
"an",
"RFC5424",
"syslog",
"Message",
"including",
"length",
"prefix",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/syslog/rfc6587/rfc6587.go#L14-L17 |
27,577 | flynn/flynn | pkg/syslog/rfc6587/rfc6587.go | Split | func Split(data []byte, atEOF bool) (advance int, token []byte, err error) {
return split(false, data, atEOF)
} | go | func Split(data []byte, atEOF bool) (advance int, token []byte, err error) {
return split(false, data, atEOF)
} | [
"func",
"Split",
"(",
"data",
"[",
"]",
"byte",
",",
"atEOF",
"bool",
")",
"(",
"advance",
"int",
",",
"token",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"split",
"(",
"false",
",",
"data",
",",
"atEOF",
")",
"\n",
"}"
] | // Split is a bufio.SplitFunc that splits on RFC6587-framed syslog messages. | [
"Split",
"is",
"a",
"bufio",
".",
"SplitFunc",
"that",
"splits",
"on",
"RFC6587",
"-",
"framed",
"syslog",
"messages",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/syslog/rfc6587/rfc6587.go#L24-L26 |
27,578 | flynn/flynn | pkg/syslog/rfc6587/rfc6587.go | SplitWithNewlines | func SplitWithNewlines(data []byte, atEOF bool) (advance int, token []byte, err error) {
return split(true, data, atEOF)
} | go | func SplitWithNewlines(data []byte, atEOF bool) (advance int, token []byte, err error) {
return split(true, data, atEOF)
} | [
"func",
"SplitWithNewlines",
"(",
"data",
"[",
"]",
"byte",
",",
"atEOF",
"bool",
")",
"(",
"advance",
"int",
",",
"token",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"split",
"(",
"true",
",",
"data",
",",
"atEOF",
")",
"\n",
"}"
] | // SplitWithNewlines is a bufio.SplitFunc that splits on RFC6587-framed syslog
// messages that are each followed by a newline. | [
"SplitWithNewlines",
"is",
"a",
"bufio",
".",
"SplitFunc",
"that",
"splits",
"on",
"RFC6587",
"-",
"framed",
"syslog",
"messages",
"that",
"are",
"each",
"followed",
"by",
"a",
"newline",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/syslog/rfc6587/rfc6587.go#L30-L32 |
27,579 | flynn/flynn | pkg/connutil/close_notify.go | CloseNotifyConn | func CloseNotifyConn(conn net.Conn) net.Conn {
pr, pw := io.Pipe()
c := &closeNotifyConn{
Conn: conn,
r: pr,
cnc: make(chan bool),
}
go func() {
_, err := io.Copy(pw, conn)
if err == nil {
err = io.EOF
}
pw.CloseWithError(err)
close(c.cnc)
}()
return c
} | go | func CloseNotifyConn(conn net.Conn) net.Conn {
pr, pw := io.Pipe()
c := &closeNotifyConn{
Conn: conn,
r: pr,
cnc: make(chan bool),
}
go func() {
_, err := io.Copy(pw, conn)
if err == nil {
err = io.EOF
}
pw.CloseWithError(err)
close(c.cnc)
}()
return c
} | [
"func",
"CloseNotifyConn",
"(",
"conn",
"net",
".",
"Conn",
")",
"net",
".",
"Conn",
"{",
"pr",
",",
"pw",
":=",
"io",
".",
"Pipe",
"(",
")",
"\n\n",
"c",
":=",
"&",
"closeNotifyConn",
"{",
"Conn",
":",
"conn",
",",
"r",
":",
"pr",
",",
"cnc",
... | // CloseNotifyConn returns a net.Conn that implements http.CloseNotifier.
// Used to detect connections closed early on the client side. | [
"CloseNotifyConn",
"returns",
"a",
"net",
".",
"Conn",
"that",
"implements",
"http",
".",
"CloseNotifier",
".",
"Used",
"to",
"detect",
"connections",
"closed",
"early",
"on",
"the",
"client",
"side",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/connutil/close_notify.go#L21-L40 |
27,580 | flynn/flynn | pkg/sse/sse.go | Decode | func (dec *Decoder) Decode(v interface{}) error {
data, err := dec.Reader.Read()
if err != nil {
return err
}
return json.Unmarshal(data, v)
} | go | func (dec *Decoder) Decode(v interface{}) error {
data, err := dec.Reader.Read()
if err != nil {
return err
}
return json.Unmarshal(data, v)
} | [
"func",
"(",
"dec",
"*",
"Decoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"data",
",",
"err",
":=",
"dec",
".",
"Reader",
".",
"Read",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",... | // Decode finds the next "data" field and decodes it into v | [
"Decode",
"finds",
"the",
"next",
"data",
"field",
"and",
"decodes",
"it",
"into",
"v"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sse/sse.go#L103-L109 |
27,581 | flynn/flynn | flannel/discoverd/registry.go | WatchSubnets | func (r *registry) WatchSubnets(since uint64, stop chan bool) (*subnet.Response, error) {
for {
select {
case event, ok := <-r.events:
if !ok {
return nil, errors.New("unexpected close of discoverd event stream")
}
if event.Kind != discoverd.EventKindServiceMeta {
continue
}
net := &Network{... | go | func (r *registry) WatchSubnets(since uint64, stop chan bool) (*subnet.Response, error) {
for {
select {
case event, ok := <-r.events:
if !ok {
return nil, errors.New("unexpected close of discoverd event stream")
}
if event.Kind != discoverd.EventKindServiceMeta {
continue
}
net := &Network{... | [
"func",
"(",
"r",
"*",
"registry",
")",
"WatchSubnets",
"(",
"since",
"uint64",
",",
"stop",
"chan",
"bool",
")",
"(",
"*",
"subnet",
".",
"Response",
",",
"error",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"event",
",",
"ok",
":=",
"<-",
"r",
... | // WatchSubnets waits for a service metadata event with an index greater than
// a given value, and then returns a response. | [
"WatchSubnets",
"waits",
"for",
"a",
"service",
"metadata",
"event",
"with",
"an",
"index",
"greater",
"than",
"a",
"given",
"value",
"and",
"then",
"returns",
"a",
"response",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/flannel/discoverd/registry.go#L99-L128 |
27,582 | flynn/flynn | builder/build.go | newLogger | func newLogger(tty bool, file string, verbose bool) log15.Logger {
stdoutFormat := log15.LogfmtFormat()
if tty {
stdoutFormat = log15.TerminalFormat()
}
stdoutHandler := log15.StreamHandler(os.Stdout, stdoutFormat)
if !verbose {
stdoutHandler = log15.LvlFilterHandler(log15.LvlInfo, stdoutHandler)
}
log := lo... | go | func newLogger(tty bool, file string, verbose bool) log15.Logger {
stdoutFormat := log15.LogfmtFormat()
if tty {
stdoutFormat = log15.TerminalFormat()
}
stdoutHandler := log15.StreamHandler(os.Stdout, stdoutFormat)
if !verbose {
stdoutHandler = log15.LvlFilterHandler(log15.LvlInfo, stdoutHandler)
}
log := lo... | [
"func",
"newLogger",
"(",
"tty",
"bool",
",",
"file",
"string",
",",
"verbose",
"bool",
")",
"log15",
".",
"Logger",
"{",
"stdoutFormat",
":=",
"log15",
".",
"LogfmtFormat",
"(",
")",
"\n",
"if",
"tty",
"{",
"stdoutFormat",
"=",
"log15",
".",
"TerminalFo... | // newLogger returns a log15.Logger which writes to stdout and a log file | [
"newLogger",
"returns",
"a",
"log15",
".",
"Logger",
"which",
"writes",
"to",
"stdout",
"and",
"a",
"log",
"file"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/builder/build.go#L296-L311 |
27,583 | flynn/flynn | builder/build.go | NewProgressBar | func NewProgressBar(count int, tty bool) (*pb.ProgressBar, error) {
bar := pb.New(count)
if !tty {
bar.Output = os.Stderr
return bar, nil
}
// replace os.Stdout / os.Stderr with a pipe and copy output to a
// channel so that the progress bar can be wiped before printing output
type stdOutput struct {
Out ... | go | func NewProgressBar(count int, tty bool) (*pb.ProgressBar, error) {
bar := pb.New(count)
if !tty {
bar.Output = os.Stderr
return bar, nil
}
// replace os.Stdout / os.Stderr with a pipe and copy output to a
// channel so that the progress bar can be wiped before printing output
type stdOutput struct {
Out ... | [
"func",
"NewProgressBar",
"(",
"count",
"int",
",",
"tty",
"bool",
")",
"(",
"*",
"pb",
".",
"ProgressBar",
",",
"error",
")",
"{",
"bar",
":=",
"pb",
".",
"New",
"(",
"count",
")",
"\n\n",
"if",
"!",
"tty",
"{",
"bar",
".",
"Output",
"=",
"os",
... | // NewProgressBar creates a progress bar which is pinned to the bottom of the
// terminal screen | [
"NewProgressBar",
"creates",
"a",
"progress",
"bar",
"which",
"is",
"pinned",
"to",
"the",
"bottom",
"of",
"the",
"terminal",
"screen"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/builder/build.go#L1021-L1092 |
27,584 | flynn/flynn | pkg/tufutil/tufutil.go | GetVersion | func GetVersion(client *tuf.Client, name string) (string, error) {
targets, err := client.Targets()
if err != nil {
return "", err
}
target, ok := targets[name]
if !ok {
return "", fmt.Errorf("missing %q in tuf targets", name)
}
if target.Custom == nil || len(*target.Custom) == 0 {
return "", errors.New("m... | go | func GetVersion(client *tuf.Client, name string) (string, error) {
targets, err := client.Targets()
if err != nil {
return "", err
}
target, ok := targets[name]
if !ok {
return "", fmt.Errorf("missing %q in tuf targets", name)
}
if target.Custom == nil || len(*target.Custom) == 0 {
return "", errors.New("m... | [
"func",
"GetVersion",
"(",
"client",
"*",
"tuf",
".",
"Client",
",",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"targets",
",",
"err",
":=",
"client",
".",
"Targets",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",... | // GetVersion returns the given target's version from custom metadata | [
"GetVersion",
"returns",
"the",
"given",
"target",
"s",
"version",
"from",
"custom",
"metadata"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/tufutil/tufutil.go#L69-L89 |
27,585 | flynn/flynn | pkg/httphelper/httphelper.go | IsRetryableError | func IsRetryableError(err error) bool {
e, ok := err.(JSONError)
return ok && e.Retry
} | go | func IsRetryableError(err error) bool {
e, ok := err.(JSONError)
return ok && e.Retry
} | [
"func",
"IsRetryableError",
"(",
"err",
"error",
")",
"bool",
"{",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"JSONError",
")",
"\n",
"return",
"ok",
"&&",
"e",
".",
"Retry",
"\n",
"}"
] | // IsRetryableError indicates whether a HTTP request can be safely retried. | [
"IsRetryableError",
"indicates",
"whether",
"a",
"HTTP",
"request",
"can",
"be",
"safely",
"retried",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/httphelper/httphelper.go#L89-L92 |
27,586 | flynn/flynn | pkg/sirenia/state/state.go | evalLater | func (p *Peer) evalLater(delay time.Duration) {
if p.retryCh != nil {
p.retryCh <- struct{}{}
return
}
time.AfterFunc(delay, p.triggerEval)
} | go | func (p *Peer) evalLater(delay time.Duration) {
if p.retryCh != nil {
p.retryCh <- struct{}{}
return
}
time.AfterFunc(delay, p.triggerEval)
} | [
"func",
"(",
"p",
"*",
"Peer",
")",
"evalLater",
"(",
"delay",
"time",
".",
"Duration",
")",
"{",
"if",
"p",
".",
"retryCh",
"!=",
"nil",
"{",
"p",
".",
"retryCh",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"time",
"."... | // evalLater triggers a cluster state evaluation after delay has elapsed | [
"evalLater",
"triggers",
"a",
"cluster",
"state",
"evaluation",
"after",
"delay",
"has",
"elapsed"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/state/state.go#L440-L446 |
27,587 | flynn/flynn | pkg/sirenia/state/state.go | startTransitionToNormalMode | func (p *Peer) startTransitionToNormalMode() {
log := p.log.New("fn", "startTransitionToNormalMode")
if p.Info().State.Primary.Meta[p.idKey] != p.id || p.Info().Role != RolePrimary {
panic("startTransitionToNormalMode called when not primary")
}
// In the normal takeover case, we'd pick an async. In this case, w... | go | func (p *Peer) startTransitionToNormalMode() {
log := p.log.New("fn", "startTransitionToNormalMode")
if p.Info().State.Primary.Meta[p.idKey] != p.id || p.Info().Role != RolePrimary {
panic("startTransitionToNormalMode called when not primary")
}
// In the normal takeover case, we'd pick an async. In this case, w... | [
"func",
"(",
"p",
"*",
"Peer",
")",
"startTransitionToNormalMode",
"(",
")",
"{",
"log",
":=",
"p",
".",
"log",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"p",
".",
"Info",
"(",
")",
".",
"State",
".",
"Primary",
".",
"Meta"... | // As the primary, converts the current cluster to normal mode from singleton
// mode. | [
"As",
"the",
"primary",
"converts",
"the",
"current",
"cluster",
"to",
"normal",
"mode",
"from",
"singleton",
"mode",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/state/state.go#L946-L976 |
27,588 | flynn/flynn | pkg/sirenia/state/state.go | applyConfig | func (p *Peer) applyConfig() (err error) {
p.moving()
log := p.log.New("fn", "applyConfig")
if p.online == nil {
panic("applyConfig with database in unknown state")
}
config := p.Config()
if p.applied != nil && p.applied.Equal(config) && p.applied.State.Equal(config.State) {
log.Info("skipping config apply,... | go | func (p *Peer) applyConfig() (err error) {
p.moving()
log := p.log.New("fn", "applyConfig")
if p.online == nil {
panic("applyConfig with database in unknown state")
}
config := p.Config()
if p.applied != nil && p.applied.Equal(config) && p.applied.State.Equal(config.State) {
log.Info("skipping config apply,... | [
"func",
"(",
"p",
"*",
"Peer",
")",
"applyConfig",
"(",
")",
"(",
"err",
"error",
")",
"{",
"p",
".",
"moving",
"(",
")",
"\n",
"log",
":=",
"p",
".",
"log",
".",
"New",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"p",
".",
"online... | // Reconfigure database based on the current configuration. During
// reconfiguration, new requests to reconfigure will be ignored, and incoming
// cluster state changes will be recorded but otherwise ignored. When
// reconfiguration completes, if the desired configuration has changed, we'll
// take another lap to appl... | [
"Reconfigure",
"database",
"based",
"on",
"the",
"current",
"configuration",
".",
"During",
"reconfiguration",
"new",
"requests",
"to",
"reconfigure",
"will",
"be",
"ignored",
"and",
"incoming",
"cluster",
"state",
"changes",
"will",
"be",
"recorded",
"but",
"othe... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/state/state.go#L1009-L1075 |
27,589 | flynn/flynn | pkg/sirenia/state/state.go | whichAsync | func (p *Peer) whichAsync() int {
for i, a := range p.Info().State.Async {
if p.id == a.Meta[p.idKey] {
return i
}
}
return -1
} | go | func (p *Peer) whichAsync() int {
for i, a := range p.Info().State.Async {
if p.id == a.Meta[p.idKey] {
return i
}
}
return -1
} | [
"func",
"(",
"p",
"*",
"Peer",
")",
"whichAsync",
"(",
")",
"int",
"{",
"for",
"i",
",",
"a",
":=",
"range",
"p",
".",
"Info",
"(",
")",
".",
"State",
".",
"Async",
"{",
"if",
"p",
".",
"id",
"==",
"a",
".",
"Meta",
"[",
"p",
".",
"idKey",
... | // Determine our index in the async peer list. -1 means not present. | [
"Determine",
"our",
"index",
"in",
"the",
"async",
"peer",
"list",
".",
"-",
"1",
"means",
"not",
"present",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/state/state.go#L1090-L1097 |
27,590 | flynn/flynn | pkg/sirenia/state/state.go | lookupUpstream | func (p *Peer) lookupUpstream(whichAsync int) *discoverd.Instance {
if whichAsync == 0 {
return p.Info().State.Sync
}
return p.Info().State.Async[whichAsync-1]
} | go | func (p *Peer) lookupUpstream(whichAsync int) *discoverd.Instance {
if whichAsync == 0 {
return p.Info().State.Sync
}
return p.Info().State.Async[whichAsync-1]
} | [
"func",
"(",
"p",
"*",
"Peer",
")",
"lookupUpstream",
"(",
"whichAsync",
"int",
")",
"*",
"discoverd",
".",
"Instance",
"{",
"if",
"whichAsync",
"==",
"0",
"{",
"return",
"p",
".",
"Info",
"(",
")",
".",
"State",
".",
"Sync",
"\n",
"}",
"\n",
"retu... | // Return the upstream peer for a given one of the async peers | [
"Return",
"the",
"upstream",
"peer",
"for",
"a",
"given",
"one",
"of",
"the",
"async",
"peers"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/state/state.go#L1100-L1105 |
27,591 | flynn/flynn | pkg/sirenia/state/state.go | lookupDownstream | func (p *Peer) lookupDownstream(whichAsync int) *discoverd.Instance {
async := p.Info().State.Async
if whichAsync == len(async)-1 {
return nil
}
return async[whichAsync+1]
} | go | func (p *Peer) lookupDownstream(whichAsync int) *discoverd.Instance {
async := p.Info().State.Async
if whichAsync == len(async)-1 {
return nil
}
return async[whichAsync+1]
} | [
"func",
"(",
"p",
"*",
"Peer",
")",
"lookupDownstream",
"(",
"whichAsync",
"int",
")",
"*",
"discoverd",
".",
"Instance",
"{",
"async",
":=",
"p",
".",
"Info",
"(",
")",
".",
"State",
".",
"Async",
"\n",
"if",
"whichAsync",
"==",
"len",
"(",
"async",... | // Return the downstream peer for a given one of the async peers | [
"Return",
"the",
"downstream",
"peer",
"for",
"a",
"given",
"one",
"of",
"the",
"async",
"peers"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/state/state.go#L1108-L1114 |
27,592 | flynn/flynn | pkg/sirenia/state/state.go | peerIsPresent | func (p *Peer) peerIsPresent(other *discoverd.Instance) bool {
// We should never even be asking whether we're present. If we need to do
// this at some point in the future, we need to consider we should always
// consider ourselves present or whether we should check the list.
if other.Meta[p.idKey] == p.id {
pan... | go | func (p *Peer) peerIsPresent(other *discoverd.Instance) bool {
// We should never even be asking whether we're present. If we need to do
// this at some point in the future, we need to consider we should always
// consider ourselves present or whether we should check the list.
if other.Meta[p.idKey] == p.id {
pan... | [
"func",
"(",
"p",
"*",
"Peer",
")",
"peerIsPresent",
"(",
"other",
"*",
"discoverd",
".",
"Instance",
")",
"bool",
"{",
"// We should never even be asking whether we're present. If we need to do",
"// this at some point in the future, we need to consider we should always",
"// co... | // Returns true if the given other peer appears to be present in the most
// recently received list of present peers. | [
"Returns",
"true",
"if",
"the",
"given",
"other",
"peer",
"appears",
"to",
"be",
"present",
"in",
"the",
"most",
"recently",
"received",
"list",
"of",
"present",
"peers",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/sirenia/state/state.go#L1118-L1132 |
27,593 | flynn/flynn | router/proxy/reverseproxy.go | NewReverseProxy | func NewReverseProxy(bf BackendListFunc, stickyKey *[32]byte, sticky bool, rt RequestTracker, l log15.Logger) *ReverseProxy {
return &ReverseProxy{
transport: &transport{
getBackends: bf,
stickyCookieKey: stickyKey,
useStickySessions: sticky,
},
FlushInterval: 10 * time.Millisecond,
RequestTr... | go | func NewReverseProxy(bf BackendListFunc, stickyKey *[32]byte, sticky bool, rt RequestTracker, l log15.Logger) *ReverseProxy {
return &ReverseProxy{
transport: &transport{
getBackends: bf,
stickyCookieKey: stickyKey,
useStickySessions: sticky,
},
FlushInterval: 10 * time.Millisecond,
RequestTr... | [
"func",
"NewReverseProxy",
"(",
"bf",
"BackendListFunc",
",",
"stickyKey",
"*",
"[",
"32",
"]",
"byte",
",",
"sticky",
"bool",
",",
"rt",
"RequestTracker",
",",
"l",
"log15",
".",
"Logger",
")",
"*",
"ReverseProxy",
"{",
"return",
"&",
"ReverseProxy",
"{",... | // NewReverseProxy initializes a new ReverseProxy with a callback to get
// backends, a stickyKey for encrypting sticky session cookies, and a flag
// sticky to enable sticky sessions. | [
"NewReverseProxy",
"initializes",
"a",
"new",
"ReverseProxy",
"with",
"a",
"callback",
"to",
"get",
"backends",
"a",
"stickyKey",
"for",
"encrypting",
"sticky",
"session",
"cookies",
"and",
"a",
"flag",
"sticky",
"to",
"enable",
"sticky",
"sessions",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/proxy/reverseproxy.go#L71-L82 |
27,594 | flynn/flynn | router/proxy/reverseproxy.go | ServeConn | func (p *ReverseProxy) ServeConn(ctx context.Context, dconn net.Conn) {
transport := p.transport
if transport == nil {
panic("router: nil transport for proxy")
}
defer dconn.Close()
clientGone := dconn.(http.CloseNotifier).CloseNotify()
ctx, cancel := context.WithCancel(ctx)
defer cancel() // finish cancellat... | go | func (p *ReverseProxy) ServeConn(ctx context.Context, dconn net.Conn) {
transport := p.transport
if transport == nil {
panic("router: nil transport for proxy")
}
defer dconn.Close()
clientGone := dconn.(http.CloseNotifier).CloseNotify()
ctx, cancel := context.WithCancel(ctx)
defer cancel() // finish cancellat... | [
"func",
"(",
"p",
"*",
"ReverseProxy",
")",
"ServeConn",
"(",
"ctx",
"context",
".",
"Context",
",",
"dconn",
"net",
".",
"Conn",
")",
"{",
"transport",
":=",
"p",
".",
"transport",
"\n",
"if",
"transport",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",... | // ServeConn takes an inbound conn and proxies it to a backend. | [
"ServeConn",
"takes",
"an",
"inbound",
"conn",
"and",
"proxies",
"it",
"to",
"a",
"backend",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/router/proxy/reverseproxy.go#L162-L190 |
27,595 | flynn/flynn | discoverd/deployment/deployment.go | update | func (d *Deployment) update() error {
select {
case event, ok := <-d.events:
if !ok {
return fmt.Errorf("service stream closed unexpectedly: %s", d.stream.Err())
}
if event.Kind == discoverd.EventKindServiceMeta {
d.meta = event.ServiceMeta
}
default:
}
return nil
} | go | func (d *Deployment) update() error {
select {
case event, ok := <-d.events:
if !ok {
return fmt.Errorf("service stream closed unexpectedly: %s", d.stream.Err())
}
if event.Kind == discoverd.EventKindServiceMeta {
d.meta = event.ServiceMeta
}
default:
}
return nil
} | [
"func",
"(",
"d",
"*",
"Deployment",
")",
"update",
"(",
")",
"error",
"{",
"select",
"{",
"case",
"event",
",",
"ok",
":=",
"<-",
"d",
".",
"events",
":",
"if",
"!",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"d",
".",
... | // update drains any pending events, updating the service metadata, it doesn't block. | [
"update",
"drains",
"any",
"pending",
"events",
"updating",
"the",
"service",
"metadata",
"it",
"doesn",
"t",
"block",
"."
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/deployment/deployment.go#L71-L83 |
27,596 | flynn/flynn | discoverd/deployment/deployment.go | MarkDone | func (d *Deployment) MarkDone(addr string) error {
return attempts.Run(func() error {
if err := d.update(); err != nil {
return err
}
deploymentMeta, err := d.decode(d.meta)
if err != nil {
return err
}
deploymentMeta.States[addr] = DeploymentStateDone
return d.set(d.meta, deploymentMeta)
})
} | go | func (d *Deployment) MarkDone(addr string) error {
return attempts.Run(func() error {
if err := d.update(); err != nil {
return err
}
deploymentMeta, err := d.decode(d.meta)
if err != nil {
return err
}
deploymentMeta.States[addr] = DeploymentStateDone
return d.set(d.meta, deploymentMeta)
})
} | [
"func",
"(",
"d",
"*",
"Deployment",
")",
"MarkDone",
"(",
"addr",
"string",
")",
"error",
"{",
"return",
"attempts",
".",
"Run",
"(",
"func",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"d",
".",
"update",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
... | // MarkDone marks the addr as done in the service metadata | [
"MarkDone",
"marks",
"the",
"addr",
"as",
"done",
"in",
"the",
"service",
"metadata"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/deployment/deployment.go#L169-L184 |
27,597 | flynn/flynn | discoverd/deployment/deployment.go | Wait | func (d *Deployment) Wait(id string, timeout time.Duration, log log15.Logger) error {
timeoutCh := time.After(timeout)
for {
actual := 0
select {
case event, ok := <-d.events:
if !ok {
return fmt.Errorf("service stream closed unexpectedly: %s", d.stream.Err())
}
if event.Kind == discoverd.EventKind... | go | func (d *Deployment) Wait(id string, timeout time.Duration, log log15.Logger) error {
timeoutCh := time.After(timeout)
for {
actual := 0
select {
case event, ok := <-d.events:
if !ok {
return fmt.Errorf("service stream closed unexpectedly: %s", d.stream.Err())
}
if event.Kind == discoverd.EventKind... | [
"func",
"(",
"d",
"*",
"Deployment",
")",
"Wait",
"(",
"id",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"log",
"log15",
".",
"Logger",
")",
"error",
"{",
"timeoutCh",
":=",
"time",
".",
"After",
"(",
"timeout",
")",
"\n",
"for",
"{",
"... | // Wait waits for an expected number of "done" addresses in the service metadata | [
"Wait",
"waits",
"for",
"an",
"expected",
"number",
"of",
"done",
"addresses",
"in",
"the",
"service",
"metadata"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/deployment/deployment.go#L187-L221 |
27,598 | flynn/flynn | discoverd/deployment/deployment.go | Create | func (d *Deployment) Create(id string) error {
return attempts.Run(func() error {
if err := d.set(&discoverd.ServiceMeta{}, NewDeploymentMeta(id)); err == nil {
return nil
}
if err := d.update(); err != nil {
return err
}
return d.set(d.meta, NewDeploymentMeta(id))
})
} | go | func (d *Deployment) Create(id string) error {
return attempts.Run(func() error {
if err := d.set(&discoverd.ServiceMeta{}, NewDeploymentMeta(id)); err == nil {
return nil
}
if err := d.update(); err != nil {
return err
}
return d.set(d.meta, NewDeploymentMeta(id))
})
} | [
"func",
"(",
"d",
"*",
"Deployment",
")",
"Create",
"(",
"id",
"string",
")",
"error",
"{",
"return",
"attempts",
".",
"Run",
"(",
"func",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"d",
".",
"set",
"(",
"&",
"discoverd",
".",
"ServiceMeta",
"{",
... | // Create starts a new deployment with a given ID | [
"Create",
"starts",
"a",
"new",
"deployment",
"with",
"a",
"given",
"ID"
] | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/deployment/deployment.go#L224-L234 |
27,599 | flynn/flynn | pkg/cluster/attach.go | Attach | func (c *Host) Attach(req *host.AttachReq, wait bool) (AttachClient, error) {
rwc, err := c.c.Hijack("POST", "/attach", http.Header{"Upgrade": {"flynn-attach/0"}}, req)
if err != nil {
return nil, err
}
attachState := make([]byte, 1)
if _, err := rwc.Read(attachState); err != nil {
rwc.Close()
return nil, e... | go | func (c *Host) Attach(req *host.AttachReq, wait bool) (AttachClient, error) {
rwc, err := c.c.Hijack("POST", "/attach", http.Header{"Upgrade": {"flynn-attach/0"}}, req)
if err != nil {
return nil, err
}
attachState := make([]byte, 1)
if _, err := rwc.Read(attachState); err != nil {
rwc.Close()
return nil, e... | [
"func",
"(",
"c",
"*",
"Host",
")",
"Attach",
"(",
"req",
"*",
"host",
".",
"AttachReq",
",",
"wait",
"bool",
")",
"(",
"AttachClient",
",",
"error",
")",
"{",
"rwc",
",",
"err",
":=",
"c",
".",
"c",
".",
"Hijack",
"(",
"\"",
"\"",
",",
"\"",
... | // Attach attaches to the job specified in req and returns an attach client. If
// wait is true, the client will wait for the job to start before returning the
// first bytes. If wait is false and the job is not running, ErrWouldWait is
// returned. | [
"Attach",
"attaches",
"to",
"the",
"job",
"specified",
"in",
"req",
"and",
"returns",
"an",
"attach",
"client",
".",
"If",
"wait",
"is",
"true",
"the",
"client",
"will",
"wait",
"for",
"the",
"job",
"to",
"start",
"before",
"returning",
"the",
"first",
"... | b4b05fce92da5fbc53b272362d87b994b88a3869 | https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/cluster/attach.go#L24-L85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.