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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
130,700 | luci/luci-go | vpython/venv/prune.go | prune | func prune(c context.Context, cfg *Config, exempt stringset.Set) error {
pruneThreshold := cfg.PruneThreshold
if pruneThreshold <= 0 {
// Pruning is disabled.
return nil
}
now := clock.Now(c)
minPruneAge := now.Add(-pruneThreshold)
// Run a series of independent scan/prune operations.
logging.Debugf(c, "Pr... | go | func prune(c context.Context, cfg *Config, exempt stringset.Set) error {
pruneThreshold := cfg.PruneThreshold
if pruneThreshold <= 0 {
// Pruning is disabled.
return nil
}
now := clock.Now(c)
minPruneAge := now.Add(-pruneThreshold)
// Run a series of independent scan/prune operations.
logging.Debugf(c, "Pr... | [
"func",
"prune",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Config",
",",
"exempt",
"stringset",
".",
"Set",
")",
"error",
"{",
"pruneThreshold",
":=",
"cfg",
".",
"PruneThreshold",
"\n",
"if",
"pruneThreshold",
"<=",
"0",
"{",
"// Pruning is d... | // prune examines environments in cfg's BaseDir. If any are found that are older
// than the prune threshold in "cfg", they will be safely deleted.
//
// If exempt is not nil, it contains a list of VirtualEnv names that will be
// exempted from pruning. This is used to prevent pruning from modifying
// environments tha... | [
"prune",
"examines",
"environments",
"in",
"cfg",
"s",
"BaseDir",
".",
"If",
"any",
"are",
"found",
"that",
"are",
"older",
"than",
"the",
"prune",
"threshold",
"in",
"cfg",
"they",
"will",
"be",
"safely",
"deleted",
".",
"If",
"exempt",
"is",
"not",
"ni... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/prune.go#L39-L114 |
130,701 | luci/luci-go | milo/buildsource/buildbot/buildstore/blame.go | blame | func blame(c context.Context, b *buildbot.Build) error {
if err := fetchChangesCached(c, b); err != nil {
return err
}
blame := stringset.New(len(b.Sourcestamp.Changes))
b.Blame = make([]string, 0, len(b.Sourcestamp.Changes))
for _, c := range b.Sourcestamp.Changes {
if blame.Add(c.Who) {
b.Blame = append(b... | go | func blame(c context.Context, b *buildbot.Build) error {
if err := fetchChangesCached(c, b); err != nil {
return err
}
blame := stringset.New(len(b.Sourcestamp.Changes))
b.Blame = make([]string, 0, len(b.Sourcestamp.Changes))
for _, c := range b.Sourcestamp.Changes {
if blame.Add(c.Who) {
b.Blame = append(b... | [
"func",
"blame",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"error",
"{",
"if",
"err",
":=",
"fetchChangesCached",
"(",
"c",
",",
"b",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"b... | // blame loads changes from gitiles and computes b.Blame and
// b.SourceStamp.Changes from b.SourceStamp.Repository,
// b.SourceStamp.Revision and builds previous to b.
//
// Memcaches results. | [
"blame",
"loads",
"changes",
"from",
"gitiles",
"and",
"computes",
"b",
".",
"Blame",
"and",
"b",
".",
"SourceStamp",
".",
"Changes",
"from",
"b",
".",
"SourceStamp",
".",
"Repository",
"b",
".",
"SourceStamp",
".",
"Revision",
"and",
"builds",
"previous",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/blame.go#L49-L61 |
130,702 | luci/luci-go | milo/buildsource/buildbot/buildstore/blame.go | fetchChangesCached | func fetchChangesCached(c context.Context, b *buildbot.Build) error {
report := func(err error, msg string) {
logging.WithError(err).Errorf(c, "build %q change memcaching: %s", b.ID(), msg)
}
cache := memcache.NewItem(c, "buildbot_changes/"+b.ID().String())
if err := memcache.Get(c, cache); err == nil {
err :=... | go | func fetchChangesCached(c context.Context, b *buildbot.Build) error {
report := func(err error, msg string) {
logging.WithError(err).Errorf(c, "build %q change memcaching: %s", b.ID(), msg)
}
cache := memcache.NewItem(c, "buildbot_changes/"+b.ID().String())
if err := memcache.Get(c, cache); err == nil {
err :=... | [
"func",
"fetchChangesCached",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"error",
"{",
"report",
":=",
"func",
"(",
"err",
"error",
",",
"msg",
"string",
")",
"{",
"logging",
".",
"WithError",
"(",
"err",
")",
... | // fetchChangesCached is same as fetchChanges, but with memcaching. | [
"fetchChangesCached",
"is",
"same",
"as",
"fetchChanges",
"but",
"with",
"memcaching",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/blame.go#L64-L98 |
130,703 | luci/luci-go | milo/buildsource/buildbot/buildstore/blame.go | fetchChanges | func fetchChanges(c context.Context, b *buildbot.Build) error {
memcache.Set(c, buildRevCache(c, b))
// initialize the slice so that when serialized to JSON, it is [], not null.
b.Sourcestamp.Changes = []buildbot.Change{}
host, project, err := gitiles.ParseRepoURL(b.Sourcestamp.Repository)
if err != nil {
logg... | go | func fetchChanges(c context.Context, b *buildbot.Build) error {
memcache.Set(c, buildRevCache(c, b))
// initialize the slice so that when serialized to JSON, it is [], not null.
b.Sourcestamp.Changes = []buildbot.Change{}
host, project, err := gitiles.ParseRepoURL(b.Sourcestamp.Repository)
if err != nil {
logg... | [
"func",
"fetchChanges",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"error",
"{",
"memcache",
".",
"Set",
"(",
"c",
",",
"buildRevCache",
"(",
"c",
",",
"b",
")",
")",
"\n\n",
"// initialize the slice so that when ser... | // fetchChanges populates b.SourceStamp.Changes from Gitiles.
//
// Uses memcache to read the revision of the previous build.
// If not available, loads the previous build that has a commit hash revision. | [
"fetchChanges",
"populates",
"b",
".",
"SourceStamp",
".",
"Changes",
"from",
"Gitiles",
".",
"Uses",
"memcache",
"to",
"read",
"the",
"revision",
"of",
"the",
"previous",
"build",
".",
"If",
"not",
"available",
"loads",
"the",
"previous",
"build",
"that",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/blame.go#L104-L165 |
130,704 | luci/luci-go | milo/buildsource/buildbot/buildstore/blame.go | changeFromGitiles | func changeFromGitiles(repoURL, branch string, commit *gitpb.Commit) buildbot.Change {
ct, _ := ptypes.Timestamp(commit.Committer.Time)
return buildbot.Change{
At: ct.Format("Mon _2 Jan 2006 15:04:05"),
Branch: &branch,
Comments: commit.Message,
Repository: repoURL,
Rev: commit.Id,
Re... | go | func changeFromGitiles(repoURL, branch string, commit *gitpb.Commit) buildbot.Change {
ct, _ := ptypes.Timestamp(commit.Committer.Time)
return buildbot.Change{
At: ct.Format("Mon _2 Jan 2006 15:04:05"),
Branch: &branch,
Comments: commit.Message,
Repository: repoURL,
Rev: commit.Id,
Re... | [
"func",
"changeFromGitiles",
"(",
"repoURL",
",",
"branch",
"string",
",",
"commit",
"*",
"gitpb",
".",
"Commit",
")",
"buildbot",
".",
"Change",
"{",
"ct",
",",
"_",
":=",
"ptypes",
".",
"Timestamp",
"(",
"commit",
".",
"Committer",
".",
"Time",
")",
... | // changeFromGitiles converts a gitiles.Commit to a buildbot change. | [
"changeFromGitiles",
"converts",
"a",
"gitiles",
".",
"Commit",
"to",
"a",
"buildbot",
"change",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/blame.go#L168-L182 |
130,705 | luci/luci-go | milo/buildsource/buildbot/buildstore/blame.go | getPrevRev | func getPrevRev(c context.Context, b *buildbot.Build, maxRecursionDepth int) (string, error) {
// note: we cannot use exponential scan here because there may be build
// number gaps anywhere, for example given build numbers 10 20 30 40,
// if we check 25 while scanning [20, 40), we don't know if we should continue
... | go | func getPrevRev(c context.Context, b *buildbot.Build, maxRecursionDepth int) (string, error) {
// note: we cannot use exponential scan here because there may be build
// number gaps anywhere, for example given build numbers 10 20 30 40,
// if we check 25 while scanning [20, 40), we don't know if we should continue
... | [
"func",
"getPrevRev",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
",",
"maxRecursionDepth",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"// note: we cannot use exponential scan here because there may be build",
"// number gaps ... | // getPrevRev returns revision of the closest previous build with a commit
// hash, or "" if not found.
// Memcaches results. | [
"getPrevRev",
"returns",
"revision",
"of",
"the",
"closest",
"previous",
"build",
"with",
"a",
"commit",
"hash",
"or",
"if",
"not",
"found",
".",
"Memcaches",
"results",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/blame.go#L187-L241 |
130,706 | luci/luci-go | milo/buildsource/buildbot/buildstore/blame.go | buildRevCache | func buildRevCache(c context.Context, b *buildbot.Build) memcache.Item {
item := memcache.NewItem(c, "buildbot_revision/"+b.ID().String())
if b.Sourcestamp != nil {
item.SetValue([]byte(b.Sourcestamp.Revision))
}
return item
} | go | func buildRevCache(c context.Context, b *buildbot.Build) memcache.Item {
item := memcache.NewItem(c, "buildbot_revision/"+b.ID().String())
if b.Sourcestamp != nil {
item.SetValue([]byte(b.Sourcestamp.Revision))
}
return item
} | [
"func",
"buildRevCache",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"memcache",
".",
"Item",
"{",
"item",
":=",
"memcache",
".",
"NewItem",
"(",
"c",
",",
"\"",
"\"",
"+",
"b",
".",
"ID",
"(",
")",
".",
"St... | // buildRevCache returns a memcache.Item for the build's revision.
// Initializes the value with current revision. | [
"buildRevCache",
"returns",
"a",
"memcache",
".",
"Item",
"for",
"the",
"build",
"s",
"revision",
".",
"Initializes",
"the",
"value",
"with",
"current",
"revision",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/blame.go#L245-L251 |
130,707 | luci/luci-go | common/tsmon/field/serialize.go | SerializeDescriptor | func SerializeDescriptor(fields []Field) []*pb.MetricsDataSet_MetricFieldDescriptor {
ret := make([]*pb.MetricsDataSet_MetricFieldDescriptor, len(fields))
for i, f := range fields {
d := &pb.MetricsDataSet_MetricFieldDescriptor{
Name: proto.String(f.Name),
}
switch f.Type {
case StringType:
d.FieldTyp... | go | func SerializeDescriptor(fields []Field) []*pb.MetricsDataSet_MetricFieldDescriptor {
ret := make([]*pb.MetricsDataSet_MetricFieldDescriptor, len(fields))
for i, f := range fields {
d := &pb.MetricsDataSet_MetricFieldDescriptor{
Name: proto.String(f.Name),
}
switch f.Type {
case StringType:
d.FieldTyp... | [
"func",
"SerializeDescriptor",
"(",
"fields",
"[",
"]",
"Field",
")",
"[",
"]",
"*",
"pb",
".",
"MetricsDataSet_MetricFieldDescriptor",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"*",
"pb",
".",
"MetricsDataSet_MetricFieldDescriptor",
",",
"len",
"(",
"fields",
... | // SerializeDescriptor returns a slice of field descriptors, representing just
// the names and types of fields. | [
"SerializeDescriptor",
"returns",
"a",
"slice",
"of",
"field",
"descriptors",
"representing",
"just",
"the",
"names",
"and",
"types",
"of",
"fields",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/field/serialize.go#L25-L46 |
130,708 | luci/luci-go | common/tsmon/field/serialize.go | Serialize | func Serialize(fields []Field, values []interface{}) []*pb.MetricsData_MetricField {
ret := make([]*pb.MetricsData_MetricField, len(fields))
for i, f := range fields {
d := &pb.MetricsData_MetricField{
Name: proto.String(f.Name),
}
switch f.Type {
case StringType:
d.Value = &pb.MetricsData_MetricField... | go | func Serialize(fields []Field, values []interface{}) []*pb.MetricsData_MetricField {
ret := make([]*pb.MetricsData_MetricField, len(fields))
for i, f := range fields {
d := &pb.MetricsData_MetricField{
Name: proto.String(f.Name),
}
switch f.Type {
case StringType:
d.Value = &pb.MetricsData_MetricField... | [
"func",
"Serialize",
"(",
"fields",
"[",
"]",
"Field",
",",
"values",
"[",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"*",
"pb",
".",
"MetricsData_MetricField",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"*",
"pb",
".",
"MetricsData_MetricField",
",",
... | // Serialize returns a slice of ts_mon_proto.MetricsData.MetricsField messages
// representing the field names and values. | [
"Serialize",
"returns",
"a",
"slice",
"of",
"ts_mon_proto",
".",
"MetricsData",
".",
"MetricsField",
"messages",
"representing",
"the",
"field",
"names",
"and",
"values",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/field/serialize.go#L50-L71 |
130,709 | luci/luci-go | cipd/appengine/ui/common.go | routeToPage | func routeToPage(c *router.Context) error {
path := c.Params.ByName("path")
switch chunks := strings.SplitN(path, "/+/", 2); {
case len(chunks) <= 1: // no '/+/' in path => prefix listing page
return prefixListingPage(c, path)
case len(chunks) == 2 && chunks[1] == "": // ends with '/+/' => package page
return p... | go | func routeToPage(c *router.Context) error {
path := c.Params.ByName("path")
switch chunks := strings.SplitN(path, "/+/", 2); {
case len(chunks) <= 1: // no '/+/' in path => prefix listing page
return prefixListingPage(c, path)
case len(chunks) == 2 && chunks[1] == "": // ends with '/+/' => package page
return p... | [
"func",
"routeToPage",
"(",
"c",
"*",
"router",
".",
"Context",
")",
"error",
"{",
"path",
":=",
"c",
".",
"Params",
".",
"ByName",
"(",
"\"",
"\"",
")",
"\n",
"switch",
"chunks",
":=",
"strings",
".",
"SplitN",
"(",
"path",
",",
"\"",
"\"",
",",
... | // routeToPage routes to an appropriate page depending on the request URL. | [
"routeToPage",
"routes",
"to",
"an",
"appropriate",
"page",
"depending",
"on",
"the",
"request",
"URL",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/ui/common.go#L72-L84 |
130,710 | luci/luci-go | tumble/service.go | FireAllTasks | func (s *Service) FireAllTasks(c context.Context) error {
cfg := getConfig(c)
namespaces, err := s.getNamespaces(c, cfg)
if err != nil {
return err
}
// Probe each namespace in parallel. Each probe function reports its own
// errors, so the work pool will never return any non-nil error response.
var errCount... | go | func (s *Service) FireAllTasks(c context.Context) error {
cfg := getConfig(c)
namespaces, err := s.getNamespaces(c, cfg)
if err != nil {
return err
}
// Probe each namespace in parallel. Each probe function reports its own
// errors, so the work pool will never return any non-nil error response.
var errCount... | [
"func",
"(",
"s",
"*",
"Service",
")",
"FireAllTasks",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"cfg",
":=",
"getConfig",
"(",
"c",
")",
"\n\n",
"namespaces",
",",
"err",
":=",
"s",
".",
"getNamespaces",
"(",
"c",
",",
"cfg",
")",
"\... | // FireAllTasks searches for work in all namespaces, and fires off a process
// task for any shards it finds that have at least one Mutation present to
// ensure that no work languishes forever. This may not be needed in
// a constantly-loaded system with good tumble key distribution. | [
"FireAllTasks",
"searches",
"for",
"work",
"in",
"all",
"namespaces",
"and",
"fires",
"off",
"a",
"process",
"task",
"for",
"any",
"shards",
"it",
"finds",
"that",
"have",
"at",
"least",
"one",
"Mutation",
"present",
"to",
"ensure",
"that",
"no",
"work",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tumble/service.go#L89-L122 |
130,711 | luci/luci-go | tumble/service.go | processURL | func processURL(ts timestamp, shard uint64, ns string, loop bool) string {
v := strings.NewReplacer(
":shard_id", fmt.Sprint(shard),
":timestamp", strconv.FormatInt(int64(ts), 10),
).Replace(processShardPattern)
// Append our namespace query parameter. This is cosmetic, and the default
// namespace will have t... | go | func processURL(ts timestamp, shard uint64, ns string, loop bool) string {
v := strings.NewReplacer(
":shard_id", fmt.Sprint(shard),
":timestamp", strconv.FormatInt(int64(ts), 10),
).Replace(processShardPattern)
// Append our namespace query parameter. This is cosmetic, and the default
// namespace will have t... | [
"func",
"processURL",
"(",
"ts",
"timestamp",
",",
"shard",
"uint64",
",",
"ns",
"string",
",",
"loop",
"bool",
")",
"string",
"{",
"v",
":=",
"strings",
".",
"NewReplacer",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprint",
"(",
"shard",
")",
",",
"\"",
... | // processURL creates a new url for a process shard taskqueue task, including
// the given timestamp and shard number. | [
"processURL",
"creates",
"a",
"new",
"url",
"for",
"a",
"process",
"shard",
"taskqueue",
"task",
"including",
"the",
"given",
"timestamp",
"and",
"shard",
"number",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tumble/service.go#L280-L299 |
130,712 | luci/luci-go | server/auth/authdb/snapshot.go | IsInternalService | func (db *SnapshotDB) IsInternalService(c context.Context, hostname string) (bool, error) {
if db.internalServices == nil {
return false, nil
}
return db.internalServices.MatchString(hostname), nil
} | go | func (db *SnapshotDB) IsInternalService(c context.Context, hostname string) (bool, error) {
if db.internalServices == nil {
return false, nil
}
return db.internalServices.MatchString(hostname), nil
} | [
"func",
"(",
"db",
"*",
"SnapshotDB",
")",
"IsInternalService",
"(",
"c",
"context",
".",
"Context",
",",
"hostname",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"db",
".",
"internalServices",
"==",
"nil",
"{",
"return",
"false",
",",
"ni... | // IsInternalService returns true if the given hostname belongs to a service
// that is a part of the current LUCI deployment.
//
// What hosts are internal is controlled by 'internal_service_regexp' setting
// in security.cfg in the Auth Service configs. | [
"IsInternalService",
"returns",
"true",
"if",
"the",
"given",
"hostname",
"belongs",
"to",
"a",
"service",
"that",
"is",
"a",
"part",
"of",
"the",
"current",
"LUCI",
"deployment",
".",
"What",
"hosts",
"are",
"internal",
"is",
"controlled",
"by",
"internal_ser... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/snapshot.go#L215-L220 |
130,713 | luci/luci-go | server/auth/authdb/snapshot.go | IsMember | func (db *SnapshotDB) IsMember(c context.Context, id identity.Identity, groups []string) (bool, error) {
// TODO(vadimsh): Optimize multi-group case.
for _, gr := range groups {
switch found, err := db.isMemberImpl(c, id, gr); {
case err != nil:
return false, err
case found:
return true, nil
}
}
retur... | go | func (db *SnapshotDB) IsMember(c context.Context, id identity.Identity, groups []string) (bool, error) {
// TODO(vadimsh): Optimize multi-group case.
for _, gr := range groups {
switch found, err := db.isMemberImpl(c, id, gr); {
case err != nil:
return false, err
case found:
return true, nil
}
}
retur... | [
"func",
"(",
"db",
"*",
"SnapshotDB",
")",
"IsMember",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"identity",
".",
"Identity",
",",
"groups",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// TODO(vadimsh): Optimize multi-group case.",
... | // IsMember returns true if the given identity belongs to any of the groups.
//
// Unknown groups are considered empty. May return errors if underlying
// datastore has issues. | [
"IsMember",
"returns",
"true",
"if",
"the",
"given",
"identity",
"belongs",
"to",
"any",
"of",
"the",
"groups",
".",
"Unknown",
"groups",
"are",
"considered",
"empty",
".",
"May",
"return",
"errors",
"if",
"underlying",
"datastore",
"has",
"issues",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/snapshot.go#L226-L237 |
130,714 | luci/luci-go | server/auth/authdb/snapshot.go | CheckMembership | func (db *SnapshotDB) CheckMembership(c context.Context, id identity.Identity, groups []string) (out []string, err error) {
// TODO(vadimsh): Optimize multi-group case.
for _, gr := range groups {
switch found, err := db.isMemberImpl(c, id, gr); {
case err != nil:
return nil, err
case found:
out = append(... | go | func (db *SnapshotDB) CheckMembership(c context.Context, id identity.Identity, groups []string) (out []string, err error) {
// TODO(vadimsh): Optimize multi-group case.
for _, gr := range groups {
switch found, err := db.isMemberImpl(c, id, gr); {
case err != nil:
return nil, err
case found:
out = append(... | [
"func",
"(",
"db",
"*",
"SnapshotDB",
")",
"CheckMembership",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"identity",
".",
"Identity",
",",
"groups",
"[",
"]",
"string",
")",
"(",
"out",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"// TODO... | // CheckMembership returns groups from the given list the identity belongs to.
//
// Unlike IsMember, it doesn't stop on the first hit but continues evaluating
// all groups.
//
// Unknown groups are considered empty. The order of groups in the result may
// be different from the order in 'groups'.
//
// May return err... | [
"CheckMembership",
"returns",
"groups",
"from",
"the",
"given",
"list",
"the",
"identity",
"belongs",
"to",
".",
"Unlike",
"IsMember",
"it",
"doesn",
"t",
"stop",
"on",
"the",
"first",
"hit",
"but",
"continues",
"evaluating",
"all",
"groups",
".",
"Unknown",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/snapshot.go#L248-L259 |
130,715 | luci/luci-go | server/auth/authdb/snapshot.go | isMemberImpl | func (db *SnapshotDB) isMemberImpl(c context.Context, id identity.Identity, groupName string) (bool, error) {
// Cycle detection check uses a stack of groups currently being explored. Use
// stack allocated array as a backing store to avoid unnecessary dynamic
// allocation. If stack depth grows beyond 8, 'append' w... | go | func (db *SnapshotDB) isMemberImpl(c context.Context, id identity.Identity, groupName string) (bool, error) {
// Cycle detection check uses a stack of groups currently being explored. Use
// stack allocated array as a backing store to avoid unnecessary dynamic
// allocation. If stack depth grows beyond 8, 'append' w... | [
"func",
"(",
"db",
"*",
"SnapshotDB",
")",
"isMemberImpl",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"identity",
".",
"Identity",
",",
"groupName",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// Cycle detection check uses a stack of groups current... | // isMemberImpl implements IsMember check for a single group only. | [
"isMemberImpl",
"implements",
"IsMember",
"check",
"for",
"a",
"single",
"group",
"only",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/snapshot.go#L262-L336 |
130,716 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | getLUCIBuilders | func getLUCIBuilders(c context.Context, master string) ([]string, error) {
buildersResponse, err := buildbucket.GetBuilders(c)
if err != nil {
return nil, err
}
var result []string
for _, bucket := range buildersResponse.Buckets {
for _, builder := range bucket.Builders {
if builder.PropertiesJson == "" {
... | go | func getLUCIBuilders(c context.Context, master string) ([]string, error) {
buildersResponse, err := buildbucket.GetBuilders(c)
if err != nil {
return nil, err
}
var result []string
for _, bucket := range buildersResponse.Buckets {
for _, builder := range bucket.Builders {
if builder.PropertiesJson == "" {
... | [
"func",
"getLUCIBuilders",
"(",
"c",
"context",
".",
"Context",
",",
"master",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"buildersResponse",
",",
"err",
":=",
"buildbucket",
".",
"GetBuilders",
"(",
"c",
")",
"\n",
"if",
"err",
"!... | // getLUCIBuilders returns all LUCI builders for a given master from Swarmbucket.
// LUCI builders do not have their own concept of "master". Instead, this is
// inferred from the "mastername" property in the property JSON. | [
"getLUCIBuilders",
"returns",
"all",
"LUCI",
"builders",
"for",
"a",
"given",
"master",
"from",
"Swarmbucket",
".",
"LUCI",
"builders",
"do",
"not",
"have",
"their",
"own",
"concept",
"of",
"master",
".",
"Instead",
"this",
"is",
"inferred",
"from",
"the",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L49-L74 |
130,717 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | AllMasters | func AllMasters(c context.Context, checkAccess bool) ([]*Master, error) {
const batchSize = int32(500)
masters := make([]*Master, 0, batchSize)
q := datastore.NewQuery(masterKind)
// note: avoid calling isAllowedInternal is checkAccess is false.
// checkAccess is usually false in cron jobs where there is no auth ... | go | func AllMasters(c context.Context, checkAccess bool) ([]*Master, error) {
const batchSize = int32(500)
masters := make([]*Master, 0, batchSize)
q := datastore.NewQuery(masterKind)
// note: avoid calling isAllowedInternal is checkAccess is false.
// checkAccess is usually false in cron jobs where there is no auth ... | [
"func",
"AllMasters",
"(",
"c",
"context",
".",
"Context",
",",
"checkAccess",
"bool",
")",
"(",
"[",
"]",
"*",
"Master",
",",
"error",
")",
"{",
"const",
"batchSize",
"=",
"int32",
"(",
"500",
")",
"\n",
"masters",
":=",
"make",
"(",
"[",
"]",
"*"... | // AllMasters returns all buildbot masters. | [
"AllMasters",
"returns",
"all",
"buildbot",
"masters",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L206-L226 |
130,718 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | GetPendingCounts | func GetPendingCounts(c context.Context, builders []string) ([]int, error) {
entities := make([]builderEntity, len(builders))
for i, b := range builders {
parts := strings.SplitN(b, "/", 2)
if len(parts) < 2 {
return nil, errors.Reason("builder does not have a slash: %q", b).Err()
}
entities[i].MasterKey =... | go | func GetPendingCounts(c context.Context, builders []string) ([]int, error) {
entities := make([]builderEntity, len(builders))
for i, b := range builders {
parts := strings.SplitN(b, "/", 2)
if len(parts) < 2 {
return nil, errors.Reason("builder does not have a slash: %q", b).Err()
}
entities[i].MasterKey =... | [
"func",
"GetPendingCounts",
"(",
"c",
"context",
".",
"Context",
",",
"builders",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"int",
",",
"error",
")",
"{",
"entities",
":=",
"make",
"(",
"[",
"]",
"builderEntity",
",",
"len",
"(",
"builders",
")",
")",
... | // GetPendingCounts returns numbers of pending builds in builders.
// builders must be a list of slash-separated master, builder names. | [
"GetPendingCounts",
"returns",
"numbers",
"of",
"pending",
"builds",
"in",
"builders",
".",
"builders",
"must",
"be",
"a",
"list",
"of",
"slash",
"-",
"separated",
"master",
"builder",
"names",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L230-L253 |
130,719 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | PutPendingCount | func PutPendingCount(c context.Context, master, builder string, count int) error {
return datastore.Put(c, &builderEntity{
MasterKey: datastore.MakeKey(c, masterKind, master),
Name: builder,
PendingCount: count,
})
} | go | func PutPendingCount(c context.Context, master, builder string, count int) error {
return datastore.Put(c, &builderEntity{
MasterKey: datastore.MakeKey(c, masterKind, master),
Name: builder,
PendingCount: count,
})
} | [
"func",
"PutPendingCount",
"(",
"c",
"context",
".",
"Context",
",",
"master",
",",
"builder",
"string",
",",
"count",
"int",
")",
"error",
"{",
"return",
"datastore",
".",
"Put",
"(",
"c",
",",
"&",
"builderEntity",
"{",
"MasterKey",
":",
"datastore",
"... | // PutPendingCount persists number of pending builds to a builder.
// Useful for testing. | [
"PutPendingCount",
"persists",
"number",
"of",
"pending",
"builds",
"to",
"a",
"builder",
".",
"Useful",
"for",
"testing",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L257-L263 |
130,720 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | SaveMaster | func SaveMaster(c context.Context, master *buildbot.Master,
internal bool, expireCallback ExpireCallback) error {
entity := &masterEntity{
Name: master.Name,
Internal: internal,
Modified: clock.Now(c).UTC(),
}
toPut := []interface{}{entity}
for builderName, builder := range master.Builders {
// Trim o... | go | func SaveMaster(c context.Context, master *buildbot.Master,
internal bool, expireCallback ExpireCallback) error {
entity := &masterEntity{
Name: master.Name,
Internal: internal,
Modified: clock.Now(c).UTC(),
}
toPut := []interface{}{entity}
for builderName, builder := range master.Builders {
// Trim o... | [
"func",
"SaveMaster",
"(",
"c",
"context",
".",
"Context",
",",
"master",
"*",
"buildbot",
".",
"Master",
",",
"internal",
"bool",
",",
"expireCallback",
"ExpireCallback",
")",
"error",
"{",
"entity",
":=",
"&",
"masterEntity",
"{",
"Name",
":",
"master",
... | // SaveMaster persists the master in the storage.
//
// Expires all incomplete builds in the datastore associated with this master
// and
// - associated with builders not declared in master.Builders
// - OR or not "current" from this master's perspective and >=20min stale. | [
"SaveMaster",
"persists",
"the",
"master",
"in",
"the",
"storage",
".",
"Expires",
"all",
"incomplete",
"builds",
"in",
"the",
"datastore",
"associated",
"with",
"this",
"master",
"and",
"-",
"associated",
"with",
"builders",
"not",
"declared",
"in",
"master",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L274-L327 |
130,721 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | expireBuild | func expireBuild(c context.Context, b *buildbot.Build) error {
if !b.TimeStamp.IsZero() {
b.Times.Finish = b.TimeStamp
} else {
b.Times.Finish.Time = clock.Now(c)
}
b.Finished = true
b.Results = buildbot.Exception
b.Currentstep = nil
b.Text = append(b.Text, "Build expired on Milo")
_, err := SaveBuild(c, b)... | go | func expireBuild(c context.Context, b *buildbot.Build) error {
if !b.TimeStamp.IsZero() {
b.Times.Finish = b.TimeStamp
} else {
b.Times.Finish.Time = clock.Now(c)
}
b.Finished = true
b.Results = buildbot.Exception
b.Currentstep = nil
b.Text = append(b.Text, "Build expired on Milo")
_, err := SaveBuild(c, b)... | [
"func",
"expireBuild",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"error",
"{",
"if",
"!",
"b",
".",
"TimeStamp",
".",
"IsZero",
"(",
")",
"{",
"b",
".",
"Times",
".",
"Finish",
"=",
"b",
".",
"TimeStamp",
... | // expireBuild marks a build as finished and expired. | [
"expireBuild",
"marks",
"a",
"build",
"as",
"finished",
"and",
"expired",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L373-L385 |
130,722 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | isAllowedInternal | func isAllowedInternal(c context.Context) bool {
settings := common.GetSettings(c)
if settings.Buildbot.InternalReader == "" {
return false
}
allowed, err := auth.IsMember(c, settings.Buildbot.InternalReader)
if err != nil {
logging.WithError(err).Errorf(c, "IsMember(%q) failed", settings.Buildbot.InternalRead... | go | func isAllowedInternal(c context.Context) bool {
settings := common.GetSettings(c)
if settings.Buildbot.InternalReader == "" {
return false
}
allowed, err := auth.IsMember(c, settings.Buildbot.InternalReader)
if err != nil {
logging.WithError(err).Errorf(c, "IsMember(%q) failed", settings.Buildbot.InternalRead... | [
"func",
"isAllowedInternal",
"(",
"c",
"context",
".",
"Context",
")",
"bool",
"{",
"settings",
":=",
"common",
".",
"GetSettings",
"(",
"c",
")",
"\n",
"if",
"settings",
".",
"Buildbot",
".",
"InternalReader",
"==",
"\"",
"\"",
"{",
"return",
"false",
"... | // isAllowedInternal returns true if the current user has access to internal
// data. In case of an error, logs it and returns false to prevent from
// sniffing based on internal errors. | [
"isAllowedInternal",
"returns",
"true",
"if",
"the",
"current",
"user",
"has",
"access",
"to",
"internal",
"data",
".",
"In",
"case",
"of",
"an",
"error",
"logs",
"it",
"and",
"returns",
"false",
"to",
"prevent",
"from",
"sniffing",
"based",
"on",
"internal"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L397-L408 |
130,723 | luci/luci-go | milo/buildsource/buildbot/buildstore/master.go | CanAccessMaster | func CanAccessMaster(c context.Context, name string) error {
if ex, err := datastore.Exists(c, &masterPublic{Name: name}); err == nil && ex.Get(0) {
// It exists => it is public
return nil
}
if isAllowedInternal(c) {
return nil
}
code := grpcutil.NotFoundTag
if auth.CurrentUser(c).Identity == identity.Ano... | go | func CanAccessMaster(c context.Context, name string) error {
if ex, err := datastore.Exists(c, &masterPublic{Name: name}); err == nil && ex.Get(0) {
// It exists => it is public
return nil
}
if isAllowedInternal(c) {
return nil
}
code := grpcutil.NotFoundTag
if auth.CurrentUser(c).Identity == identity.Ano... | [
"func",
"CanAccessMaster",
"(",
"c",
"context",
".",
"Context",
",",
"name",
"string",
")",
"error",
"{",
"if",
"ex",
",",
"err",
":=",
"datastore",
".",
"Exists",
"(",
"c",
",",
"&",
"masterPublic",
"{",
"Name",
":",
"name",
"}",
")",
";",
"err",
... | // CanAccessMaster returns nil if the currently logged in user can see the
// masters, or if the given master is a known public master,
// otherwise an error. | [
"CanAccessMaster",
"returns",
"nil",
"if",
"the",
"currently",
"logged",
"in",
"user",
"can",
"see",
"the",
"masters",
"or",
"if",
"the",
"given",
"master",
"is",
"a",
"known",
"public",
"master",
"otherwise",
"an",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/master.go#L413-L429 |
130,724 | luci/luci-go | cipd/client/cipd/internal/checksum.go | MarshalWithSHA256 | func MarshalWithSHA256(pm proto.Message) ([]byte, error) {
blob, err := proto.Marshal(pm)
if err != nil {
return nil, err
}
sum := sha256.Sum256(blob)
envelope := messages.BlobWithSHA256{Blob: blob, Sha256: sum[:]}
return proto.Marshal(&envelope)
} | go | func MarshalWithSHA256(pm proto.Message) ([]byte, error) {
blob, err := proto.Marshal(pm)
if err != nil {
return nil, err
}
sum := sha256.Sum256(blob)
envelope := messages.BlobWithSHA256{Blob: blob, Sha256: sum[:]}
return proto.Marshal(&envelope)
} | [
"func",
"MarshalWithSHA256",
"(",
"pm",
"proto",
".",
"Message",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"blob",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"pm",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"er... | // MarshalWithSHA256 serializes proto message to bytes, calculates SHA256
// checksum of it, and returns serialized envelope that contains both.
//
// UnmarshalWithSHA256 can then be used to verify SHA256 and deserialized the
// original object. | [
"MarshalWithSHA256",
"serializes",
"proto",
"message",
"to",
"bytes",
"calculates",
"SHA256",
"checksum",
"of",
"it",
"and",
"returns",
"serialized",
"envelope",
"that",
"contains",
"both",
".",
"UnmarshalWithSHA256",
"can",
"then",
"be",
"used",
"to",
"verify",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/checksum.go#L37-L45 |
130,725 | luci/luci-go | cipd/client/cipd/internal/checksum.go | UnmarshalWithSHA256 | func UnmarshalWithSHA256(buf []byte, pm proto.Message) error {
envelope := messages.BlobWithSHA256{}
if err := proto.Unmarshal(buf, &envelope); err != nil {
return err
}
if len(envelope.Sha256) == 0 {
return ErrUnknownSHA256
}
sum := sha256.Sum256(envelope.Blob)
if !bytes.Equal(sum[:], envelope.Sha256) {
r... | go | func UnmarshalWithSHA256(buf []byte, pm proto.Message) error {
envelope := messages.BlobWithSHA256{}
if err := proto.Unmarshal(buf, &envelope); err != nil {
return err
}
if len(envelope.Sha256) == 0 {
return ErrUnknownSHA256
}
sum := sha256.Sum256(envelope.Blob)
if !bytes.Equal(sum[:], envelope.Sha256) {
r... | [
"func",
"UnmarshalWithSHA256",
"(",
"buf",
"[",
"]",
"byte",
",",
"pm",
"proto",
".",
"Message",
")",
"error",
"{",
"envelope",
":=",
"messages",
".",
"BlobWithSHA256",
"{",
"}",
"\n",
"if",
"err",
":=",
"proto",
".",
"Unmarshal",
"(",
"buf",
",",
"&",... | // UnmarshalWithSHA256 is reverse of MarshalWithSHA256.
//
// It checks SHA256 checksum and deserializes the object if it matches the blob.
//
// If the expected SHA256 is not available in 'buf', returns ErrUnknownSHA256.
// This can happen when reading blobs in old format that used SHA1. | [
"UnmarshalWithSHA256",
"is",
"reverse",
"of",
"MarshalWithSHA256",
".",
"It",
"checks",
"SHA256",
"checksum",
"and",
"deserializes",
"the",
"object",
"if",
"it",
"matches",
"the",
"blob",
".",
"If",
"the",
"expected",
"SHA256",
"is",
"not",
"available",
"in",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/checksum.go#L53-L66 |
130,726 | luci/luci-go | logdog/client/cmd/logdog_butler/output.go | AddFactory | func (ocf *outputConfigFlag) AddFactory(f outputFactory) {
ocf.Options = append(ocf.Options, f.option())
} | go | func (ocf *outputConfigFlag) AddFactory(f outputFactory) {
ocf.Options = append(ocf.Options, f.option())
} | [
"func",
"(",
"ocf",
"*",
"outputConfigFlag",
")",
"AddFactory",
"(",
"f",
"outputFactory",
")",
"{",
"ocf",
".",
"Options",
"=",
"append",
"(",
"ocf",
".",
"Options",
",",
"f",
".",
"option",
"(",
")",
")",
"\n",
"}"
] | // Adds an output factory to this outputConfigFlag instance. | [
"Adds",
"an",
"output",
"factory",
"to",
"this",
"outputConfigFlag",
"instance",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/output.go#L36-L38 |
130,727 | luci/luci-go | logdog/client/cmd/logdog_butler/output.go | getFactory | func (ocf *outputConfigFlag) getFactory() outputFactory {
if ocf.Selected == nil {
return nil
}
if o, ok := ocf.Selected.(*outputOption); ok {
return o.factory
}
return nil
} | go | func (ocf *outputConfigFlag) getFactory() outputFactory {
if ocf.Selected == nil {
return nil
}
if o, ok := ocf.Selected.(*outputOption); ok {
return o.factory
}
return nil
} | [
"func",
"(",
"ocf",
"*",
"outputConfigFlag",
")",
"getFactory",
"(",
")",
"outputFactory",
"{",
"if",
"ocf",
".",
"Selected",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"o",
",",
"ok",
":=",
"ocf",
".",
"Selected",
".",
"(",
"*",
"... | // Returns the Factory associated with the configured flag. | [
"Returns",
"the",
"Factory",
"associated",
"with",
"the",
"configured",
"flag",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/output.go#L41-L50 |
130,728 | luci/luci-go | logdog/client/cmd/logdog_butler/output.go | newOutputOption | func newOutputOption(name, description string, f outputFactory) *outputOption {
return &outputOption{
FlagOption: multiflag.FlagOption{
Name: name,
Description: description,
},
factory: f,
}
} | go | func newOutputOption(name, description string, f outputFactory) *outputOption {
return &outputOption{
FlagOption: multiflag.FlagOption{
Name: name,
Description: description,
},
factory: f,
}
} | [
"func",
"newOutputOption",
"(",
"name",
",",
"description",
"string",
",",
"f",
"outputFactory",
")",
"*",
"outputOption",
"{",
"return",
"&",
"outputOption",
"{",
"FlagOption",
":",
"multiflag",
".",
"FlagOption",
"{",
"Name",
":",
"name",
",",
"Description",... | // newOutputOption instantiates a new outputOption. | [
"newOutputOption",
"instantiates",
"a",
"new",
"outputOption",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/output.go#L60-L68 |
130,729 | luci/luci-go | tokenserver/appengine/impl/certconfig/rpc_list_cas.go | ListCAs | func (r *ListCAsRPC) ListCAs(c context.Context, _ *empty.Empty) (*admin.ListCAsResponse, error) {
names, err := ListCAs(c)
if err != nil {
return nil, status.Errorf(codes.Internal, "transient datastore error - %s", err)
}
return &admin.ListCAsResponse{Cn: names}, nil
} | go | func (r *ListCAsRPC) ListCAs(c context.Context, _ *empty.Empty) (*admin.ListCAsResponse, error) {
names, err := ListCAs(c)
if err != nil {
return nil, status.Errorf(codes.Internal, "transient datastore error - %s", err)
}
return &admin.ListCAsResponse{Cn: names}, nil
} | [
"func",
"(",
"r",
"*",
"ListCAsRPC",
")",
"ListCAs",
"(",
"c",
"context",
".",
"Context",
",",
"_",
"*",
"empty",
".",
"Empty",
")",
"(",
"*",
"admin",
".",
"ListCAsResponse",
",",
"error",
")",
"{",
"names",
",",
"err",
":=",
"ListCAs",
"(",
"c",
... | // ListCAs returns a list of Common Names of registered CAs. | [
"ListCAs",
"returns",
"a",
"list",
"of",
"Common",
"Names",
"of",
"registered",
"CAs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certconfig/rpc_list_cas.go#L33-L39 |
130,730 | luci/luci-go | gce/appengine/backend/queues.go | countVMs | func countVMs(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.CountVMs)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
// Count VMs per project, server and zone.
// VMs ... | go | func countVMs(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.CountVMs)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
// Count VMs per project, server and zone.
// VMs ... | [
"func",
"countVMs",
"(",
"c",
"context",
".",
"Context",
",",
"payload",
"proto",
".",
"Message",
")",
"error",
"{",
"task",
",",
"ok",
":=",
"payload",
".",
"(",
"*",
"tasks",
".",
"CountVMs",
")",
"\n",
"switch",
"{",
"case",
"!",
"ok",
":",
"ret... | // countVMs counts the VMs for a given config. | [
"countVMs",
"counts",
"the",
"VMs",
"for",
"a",
"given",
"config",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/backend/queues.go#L44-L100 |
130,731 | luci/luci-go | gce/appengine/backend/queues.go | drainVM | func drainVM(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.DrainVM)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
vm := &model.VM{
ID: task.Id,
}
switch err := dat... | go | func drainVM(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.DrainVM)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
vm := &model.VM{
ID: task.Id,
}
switch err := dat... | [
"func",
"drainVM",
"(",
"c",
"context",
".",
"Context",
",",
"payload",
"proto",
".",
"Message",
")",
"error",
"{",
"task",
",",
"ok",
":=",
"payload",
".",
"(",
"*",
"tasks",
".",
"DrainVM",
")",
"\n",
"switch",
"{",
"case",
"!",
"ok",
":",
"retur... | // drainVM drains a given VM. | [
"drainVM",
"drains",
"a",
"given",
"VM",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/backend/queues.go#L106-L159 |
130,732 | luci/luci-go | gce/appengine/backend/queues.go | getSuffix | func getSuffix(c context.Context) string {
const allowed = "abcdefghijklmnopqrstuvwxyz0123456789"
suf := make([]byte, 4)
for i := range suf {
suf[i] = allowed[mathrand.Intn(c, len(allowed))]
}
return string(suf)
} | go | func getSuffix(c context.Context) string {
const allowed = "abcdefghijklmnopqrstuvwxyz0123456789"
suf := make([]byte, 4)
for i := range suf {
suf[i] = allowed[mathrand.Intn(c, len(allowed))]
}
return string(suf)
} | [
"func",
"getSuffix",
"(",
"c",
"context",
".",
"Context",
")",
"string",
"{",
"const",
"allowed",
"=",
"\"",
"\"",
"\n",
"suf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"for",
"i",
":=",
"range",
"suf",
"{",
"suf",
"[",
"i",
"]... | // getSuffix returns a random suffix to use when naming a GCE instance. | [
"getSuffix",
"returns",
"a",
"random",
"suffix",
"to",
"use",
"when",
"naming",
"a",
"GCE",
"instance",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/backend/queues.go#L162-L169 |
130,733 | luci/luci-go | gce/appengine/backend/queues.go | createVM | func createVM(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.CreateVM)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
case task.GetConfig() == "":
return errors.Reason("c... | go | func createVM(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.CreateVM)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
case task.GetConfig() == "":
return errors.Reason("c... | [
"func",
"createVM",
"(",
"c",
"context",
".",
"Context",
",",
"payload",
"proto",
".",
"Message",
")",
"error",
"{",
"task",
",",
"ok",
":=",
"payload",
".",
"(",
"*",
"tasks",
".",
"CreateVM",
")",
"\n",
"switch",
"{",
"case",
"!",
"ok",
":",
"ret... | // createVM creates a VM if it doesn't already exist. | [
"createVM",
"creates",
"a",
"VM",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/backend/queues.go#L175-L223 |
130,734 | luci/luci-go | gce/appengine/backend/queues.go | expandConfig | func expandConfig(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.ExpandConfig)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
cfg, err := getConfig(c).Get(c, &config.Get... | go | func expandConfig(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.ExpandConfig)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
cfg, err := getConfig(c).Get(c, &config.Get... | [
"func",
"expandConfig",
"(",
"c",
"context",
".",
"Context",
",",
"payload",
"proto",
".",
"Message",
")",
"error",
"{",
"task",
",",
"ok",
":=",
"payload",
".",
"(",
"*",
"tasks",
".",
"ExpandConfig",
")",
"\n",
"switch",
"{",
"case",
"!",
"ok",
":"... | // expandConfig creates task queue tasks to create each VM in the given config. | [
"expandConfig",
"creates",
"task",
"queue",
"tasks",
"to",
"create",
"each",
"VM",
"in",
"the",
"given",
"config",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/backend/queues.go#L229-L270 |
130,735 | luci/luci-go | gce/appengine/backend/queues.go | reportQuota | func reportQuota(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.ReportQuota)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
p := &model.Project{
ID: task.Id,
}
if er... | go | func reportQuota(c context.Context, payload proto.Message) error {
task, ok := payload.(*tasks.ReportQuota)
switch {
case !ok:
return errors.Reason("unexpected payload type %T", payload).Err()
case task.GetId() == "":
return errors.Reason("ID is required").Err()
}
p := &model.Project{
ID: task.Id,
}
if er... | [
"func",
"reportQuota",
"(",
"c",
"context",
".",
"Context",
",",
"payload",
"proto",
".",
"Message",
")",
"error",
"{",
"task",
",",
"ok",
":=",
"payload",
".",
"(",
"*",
"tasks",
".",
"ReportQuota",
")",
"\n",
"switch",
"{",
"case",
"!",
"ok",
":",
... | // reportQuota reports GCE quota utilization. | [
"reportQuota",
"reports",
"GCE",
"quota",
"utilization",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/backend/queues.go#L276-L310 |
130,736 | luci/luci-go | common/isolatedclient/isolatedclient.go | NewBytesSource | func NewBytesSource(d []byte) Source {
return func() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(d)), nil
}
} | go | func NewBytesSource(d []byte) Source {
return func() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(d)), nil
}
} | [
"func",
"NewBytesSource",
"(",
"d",
"[",
"]",
"byte",
")",
"Source",
"{",
"return",
"func",
"(",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"return",
"ioutil",
".",
"NopCloser",
"(",
"bytes",
".",
"NewReader",
"(",
"d",
")",
")",
",... | // NewBytesSource returns a Source implementation that reads from the supplied
// byte slice. | [
"NewBytesSource",
"returns",
"a",
"Source",
"implementation",
"that",
"reads",
"from",
"the",
"supplied",
"byte",
"slice",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolatedclient/isolatedclient.go#L46-L50 |
130,737 | luci/luci-go | common/isolatedclient/isolatedclient.go | ServerCapabilities | func (i *Client) ServerCapabilities(c context.Context) (*isolateservice.HandlersEndpointsV1ServerDetails, error) {
out := &isolateservice.HandlersEndpointsV1ServerDetails{}
if err := i.postJSON(c, "/_ah/api/isolateservice/v1/server_details", nil, map[string]string{}, out); err != nil {
return nil, err
}
return ou... | go | func (i *Client) ServerCapabilities(c context.Context) (*isolateservice.HandlersEndpointsV1ServerDetails, error) {
out := &isolateservice.HandlersEndpointsV1ServerDetails{}
if err := i.postJSON(c, "/_ah/api/isolateservice/v1/server_details", nil, map[string]string{}, out); err != nil {
return nil, err
}
return ou... | [
"func",
"(",
"i",
"*",
"Client",
")",
"ServerCapabilities",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"*",
"isolateservice",
".",
"HandlersEndpointsV1ServerDetails",
",",
"error",
")",
"{",
"out",
":=",
"&",
"isolateservice",
".",
"HandlersEndpointsV1Server... | // ServerCapabilities returns the server details. | [
"ServerCapabilities",
"returns",
"the",
"server",
"details",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolatedclient/isolatedclient.go#L130-L136 |
130,738 | luci/luci-go | common/isolatedclient/isolatedclient.go | Contains | func (i *Client) Contains(c context.Context, items []*isolateservice.HandlersEndpointsV1Digest) (out []*PushState, err error) {
end := tracer.Span(i, "contains", tracer.Args{"number": len(items)})
defer func() { end(tracer.Args{"err": err}) }()
in := isolateservice.HandlersEndpointsV1DigestCollection{Items: items, N... | go | func (i *Client) Contains(c context.Context, items []*isolateservice.HandlersEndpointsV1Digest) (out []*PushState, err error) {
end := tracer.Span(i, "contains", tracer.Args{"number": len(items)})
defer func() { end(tracer.Args{"err": err}) }()
in := isolateservice.HandlersEndpointsV1DigestCollection{Items: items, N... | [
"func",
"(",
"i",
"*",
"Client",
")",
"Contains",
"(",
"c",
"context",
".",
"Context",
",",
"items",
"[",
"]",
"*",
"isolateservice",
".",
"HandlersEndpointsV1Digest",
")",
"(",
"out",
"[",
"]",
"*",
"PushState",
",",
"err",
"error",
")",
"{",
"end",
... | // Contains looks up cache presence on the server of multiple items.
//
// The returned list is in the same order as 'items', with entries nil for
// items that were present. | [
"Contains",
"looks",
"up",
"cache",
"presence",
"on",
"the",
"server",
"of",
"multiple",
"items",
".",
"The",
"returned",
"list",
"is",
"in",
"the",
"same",
"order",
"as",
"items",
"with",
"entries",
"nil",
"for",
"items",
"that",
"were",
"present",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolatedclient/isolatedclient.go#L142-L161 |
130,739 | luci/luci-go | common/isolatedclient/isolatedclient.go | Fetch | func (i *Client) Fetch(c context.Context, digest isolated.HexDigest, dest io.Writer) error {
// Perform initial request.
name := ""
switch i.h {
case crypto.SHA1:
name = "sha-1"
case crypto.SHA256:
name = "sha-256"
case crypto.SHA512:
name = "sha-512"
}
url := i.url + "/_ah/api/isolateservice/v1/retrieve"... | go | func (i *Client) Fetch(c context.Context, digest isolated.HexDigest, dest io.Writer) error {
// Perform initial request.
name := ""
switch i.h {
case crypto.SHA1:
name = "sha-1"
case crypto.SHA256:
name = "sha-256"
case crypto.SHA512:
name = "sha-512"
}
url := i.url + "/_ah/api/isolateservice/v1/retrieve"... | [
"func",
"(",
"i",
"*",
"Client",
")",
"Fetch",
"(",
"c",
"context",
".",
"Context",
",",
"digest",
"isolated",
".",
"HexDigest",
",",
"dest",
"io",
".",
"Writer",
")",
"error",
"{",
"// Perform initial request.",
"name",
":=",
"\"",
"\"",
"\n",
"switch",... | // Fetch downloads an item from the server. | [
"Fetch",
"downloads",
"an",
"item",
"from",
"the",
"server",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolatedclient/isolatedclient.go#L196-L238 |
130,740 | luci/luci-go | common/isolatedclient/isolatedclient.go | postJSON | func (i *Client) postJSON(c context.Context, resource string, headers map[string]string, in, out interface{}) error {
if len(resource) == 0 || resource[0] != '/' {
return errors.New("resource must start with '/'")
}
_, err := lhttp.PostJSON(c, i.retryFactory, i.authClient, i.url+resource, headers, in, out)
return... | go | func (i *Client) postJSON(c context.Context, resource string, headers map[string]string, in, out interface{}) error {
if len(resource) == 0 || resource[0] != '/' {
return errors.New("resource must start with '/'")
}
_, err := lhttp.PostJSON(c, i.retryFactory, i.authClient, i.url+resource, headers, in, out)
return... | [
"func",
"(",
"i",
"*",
"Client",
")",
"postJSON",
"(",
"c",
"context",
".",
"Context",
",",
"resource",
"string",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
",",
"in",
",",
"out",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"("... | // postJSON does authenticated POST request. | [
"postJSON",
"does",
"authenticated",
"POST",
"request",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolatedclient/isolatedclient.go#L241-L247 |
130,741 | luci/luci-go | common/isolatedclient/isolatedclient.go | Fetch | func (gcs defaultGCSHandler) Fetch(c context.Context, i *Client, content isolateservice.HandlersEndpointsV1RetrievedContent, dest io.Writer) error {
rgen := func() (*http.Request, error) {
return http.NewRequest("GET", content.Url, nil)
}
handler := func(resp *http.Response) error {
defer resp.Body.Close()
dec... | go | func (gcs defaultGCSHandler) Fetch(c context.Context, i *Client, content isolateservice.HandlersEndpointsV1RetrievedContent, dest io.Writer) error {
rgen := func() (*http.Request, error) {
return http.NewRequest("GET", content.Url, nil)
}
handler := func(resp *http.Response) error {
defer resp.Body.Close()
dec... | [
"func",
"(",
"gcs",
"defaultGCSHandler",
")",
"Fetch",
"(",
"c",
"context",
".",
"Context",
",",
"i",
"*",
"Client",
",",
"content",
"isolateservice",
".",
"HandlersEndpointsV1RetrievedContent",
",",
"dest",
"io",
".",
"Writer",
")",
"error",
"{",
"rgen",
":... | // Fetch uses the provided HandlersEndpointsV1RetrievedContent response to
// download content from GCS to the provided dest. | [
"Fetch",
"uses",
"the",
"provided",
"HandlersEndpointsV1RetrievedContent",
"response",
"to",
"download",
"content",
"from",
"GCS",
"to",
"the",
"provided",
"dest",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolatedclient/isolatedclient.go#L296-L312 |
130,742 | luci/luci-go | common/isolatedclient/isolatedclient.go | Push | func (gcs defaultGCSHandler) Push(c context.Context, i *Client, status isolateservice.HandlersEndpointsV1PreuploadStatus, source Source) error {
// GsUploadUrl is signed Google Storage URL that doesn't require additional
// authentication. In fact, using authClient causes HTTP 403 because
// authClient's tokens don'... | go | func (gcs defaultGCSHandler) Push(c context.Context, i *Client, status isolateservice.HandlersEndpointsV1PreuploadStatus, source Source) error {
// GsUploadUrl is signed Google Storage URL that doesn't require additional
// authentication. In fact, using authClient causes HTTP 403 because
// authClient's tokens don'... | [
"func",
"(",
"gcs",
"defaultGCSHandler",
")",
"Push",
"(",
"c",
"context",
".",
"Context",
",",
"i",
"*",
"Client",
",",
"status",
"isolateservice",
".",
"HandlersEndpointsV1PreuploadStatus",
",",
"source",
"Source",
")",
"error",
"{",
"// GsUploadUrl is signed Go... | // Push uploads content from the provided source to the GCS path specified in
// the HandlersEndpointsV1PreuploadStatus response. | [
"Push",
"uploads",
"content",
"from",
"the",
"provided",
"source",
"to",
"the",
"GCS",
"path",
"specified",
"in",
"the",
"HandlersEndpointsV1PreuploadStatus",
"response",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolatedclient/isolatedclient.go#L316-L345 |
130,743 | luci/luci-go | luci_notify/config/validate.go | init | func init() {
validation.Rules.Add(
"regex:projects/.*",
"${appid}.cfg",
func(ctx *validation.Context, configSet, path string, content []byte) error {
cfg := ¬ifypb.ProjectConfig{}
if err := proto.UnmarshalText(string(content), cfg); err != nil {
ctx.Errorf("invalid ProjectConfig proto message: %s",... | go | func init() {
validation.Rules.Add(
"regex:projects/.*",
"${appid}.cfg",
func(ctx *validation.Context, configSet, path string, content []byte) error {
cfg := ¬ifypb.ProjectConfig{}
if err := proto.UnmarshalText(string(content), cfg); err != nil {
ctx.Errorf("invalid ProjectConfig proto message: %s",... | [
"func",
"init",
"(",
")",
"{",
"validation",
".",
"Rules",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"func",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"configSet",
",",
"path",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"... | // init registers validators for the project config and email template files. | [
"init",
"registers",
"validators",
"for",
"the",
"project",
"config",
"and",
"email",
"template",
"files",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/validate.go#L41-L59 |
130,744 | luci/luci-go | luci_notify/config/validate.go | validateNotification | func validateNotification(c *validation.Context, cfgNotification *notifypb.Notification) {
if cfgNotification.Email != nil {
for _, addr := range cfgNotification.Email.Recipients {
if _, err := mail.ParseAddress(addr); err != nil {
c.Errorf(badEmailError, addr)
}
}
}
} | go | func validateNotification(c *validation.Context, cfgNotification *notifypb.Notification) {
if cfgNotification.Email != nil {
for _, addr := range cfgNotification.Email.Recipients {
if _, err := mail.ParseAddress(addr); err != nil {
c.Errorf(badEmailError, addr)
}
}
}
} | [
"func",
"validateNotification",
"(",
"c",
"*",
"validation",
".",
"Context",
",",
"cfgNotification",
"*",
"notifypb",
".",
"Notification",
")",
"{",
"if",
"cfgNotification",
".",
"Email",
"!=",
"nil",
"{",
"for",
"_",
",",
"addr",
":=",
"range",
"cfgNotifica... | // validateNotification is a helper function for validateConfig which validates
// an individual notification configuration. | [
"validateNotification",
"is",
"a",
"helper",
"function",
"for",
"validateConfig",
"which",
"validates",
"an",
"individual",
"notification",
"configuration",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/validate.go#L72-L80 |
130,745 | luci/luci-go | luci_notify/config/validate.go | validateBuilder | func validateBuilder(c *validation.Context, cfgBuilder *notifypb.Builder, builderNames stringset.Set) {
if cfgBuilder.Bucket == "" {
c.Errorf(requiredFieldError, "bucket")
}
if strings.HasPrefix(cfgBuilder.Bucket, "luci.") {
// TODO(tandrii): change to warning once our validation library supports it.
c.Errorf(... | go | func validateBuilder(c *validation.Context, cfgBuilder *notifypb.Builder, builderNames stringset.Set) {
if cfgBuilder.Bucket == "" {
c.Errorf(requiredFieldError, "bucket")
}
if strings.HasPrefix(cfgBuilder.Bucket, "luci.") {
// TODO(tandrii): change to warning once our validation library supports it.
c.Errorf(... | [
"func",
"validateBuilder",
"(",
"c",
"*",
"validation",
".",
"Context",
",",
"cfgBuilder",
"*",
"notifypb",
".",
"Builder",
",",
"builderNames",
"stringset",
".",
"Set",
")",
"{",
"if",
"cfgBuilder",
".",
"Bucket",
"==",
"\"",
"\"",
"{",
"c",
".",
"Error... | // validateBuilder is a helper function for validateConfig which validates
// an individual Builder. | [
"validateBuilder",
"is",
"a",
"helper",
"function",
"for",
"validateConfig",
"which",
"validates",
"an",
"individual",
"Builder",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/validate.go#L84-L104 |
130,746 | luci/luci-go | luci_notify/config/validate.go | validateNotifier | func validateNotifier(c *validation.Context, cfgNotifier *notifypb.Notifier, builderNames stringset.Set) {
for i, cfgNotification := range cfgNotifier.Notifications {
c.Enter("notification #%d", i+1)
validateNotification(c, cfgNotification)
c.Exit()
}
for i, cfgBuilder := range cfgNotifier.Builders {
c.Enter... | go | func validateNotifier(c *validation.Context, cfgNotifier *notifypb.Notifier, builderNames stringset.Set) {
for i, cfgNotification := range cfgNotifier.Notifications {
c.Enter("notification #%d", i+1)
validateNotification(c, cfgNotification)
c.Exit()
}
for i, cfgBuilder := range cfgNotifier.Builders {
c.Enter... | [
"func",
"validateNotifier",
"(",
"c",
"*",
"validation",
".",
"Context",
",",
"cfgNotifier",
"*",
"notifypb",
".",
"Notifier",
",",
"builderNames",
"stringset",
".",
"Set",
")",
"{",
"for",
"i",
",",
"cfgNotification",
":=",
"range",
"cfgNotifier",
".",
"Not... | // validateNotifier validates a Notifier. | [
"validateNotifier",
"validates",
"a",
"Notifier",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/validate.go#L107-L118 |
130,747 | luci/luci-go | luci_notify/config/validate.go | validateProjectConfig | func validateProjectConfig(ctx *validation.Context, projectCfg *notifypb.ProjectConfig) {
builderNames := stringset.New(len(projectCfg.Notifiers)) // At least one builder per notifier
for i, cfgNotifier := range projectCfg.Notifiers {
ctx.Enter("notifier #%d", i+1)
validateNotifier(ctx, cfgNotifier, builderNames)... | go | func validateProjectConfig(ctx *validation.Context, projectCfg *notifypb.ProjectConfig) {
builderNames := stringset.New(len(projectCfg.Notifiers)) // At least one builder per notifier
for i, cfgNotifier := range projectCfg.Notifiers {
ctx.Enter("notifier #%d", i+1)
validateNotifier(ctx, cfgNotifier, builderNames)... | [
"func",
"validateProjectConfig",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"projectCfg",
"*",
"notifypb",
".",
"ProjectConfig",
")",
"{",
"builderNames",
":=",
"stringset",
".",
"New",
"(",
"len",
"(",
"projectCfg",
".",
"Notifiers",
")",
")",
"// ... | // validateProjectConfig returns an error if the configuration violates any of the
// requirements in the proto definition. | [
"validateProjectConfig",
"returns",
"an",
"error",
"if",
"the",
"configuration",
"violates",
"any",
"of",
"the",
"requirements",
"in",
"the",
"proto",
"definition",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/validate.go#L122-L129 |
130,748 | luci/luci-go | luci_notify/config/validate.go | validateSettings | func validateSettings(ctx *validation.Context, settings *notifypb.Settings) {
switch {
case settings.MiloHost == "":
ctx.Errorf(requiredFieldError, "milo_host")
case validation.ValidateHostname(settings.MiloHost) != nil:
ctx.Errorf(invalidFieldError, "milo_host")
}
} | go | func validateSettings(ctx *validation.Context, settings *notifypb.Settings) {
switch {
case settings.MiloHost == "":
ctx.Errorf(requiredFieldError, "milo_host")
case validation.ValidateHostname(settings.MiloHost) != nil:
ctx.Errorf(invalidFieldError, "milo_host")
}
} | [
"func",
"validateSettings",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"settings",
"*",
"notifypb",
".",
"Settings",
")",
"{",
"switch",
"{",
"case",
"settings",
".",
"MiloHost",
"==",
"\"",
"\"",
":",
"ctx",
".",
"Errorf",
"(",
"requiredFieldErro... | // validateSettings returns an error if the service configuration violates any
// of the requirements in the proto definition. | [
"validateSettings",
"returns",
"an",
"error",
"if",
"the",
"service",
"configuration",
"violates",
"any",
"of",
"the",
"requirements",
"in",
"the",
"proto",
"definition",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/validate.go#L133-L140 |
130,749 | luci/luci-go | luci_notify/config/validate.go | validateEmailTemplateFile | func validateEmailTemplateFile(ctx *validation.Context, configSet, path string, content []byte) error {
// Validate file name.
rgx := emailTemplateFilenameRegexp(ctx.Context)
if !rgx.MatchString(path) {
ctx.Errorf("filename does not match %q", rgx.String())
}
// Validate file contents.
subject, body, err := sp... | go | func validateEmailTemplateFile(ctx *validation.Context, configSet, path string, content []byte) error {
// Validate file name.
rgx := emailTemplateFilenameRegexp(ctx.Context)
if !rgx.MatchString(path) {
ctx.Errorf("filename does not match %q", rgx.String())
}
// Validate file contents.
subject, body, err := sp... | [
"func",
"validateEmailTemplateFile",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"configSet",
",",
"path",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"error",
"{",
"// Validate file name.",
"rgx",
":=",
"emailTemplateFilenameRegexp",
"(",
"ctx",
".... | // validateEmailTemplateFile validates an email template file, including
// its filename and contents. | [
"validateEmailTemplateFile",
"validates",
"an",
"email",
"template",
"file",
"including",
"its",
"filename",
"and",
"contents",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/validate.go#L144-L168 |
130,750 | luci/luci-go | logdog/server/bundleServicesClient/client.go | RegisterStream | func (c *Client) RegisterStream(ctx context.Context, in *s.RegisterStreamRequest, opts ...grpc.CallOption) (
*s.RegisterStreamResponse, error) {
resp, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_RegisterStream{RegisterStream: in},
})
if err != nil {
return nil, err
}
re... | go | func (c *Client) RegisterStream(ctx context.Context, in *s.RegisterStreamRequest, opts ...grpc.CallOption) (
*s.RegisterStreamResponse, error) {
resp, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_RegisterStream{RegisterStream: in},
})
if err != nil {
return nil, err
}
re... | [
"func",
"(",
"c",
"*",
"Client",
")",
"RegisterStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"s",
".",
"RegisterStreamRequest",
",",
"opts",
"...",
"grpc",
".",
"CallOption",
")",
"(",
"*",
"s",
".",
"RegisterStreamResponse",
",",
"erro... | // RegisterStream implements ServicesClient. | [
"RegisterStream",
"implements",
"ServicesClient",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/bundleServicesClient/client.go#L72-L83 |
130,751 | luci/luci-go | logdog/server/bundleServicesClient/client.go | LoadStream | func (c *Client) LoadStream(ctx context.Context, in *s.LoadStreamRequest, opts ...grpc.CallOption) (
*s.LoadStreamResponse, error) {
resp, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_LoadStream{LoadStream: in},
})
if err != nil {
return nil, err
}
return resp.GetLoadStr... | go | func (c *Client) LoadStream(ctx context.Context, in *s.LoadStreamRequest, opts ...grpc.CallOption) (
*s.LoadStreamResponse, error) {
resp, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_LoadStream{LoadStream: in},
})
if err != nil {
return nil, err
}
return resp.GetLoadStr... | [
"func",
"(",
"c",
"*",
"Client",
")",
"LoadStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"s",
".",
"LoadStreamRequest",
",",
"opts",
"...",
"grpc",
".",
"CallOption",
")",
"(",
"*",
"s",
".",
"LoadStreamResponse",
",",
"error",
")",
... | // LoadStream implements ServicesClient. | [
"LoadStream",
"implements",
"ServicesClient",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/bundleServicesClient/client.go#L86-L97 |
130,752 | luci/luci-go | logdog/server/bundleServicesClient/client.go | TerminateStream | func (c *Client) TerminateStream(ctx context.Context, in *s.TerminateStreamRequest, opts ...grpc.CallOption) (
*empty.Empty, error) {
_, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_TerminateStream{TerminateStream: in},
})
if err != nil {
return nil, err
}
return &empty.... | go | func (c *Client) TerminateStream(ctx context.Context, in *s.TerminateStreamRequest, opts ...grpc.CallOption) (
*empty.Empty, error) {
_, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_TerminateStream{TerminateStream: in},
})
if err != nil {
return nil, err
}
return &empty.... | [
"func",
"(",
"c",
"*",
"Client",
")",
"TerminateStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"s",
".",
"TerminateStreamRequest",
",",
"opts",
"...",
"grpc",
".",
"CallOption",
")",
"(",
"*",
"empty",
".",
"Empty",
",",
"error",
")",
... | // TerminateStream implements ServicesClient. | [
"TerminateStream",
"implements",
"ServicesClient",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/bundleServicesClient/client.go#L100-L111 |
130,753 | luci/luci-go | logdog/server/bundleServicesClient/client.go | ArchiveStream | func (c *Client) ArchiveStream(ctx context.Context, in *s.ArchiveStreamRequest, opts ...grpc.CallOption) (
*empty.Empty, error) {
_, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_ArchiveStream{ArchiveStream: in},
})
if err != nil {
return nil, err
}
return &empty.Empty{},... | go | func (c *Client) ArchiveStream(ctx context.Context, in *s.ArchiveStreamRequest, opts ...grpc.CallOption) (
*empty.Empty, error) {
_, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
Value: &s.BatchRequest_Entry_ArchiveStream{ArchiveStream: in},
})
if err != nil {
return nil, err
}
return &empty.Empty{},... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ArchiveStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"s",
".",
"ArchiveStreamRequest",
",",
"opts",
"...",
"grpc",
".",
"CallOption",
")",
"(",
"*",
"empty",
".",
"Empty",
",",
"error",
")",
"{... | // ArchiveStream implements ServicesClient. | [
"ArchiveStream",
"implements",
"ServicesClient",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/bundleServicesClient/client.go#L114-L125 |
130,754 | luci/luci-go | logdog/server/bundleServicesClient/client.go | Flush | func (c *Client) Flush() {
c.initBundler()
c.bundler.Flush()
c.outstanding.Wait()
} | go | func (c *Client) Flush() {
c.initBundler()
c.bundler.Flush()
c.outstanding.Wait()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Flush",
"(",
")",
"{",
"c",
".",
"initBundler",
"(",
")",
"\n",
"c",
".",
"bundler",
".",
"Flush",
"(",
")",
"\n",
"c",
".",
"outstanding",
".",
"Wait",
"(",
")",
"\n",
"}"
] | // Flush flushes the Bundler. It should be called when terminating to ensure
// that buffered client requests have been completed. | [
"Flush",
"flushes",
"the",
"Bundler",
".",
"It",
"should",
"be",
"called",
"when",
"terminating",
"to",
"ensure",
"that",
"buffered",
"client",
"requests",
"have",
"been",
"completed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/bundleServicesClient/client.go#L129-L133 |
130,755 | luci/luci-go | logdog/server/bundleServicesClient/client.go | bundleRPC | func (c *Client) bundleRPC(ctx context.Context, opts []grpc.CallOption, req *s.BatchRequest_Entry) (*s.BatchResponse_Entry, error) {
c.initBundler()
be := &batchEntry{
req: req,
ctx: ctx,
opts: opts,
complete: make(chan *s.BatchResponse_Entry, 1),
}
if err := c.addEntry(be); err != nil {
re... | go | func (c *Client) bundleRPC(ctx context.Context, opts []grpc.CallOption, req *s.BatchRequest_Entry) (*s.BatchResponse_Entry, error) {
c.initBundler()
be := &batchEntry{
req: req,
ctx: ctx,
opts: opts,
complete: make(chan *s.BatchResponse_Entry, 1),
}
if err := c.addEntry(be); err != nil {
re... | [
"func",
"(",
"c",
"*",
"Client",
")",
"bundleRPC",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"[",
"]",
"grpc",
".",
"CallOption",
",",
"req",
"*",
"s",
".",
"BatchRequest_Entry",
")",
"(",
"*",
"s",
".",
"BatchResponse_Entry",
",",
"error",
... | // bundleRPC adds req to the underlying Bundler, blocks until it completes, and
// returns its response. | [
"bundleRPC",
"adds",
"req",
"to",
"the",
"underlying",
"Bundler",
"blocks",
"until",
"it",
"completes",
"and",
"returns",
"its",
"response",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/bundleServicesClient/client.go#L147-L165 |
130,756 | luci/luci-go | common/iotools/bufferingreaderat.go | init | func (l *blocksLRU) init(capacity int) {
l.capacity = capacity
l.blocks = make(map[int64]*list.Element, capacity)
l.ll.Init()
} | go | func (l *blocksLRU) init(capacity int) {
l.capacity = capacity
l.blocks = make(map[int64]*list.Element, capacity)
l.ll.Init()
} | [
"func",
"(",
"l",
"*",
"blocksLRU",
")",
"init",
"(",
"capacity",
"int",
")",
"{",
"l",
".",
"capacity",
"=",
"capacity",
"\n",
"l",
".",
"blocks",
"=",
"make",
"(",
"map",
"[",
"int64",
"]",
"*",
"list",
".",
"Element",
",",
"capacity",
")",
"\n... | // init initializes LRU guts. | [
"init",
"initializes",
"LRU",
"guts",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/iotools/bufferingreaderat.go#L41-L45 |
130,757 | luci/luci-go | common/iotools/bufferingreaderat.go | prepareForAdd | func (l *blocksLRU) prepareForAdd() {
switch {
case l.ll.Len() > l.capacity:
panic("impossible")
case l.ll.Len() == l.capacity:
oldest := l.ll.Remove(l.ll.Back()).(block)
delete(l.blocks, oldest.offset)
l.evicted(oldest)
}
} | go | func (l *blocksLRU) prepareForAdd() {
switch {
case l.ll.Len() > l.capacity:
panic("impossible")
case l.ll.Len() == l.capacity:
oldest := l.ll.Remove(l.ll.Back()).(block)
delete(l.blocks, oldest.offset)
l.evicted(oldest)
}
} | [
"func",
"(",
"l",
"*",
"blocksLRU",
")",
"prepareForAdd",
"(",
")",
"{",
"switch",
"{",
"case",
"l",
".",
"ll",
".",
"Len",
"(",
")",
">",
"l",
".",
"capacity",
":",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"case",
"l",
".",
"ll",
".",
"Len",
"("... | // prepareForAdd removes oldest item from the list if it is at the capacity.
//
// Does nothing if it's not yet full. | [
"prepareForAdd",
"removes",
"oldest",
"item",
"from",
"the",
"list",
"if",
"it",
"is",
"at",
"the",
"capacity",
".",
"Does",
"nothing",
"if",
"it",
"s",
"not",
"yet",
"full",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/iotools/bufferingreaderat.go#L60-L69 |
130,758 | luci/luci-go | common/iotools/bufferingreaderat.go | grabBuf | func (r *bufferingReaderAt) grabBuf() []byte {
if len(r.pool) != 0 {
b := r.pool[len(r.pool)-1]
r.pool = r.pool[:len(r.pool)-1]
return b
}
return make([]byte, r.blockSize)
} | go | func (r *bufferingReaderAt) grabBuf() []byte {
if len(r.pool) != 0 {
b := r.pool[len(r.pool)-1]
r.pool = r.pool[:len(r.pool)-1]
return b
}
return make([]byte, r.blockSize)
} | [
"func",
"(",
"r",
"*",
"bufferingReaderAt",
")",
"grabBuf",
"(",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"r",
".",
"pool",
")",
"!=",
"0",
"{",
"b",
":=",
"r",
".",
"pool",
"[",
"len",
"(",
"r",
".",
"pool",
")",
"-",
"1",
"]",
"\n",
... | // grabBuf returns a byte slice of blockSize size. | [
"grabBuf",
"returns",
"a",
"byte",
"slice",
"of",
"blockSize",
"size",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/iotools/bufferingreaderat.go#L129-L136 |
130,759 | luci/luci-go | common/iotools/bufferingreaderat.go | recycleBuf | func (r *bufferingReaderAt) recycleBuf(b []byte) {
if cap(b) != r.blockSize {
panic("trying to return a buffer not initially requested via grabBuf")
}
if len(r.pool)+1 > cap(r.pool) {
panic("unexpected growth of byte buffer pool beyond capacity")
}
r.pool = append(r.pool, b[:cap(b)])
} | go | func (r *bufferingReaderAt) recycleBuf(b []byte) {
if cap(b) != r.blockSize {
panic("trying to return a buffer not initially requested via grabBuf")
}
if len(r.pool)+1 > cap(r.pool) {
panic("unexpected growth of byte buffer pool beyond capacity")
}
r.pool = append(r.pool, b[:cap(b)])
} | [
"func",
"(",
"r",
"*",
"bufferingReaderAt",
")",
"recycleBuf",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"if",
"cap",
"(",
"b",
")",
"!=",
"r",
".",
"blockSize",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"r",
".",
"po... | // recycleBuf is called when the buffer is no longer needed to put it for reuse. | [
"recycleBuf",
"is",
"called",
"when",
"the",
"buffer",
"is",
"no",
"longer",
"needed",
"to",
"put",
"it",
"for",
"reuse",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/iotools/bufferingreaderat.go#L139-L147 |
130,760 | luci/luci-go | common/iotools/bufferingreaderat.go | ReadAt | func (r *bufferingReaderAt) ReadAt(p []byte, offset int64) (read int, err error) {
if len(p) == 0 {
return r.r.ReadAt(p, offset)
}
r.l.Lock()
defer r.l.Unlock()
bs := int64(r.blockSize)
blockOff := int64((offset / bs) * bs) // block-aligned offset
// Sequentially read blocks that intersect with the requeste... | go | func (r *bufferingReaderAt) ReadAt(p []byte, offset int64) (read int, err error) {
if len(p) == 0 {
return r.r.ReadAt(p, offset)
}
r.l.Lock()
defer r.l.Unlock()
bs := int64(r.blockSize)
blockOff := int64((offset / bs) * bs) // block-aligned offset
// Sequentially read blocks that intersect with the requeste... | [
"func",
"(",
"r",
"*",
"bufferingReaderAt",
")",
"ReadAt",
"(",
"p",
"[",
"]",
"byte",
",",
"offset",
"int64",
")",
"(",
"read",
"int",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"p",
")",
"==",
"0",
"{",
"return",
"r",
".",
"r",
".",
"... | // ReadAt implements io.ReaderAt interface. | [
"ReadAt",
"implements",
"io",
".",
"ReaderAt",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/iotools/bufferingreaderat.go#L200-L246 |
130,761 | luci/luci-go | milo/frontend/ui/builder.go | SwarmingURL | func (mp *MachinePool) SwarmingURL() string {
if mp.SwarmingHost == "" {
return ""
}
u := &url.URL{
Scheme: "https",
Host: mp.SwarmingHost,
Path: "botlist",
RawQuery: url.Values{
"f": mp.Dimensions,
}.Encode(),
}
return u.String()
} | go | func (mp *MachinePool) SwarmingURL() string {
if mp.SwarmingHost == "" {
return ""
}
u := &url.URL{
Scheme: "https",
Host: mp.SwarmingHost,
Path: "botlist",
RawQuery: url.Values{
"f": mp.Dimensions,
}.Encode(),
}
return u.String()
} | [
"func",
"(",
"mp",
"*",
"MachinePool",
")",
"SwarmingURL",
"(",
")",
"string",
"{",
"if",
"mp",
".",
"SwarmingHost",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"u",
":=",
"&",
"url",
".",
"URL",
"{",
"Scheme",
":",
"\"",
"\"",
... | // SwarmingURL returns the swarming bot URL for the machine pool, if available. | [
"SwarmingURL",
"returns",
"the",
"swarming",
"bot",
"URL",
"for",
"the",
"machine",
"pool",
"if",
"available",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/builder.go#L110-L123 |
130,762 | luci/luci-go | milo/frontend/ui/builder.go | NewMachinePool | func NewMachinePool(c context.Context, botPool *model.BotPool) *MachinePool {
fiveMinAgo := clock.Now(c).Add(-time.Minute * 5)
result := &MachinePool{
Total: len(botPool.Bots),
Bots: make([]Bot, len(botPool.Bots)),
Dimensions: botPool.Descriptor.Dimensions().Format(),
SwarmingHost: botPool.De... | go | func NewMachinePool(c context.Context, botPool *model.BotPool) *MachinePool {
fiveMinAgo := clock.Now(c).Add(-time.Minute * 5)
result := &MachinePool{
Total: len(botPool.Bots),
Bots: make([]Bot, len(botPool.Bots)),
Dimensions: botPool.Descriptor.Dimensions().Format(),
SwarmingHost: botPool.De... | [
"func",
"NewMachinePool",
"(",
"c",
"context",
".",
"Context",
",",
"botPool",
"*",
"model",
".",
"BotPool",
")",
"*",
"MachinePool",
"{",
"fiveMinAgo",
":=",
"clock",
".",
"Now",
"(",
"c",
")",
".",
"Add",
"(",
"-",
"time",
".",
"Minute",
"*",
"5",
... | // NewMachinePool calculates stats from a model.Bot and generates a MachinePool.
// This requires a context because setting the UI Status field requires the current time. | [
"NewMachinePool",
"calculates",
"stats",
"from",
"a",
"model",
".",
"Bot",
"and",
"generates",
"a",
"MachinePool",
".",
"This",
"requires",
"a",
"context",
"because",
"setting",
"the",
"UI",
"Status",
"field",
"requires",
"the",
"current",
"time",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/builder.go#L127-L152 |
130,763 | luci/luci-go | dm/api/service/v1/walk_graph_normalize.go | Normalize | func (e *WalkGraphReq_Exclude) Normalize() error {
if len(e.Quests) > 0 {
e.Quests = e.Quests[:set.Uniq(sort.StringSlice(e.Quests))]
}
return e.Attempts.Normalize()
} | go | func (e *WalkGraphReq_Exclude) Normalize() error {
if len(e.Quests) > 0 {
e.Quests = e.Quests[:set.Uniq(sort.StringSlice(e.Quests))]
}
return e.Attempts.Normalize()
} | [
"func",
"(",
"e",
"*",
"WalkGraphReq_Exclude",
")",
"Normalize",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"e",
".",
"Quests",
")",
">",
"0",
"{",
"e",
".",
"Quests",
"=",
"e",
".",
"Quests",
"[",
":",
"set",
".",
"Uniq",
"(",
"sort",
".",
"Str... | // Normalize returns an error iff the WalkGraphReq_Exclude is invalid. | [
"Normalize",
"returns",
"an",
"error",
"iff",
"the",
"WalkGraphReq_Exclude",
"is",
"invalid",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/walk_graph_normalize.go#L68-L73 |
130,764 | luci/luci-go | dm/api/service/v1/walk_graph_normalize.go | Normalize | func (w *WalkGraphReq) Normalize() error {
if w.Auth != nil {
if err := w.Auth.Normalize(); err != nil {
return err
}
}
if w.Query == nil {
return errors.New("must specify a Query")
}
if err := w.Query.Normalize(); err != nil {
return err
}
if w.Mode == nil {
w.Mode = &WalkGraphReq_Mode{}
}
if ... | go | func (w *WalkGraphReq) Normalize() error {
if w.Auth != nil {
if err := w.Auth.Normalize(); err != nil {
return err
}
}
if w.Query == nil {
return errors.New("must specify a Query")
}
if err := w.Query.Normalize(); err != nil {
return err
}
if w.Mode == nil {
w.Mode = &WalkGraphReq_Mode{}
}
if ... | [
"func",
"(",
"w",
"*",
"WalkGraphReq",
")",
"Normalize",
"(",
")",
"error",
"{",
"if",
"w",
".",
"Auth",
"!=",
"nil",
"{",
"if",
"err",
":=",
"w",
".",
"Auth",
".",
"Normalize",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}"... | // Normalize returns an error iff the WalkGraphReq is invalid. | [
"Normalize",
"returns",
"an",
"error",
"iff",
"the",
"WalkGraphReq",
"is",
"invalid",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/walk_graph_normalize.go#L76-L141 |
130,765 | luci/luci-go | cipd/client/cipd/builder/builder.go | zipInputFiles | func zipInputFiles(ctx context.Context, files []fs.File, w io.Writer, level int) error {
logging.Infof(ctx, "About to zip %d files with compression level %d", len(files), level)
writer := zip.NewWriter(w)
defer writer.Close()
writer.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
r... | go | func zipInputFiles(ctx context.Context, files []fs.File, w io.Writer, level int) error {
logging.Infof(ctx, "About to zip %d files with compression level %d", len(files), level)
writer := zip.NewWriter(w)
defer writer.Close()
writer.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
r... | [
"func",
"zipInputFiles",
"(",
"ctx",
"context",
".",
"Context",
",",
"files",
"[",
"]",
"fs",
".",
"File",
",",
"w",
"io",
".",
"Writer",
",",
"level",
"int",
")",
"error",
"{",
"logging",
".",
"Infof",
"(",
"ctx",
",",
"\"",
"\"",
",",
"len",
"(... | // zipInputFiles deterministically builds a zip archive out of input files and
// writes it to the writer. Files are written in the order given. | [
"zipInputFiles",
"deterministically",
"builds",
"a",
"zip",
"archive",
"out",
"of",
"input",
"files",
"and",
"writes",
"it",
"to",
"the",
"writer",
".",
"Files",
"are",
"written",
"in",
"the",
"order",
"given",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/builder/builder.go#L139-L210 |
130,766 | luci/luci-go | cipd/client/cipd/builder/builder.go | makeManifestFile | func makeManifestFile(opts Options) (fs.File, error) {
if opts.VersionFile != "" && !fs.IsCleanSlashPath(opts.VersionFile) {
return nil, fmt.Errorf("version file path should be a clean path relative to a package root: %s", opts.VersionFile)
}
if err := pkg.ValidateInstallMode(opts.InstallMode); err != nil {
retu... | go | func makeManifestFile(opts Options) (fs.File, error) {
if opts.VersionFile != "" && !fs.IsCleanSlashPath(opts.VersionFile) {
return nil, fmt.Errorf("version file path should be a clean path relative to a package root: %s", opts.VersionFile)
}
if err := pkg.ValidateInstallMode(opts.InstallMode); err != nil {
retu... | [
"func",
"makeManifestFile",
"(",
"opts",
"Options",
")",
"(",
"fs",
".",
"File",
",",
"error",
")",
"{",
"if",
"opts",
".",
"VersionFile",
"!=",
"\"",
"\"",
"&&",
"!",
"fs",
".",
"IsCleanSlashPath",
"(",
"opts",
".",
"VersionFile",
")",
"{",
"return",
... | // makeManifestFile generates a package manifest file and returns it as
// File interface. | [
"makeManifestFile",
"generates",
"a",
"package",
"manifest",
"file",
"and",
"returns",
"it",
"as",
"File",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/builder/builder.go#L343-L366 |
130,767 | luci/luci-go | common/tsmon/state.go | NewState | func NewState() *State {
return &State{
store: store.NewNilStore(),
monitor: monitor.NewNilMonitor(),
invokeGlobalCallbacksOnFlush: true,
}
} | go | func NewState() *State {
return &State{
store: store.NewNilStore(),
monitor: monitor.NewNilMonitor(),
invokeGlobalCallbacksOnFlush: true,
}
} | [
"func",
"NewState",
"(",
")",
"*",
"State",
"{",
"return",
"&",
"State",
"{",
"store",
":",
"store",
".",
"NewNilStore",
"(",
")",
",",
"monitor",
":",
"monitor",
".",
"NewNilMonitor",
"(",
")",
",",
"invokeGlobalCallbacksOnFlush",
":",
"true",
",",
"}",... | // NewState returns a new State instance, configured with a nil store and nil
// monitor. By default, global callbacks that are registered will be invoked
// when flushing registered metrics. | [
"NewState",
"returns",
"a",
"new",
"State",
"instance",
"configured",
"with",
"a",
"nil",
"store",
"and",
"nil",
"monitor",
".",
"By",
"default",
"global",
"callbacks",
"that",
"are",
"registered",
"will",
"be",
"invoked",
"when",
"flushing",
"registered",
"me... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L44-L50 |
130,768 | luci/luci-go | common/tsmon/state.go | Callbacks | func (s *State) Callbacks() []Callback {
s.mu.RLock()
defer s.mu.RUnlock()
return append([]Callback{}, s.callbacks...)
} | go | func (s *State) Callbacks() []Callback {
s.mu.RLock()
defer s.mu.RUnlock()
return append([]Callback{}, s.callbacks...)
} | [
"func",
"(",
"s",
"*",
"State",
")",
"Callbacks",
"(",
")",
"[",
"]",
"Callback",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"append",
"(",
"[",
"]",
"Callback",
"{",
... | // Callbacks returns all registered Callbacks. | [
"Callbacks",
"returns",
"all",
"registered",
"Callbacks",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L61-L66 |
130,769 | luci/luci-go | common/tsmon/state.go | GlobalCallbacks | func (s *State) GlobalCallbacks() []GlobalCallback {
s.mu.RLock()
defer s.mu.RUnlock()
return append([]GlobalCallback{}, s.globalCallbacks...)
} | go | func (s *State) GlobalCallbacks() []GlobalCallback {
s.mu.RLock()
defer s.mu.RUnlock()
return append([]GlobalCallback{}, s.globalCallbacks...)
} | [
"func",
"(",
"s",
"*",
"State",
")",
"GlobalCallbacks",
"(",
")",
"[",
"]",
"GlobalCallback",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"append",
"(",
"[",
"]",
"Global... | // GlobalCallbacks returns all registered GlobalCallbacks. | [
"GlobalCallbacks",
"returns",
"all",
"registered",
"GlobalCallbacks",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L69-L74 |
130,770 | luci/luci-go | common/tsmon/state.go | InhibitGlobalCallbacksOnFlush | func (s *State) InhibitGlobalCallbacksOnFlush() {
s.mu.Lock()
defer s.mu.Unlock()
s.invokeGlobalCallbacksOnFlush = false
} | go | func (s *State) InhibitGlobalCallbacksOnFlush() {
s.mu.Lock()
defer s.mu.Unlock()
s.invokeGlobalCallbacksOnFlush = false
} | [
"func",
"(",
"s",
"*",
"State",
")",
"InhibitGlobalCallbacksOnFlush",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"invokeGlobalCallbacksOnFlush",
"=",
"false",
"\n",
... | // InhibitGlobalCallbacksOnFlush signals that the registered global callbacks
// are not to be executed upon flushing registered metrics. | [
"InhibitGlobalCallbacksOnFlush",
"signals",
"that",
"the",
"registered",
"global",
"callbacks",
"are",
"not",
"to",
"be",
"executed",
"upon",
"flushing",
"registered",
"metrics",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L78-L83 |
130,771 | luci/luci-go | common/tsmon/state.go | InvokeGlobalCallbacksOnFlush | func (s *State) InvokeGlobalCallbacksOnFlush() {
s.mu.Lock()
defer s.mu.Unlock()
s.invokeGlobalCallbacksOnFlush = true
} | go | func (s *State) InvokeGlobalCallbacksOnFlush() {
s.mu.Lock()
defer s.mu.Unlock()
s.invokeGlobalCallbacksOnFlush = true
} | [
"func",
"(",
"s",
"*",
"State",
")",
"InvokeGlobalCallbacksOnFlush",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"invokeGlobalCallbacksOnFlush",
"=",
"true",
"\n",
"}... | // InvokeGlobalCallbacksOnFlush signals that the registered global callbacks
// are to be be executed upon flushing registered metrics. | [
"InvokeGlobalCallbacksOnFlush",
"signals",
"that",
"the",
"registered",
"global",
"callbacks",
"are",
"to",
"be",
"be",
"executed",
"upon",
"flushing",
"registered",
"metrics",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L87-L92 |
130,772 | luci/luci-go | common/tsmon/state.go | Monitor | func (s *State) Monitor() monitor.Monitor {
s.mu.RLock()
defer s.mu.RUnlock()
return s.monitor
} | go | func (s *State) Monitor() monitor.Monitor {
s.mu.RLock()
defer s.mu.RUnlock()
return s.monitor
} | [
"func",
"(",
"s",
"*",
"State",
")",
"Monitor",
"(",
")",
"monitor",
".",
"Monitor",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"monitor",
"\n",
"}"
] | // Monitor returns the State's monitor. | [
"Monitor",
"returns",
"the",
"State",
"s",
"monitor",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L95-L100 |
130,773 | luci/luci-go | common/tsmon/state.go | Store | func (s *State) Store() store.Store {
s.mu.RLock()
defer s.mu.RUnlock()
return s.store
} | go | func (s *State) Store() store.Store {
s.mu.RLock()
defer s.mu.RUnlock()
return s.store
} | [
"func",
"(",
"s",
"*",
"State",
")",
"Store",
"(",
")",
"store",
".",
"Store",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"store",
"\n",
"}"
] | // Store returns the State's store. | [
"Store",
"returns",
"the",
"State",
"s",
"store",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L119-L124 |
130,774 | luci/luci-go | common/tsmon/state.go | SetMonitor | func (s *State) SetMonitor(m monitor.Monitor) {
s.mu.Lock()
defer s.mu.Unlock()
s.monitor = m
} | go | func (s *State) SetMonitor(m monitor.Monitor) {
s.mu.Lock()
defer s.mu.Unlock()
s.monitor = m
} | [
"func",
"(",
"s",
"*",
"State",
")",
"SetMonitor",
"(",
"m",
"monitor",
".",
"Monitor",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"monitor",
"=",
"m",
"\n",
"}"
... | // SetMonitor sets the Store's monitor. | [
"SetMonitor",
"sets",
"the",
"Store",
"s",
"monitor",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L127-L132 |
130,775 | luci/luci-go | common/tsmon/state.go | SetStore | func (s *State) SetStore(st store.Store) {
s.mu.Lock()
defer s.mu.Unlock()
s.store = st
} | go | func (s *State) SetStore(st store.Store) {
s.mu.Lock()
defer s.mu.Unlock()
s.store = st
} | [
"func",
"(",
"s",
"*",
"State",
")",
"SetStore",
"(",
"st",
"store",
".",
"Store",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"store",
"=",
"st",
"\n",
"}"
] | // SetStore changes the metric store. All metrics that were registered with
// the old store will be re-registered on the new store. | [
"SetStore",
"changes",
"the",
"metric",
"store",
".",
"All",
"metrics",
"that",
"were",
"registered",
"with",
"the",
"old",
"store",
"will",
"be",
"re",
"-",
"registered",
"on",
"the",
"new",
"store",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L136-L141 |
130,776 | luci/luci-go | common/tsmon/state.go | ResetCumulativeMetrics | func (s *State) ResetCumulativeMetrics(ctx context.Context) {
store := s.Store()
registry.Iter(func(m types.Metric) {
if m.Info().ValueType.IsCumulative() {
store.Reset(ctx, m)
}
})
} | go | func (s *State) ResetCumulativeMetrics(ctx context.Context) {
store := s.Store()
registry.Iter(func(m types.Metric) {
if m.Info().ValueType.IsCumulative() {
store.Reset(ctx, m)
}
})
} | [
"func",
"(",
"s",
"*",
"State",
")",
"ResetCumulativeMetrics",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"store",
":=",
"s",
".",
"Store",
"(",
")",
"\n\n",
"registry",
".",
"Iter",
"(",
"func",
"(",
"m",
"types",
".",
"Metric",
")",
"{",
"i... | // ResetCumulativeMetrics resets only cumulative metrics. | [
"ResetCumulativeMetrics",
"resets",
"only",
"cumulative",
"metrics",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L144-L152 |
130,777 | luci/luci-go | common/tsmon/state.go | RunGlobalCallbacks | func (s *State) RunGlobalCallbacks(ctx context.Context) {
for _, cb := range s.GlobalCallbacks() {
cb.Callback(ctx)
}
} | go | func (s *State) RunGlobalCallbacks(ctx context.Context) {
for _, cb := range s.GlobalCallbacks() {
cb.Callback(ctx)
}
} | [
"func",
"(",
"s",
"*",
"State",
")",
"RunGlobalCallbacks",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"for",
"_",
",",
"cb",
":=",
"range",
"s",
".",
"GlobalCallbacks",
"(",
")",
"{",
"cb",
".",
"Callback",
"(",
"ctx",
")",
"\n",
"}",
"\n",
... | // RunGlobalCallbacks runs all registered global callbacks that produce global
// metrics.
//
// See RegisterGlobalCallback for more info. | [
"RunGlobalCallbacks",
"runs",
"all",
"registered",
"global",
"callbacks",
"that",
"produce",
"global",
"metrics",
".",
"See",
"RegisterGlobalCallback",
"for",
"more",
"info",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L158-L162 |
130,778 | luci/luci-go | common/tsmon/state.go | Flush | func (s *State) Flush(ctx context.Context, mon monitor.Monitor) error {
if mon == nil {
mon = s.Monitor()
}
if mon == nil {
return errors.New("no tsmon Monitor is configured")
}
// Run any callbacks that have been registered to populate values in callback
// metrics.
s.runCallbacks(ctx)
if s.invokeGlobalC... | go | func (s *State) Flush(ctx context.Context, mon monitor.Monitor) error {
if mon == nil {
mon = s.Monitor()
}
if mon == nil {
return errors.New("no tsmon Monitor is configured")
}
// Run any callbacks that have been registered to populate values in callback
// metrics.
s.runCallbacks(ctx)
if s.invokeGlobalC... | [
"func",
"(",
"s",
"*",
"State",
")",
"Flush",
"(",
"ctx",
"context",
".",
"Context",
",",
"mon",
"monitor",
".",
"Monitor",
")",
"error",
"{",
"if",
"mon",
"==",
"nil",
"{",
"mon",
"=",
"s",
".",
"Monitor",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"m... | // Flush sends all the metrics that are registered in the application.
//
// Uses given monitor if not nil, otherwise the State's current monitor. | [
"Flush",
"sends",
"all",
"the",
"metrics",
"that",
"are",
"registered",
"in",
"the",
"application",
".",
"Uses",
"given",
"monitor",
"if",
"not",
"nil",
"otherwise",
"the",
"State",
"s",
"current",
"monitor",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L167-L216 |
130,779 | luci/luci-go | common/tsmon/state.go | resetGlobalCallbackMetrics | func (s *State) resetGlobalCallbackMetrics(ctx context.Context) {
store := s.Store()
for _, cb := range s.GlobalCallbacks() {
for _, m := range cb.metrics {
store.Reset(ctx, m)
}
}
} | go | func (s *State) resetGlobalCallbackMetrics(ctx context.Context) {
store := s.Store()
for _, cb := range s.GlobalCallbacks() {
for _, m := range cb.metrics {
store.Reset(ctx, m)
}
}
} | [
"func",
"(",
"s",
"*",
"State",
")",
"resetGlobalCallbackMetrics",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"store",
":=",
"s",
".",
"Store",
"(",
")",
"\n\n",
"for",
"_",
",",
"cb",
":=",
"range",
"s",
".",
"GlobalCallbacks",
"(",
")",
"{",
... | // resetGlobalCallbackMetrics resets metrics produced by global callbacks.
//
// See RegisterGlobalCallback for more info. | [
"resetGlobalCallbackMetrics",
"resets",
"metrics",
"produced",
"by",
"global",
"callbacks",
".",
"See",
"RegisterGlobalCallback",
"for",
"more",
"info",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L221-L229 |
130,780 | luci/luci-go | common/tsmon/state.go | runCallbacks | func (s *State) runCallbacks(ctx context.Context) {
for _, cb := range s.Callbacks() {
cb(ctx)
}
} | go | func (s *State) runCallbacks(ctx context.Context) {
for _, cb := range s.Callbacks() {
cb(ctx)
}
} | [
"func",
"(",
"s",
"*",
"State",
")",
"runCallbacks",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"for",
"_",
",",
"cb",
":=",
"range",
"s",
".",
"Callbacks",
"(",
")",
"{",
"cb",
"(",
"ctx",
")",
"\n",
"}",
"\n",
"}"
] | // runCallbacks runs any callbacks that have been registered to populate values
// in callback metrics. | [
"runCallbacks",
"runs",
"any",
"callbacks",
"that",
"have",
"been",
"registered",
"to",
"populate",
"values",
"in",
"callback",
"metrics",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/state.go#L233-L237 |
130,781 | luci/luci-go | logdog/client/butler/buffered_callback/datagram.go | assertGetDatagram | func assertGetDatagram(le *logpb.LogEntry) *logpb.Datagram {
if dg := le.GetDatagram(); dg == nil {
panic(
errors.Annotate(
InvalidStreamType,
fmt.Sprintf("got %T, expected *logpb.LogEntry_Datagram", le.Content),
).Err(),
)
} else {
return dg
}
} | go | func assertGetDatagram(le *logpb.LogEntry) *logpb.Datagram {
if dg := le.GetDatagram(); dg == nil {
panic(
errors.Annotate(
InvalidStreamType,
fmt.Sprintf("got %T, expected *logpb.LogEntry_Datagram", le.Content),
).Err(),
)
} else {
return dg
}
} | [
"func",
"assertGetDatagram",
"(",
"le",
"*",
"logpb",
".",
"LogEntry",
")",
"*",
"logpb",
".",
"Datagram",
"{",
"if",
"dg",
":=",
"le",
".",
"GetDatagram",
"(",
")",
";",
"dg",
"==",
"nil",
"{",
"panic",
"(",
"errors",
".",
"Annotate",
"(",
"InvalidS... | // assertGetDatagram panics if the passed LogEntry does not contain Datagram data, or returns it. | [
"assertGetDatagram",
"panics",
"if",
"the",
"passed",
"LogEntry",
"does",
"not",
"contain",
"Datagram",
"data",
"or",
"returns",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/buffered_callback/datagram.go#L26-L37 |
130,782 | luci/luci-go | appengine/datastorecache/manager.go | installCronRoute | func (m *manager) installCronRoute(path string, r *router.Router, base router.MiddlewareChain) {
r.GET(path, base, errHTTPHandler(m.handleManageCronGET))
} | go | func (m *manager) installCronRoute(path string, r *router.Router, base router.MiddlewareChain) {
r.GET(path, base, errHTTPHandler(m.handleManageCronGET))
} | [
"func",
"(",
"m",
"*",
"manager",
")",
"installCronRoute",
"(",
"path",
"string",
",",
"r",
"*",
"router",
".",
"Router",
",",
"base",
"router",
".",
"MiddlewareChain",
")",
"{",
"r",
".",
"GET",
"(",
"path",
",",
"base",
",",
"errHTTPHandler",
"(",
... | // installCronRoute installs a handler for this manager's cron task into the
// supplied Router at the specified path.
//
// It is recommended to assert in the middleware that this endpoint is only
// accessible from a cron task. | [
"installCronRoute",
"installs",
"a",
"handler",
"for",
"this",
"manager",
"s",
"cron",
"task",
"into",
"the",
"supplied",
"Router",
"at",
"the",
"specified",
"path",
".",
"It",
"is",
"recommended",
"to",
"assert",
"in",
"the",
"middleware",
"that",
"this",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/datastorecache/manager.go#L84-L86 |
130,783 | luci/luci-go | logdog/client/butlerlib/streamproto/streamType.go | DefaultContentType | func (t StreamType) DefaultContentType() types.ContentType {
switch logpb.StreamType(t) {
case logpb.StreamType_TEXT:
return types.ContentTypeText
case logpb.StreamType_DATAGRAM:
return types.ContentTypeLogdogDatagram
case logpb.StreamType_BINARY:
fallthrough
default:
return types.ContentTypeBinary
}
} | go | func (t StreamType) DefaultContentType() types.ContentType {
switch logpb.StreamType(t) {
case logpb.StreamType_TEXT:
return types.ContentTypeText
case logpb.StreamType_DATAGRAM:
return types.ContentTypeLogdogDatagram
case logpb.StreamType_BINARY:
fallthrough
default:
return types.ContentTypeBinary
}
} | [
"func",
"(",
"t",
"StreamType",
")",
"DefaultContentType",
"(",
")",
"types",
".",
"ContentType",
"{",
"switch",
"logpb",
".",
"StreamType",
"(",
"t",
")",
"{",
"case",
"logpb",
".",
"StreamType_TEXT",
":",
"return",
"types",
".",
"ContentTypeText",
"\n\n",
... | // DefaultContentType returns the default ContentType for a given stream type. | [
"DefaultContentType",
"returns",
"the",
"default",
"ContentType",
"for",
"a",
"given",
"stream",
"type",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butlerlib/streamproto/streamType.go#L31-L44 |
130,784 | luci/luci-go | common/api/gerrit/gerrit.go | NormalizeGerritURL | func NormalizeGerritURL(gerritURL string) (string, error) {
u, err := url.Parse(gerritURL)
if err != nil {
return "", err
}
if u.Scheme != "https" {
return "", fmt.Errorf("%s should start with https://", gerritURL)
}
if !strings.HasSuffix(u.Host, "-review.googlesource.com") {
return "", errors.New("only *-r... | go | func NormalizeGerritURL(gerritURL string) (string, error) {
u, err := url.Parse(gerritURL)
if err != nil {
return "", err
}
if u.Scheme != "https" {
return "", fmt.Errorf("%s should start with https://", gerritURL)
}
if !strings.HasSuffix(u.Host, "-review.googlesource.com") {
return "", errors.New("only *-r... | [
"func",
"NormalizeGerritURL",
"(",
"gerritURL",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"gerritURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}... | // NormalizeGerritURL returns canonical for Gerrit URL.
//
// error is returned if validation fails. | [
"NormalizeGerritURL",
"returns",
"canonical",
"for",
"Gerrit",
"URL",
".",
"error",
"is",
"returned",
"if",
"validation",
"fails",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gerrit/gerrit.go#L246-L267 |
130,785 | luci/luci-go | common/api/gerrit/gerrit.go | NewClient | func NewClient(c *http.Client, gerritURL string) (*Client, error) {
u, err := NormalizeGerritURL(gerritURL)
if err != nil {
return nil, err
}
pu, err := url.Parse(u)
if err != nil {
return nil, err
}
return &Client{c, *pu}, nil
} | go | func NewClient(c *http.Client, gerritURL string) (*Client, error) {
u, err := NormalizeGerritURL(gerritURL)
if err != nil {
return nil, err
}
pu, err := url.Parse(u)
if err != nil {
return nil, err
}
return &Client{c, *pu}, nil
} | [
"func",
"NewClient",
"(",
"c",
"*",
"http",
".",
"Client",
",",
"gerritURL",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"NormalizeGerritURL",
"(",
"gerritURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // NewClient creates a new instance of Client and validates and stores
// the URL to reach Gerrit. The result is wrapped inside a Client so that
// the apis can be called directly on the value returned by this function. | [
"NewClient",
"creates",
"a",
"new",
"instance",
"of",
"Client",
"and",
"validates",
"and",
"stores",
"the",
"URL",
"to",
"reach",
"Gerrit",
".",
"The",
"result",
"is",
"wrapped",
"inside",
"a",
"Client",
"so",
"that",
"the",
"apis",
"can",
"be",
"called",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gerrit/gerrit.go#L282-L292 |
130,786 | luci/luci-go | common/api/gerrit/gerrit.go | queryString | func (qr *ChangeQueryParams) queryString() url.Values {
qs := make(url.Values, len(qr.Options)+3)
qs.Add("q", qr.Query)
if qr.N > 0 {
qs.Add("n", strconv.Itoa(qr.N))
}
if qr.S > 0 {
qs.Add("S", strconv.Itoa(qr.S))
}
for _, o := range qr.Options {
qs.Add("o", o)
}
return qs
} | go | func (qr *ChangeQueryParams) queryString() url.Values {
qs := make(url.Values, len(qr.Options)+3)
qs.Add("q", qr.Query)
if qr.N > 0 {
qs.Add("n", strconv.Itoa(qr.N))
}
if qr.S > 0 {
qs.Add("S", strconv.Itoa(qr.S))
}
for _, o := range qr.Options {
qs.Add("o", o)
}
return qs
} | [
"func",
"(",
"qr",
"*",
"ChangeQueryParams",
")",
"queryString",
"(",
")",
"url",
".",
"Values",
"{",
"qs",
":=",
"make",
"(",
"url",
".",
"Values",
",",
"len",
"(",
"qr",
".",
"Options",
")",
"+",
"3",
")",
"\n",
"qs",
".",
"Add",
"(",
"\"",
"... | // queryString renders the ChangeQueryParams as a url.Values. | [
"queryString",
"renders",
"the",
"ChangeQueryParams",
"as",
"a",
"url",
".",
"Values",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gerrit/gerrit.go#L314-L327 |
130,787 | luci/luci-go | common/api/gerrit/gerrit.go | ChangeQuery | func (c *Client) ChangeQuery(ctx context.Context, qr ChangeQueryParams) ([]*Change, bool, error) {
var resp struct {
Collection []*Change
}
if _, err := c.get(ctx, "a/changes/", qr.queryString(), &resp.Collection); err != nil {
return nil, false, err
}
result := resp.Collection
if len(result) == 0 {
return ... | go | func (c *Client) ChangeQuery(ctx context.Context, qr ChangeQueryParams) ([]*Change, bool, error) {
var resp struct {
Collection []*Change
}
if _, err := c.get(ctx, "a/changes/", qr.queryString(), &resp.Collection); err != nil {
return nil, false, err
}
result := resp.Collection
if len(result) == 0 {
return ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ChangeQuery",
"(",
"ctx",
"context",
".",
"Context",
",",
"qr",
"ChangeQueryParams",
")",
"(",
"[",
"]",
"*",
"Change",
",",
"bool",
",",
"error",
")",
"{",
"var",
"resp",
"struct",
"{",
"Collection",
"[",
"]",
... | // ChangeQuery returns a list of Gerrit changes for a given ChangeQueryParams.
//
// One example use case for this is getting the CL for a given commit hash.
// Only the .Query property of the qr parameter is required.
//
// Returns a slice of Change, whether there are more changes to fetch
// and an error. | [
"ChangeQuery",
"returns",
"a",
"list",
"of",
"Gerrit",
"changes",
"for",
"a",
"given",
"ChangeQueryParams",
".",
"One",
"example",
"use",
"case",
"for",
"this",
"is",
"getting",
"the",
"CL",
"for",
"a",
"given",
"commit",
"hash",
".",
"Only",
"the",
".",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gerrit/gerrit.go#L336-L350 |
130,788 | luci/luci-go | common/api/gerrit/gerrit.go | queryString | func (qr *ChangeDetailsParams) queryString() url.Values {
qs := make(url.Values, len(qr.Options))
for _, o := range qr.Options {
qs.Add("o", o)
}
return qs
} | go | func (qr *ChangeDetailsParams) queryString() url.Values {
qs := make(url.Values, len(qr.Options))
for _, o := range qr.Options {
qs.Add("o", o)
}
return qs
} | [
"func",
"(",
"qr",
"*",
"ChangeDetailsParams",
")",
"queryString",
"(",
")",
"url",
".",
"Values",
"{",
"qs",
":=",
"make",
"(",
"url",
".",
"Values",
",",
"len",
"(",
"qr",
".",
"Options",
")",
")",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"qr... | // queryString renders the ChangeDetailsParams as a url.Values. | [
"queryString",
"renders",
"the",
"ChangeDetailsParams",
"as",
"a",
"url",
".",
"Values",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gerrit/gerrit.go#L364-L370 |
130,789 | luci/luci-go | common/api/gerrit/gerrit.go | CreateChange | func (c *Client) CreateChange(ctx context.Context, ci *ChangeInput) (*Change, error) {
var resp Change
if _, err := c.post(ctx, "a/changes/", ci, &resp); err != nil {
return nil, err
}
return &resp, nil
} | go | func (c *Client) CreateChange(ctx context.Context, ci *ChangeInput) (*Change, error) {
var resp Change
if _, err := c.post(ctx, "a/changes/", ci, &resp); err != nil {
return nil, err
}
return &resp, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateChange",
"(",
"ctx",
"context",
".",
"Context",
",",
"ci",
"*",
"ChangeInput",
")",
"(",
"*",
"Change",
",",
"error",
")",
"{",
"var",
"resp",
"Change",
"\n",
"if",
"_",
",",
"err",
":=",
"c",
".",
"po... | // CreateChange creates a new change in Gerrit.
//
// Returns a Change describing the newly created change or an error. | [
"CreateChange",
"creates",
"a",
"new",
"change",
"in",
"Gerrit",
".",
"Returns",
"a",
"Change",
"describing",
"the",
"newly",
"created",
"change",
"or",
"an",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gerrit/gerrit.go#L446-L452 |
130,790 | luci/luci-go | milo/buildsource/buildbot/buildstore/query.go | GetBuilds | func GetBuilds(c context.Context, q Query) (*QueryResult, error) {
switch {
case q.Master == "":
return nil, errors.New("master is required")
case q.Builder == "":
return nil, errors.New("builder is required")
}
if !EmulationEnabled(c) {
return getDatastoreBuilds(c, q, true)
}
var emulatedBuilds, buildbo... | go | func GetBuilds(c context.Context, q Query) (*QueryResult, error) {
switch {
case q.Master == "":
return nil, errors.New("master is required")
case q.Builder == "":
return nil, errors.New("builder is required")
}
if !EmulationEnabled(c) {
return getDatastoreBuilds(c, q, true)
}
var emulatedBuilds, buildbo... | [
"func",
"GetBuilds",
"(",
"c",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"*",
"QueryResult",
",",
"error",
")",
"{",
"switch",
"{",
"case",
"q",
".",
"Master",
"==",
"\"",
"\"",
":",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
... | // GetBuilds executes a build query and returns results.
// Does not check access. | [
"GetBuilds",
"executes",
"a",
"build",
"query",
"and",
"returns",
"results",
".",
"Does",
"not",
"check",
"access",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/query.go#L112-L147 |
130,791 | luci/luci-go | milo/buildsource/buildbot/buildstore/query.go | mergeBuilds | func mergeBuilds(a, b []*buildbot.Build) []*buildbot.Build {
ret := make([]*buildbot.Build, len(a), len(a)+len(b))
copy(ret, a)
// add builds from b that have unique build numbers.
aNumbers := make(map[int]struct{}, len(a))
for _, build := range a {
aNumbers[build.Number] = struct{}{}
}
for _, build := range ... | go | func mergeBuilds(a, b []*buildbot.Build) []*buildbot.Build {
ret := make([]*buildbot.Build, len(a), len(a)+len(b))
copy(ret, a)
// add builds from b that have unique build numbers.
aNumbers := make(map[int]struct{}, len(a))
for _, build := range a {
aNumbers[build.Number] = struct{}{}
}
for _, build := range ... | [
"func",
"mergeBuilds",
"(",
"a",
",",
"b",
"[",
"]",
"*",
"buildbot",
".",
"Build",
")",
"[",
"]",
"*",
"buildbot",
".",
"Build",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"*",
"buildbot",
".",
"Build",
",",
"len",
"(",
"a",
")",
",",
"len",
"... | // mergeBuilds merges builds from a and b to one slice.
// The returned builds are ordered by build numbers, descending.
//
// If a build number is present in both a and b, b's build is ignored. | [
"mergeBuilds",
"merges",
"builds",
"from",
"a",
"and",
"b",
"to",
"one",
"slice",
".",
"The",
"returned",
"builds",
"are",
"ordered",
"by",
"build",
"numbers",
"descending",
".",
"If",
"a",
"build",
"number",
"is",
"present",
"in",
"both",
"a",
"and",
"b... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/query.go#L153-L171 |
130,792 | luci/luci-go | scheduler/appengine/task/utils/kvlist.go | ValidateKVList | func ValidateKVList(kind string, list []string, sep rune) error {
for _, item := range list {
if !strings.ContainsRune(item, sep) {
return fmt.Errorf("bad %s, not a 'key%svalue' pair: %q", kind, string(sep), item)
}
}
return nil
} | go | func ValidateKVList(kind string, list []string, sep rune) error {
for _, item := range list {
if !strings.ContainsRune(item, sep) {
return fmt.Errorf("bad %s, not a 'key%svalue' pair: %q", kind, string(sep), item)
}
}
return nil
} | [
"func",
"ValidateKVList",
"(",
"kind",
"string",
",",
"list",
"[",
"]",
"string",
",",
"sep",
"rune",
")",
"error",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"list",
"{",
"if",
"!",
"strings",
".",
"ContainsRune",
"(",
"item",
",",
"sep",
")",
"... | // ValidateKVList makes sure each string in the list is valid key-value pair. | [
"ValidateKVList",
"makes",
"sure",
"each",
"string",
"in",
"the",
"list",
"is",
"valid",
"key",
"-",
"value",
"pair",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/utils/kvlist.go#L33-L40 |
130,793 | luci/luci-go | scheduler/appengine/task/utils/kvlist.go | KVListFromMap | func KVListFromMap(m map[string]string) KVList {
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
kvList := make([]KV, len(keys))
for i, k := range keys {
kvList[i] = KV{
Key: k,
Value: m[k],
}
}
return kvList
} | go | func KVListFromMap(m map[string]string) KVList {
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
kvList := make([]KV, len(keys))
for i, k := range keys {
kvList[i] = KV{
Key: k,
Value: m[k],
}
}
return kvList
} | [
"func",
"KVListFromMap",
"(",
"m",
"map",
"[",
"string",
"]",
"string",
")",
"KVList",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"m",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"m",
"{",
"keys",
"=",
"append... | // KVListFromMap converts a map to KVList. | [
"KVListFromMap",
"converts",
"a",
"map",
"to",
"KVList",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/utils/kvlist.go#L43-L57 |
130,794 | luci/luci-go | scheduler/appengine/task/utils/kvlist.go | UnpackKVList | func UnpackKVList(list []string, sep rune) (out KVList) {
for _, item := range list {
idx := strings.IndexRune(item, sep)
if idx == -1 {
continue
}
out = append(out, KV{
Key: item[:idx],
Value: item[idx+1:],
})
}
return out
} | go | func UnpackKVList(list []string, sep rune) (out KVList) {
for _, item := range list {
idx := strings.IndexRune(item, sep)
if idx == -1 {
continue
}
out = append(out, KV{
Key: item[:idx],
Value: item[idx+1:],
})
}
return out
} | [
"func",
"UnpackKVList",
"(",
"list",
"[",
"]",
"string",
",",
"sep",
"rune",
")",
"(",
"out",
"KVList",
")",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"list",
"{",
"idx",
":=",
"strings",
".",
"IndexRune",
"(",
"item",
",",
"sep",
")",
"\n",
"... | // UnpackKVList takes validated list of k-v pair strings and returns list of
// structs.
//
// Silently skips malformed strings. Use ValidateKVList to detect them before
// calling this function. | [
"UnpackKVList",
"takes",
"validated",
"list",
"of",
"k",
"-",
"v",
"pair",
"strings",
"and",
"returns",
"list",
"of",
"structs",
".",
"Silently",
"skips",
"malformed",
"strings",
".",
"Use",
"ValidateKVList",
"to",
"detect",
"them",
"before",
"calling",
"this"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/utils/kvlist.go#L64-L76 |
130,795 | luci/luci-go | scheduler/appengine/task/utils/kvlist.go | Pack | func (l KVList) Pack(sep rune) []string {
out := make([]string, len(l))
for i, kv := range l {
out[i] = kv.Key + string(sep) + kv.Value
}
return out
} | go | func (l KVList) Pack(sep rune) []string {
out := make([]string, len(l))
for i, kv := range l {
out[i] = kv.Key + string(sep) + kv.Value
}
return out
} | [
"func",
"(",
"l",
"KVList",
")",
"Pack",
"(",
"sep",
"rune",
")",
"[",
"]",
"string",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"l",
")",
")",
"\n",
"for",
"i",
",",
"kv",
":=",
"range",
"l",
"{",
"out",
"[",
"i",
... | // Pack converts KV list to a list of strings. | [
"Pack",
"converts",
"KV",
"list",
"to",
"a",
"list",
"of",
"strings",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/utils/kvlist.go#L79-L85 |
130,796 | luci/luci-go | scheduler/appengine/engine/dsset/dsset.go | makeTombstonesEntity | func (p *PopOp) makeTombstonesEntity() *tombstonesEntity {
p.entity.Tombstones = p.entity.Tombstones[:0]
for id, ts := range p.tombs {
p.entity.Tombstones = append(p.entity.Tombstones, struct {
ID string
Tombstoned time.Time
}{id, ts})
}
return p.entity
} | go | func (p *PopOp) makeTombstonesEntity() *tombstonesEntity {
p.entity.Tombstones = p.entity.Tombstones[:0]
for id, ts := range p.tombs {
p.entity.Tombstones = append(p.entity.Tombstones, struct {
ID string
Tombstoned time.Time
}{id, ts})
}
return p.entity
} | [
"func",
"(",
"p",
"*",
"PopOp",
")",
"makeTombstonesEntity",
"(",
")",
"*",
"tombstonesEntity",
"{",
"p",
".",
"entity",
".",
"Tombstones",
"=",
"p",
".",
"entity",
".",
"Tombstones",
"[",
":",
"0",
"]",
"\n",
"for",
"id",
",",
"ts",
":=",
"range",
... | // makeTombstonesEntity is used internally by FinishPop. | [
"makeTombstonesEntity",
"is",
"used",
"internally",
"by",
"FinishPop",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/dsset/dsset.go#L405-L414 |
130,797 | luci/luci-go | scheduler/appengine/engine/dsset/dsset.go | shardRoot | func (s *Set) shardRoot(c context.Context, n int) *datastore.Key {
return datastore.NewKey(c, "dsset.Shard", fmt.Sprintf("%s:%d", s.ID, n), 0, nil)
} | go | func (s *Set) shardRoot(c context.Context, n int) *datastore.Key {
return datastore.NewKey(c, "dsset.Shard", fmt.Sprintf("%s:%d", s.ID, n), 0, nil)
} | [
"func",
"(",
"s",
"*",
"Set",
")",
"shardRoot",
"(",
"c",
"context",
".",
"Context",
",",
"n",
"int",
")",
"*",
"datastore",
".",
"Key",
"{",
"return",
"datastore",
".",
"NewKey",
"(",
"c",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
... | // shardRoot returns entity group key to use for a given shard. | [
"shardRoot",
"returns",
"entity",
"group",
"key",
"to",
"use",
"for",
"a",
"given",
"shard",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/dsset/dsset.go#L529-L531 |
130,798 | luci/luci-go | scheduler/appengine/engine/dsset/dsset.go | batchOp | func batchOp(total int, op func(start, end int) error) error {
switch {
case total == 0:
return nil
case total <= batchSize:
return op(0, total)
}
errs := make(chan error)
ops := 0
offset := 0
for total > 0 {
count := batchSize
if count > total {
count = total
}
go func(start, end int) {
errs... | go | func batchOp(total int, op func(start, end int) error) error {
switch {
case total == 0:
return nil
case total <= batchSize:
return op(0, total)
}
errs := make(chan error)
ops := 0
offset := 0
for total > 0 {
count := batchSize
if count > total {
count = total
}
go func(start, end int) {
errs... | [
"func",
"batchOp",
"(",
"total",
"int",
",",
"op",
"func",
"(",
"start",
",",
"end",
"int",
")",
"error",
")",
"error",
"{",
"switch",
"{",
"case",
"total",
"==",
"0",
":",
"return",
"nil",
"\n",
"case",
"total",
"<=",
"batchSize",
":",
"return",
"... | // batchOp splits 'total' into batches and calls 'op' in parallel.
//
// Doesn't preserve order of returned errors! Don't try to deconstruct the
// returned multi error, the position of individual errors there does not
// correlate with the original array. | [
"batchOp",
"splits",
"total",
"into",
"batches",
"and",
"calls",
"op",
"in",
"parallel",
".",
"Doesn",
"t",
"preserve",
"order",
"of",
"returned",
"errors!",
"Don",
"t",
"try",
"to",
"deconstruct",
"the",
"returned",
"multi",
"error",
"the",
"position",
"of"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/dsset/dsset.go#L538-L580 |
130,799 | luci/luci-go | buildbucket/cli/cl.go | retrieveCLs | func (f *clsFlag) retrieveCLs(ctx context.Context, httpClient *http.Client, requirePatchset bool) ([]*pb.GerritChange, error) {
ret := make([]*pb.GerritChange, len(f.cls))
return ret, parallel.FanOutIn(func(work chan<- func() error) {
for i, cl := range f.cls {
i := i
work <- func() error {
change, err :=... | go | func (f *clsFlag) retrieveCLs(ctx context.Context, httpClient *http.Client, requirePatchset bool) ([]*pb.GerritChange, error) {
ret := make([]*pb.GerritChange, len(f.cls))
return ret, parallel.FanOutIn(func(work chan<- func() error) {
for i, cl := range f.cls {
i := i
work <- func() error {
change, err :=... | [
"func",
"(",
"f",
"*",
"clsFlag",
")",
"retrieveCLs",
"(",
"ctx",
"context",
".",
"Context",
",",
"httpClient",
"*",
"http",
".",
"Client",
",",
"requirePatchset",
"bool",
")",
"(",
"[",
"]",
"*",
"pb",
".",
"GerritChange",
",",
"error",
")",
"{",
"r... | // retrieveCLs retrieves GerritChange objects from f.cls.
// Makes Gerrit RPCs if necessary, in parallel. | [
"retrieveCLs",
"retrieves",
"GerritChange",
"objects",
"from",
"f",
".",
"cls",
".",
"Makes",
"Gerrit",
"RPCs",
"if",
"necessary",
"in",
"parallel",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/cl.go#L45-L60 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.