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,000
luci/luci-go
cipd/appengine/impl/model/package.go
CheckPackages
func CheckPackages(c context.Context, names []string, includeHidden bool) ([]string, error) { if len(names) == 0 { return nil, nil } pkgs := make([]*Package, len(names)) for i, n := range names { pkgs[i] = &Package{Name: n} } if err := datastore.Get(c, pkgs); err != nil { merr, ok := err.(errors.MultiErro...
go
func CheckPackages(c context.Context, names []string, includeHidden bool) ([]string, error) { if len(names) == 0 { return nil, nil } pkgs := make([]*Package, len(names)) for i, n := range names { pkgs[i] = &Package{Name: n} } if err := datastore.Get(c, pkgs); err != nil { merr, ok := err.(errors.MultiErro...
[ "func", "CheckPackages", "(", "c", "context", ".", "Context", ",", "names", "[", "]", "string", ",", "includeHidden", "bool", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "len", "(", "names", ")", "==", "0", "{", "return", "nil", ","...
// CheckPackages given a list of package names returns packages that exist, in // the order they are listed in the list. // // If includeHidden is false, omits hidden packages from the result. // // Returns only transient errors.
[ "CheckPackages", "given", "a", "list", "of", "package", "names", "returns", "packages", "that", "exist", "in", "the", "order", "they", "are", "listed", "in", "the", "list", ".", "If", "includeHidden", "is", "false", "omits", "hidden", "packages", "from", "th...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/package.go#L104-L138
130,001
luci/luci-go
cipd/appengine/impl/model/package.go
CheckPackageExists
func CheckPackageExists(c context.Context, pkg string) error { switch res, err := CheckPackages(c, []string{pkg}, true); { case err != nil: return errors.Annotate(err, "failed to check the package presence").Err() case len(res) == 0: return errors.Reason("no such package").Tag(grpcutil.NotFoundTag).Err() defaul...
go
func CheckPackageExists(c context.Context, pkg string) error { switch res, err := CheckPackages(c, []string{pkg}, true); { case err != nil: return errors.Annotate(err, "failed to check the package presence").Err() case len(res) == 0: return errors.Reason("no such package").Tag(grpcutil.NotFoundTag).Err() defaul...
[ "func", "CheckPackageExists", "(", "c", "context", ".", "Context", ",", "pkg", "string", ")", "error", "{", "switch", "res", ",", "err", ":=", "CheckPackages", "(", "c", ",", "[", "]", "string", "{", "pkg", "}", ",", "true", ")", ";", "{", "case", ...
// CheckPackageExists verifies the package exists. // // Returns gRPC-tagged NotFound error if there's no such package.
[ "CheckPackageExists", "verifies", "the", "package", "exists", ".", "Returns", "gRPC", "-", "tagged", "NotFound", "error", "if", "there", "s", "no", "such", "package", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/package.go#L143-L152
130,002
luci/luci-go
cipd/appengine/impl/model/package.go
SetPackageHidden
func SetPackageHidden(c context.Context, pkg string, hidden bool) error { return Txn(c, "SetPackageHidden", func(c context.Context) error { p := &Package{Name: pkg} switch err := datastore.Get(c, p); { case err == datastore.ErrNoSuchEntity: return err case err != nil: return transient.Tag.Apply(err) ca...
go
func SetPackageHidden(c context.Context, pkg string, hidden bool) error { return Txn(c, "SetPackageHidden", func(c context.Context) error { p := &Package{Name: pkg} switch err := datastore.Get(c, p); { case err == datastore.ErrNoSuchEntity: return err case err != nil: return transient.Tag.Apply(err) ca...
[ "func", "SetPackageHidden", "(", "c", "context", ".", "Context", ",", "pkg", "string", ",", "hidden", "bool", ")", "error", "{", "return", "Txn", "(", "c", ",", "\"", "\"", ",", "func", "(", "c", "context", ".", "Context", ")", "error", "{", "p", "...
// SetPackageHidden updates Hidden field of the package. // // If the package is missing returns datastore.ErrNoSuchEntity. All other errors // are transient.
[ "SetPackageHidden", "updates", "Hidden", "field", "of", "the", "package", ".", "If", "the", "package", "is", "missing", "returns", "datastore", ".", "ErrNoSuchEntity", ".", "All", "other", "errors", "are", "transient", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/package.go#L158-L181
130,003
luci/luci-go
milo/buildsource/buildbucket/build.go
BuildAddress
func BuildAddress(build *buildbucketpb.Build) string { if build == nil { return "" } num := strconv.FormatInt(build.Id, 10) if build.Number != 0 { num = strconv.FormatInt(int64(build.Number), 10) } b := build.Builder return fmt.Sprintf("luci.%s.%s/%s/%s", b.Project, b.Bucket, b.Builder, num) }
go
func BuildAddress(build *buildbucketpb.Build) string { if build == nil { return "" } num := strconv.FormatInt(build.Id, 10) if build.Number != 0 { num = strconv.FormatInt(int64(build.Number), 10) } b := build.Builder return fmt.Sprintf("luci.%s.%s/%s/%s", b.Project, b.Bucket, b.Builder, num) }
[ "func", "BuildAddress", "(", "build", "*", "buildbucketpb", ".", "Build", ")", "string", "{", "if", "build", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "num", ":=", "strconv", ".", "FormatInt", "(", "build", ".", "Id", ",", "10", ")", ...
// BuildAddress constructs the build address of a buildbucketpb.Build. // This is used as the key for the BuildSummary entity.
[ "BuildAddress", "constructs", "the", "build", "address", "of", "a", "buildbucketpb", ".", "Build", ".", "This", "is", "used", "as", "the", "key", "for", "the", "BuildSummary", "entity", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L57-L67
130,004
luci/luci-go
milo/buildsource/buildbucket/build.go
GetBuildSummary
func GetBuildSummary(c context.Context, id int64) (*model.BuildSummary, error) { // The host is set to prod because buildbot is hardcoded to talk to prod. uri := fmt.Sprintf("buildbucket://cr-buildbucket.appspot.com/build/%d", id) bs := make([]*model.BuildSummary, 0, 1) q := datastore.NewQuery("BuildSummary").Eq("C...
go
func GetBuildSummary(c context.Context, id int64) (*model.BuildSummary, error) { // The host is set to prod because buildbot is hardcoded to talk to prod. uri := fmt.Sprintf("buildbucket://cr-buildbucket.appspot.com/build/%d", id) bs := make([]*model.BuildSummary, 0, 1) q := datastore.NewQuery("BuildSummary").Eq("C...
[ "func", "GetBuildSummary", "(", "c", "context", ".", "Context", ",", "id", "int64", ")", "(", "*", "model", ".", "BuildSummary", ",", "error", ")", "{", "// The host is set to prod because buildbot is hardcoded to talk to prod.", "uri", ":=", "fmt", ".", "Sprintf", ...
// GetBuildSummary fetches a build summary where the Context URI matches the // given address.
[ "GetBuildSummary", "fetches", "a", "build", "summary", "where", "the", "Context", "URI", "matches", "the", "given", "address", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L146-L159
130,005
luci/luci-go
milo/buildsource/buildbucket/build.go
getBlame
func getBlame(c context.Context, host string, b *buildbucketpb.Build) ([]*ui.Commit, error) { commit := b.GetInput().GetGitilesCommit() // No commit? No blamelist. if commit == nil { return nil, nil } // TODO(hinoka): This converts a buildbucketpb.Commit into a string // and back into a buildbucketpb.Commit. T...
go
func getBlame(c context.Context, host string, b *buildbucketpb.Build) ([]*ui.Commit, error) { commit := b.GetInput().GetGitilesCommit() // No commit? No blamelist. if commit == nil { return nil, nil } // TODO(hinoka): This converts a buildbucketpb.Commit into a string // and back into a buildbucketpb.Commit. T...
[ "func", "getBlame", "(", "c", "context", ".", "Context", ",", "host", "string", ",", "b", "*", "buildbucketpb", ".", "Build", ")", "(", "[", "]", "*", "ui", ".", "Commit", ",", "error", ")", "{", "commit", ":=", "b", ".", "GetInput", "(", ")", "....
// getBlame fetches blame information from Gitiles. // This requires the BuildSummary to be indexed in Milo.
[ "getBlame", "fetches", "blame", "information", "from", "Gitiles", ".", "This", "requires", "the", "BuildSummary", "to", "be", "indexed", "in", "Milo", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L163-L176
130,006
luci/luci-go
milo/buildsource/buildbucket/build.go
getBugLink
func getBugLink(c *router.Context, b *buildbucketpb.Build) (string, error) { project, err := common.GetProject(c.Context, b.Builder.GetProject()) if err != nil || proto.Equal(&project.BuildBugTemplate, &config.BugTemplate{}) { return "", err } builderPath := fmt.Sprintf("/p/%s/builders/%s/%s", b.Builder.GetProje...
go
func getBugLink(c *router.Context, b *buildbucketpb.Build) (string, error) { project, err := common.GetProject(c.Context, b.Builder.GetProject()) if err != nil || proto.Equal(&project.BuildBugTemplate, &config.BugTemplate{}) { return "", err } builderPath := fmt.Sprintf("/p/%s/builders/%s/%s", b.Builder.GetProje...
[ "func", "getBugLink", "(", "c", "*", "router", ".", "Context", ",", "b", "*", "buildbucketpb", ".", "Build", ")", "(", "string", ",", "error", ")", "{", "project", ",", "err", ":=", "common", ".", "GetProject", "(", "c", ".", "Context", ",", "b", "...
// getBugLink attempts to formulate and return the build page bug link // for the given build.
[ "getBugLink", "attempts", "to", "formulate", "and", "return", "the", "build", "page", "bug", "link", "for", "the", "given", "build", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L180-L201
130,007
luci/luci-go
milo/buildsource/buildbucket/build.go
searchBuildset
func searchBuildset(buildset string, fields *field_mask.FieldMask) *buildbucketpb.SearchBuildsRequest { return &buildbucketpb.SearchBuildsRequest{ Predicate: &buildbucketpb.BuildPredicate{ Tags: []*buildbucketpb.StringPair{{Key: "buildset", Value: buildset}}, }, Fields: fields, PageSize: 1000, } }
go
func searchBuildset(buildset string, fields *field_mask.FieldMask) *buildbucketpb.SearchBuildsRequest { return &buildbucketpb.SearchBuildsRequest{ Predicate: &buildbucketpb.BuildPredicate{ Tags: []*buildbucketpb.StringPair{{Key: "buildset", Value: buildset}}, }, Fields: fields, PageSize: 1000, } }
[ "func", "searchBuildset", "(", "buildset", "string", ",", "fields", "*", "field_mask", ".", "FieldMask", ")", "*", "buildbucketpb", ".", "SearchBuildsRequest", "{", "return", "&", "buildbucketpb", ".", "SearchBuildsRequest", "{", "Predicate", ":", "&", "buildbucke...
// searchBuildset creates a searchBuildsRequest that looks for a buildset tag.
[ "searchBuildset", "creates", "a", "searchBuildsRequest", "that", "looks", "for", "a", "buildset", "tag", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L204-L212
130,008
luci/luci-go
milo/buildsource/buildbucket/build.go
getRelatedBuilds
func getRelatedBuilds(c context.Context, client buildbucketpb.BuildsClient, b *buildbucketpb.Build) ([]*ui.Build, error) { var bs []string for _, buildset := range protoutil.BuildSets(b) { // HACK(hinoka): Remove the commit/git/ buildsets because we know they're redundant // with the commit/gitiles/ buildsets, an...
go
func getRelatedBuilds(c context.Context, client buildbucketpb.BuildsClient, b *buildbucketpb.Build) ([]*ui.Build, error) { var bs []string for _, buildset := range protoutil.BuildSets(b) { // HACK(hinoka): Remove the commit/git/ buildsets because we know they're redundant // with the commit/gitiles/ buildsets, an...
[ "func", "getRelatedBuilds", "(", "c", "context", ".", "Context", ",", "client", "buildbucketpb", ".", "BuildsClient", ",", "b", "*", "buildbucketpb", ".", "Build", ")", "(", "[", "]", "*", "ui", ".", "Build", ",", "error", ")", "{", "var", "bs", "[", ...
// getRelatedBuilds fetches build summaries of builds with the same buildset as b.
[ "getRelatedBuilds", "fetches", "build", "summaries", "of", "builds", "with", "the", "same", "buildset", "as", "b", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L229-L282
130,009
luci/luci-go
milo/buildsource/buildbucket/build.go
GetBuilderID
func GetBuilderID(c context.Context, id int64) (builder *buildbucketpb.BuilderID, number int32, err error) { host, err := getHost(c) if err != nil { return } client, err := buildbucketClient(c, host, auth.AsUser) if err != nil { return } br, err := client.GetBuild(c, &buildbucketpb.GetBuildRequest{ Id: ...
go
func GetBuilderID(c context.Context, id int64) (builder *buildbucketpb.BuilderID, number int32, err error) { host, err := getHost(c) if err != nil { return } client, err := buildbucketClient(c, host, auth.AsUser) if err != nil { return } br, err := client.GetBuild(c, &buildbucketpb.GetBuildRequest{ Id: ...
[ "func", "GetBuilderID", "(", "c", "context", ".", "Context", ",", "id", "int64", ")", "(", "builder", "*", "buildbucketpb", ".", "BuilderID", ",", "number", "int32", ",", "err", "error", ")", "{", "host", ",", "err", ":=", "getHost", "(", "c", ")", "...
// GetBuilderID returns the builder, and maybe the build number, for a build id.
[ "GetBuilderID", "returns", "the", "builder", "and", "maybe", "the", "build", "number", "for", "a", "build", "id", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L292-L319
130,010
luci/luci-go
milo/buildsource/buildbucket/build.go
GetBuildPage
func GetBuildPage(ctx *router.Context, br buildbucketpb.GetBuildRequest, forceBlamelist bool) (*ui.BuildPage, error) { c := ctx.Context host, err := getHost(c) if err != nil { return nil, err } client, err := buildbucketClient(c, host, auth.AsUser) if err != nil { return nil, err } var b *buildbucketpb.Bui...
go
func GetBuildPage(ctx *router.Context, br buildbucketpb.GetBuildRequest, forceBlamelist bool) (*ui.BuildPage, error) { c := ctx.Context host, err := getHost(c) if err != nil { return nil, err } client, err := buildbucketClient(c, host, auth.AsUser) if err != nil { return nil, err } var b *buildbucketpb.Bui...
[ "func", "GetBuildPage", "(", "ctx", "*", "router", ".", "Context", ",", "br", "buildbucketpb", ".", "GetBuildRequest", ",", "forceBlamelist", "bool", ")", "(", "*", "ui", ".", "BuildPage", ",", "error", ")", "{", "c", ":=", "ctx", ".", "Context", "\n", ...
// GetBuildPage fetches the full set of information for a Milo build page from Buildbucket. // Including the blamelist and other auxiliary information.
[ "GetBuildPage", "fetches", "the", "full", "set", "of", "information", "for", "a", "Milo", "build", "page", "from", "Buildbucket", ".", "Including", "the", "blamelist", "and", "other", "auxiliary", "information", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/build.go#L354-L415
130,011
luci/luci-go
cipd/client/cipd/internal/instancecache.go
NewInstanceCache
func NewInstanceCache(fs fs.FileSystem) *InstanceCache { return &InstanceCache{ fs: fs, maxSize: instanceCacheMaxSize, maxAge: instanceCacheMaxAge, } }
go
func NewInstanceCache(fs fs.FileSystem) *InstanceCache { return &InstanceCache{ fs: fs, maxSize: instanceCacheMaxSize, maxAge: instanceCacheMaxAge, } }
[ "func", "NewInstanceCache", "(", "fs", "fs", ".", "FileSystem", ")", "*", "InstanceCache", "{", "return", "&", "InstanceCache", "{", "fs", ":", "fs", ",", "maxSize", ":", "instanceCacheMaxSize", ",", "maxAge", ":", "instanceCacheMaxAge", ",", "}", "\n", "}" ...
// NewInstanceCache initializes InstanceCache. // // fs will be the root of the cache.
[ "NewInstanceCache", "initializes", "InstanceCache", ".", "fs", "will", "be", "the", "root", "of", "the", "cache", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L75-L81
130,012
luci/luci-go
cipd/client/cipd/internal/instancecache.go
Close
func (f *cacheFile) Close(ctx context.Context, corrupt bool) error { var err error if err = f.File.Close(); err != nil && err != os.ErrClosed { corruptText := "" if corrupt { corruptText = " corrupt" } logging.WithError(err).Warningf(ctx, "failed to close%s cache file", corruptText) } else { err = nil ...
go
func (f *cacheFile) Close(ctx context.Context, corrupt bool) error { var err error if err = f.File.Close(); err != nil && err != os.ErrClosed { corruptText := "" if corrupt { corruptText = " corrupt" } logging.WithError(err).Warningf(ctx, "failed to close%s cache file", corruptText) } else { err = nil ...
[ "func", "(", "f", "*", "cacheFile", ")", "Close", "(", "ctx", "context", ".", "Context", ",", "corrupt", "bool", ")", "error", "{", "var", "err", "error", "\n", "if", "err", "=", "f", ".", "File", ".", "Close", "(", ")", ";", "err", "!=", "nil", ...
// Close removes this file from the cache if corrupt is true. // // This will be true if the cached file is determined to be broken at a higher // level. // // This implements pkg.Source.
[ "Close", "removes", "this", "file", "from", "the", "cache", "if", "corrupt", "is", "true", ".", "This", "will", "be", "true", "if", "the", "cached", "file", "is", "determined", "to", "be", "broken", "at", "a", "higher", "level", ".", "This", "implements"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L94-L116
130,013
luci/luci-go
cipd/client/cipd/internal/instancecache.go
Get
func (c *InstanceCache) Get(ctx context.Context, pin common.Pin, now time.Time) (pkg.Source, error) { if err := common.ValidatePin(pin, common.AnyHash); err != nil { return nil, err } path, err := c.fs.RootRelToAbs(pin.InstanceID) if err != nil { return nil, fmt.Errorf("invalid instance ID %q", pin.InstanceID)...
go
func (c *InstanceCache) Get(ctx context.Context, pin common.Pin, now time.Time) (pkg.Source, error) { if err := common.ValidatePin(pin, common.AnyHash); err != nil { return nil, err } path, err := c.fs.RootRelToAbs(pin.InstanceID) if err != nil { return nil, fmt.Errorf("invalid instance ID %q", pin.InstanceID)...
[ "func", "(", "c", "*", "InstanceCache", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "pin", "common", ".", "Pin", ",", "now", "time", ".", "Time", ")", "(", "pkg", ".", "Source", ",", "error", ")", "{", "if", "err", ":=", "common", "."...
// Get searches for the instance in the cache and opens it for reading. // // If the instance is not found, returns an os.IsNotExists error.
[ "Get", "searches", "for", "the", "instance", "in", "the", "cache", "and", "opens", "it", "for", "reading", ".", "If", "the", "instance", "is", "not", "found", "returns", "an", "os", ".", "IsNotExists", "error", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L126-L146
130,014
luci/luci-go
cipd/client/cipd/internal/instancecache.go
Put
func (c *InstanceCache) Put(ctx context.Context, pin common.Pin, now time.Time, write func(*os.File) error) error { if err := common.ValidatePin(pin, common.AnyHash); err != nil { return err } path, err := c.fs.RootRelToAbs(pin.InstanceID) if err != nil { return fmt.Errorf("invalid instance ID %q", pin.Instance...
go
func (c *InstanceCache) Put(ctx context.Context, pin common.Pin, now time.Time, write func(*os.File) error) error { if err := common.ValidatePin(pin, common.AnyHash); err != nil { return err } path, err := c.fs.RootRelToAbs(pin.InstanceID) if err != nil { return fmt.Errorf("invalid instance ID %q", pin.Instance...
[ "func", "(", "c", "*", "InstanceCache", ")", "Put", "(", "ctx", "context", ".", "Context", ",", "pin", "common", ".", "Pin", ",", "now", "time", ".", "Time", ",", "write", "func", "(", "*", "os", ".", "File", ")", "error", ")", "error", "{", "if"...
// Put caches an instance. // // write must write the instance contents. May remove some instances from the // cache that were not accessed for a long time.
[ "Put", "caches", "an", "instance", ".", "write", "must", "write", "the", "instance", "contents", ".", "May", "remove", "some", "instances", "from", "the", "cache", "that", "were", "not", "accessed", "for", "a", "long", "time", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L152-L170
130,015
luci/luci-go
cipd/client/cipd/internal/instancecache.go
GC
func (c *InstanceCache) GC(ctx context.Context, now time.Time) { c.withState(ctx, now, func(s *messages.InstanceCache) { c.gc(ctx, s, now) }) }
go
func (c *InstanceCache) GC(ctx context.Context, now time.Time) { c.withState(ctx, now, func(s *messages.InstanceCache) { c.gc(ctx, s, now) }) }
[ "func", "(", "c", "*", "InstanceCache", ")", "GC", "(", "ctx", "context", ".", "Context", ",", "now", "time", ".", "Time", ")", "{", "c", ".", "withState", "(", "ctx", ",", "now", ",", "func", "(", "s", "*", "messages", ".", "InstanceCache", ")", ...
// GC opportunistically purges entries that haven't been touched for too long.
[ "GC", "opportunistically", "purges", "entries", "that", "haven", "t", "been", "touched", "for", "too", "long", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L173-L177
130,016
luci/luci-go
cipd/client/cipd/internal/instancecache.go
readState
func (c *InstanceCache) readState(ctx context.Context, state *messages.InstanceCache, now time.Time) { statePath, err := c.fs.RootRelToAbs(instanceCacheStateFilename) if err != nil { panic("impossible") } stateBytes, err := ioutil.ReadFile(statePath) sync := false switch { case os.IsNotExist(err): sync = tr...
go
func (c *InstanceCache) readState(ctx context.Context, state *messages.InstanceCache, now time.Time) { statePath, err := c.fs.RootRelToAbs(instanceCacheStateFilename) if err != nil { panic("impossible") } stateBytes, err := ioutil.ReadFile(statePath) sync := false switch { case os.IsNotExist(err): sync = tr...
[ "func", "(", "c", "*", "InstanceCache", ")", "readState", "(", "ctx", "context", ".", "Context", ",", "state", "*", "messages", ".", "InstanceCache", ",", "now", "time", ".", "Time", ")", "{", "statePath", ",", "err", ":=", "c", ".", "fs", ".", "Root...
// readState loads cache state from the state file. // If the file does not exist, corrupted or its state was not synchronized // with the instance files for a long time, synchronizes it. // Newly discovered files are considered last accessed at zero time. // If synchronization fails, then the state is considered empty...
[ "readState", "loads", "cache", "state", "from", "the", "state", "file", ".", "If", "the", "file", "does", "not", "exist", "corrupted", "or", "its", "state", "was", "not", "synchronized", "with", "the", "instance", "files", "for", "a", "long", "time", "sync...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L259-L298
130,017
luci/luci-go
cipd/client/cipd/internal/instancecache.go
syncState
func (c *InstanceCache) syncState(ctx context.Context, state *messages.InstanceCache, now time.Time) error { root, err := os.Open(c.fs.Root()) switch { case os.IsNotExist(err): state.Entries = nil case err != nil: return err default: instanceIDs, err := root.Readdirnames(0) if err != nil { return err...
go
func (c *InstanceCache) syncState(ctx context.Context, state *messages.InstanceCache, now time.Time) error { root, err := os.Open(c.fs.Root()) switch { case os.IsNotExist(err): state.Entries = nil case err != nil: return err default: instanceIDs, err := root.Readdirnames(0) if err != nil { return err...
[ "func", "(", "c", "*", "InstanceCache", ")", "syncState", "(", "ctx", "context", ".", "Context", ",", "state", "*", "messages", ".", "InstanceCache", ",", "now", "time", ".", "Time", ")", "error", "{", "root", ",", "err", ":=", "os", ".", "Open", "("...
// syncState synchronizes the list of instances in the state file with instance // files. // // Preserves lastAccess of existing instances. Newly discovered files are // considered last accessed now.
[ "syncState", "synchronizes", "the", "list", "of", "instances", "in", "the", "state", "file", "with", "instance", "files", ".", "Preserves", "lastAccess", "of", "existing", "instances", ".", "Newly", "discovered", "files", "are", "considered", "last", "accessed", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L305-L347
130,018
luci/luci-go
cipd/client/cipd/internal/instancecache.go
saveState
func (c *InstanceCache) saveState(ctx context.Context, state *messages.InstanceCache) error { stateBytes, err := MarshalWithSHA256(state) if err != nil { return err } statePath, err := c.fs.RootRelToAbs(instanceCacheStateFilename) if err != nil { panic("impossible") } return fs.EnsureFile(ctx, c.fs, stateP...
go
func (c *InstanceCache) saveState(ctx context.Context, state *messages.InstanceCache) error { stateBytes, err := MarshalWithSHA256(state) if err != nil { return err } statePath, err := c.fs.RootRelToAbs(instanceCacheStateFilename) if err != nil { panic("impossible") } return fs.EnsureFile(ctx, c.fs, stateP...
[ "func", "(", "c", "*", "InstanceCache", ")", "saveState", "(", "ctx", "context", ".", "Context", ",", "state", "*", "messages", ".", "InstanceCache", ")", "error", "{", "stateBytes", ",", "err", ":=", "MarshalWithSHA256", "(", "state", ")", "\n", "if", "...
// saveState persists the cache state.
[ "saveState", "persists", "the", "cache", "state", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L350-L362
130,019
luci/luci-go
cipd/client/cipd/internal/instancecache.go
withState
func (c *InstanceCache) withState(ctx context.Context, now time.Time, f func(*messages.InstanceCache)) { state := &messages.InstanceCache{} start := clock.Now(ctx) defer func() { totalTime := clock.Since(ctx, start) if totalTime > 2*time.Second { logging.Warningf( ctx, "cipd: instance cache state update ...
go
func (c *InstanceCache) withState(ctx context.Context, now time.Time, f func(*messages.InstanceCache)) { state := &messages.InstanceCache{} start := clock.Now(ctx) defer func() { totalTime := clock.Since(ctx, start) if totalTime > 2*time.Second { logging.Warningf( ctx, "cipd: instance cache state update ...
[ "func", "(", "c", "*", "InstanceCache", ")", "withState", "(", "ctx", "context", ".", "Context", ",", "now", "time", ".", "Time", ",", "f", "func", "(", "*", "messages", ".", "InstanceCache", ")", ")", "{", "state", ":=", "&", "messages", ".", "Insta...
// withState loads cache state from the state file, calls f and saves it back. // See also readState.
[ "withState", "loads", "cache", "state", "from", "the", "state", "file", "calls", "f", "and", "saves", "it", "back", ".", "See", "also", "readState", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L366-L387
130,020
luci/luci-go
cipd/client/cipd/internal/instancecache.go
getAccessTime
func (c *InstanceCache) getAccessTime(ctx context.Context, now time.Time, pin common.Pin) (lastAccess time.Time, ok bool) { c.withState(ctx, now, func(s *messages.InstanceCache) { var entry *messages.InstanceCache_Entry if entry, ok = s.Entries[pin.InstanceID]; ok { lastAccess = google.TimeFromProto(entry.LastA...
go
func (c *InstanceCache) getAccessTime(ctx context.Context, now time.Time, pin common.Pin) (lastAccess time.Time, ok bool) { c.withState(ctx, now, func(s *messages.InstanceCache) { var entry *messages.InstanceCache_Entry if entry, ok = s.Entries[pin.InstanceID]; ok { lastAccess = google.TimeFromProto(entry.LastA...
[ "func", "(", "c", "*", "InstanceCache", ")", "getAccessTime", "(", "ctx", "context", ".", "Context", ",", "now", "time", ".", "Time", ",", "pin", "common", ".", "Pin", ")", "(", "lastAccess", "time", ".", "Time", ",", "ok", "bool", ")", "{", "c", "...
// getAccessTime returns last access time of an instance. // Used for testing.
[ "getAccessTime", "returns", "last", "access", "time", "of", "an", "instance", ".", "Used", "for", "testing", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/instancecache.go#L391-L399
130,021
luci/luci-go
tokenserver/auth/machine/auth_method.go
Authenticate
func (m *MachineTokenAuthMethod) Authenticate(c context.Context, r *http.Request) (*auth.User, error) { token := r.Header.Get(MachineTokenHeader) if token == "" { return nil, nil // no token -> the auth method is not applicable } // Deserialize both envelope and the body. envelope, body, err := deserialize(toke...
go
func (m *MachineTokenAuthMethod) Authenticate(c context.Context, r *http.Request) (*auth.User, error) { token := r.Header.Get(MachineTokenHeader) if token == "" { return nil, nil // no token -> the auth method is not applicable } // Deserialize both envelope and the body. envelope, body, err := deserialize(toke...
[ "func", "(", "m", "*", "MachineTokenAuthMethod", ")", "Authenticate", "(", "c", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ")", "(", "*", "auth", ".", "User", ",", "error", ")", "{", "token", ":=", "r", ".", "Header", ".", "G...
// Authenticate extracts peer's identity from the incoming request. // // It logs detailed errors in log, but returns only generic "bad credential" // error to the caller, to avoid leaking unnecessary information.
[ "Authenticate", "extracts", "peer", "s", "identity", "from", "the", "incoming", "request", ".", "It", "logs", "detailed", "errors", "in", "log", "but", "returns", "only", "generic", "bad", "credential", "error", "to", "the", "caller", "to", "avoid", "leaking",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/auth/machine/auth_method.go#L80-L137
130,022
luci/luci-go
tokenserver/auth/machine/auth_method.go
logTokenError
func logTokenError(c context.Context, r *http.Request, tok *tokenserver.MachineTokenBody, err error, msg string, args ...string) { fields := logging.Fields{"remoteAddr": r.RemoteAddr} if tok != nil { // Note that if token wasn't properly signed, these fields may contain // garbage. fields["machineFqdn"] = tok.M...
go
func logTokenError(c context.Context, r *http.Request, tok *tokenserver.MachineTokenBody, err error, msg string, args ...string) { fields := logging.Fields{"remoteAddr": r.RemoteAddr} if tok != nil { // Note that if token wasn't properly signed, these fields may contain // garbage. fields["machineFqdn"] = tok.M...
[ "func", "logTokenError", "(", "c", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ",", "tok", "*", "tokenserver", ".", "MachineTokenBody", ",", "err", "error", ",", "msg", "string", ",", "args", "...", "string", ")", "{", "fields", "...
// logTokenError adds a warning-level log entry with details about the request.
[ "logTokenError", "adds", "a", "warning", "-", "level", "log", "entry", "with", "details", "about", "the", "request", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/auth/machine/auth_method.go#L140-L156
130,023
luci/luci-go
tokenserver/auth/machine/auth_method.go
deserialize
func deserialize(token string) (*tokenserver.MachineTokenEnvelope, *tokenserver.MachineTokenBody, error) { tokenBinBlob, err := base64.RawStdEncoding.DecodeString(token) if err != nil { return nil, nil, err } envelope := &tokenserver.MachineTokenEnvelope{} if err := proto.Unmarshal(tokenBinBlob, envelope); err !...
go
func deserialize(token string) (*tokenserver.MachineTokenEnvelope, *tokenserver.MachineTokenBody, error) { tokenBinBlob, err := base64.RawStdEncoding.DecodeString(token) if err != nil { return nil, nil, err } envelope := &tokenserver.MachineTokenEnvelope{} if err := proto.Unmarshal(tokenBinBlob, envelope); err !...
[ "func", "deserialize", "(", "token", "string", ")", "(", "*", "tokenserver", ".", "MachineTokenEnvelope", ",", "*", "tokenserver", ".", "MachineTokenBody", ",", "error", ")", "{", "tokenBinBlob", ",", "err", ":=", "base64", ".", "RawStdEncoding", ".", "DecodeS...
// deserialize parses MachineTokenEnvelope and MachineTokenBody.
[ "deserialize", "parses", "MachineTokenEnvelope", "and", "MachineTokenBody", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/auth/machine/auth_method.go#L159-L173
130,024
luci/luci-go
tokenserver/auth/machine/auth_method.go
checkExpiration
func checkExpiration(body *tokenserver.MachineTokenBody, now time.Time) error { notBefore := time.Unix(int64(body.IssuedAt), 0) notAfter := notBefore.Add(time.Duration(body.Lifetime) * time.Second) if now.Before(notBefore.Add(-allowedClockDrift)) { diff := notBefore.Sub(now) return fmt.Errorf("token is not valid...
go
func checkExpiration(body *tokenserver.MachineTokenBody, now time.Time) error { notBefore := time.Unix(int64(body.IssuedAt), 0) notAfter := notBefore.Add(time.Duration(body.Lifetime) * time.Second) if now.Before(notBefore.Add(-allowedClockDrift)) { diff := notBefore.Sub(now) return fmt.Errorf("token is not valid...
[ "func", "checkExpiration", "(", "body", "*", "tokenserver", ".", "MachineTokenBody", ",", "now", "time", ".", "Time", ")", "error", "{", "notBefore", ":=", "time", ".", "Unix", "(", "int64", "(", "body", ".", "IssuedAt", ")", ",", "0", ")", "\n", "notA...
// checkExpiration returns nil if the token is non-expired yet. // // Allows some clock drift, see allowedClockDrift.
[ "checkExpiration", "returns", "nil", "if", "the", "token", "is", "non", "-", "expired", "yet", ".", "Allows", "some", "clock", "drift", "see", "allowedClockDrift", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/auth/machine/auth_method.go#L178-L190
130,025
luci/luci-go
tokenserver/auth/machine/auth_method.go
checkSignature
func (m *MachineTokenAuthMethod) checkSignature(c context.Context, signerEmail string, envelope *tokenserver.MachineTokenEnvelope) error { // Note that FetchCertificatesForServiceAccount implements caching inside. fetcher := m.certsFetcher if fetcher == nil { fetcher = signing.FetchCertificatesForServiceAccount }...
go
func (m *MachineTokenAuthMethod) checkSignature(c context.Context, signerEmail string, envelope *tokenserver.MachineTokenEnvelope) error { // Note that FetchCertificatesForServiceAccount implements caching inside. fetcher := m.certsFetcher if fetcher == nil { fetcher = signing.FetchCertificatesForServiceAccount }...
[ "func", "(", "m", "*", "MachineTokenAuthMethod", ")", "checkSignature", "(", "c", "context", ".", "Context", ",", "signerEmail", "string", ",", "envelope", "*", "tokenserver", ".", "MachineTokenEnvelope", ")", "error", "{", "// Note that FetchCertificatesForServiceAcc...
// checkSignature verifies the token signature.
[ "checkSignature", "verifies", "the", "token", "signature", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/auth/machine/auth_method.go#L193-L204
130,026
luci/luci-go
tools/internal/apigen/main.go
AddToFlagSet
func (a *Application) AddToFlagSet(fs *flag.FlagSet) { flag.StringVar(&a.servicePath, "service", ".", "Path to the AppEngine service to generate from.") flag.StringVar(&a.serviceAPIRoot, "service-api-root", "/_ah/api/", "The service's API root path.") flag.StringVar(&a.genPath, "generator", "google-api-go-genera...
go
func (a *Application) AddToFlagSet(fs *flag.FlagSet) { flag.StringVar(&a.servicePath, "service", ".", "Path to the AppEngine service to generate from.") flag.StringVar(&a.serviceAPIRoot, "service-api-root", "/_ah/api/", "The service's API root path.") flag.StringVar(&a.genPath, "generator", "google-api-go-genera...
[ "func", "(", "a", "*", "Application", ")", "AddToFlagSet", "(", "fs", "*", "flag", ".", "FlagSet", ")", "{", "flag", ".", "StringVar", "(", "&", "a", ".", "servicePath", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "flag", ".", ...
// AddToFlagSet adds application-level flags to the supplied FlagSet.
[ "AddToFlagSet", "adds", "application", "-", "level", "flags", "to", "the", "supplied", "FlagSet", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/internal/apigen/main.go#L97-L113
130,027
luci/luci-go
tools/internal/apigen/main.go
retryHTTP
func retryHTTP(c context.Context, u url.URL, method, body string) ([]byte, error) { client := http.Client{} gen := func() retry.Iterator { return &retry.Limited{ Delay: 2 * time.Second, Retries: 20, } } output := []byte(nil) err := retry.Retry(c, gen, func() error { req := http.Request{ Method: ...
go
func retryHTTP(c context.Context, u url.URL, method, body string) ([]byte, error) { client := http.Client{} gen := func() retry.Iterator { return &retry.Limited{ Delay: 2 * time.Second, Retries: 20, } } output := []byte(nil) err := retry.Retry(c, gen, func() error { req := http.Request{ Method: ...
[ "func", "retryHTTP", "(", "c", "context", ".", "Context", ",", "u", "url", ".", "URL", ",", "method", ",", "body", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "client", ":=", "http", ".", "Client", "{", "}", "\n\n", "gen", ":=",...
// retryHTTP executes an HTTP call to the specified URL, retrying if it fails. // // It will return an error if no successful HTTP results were returned. // Otherwise, it will return the body of the successful HTTP response.
[ "retryHTTP", "executes", "an", "HTTP", "call", "to", "the", "specified", "URL", "retrying", "if", "it", "fails", ".", "It", "will", "return", "an", "error", "if", "no", "successful", "HTTP", "results", "were", "returned", ".", "Otherwise", "it", "will", "r...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/internal/apigen/main.go#L139-L196
130,028
luci/luci-go
tools/internal/apigen/main.go
generateAPI
func (a *Application) generateAPI(c context.Context, item *directoryItem, discoveryURL *url.URL, dst string) error { tmpdir, err := ioutil.TempDir(os.TempDir(), "apigen") if err != nil { return err } defer func() { os.RemoveAll(tmpdir) }() gendir := augPath(tmpdir, "gen") headerPath := augPath(tmpdir, "head...
go
func (a *Application) generateAPI(c context.Context, item *directoryItem, discoveryURL *url.URL, dst string) error { tmpdir, err := ioutil.TempDir(os.TempDir(), "apigen") if err != nil { return err } defer func() { os.RemoveAll(tmpdir) }() gendir := augPath(tmpdir, "gen") headerPath := augPath(tmpdir, "head...
[ "func", "(", "a", "*", "Application", ")", "generateAPI", "(", "c", "context", ".", "Context", ",", "item", "*", "directoryItem", ",", "discoveryURL", "*", "url", ".", "URL", ",", "dst", "string", ")", "error", "{", "tmpdir", ",", "err", ":=", "ioutil"...
// generateAPI generates and installs a single directory item's API.
[ "generateAPI", "generates", "and", "installs", "a", "single", "directory", "item", "s", "API", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/internal/apigen/main.go#L294-L381
130,029
luci/luci-go
starlark/interpreter/interpreter.go
String
func (key moduleKey) String() string { pkg := "" if key.pkg != MainPkg { pkg = "@" + key.pkg } return pkg + "//" + key.path }
go
func (key moduleKey) String() string { pkg := "" if key.pkg != MainPkg { pkg = "@" + key.pkg } return pkg + "//" + key.path }
[ "func", "(", "key", "moduleKey", ")", "String", "(", ")", "string", "{", "pkg", ":=", "\"", "\"", "\n", "if", "key", ".", "pkg", "!=", "MainPkg", "{", "pkg", "=", "\"", "\"", "+", "key", ".", "pkg", "\n", "}", "\n", "return", "pkg", "+", "\"", ...
// String returns a fully-qualified module name to use in error messages. // // If is either "@pkg//path" or just "//path" if pkg is "__main__". We omit the // name of the top-level package with user-supplied code ("__main__") to avoid // confusing users who are oblivious of packages.
[ "String", "returns", "a", "fully", "-", "qualified", "module", "name", "to", "use", "in", "error", "messages", ".", "If", "is", "either" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/interpreter.go#L271-L277
130,030
luci/luci-go
starlark/interpreter/interpreter.go
makeModuleKey
func makeModuleKey(ref string, th *starlark.Thread) (key moduleKey, err error) { defer func() { if err == nil && (strings.HasPrefix(key.path, "../") || key.path == "..") { err = errors.New("outside the package root") } }() // 'th' can be nil here if makeModuleKey is called by LoadModule or // ExecModule: th...
go
func makeModuleKey(ref string, th *starlark.Thread) (key moduleKey, err error) { defer func() { if err == nil && (strings.HasPrefix(key.path, "../") || key.path == "..") { err = errors.New("outside the package root") } }() // 'th' can be nil here if makeModuleKey is called by LoadModule or // ExecModule: th...
[ "func", "makeModuleKey", "(", "ref", "string", ",", "th", "*", "starlark", ".", "Thread", ")", "(", "key", "moduleKey", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "err", "==", "nil", "&&", "(", "strings", ".", "HasPrefix", ...
// makeModuleKey takes '[@pkg]//<path>' or '<path>', parses and normalizes it. // // Converts the path to be relative to the package root. Does some light // validation, in particular checking the resulting path is doesn't star with // '../'. Module loaders are expected to validate module paths more rigorously // (sinc...
[ "makeModuleKey", "takes", "[" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/interpreter.go#L289-L345
130,031
luci/luci-go
starlark/interpreter/interpreter.go
Init
func (intr *Interpreter) Init(ctx context.Context) error { intr.modules = map[moduleKey]*loadedModule{} intr.execed = map[moduleKey]struct{}{} intr.globals = make(starlark.StringDict, len(intr.Predeclared)+1) for k, v := range intr.Predeclared { intr.globals[k] = v } intr.globals["exec"] = intr.execBuiltin() ...
go
func (intr *Interpreter) Init(ctx context.Context) error { intr.modules = map[moduleKey]*loadedModule{} intr.execed = map[moduleKey]struct{}{} intr.globals = make(starlark.StringDict, len(intr.Predeclared)+1) for k, v := range intr.Predeclared { intr.globals[k] = v } intr.globals["exec"] = intr.execBuiltin() ...
[ "func", "(", "intr", "*", "Interpreter", ")", "Init", "(", "ctx", "context", ".", "Context", ")", "error", "{", "intr", ".", "modules", "=", "map", "[", "moduleKey", "]", "*", "loadedModule", "{", "}", "\n", "intr", ".", "execed", "=", "map", "[", ...
// Init initializes the interpreter and loads '@stdlib//builtins.star'. // // Registers whatever was passed via Predeclared plus 'exec'. Then loads // '@stdlib//builtins.star', which may define more symbols or override already // defined ones. Whatever symbols not starting with '_' end up in the global // dict of '@std...
[ "Init", "initializes", "the", "interpreter", "and", "loads" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/interpreter.go#L362-L383
130,032
luci/luci-go
starlark/interpreter/interpreter.go
LoadSource
func (intr *Interpreter) LoadSource(th *starlark.Thread, ref string) (string, error) { if kind := GetThreadKind(th); kind != ThreadLoading && kind != ThreadExecing { return "", errors.New("wrong kind of thread (not enough information to " + "resolve the file reference), only threads that do 'load' and 'exec' can ...
go
func (intr *Interpreter) LoadSource(th *starlark.Thread, ref string) (string, error) { if kind := GetThreadKind(th); kind != ThreadLoading && kind != ThreadExecing { return "", errors.New("wrong kind of thread (not enough information to " + "resolve the file reference), only threads that do 'load' and 'exec' can ...
[ "func", "(", "intr", "*", "Interpreter", ")", "LoadSource", "(", "th", "*", "starlark", ".", "Thread", ",", "ref", "string", ")", "(", "string", ",", "error", ")", "{", "if", "kind", ":=", "GetThreadKind", "(", "th", ")", ";", "kind", "!=", "ThreadLo...
// LoadSource returns a body of a file inside a package. // // It doesn't have to be a Starlark file, can be any text file as long as // the corresponding package Loader can find it. // // 'ref' is either an absolute reference to the file, in the same format as // accepted by 'load' and 'exec' (i.e. "[@pkg]//path"), or...
[ "LoadSource", "returns", "a", "body", "of", "a", "file", "inside", "a", "package", ".", "It", "doesn", "t", "have", "to", "be", "a", "Starlark", "file", "can", "be", "any", "text", "file", "as", "long", "as", "the", "corresponding", "package", "Loader", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/interpreter.go#L471-L495
130,033
luci/luci-go
starlark/interpreter/interpreter.go
invokeLoader
func (intr *Interpreter) invokeLoader(key moduleKey) (dict starlark.StringDict, src string, err error) { loader, ok := intr.Packages[key.pkg] if !ok { return nil, "", ErrNoPackage } return loader(key.path) }
go
func (intr *Interpreter) invokeLoader(key moduleKey) (dict starlark.StringDict, src string, err error) { loader, ok := intr.Packages[key.pkg] if !ok { return nil, "", ErrNoPackage } return loader(key.path) }
[ "func", "(", "intr", "*", "Interpreter", ")", "invokeLoader", "(", "key", "moduleKey", ")", "(", "dict", "starlark", ".", "StringDict", ",", "src", "string", ",", "err", "error", ")", "{", "loader", ",", "ok", ":=", "intr", ".", "Packages", "[", "key",...
// invokeLoader loads the module via the loader associated with the package.
[ "invokeLoader", "loads", "the", "module", "via", "the", "loader", "associated", "with", "the", "package", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/interpreter.go#L571-L577
130,034
luci/luci-go
starlark/interpreter/interpreter.go
runModule
func (intr *Interpreter) runModule(ctx context.Context, key moduleKey, kind ThreadKind) (starlark.StringDict, error) { // Grab the source code. dict, src, err := intr.invokeLoader(key) switch { case err != nil: return nil, err case dict != nil: // This is a native module constructed in Go, no need to interpret...
go
func (intr *Interpreter) runModule(ctx context.Context, key moduleKey, kind ThreadKind) (starlark.StringDict, error) { // Grab the source code. dict, src, err := intr.invokeLoader(key) switch { case err != nil: return nil, err case dict != nil: // This is a native module constructed in Go, no need to interpret...
[ "func", "(", "intr", "*", "Interpreter", ")", "runModule", "(", "ctx", "context", ".", "Context", ",", "key", "moduleKey", ",", "kind", "ThreadKind", ")", "(", "starlark", ".", "StringDict", ",", "error", ")", "{", "// Grab the source code.", "dict", ",", ...
// runModule really loads and executes the module, used by both LoadModule and // ExecModule.
[ "runModule", "really", "loads", "and", "executes", "the", "module", "used", "by", "both", "LoadModule", "and", "ExecModule", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/interpreter.go#L581-L632
130,035
luci/luci-go
milo/buildsource/buildbot/buildstore/build.go
summarizeBuild
func summarizeBuild(c context.Context, b *buildbot.Build) (*model.BuildSummary, error) { bs := &model.BuildSummary{ BuildKey: datastore.KeyForObj(c, (*buildEntity)(b)), BuilderID: fmt.Sprintf("buildbot/%s/%s", b.Master, b.Buildername), BuildID: fmt.Sprintf("buildbot/%s/%s/%d", b.Master, b.Buildername, b.Numbe...
go
func summarizeBuild(c context.Context, b *buildbot.Build) (*model.BuildSummary, error) { bs := &model.BuildSummary{ BuildKey: datastore.KeyForObj(c, (*buildEntity)(b)), BuilderID: fmt.Sprintf("buildbot/%s/%s", b.Master, b.Buildername), BuildID: fmt.Sprintf("buildbot/%s/%s/%d", b.Master, b.Buildername, b.Numbe...
[ "func", "summarizeBuild", "(", "c", "context", ".", "Context", ",", "b", "*", "buildbot", ".", "Build", ")", "(", "*", "model", ".", "BuildSummary", ",", "error", ")", "{", "bs", ":=", "&", "model", ".", "BuildSummary", "{", "BuildKey", ":", "datastore...
// summarizeBuild creates a build summary from the buildbot build.
[ "summarizeBuild", "creates", "a", "build", "summary", "from", "the", "buildbot", "build", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/build.go#L286-L327
130,036
luci/luci-go
milo/buildsource/buildbot/buildstore/build.go
SaveBuild
func SaveBuild(c context.Context, b *buildbot.Build) (replaced bool, err error) { bs, err := summarizeBuild(c, b) if err != nil { err = errors.Annotate(err, "summarizing build").Err() return } err = datastore.RunInTransaction(c, func(c context.Context) error { existingBS := &model.BuildSummary{ BuildKey: ...
go
func SaveBuild(c context.Context, b *buildbot.Build) (replaced bool, err error) { bs, err := summarizeBuild(c, b) if err != nil { err = errors.Annotate(err, "summarizing build").Err() return } err = datastore.RunInTransaction(c, func(c context.Context) error { existingBS := &model.BuildSummary{ BuildKey: ...
[ "func", "SaveBuild", "(", "c", "context", ".", "Context", ",", "b", "*", "buildbot", ".", "Build", ")", "(", "replaced", "bool", ",", "err", "error", ")", "{", "bs", ",", "err", ":=", "summarizeBuild", "(", "c", ",", "b", ")", "\n", "if", "err", ...
// SaveBuild persists the build in the storage. // // This will also update the model.BuildSummary and model.BuilderSummary.
[ "SaveBuild", "persists", "the", "build", "in", "the", "storage", ".", "This", "will", "also", "update", "the", "model", ".", "BuildSummary", "and", "model", ".", "BuilderSummary", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/build.go#L332-L378
130,037
luci/luci-go
milo/buildsource/buildbot/buildstore/build.go
getID
func (b *buildEntity) getID() string { s := []string{b.Master, b.Buildername, strconv.Itoa(b.Number)} id, err := json.Marshal(s) if err != nil { panic(err) // This can't fail. } return string(id) }
go
func (b *buildEntity) getID() string { s := []string{b.Master, b.Buildername, strconv.Itoa(b.Number)} id, err := json.Marshal(s) if err != nil { panic(err) // This can't fail. } return string(id) }
[ "func", "(", "b", "*", "buildEntity", ")", "getID", "(", ")", "string", "{", "s", ":=", "[", "]", "string", "{", "b", ".", "Master", ",", "b", ".", "Buildername", ",", "strconv", ".", "Itoa", "(", "b", ".", "Number", ")", "}", "\n", "id", ",", ...
// getID is a helper function that returns b's datastore key.
[ "getID", "is", "a", "helper", "function", "that", "returns", "b", "s", "datastore", "key", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/build.go#L391-L398
130,038
luci/luci-go
milo/buildsource/buildbot/buildstore/build.go
Save
func (b *buildEntity) Save(withMeta bool) (datastore.PropertyMap, error) { var ps datastore.PropertyMap if withMeta { ps = b.GetAllMeta() } else { ps = datastore.PropertyMap{} } build := (*buildbot.Build)(b) data, err := encode(b) if err != nil { return nil, err } if len(data) > maxDataSize { return ...
go
func (b *buildEntity) Save(withMeta bool) (datastore.PropertyMap, error) { var ps datastore.PropertyMap if withMeta { ps = b.GetAllMeta() } else { ps = datastore.PropertyMap{} } build := (*buildbot.Build)(b) data, err := encode(b) if err != nil { return nil, err } if len(data) > maxDataSize { return ...
[ "func", "(", "b", "*", "buildEntity", ")", "Save", "(", "withMeta", "bool", ")", "(", "datastore", ".", "PropertyMap", ",", "error", ")", "{", "var", "ps", "datastore", ".", "PropertyMap", "\n", "if", "withMeta", "{", "ps", "=", "b", ".", "GetAllMeta",...
// Save converts b to a property map. // The encoded build goes into "data" property. // In addition, Save returns "master", "builder", "number" and "finished" // properties for queries.
[ "Save", "converts", "b", "to", "a", "property", "map", ".", "The", "encoded", "build", "goes", "into", "data", "property", ".", "In", "addition", "Save", "returns", "master", "builder", "number", "and", "finished", "properties", "for", "queries", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/build.go#L452-L478
130,039
luci/luci-go
milo/buildsource/buildbot/buildstore/build.go
Load
func (b *buildEntity) Load(pm datastore.PropertyMap) error { if p, ok := pm["id"]; ok { b.SetMeta("id", p.Slice()[0].Value()) } if p, ok := pm["data"]; ok { data, err := p.Slice()[0].Project(datastore.PTBytes) if err != nil { return err } build := (*buildbot.Build)(b) if err := decode(build, data.([]...
go
func (b *buildEntity) Load(pm datastore.PropertyMap) error { if p, ok := pm["id"]; ok { b.SetMeta("id", p.Slice()[0].Value()) } if p, ok := pm["data"]; ok { data, err := p.Slice()[0].Project(datastore.PTBytes) if err != nil { return err } build := (*buildbot.Build)(b) if err := decode(build, data.([]...
[ "func", "(", "b", "*", "buildEntity", ")", "Load", "(", "pm", "datastore", ".", "PropertyMap", ")", "error", "{", "if", "p", ",", "ok", ":=", "pm", "[", "\"", "\"", "]", ";", "ok", "{", "b", ".", "SetMeta", "(", "\"", "\"", ",", "p", ".", "Sl...
// Load loads b from the datastore property map. // Also promotes LogDog links.
[ "Load", "loads", "b", "from", "the", "datastore", "property", "map", ".", "Also", "promotes", "LogDog", "links", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/build.go#L482-L500
130,040
luci/luci-go
milo/buildsource/buildbot/buildstore/build.go
addViewPath
func (b *buildEntity) addViewPath() { if b == nil { // Could be nil e.g. as part of a query result. return } b.ViewPath = (&model.BuildSummary{ BuildID: fmt.Sprintf("buildbot/%s/%s/%d", b.Master, b.Buildername, b.Number), }).SelfLink() }
go
func (b *buildEntity) addViewPath() { if b == nil { // Could be nil e.g. as part of a query result. return } b.ViewPath = (&model.BuildSummary{ BuildID: fmt.Sprintf("buildbot/%s/%s/%d", b.Master, b.Buildername, b.Number), }).SelfLink() }
[ "func", "(", "b", "*", "buildEntity", ")", "addViewPath", "(", ")", "{", "if", "b", "==", "nil", "{", "// Could be nil e.g. as part of a query result.", "return", "\n", "}", "\n", "b", ".", "ViewPath", "=", "(", "&", "model", ".", "BuildSummary", "{", "Bui...
// addViewPath populates the 'ViewPath' field of the underlying buildbot.Build // struct.
[ "addViewPath", "populates", "the", "ViewPath", "field", "of", "the", "underlying", "buildbot", ".", "Build", "struct", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/build.go#L504-L512
130,041
luci/luci-go
milo/buildsource/buildbot/buildstore/build.go
promoteLogdogAliases
func promoteLogdogAliases(b *buildbot.Build) { // If this is a LogDog-only build, we want to promote the LogDog links. if loc, ok := b.PropertyValue("log_location").(string); ok && strings.HasPrefix(loc, "logdog://") { linkMap := map[string]string{} for i := range b.Steps { promoteLogDogLinks(&b.Steps[i], i ==...
go
func promoteLogdogAliases(b *buildbot.Build) { // If this is a LogDog-only build, we want to promote the LogDog links. if loc, ok := b.PropertyValue("log_location").(string); ok && strings.HasPrefix(loc, "logdog://") { linkMap := map[string]string{} for i := range b.Steps { promoteLogDogLinks(&b.Steps[i], i ==...
[ "func", "promoteLogdogAliases", "(", "b", "*", "buildbot", ".", "Build", ")", "{", "// If this is a LogDog-only build, we want to promote the LogDog links.", "if", "loc", ",", "ok", ":=", "b", ".", "PropertyValue", "(", "\"", "\"", ")", ".", "(", "string", ")", ...
// promoteLogdogAliases promotes LogDog links to first-class links.
[ "promoteLogdogAliases", "promotes", "LogDog", "links", "to", "first", "-", "class", "links", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/build.go#L515-L535
130,042
luci/luci-go
config/validation/rules.go
ConfigPatterns
func (r *RuleSet) ConfigPatterns(c context.Context) ([]*ConfigPattern, error) { r.l.RLock() defer r.l.RUnlock() out := make([]*ConfigPattern, len(r.r)) for i, rule := range r.r { var err error if out[i], err = r.renderedConfigPattern(c, rule); err != nil { return nil, err } } return out, nil }
go
func (r *RuleSet) ConfigPatterns(c context.Context) ([]*ConfigPattern, error) { r.l.RLock() defer r.l.RUnlock() out := make([]*ConfigPattern, len(r.r)) for i, rule := range r.r { var err error if out[i], err = r.renderedConfigPattern(c, rule); err != nil { return nil, err } } return out, nil }
[ "func", "(", "r", "*", "RuleSet", ")", "ConfigPatterns", "(", "c", "context", ".", "Context", ")", "(", "[", "]", "*", "ConfigPattern", ",", "error", ")", "{", "r", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "l", ".", "RUnlock", ...
// ConfigPatterns renders all registered config patterns and returns them. // // Used by the metadata handler to notify the config service about config files // we understand.
[ "ConfigPatterns", "renders", "all", "registered", "config", "patterns", "and", "returns", "them", ".", "Used", "by", "the", "metadata", "handler", "to", "notify", "the", "config", "service", "about", "config", "files", "we", "understand", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/rules.go#L142-L155
130,043
luci/luci-go
config/validation/rules.go
renderedConfigPattern
func (r *RuleSet) renderedConfigPattern(c context.Context, rule *rule) (*ConfigPattern, error) { sub := func(name string) (string, error) { if cb := r.v[name]; cb != nil { return cb(c) } return "", fmt.Errorf("no placeholder named %q is registered", name) } configSet, err := renderPatternString(rule.config...
go
func (r *RuleSet) renderedConfigPattern(c context.Context, rule *rule) (*ConfigPattern, error) { sub := func(name string) (string, error) { if cb := r.v[name]; cb != nil { return cb(c) } return "", fmt.Errorf("no placeholder named %q is registered", name) } configSet, err := renderPatternString(rule.config...
[ "func", "(", "r", "*", "RuleSet", ")", "renderedConfigPattern", "(", "c", "context", ".", "Context", ",", "rule", "*", "rule", ")", "(", "*", "ConfigPattern", ",", "error", ")", "{", "sub", ":=", "func", "(", "name", "string", ")", "(", "string", ","...
// renderedConfigPattern expands variables in the config patterns. // // Must be called with r.l read lock held.
[ "renderedConfigPattern", "expands", "variables", "in", "the", "config", "patterns", ".", "Must", "be", "called", "with", "r", ".", "l", "read", "lock", "held", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/rules.go#L202-L223
130,044
luci/luci-go
common/data/rand/mathrand/impl.go
Int63
func (l *Locking) Int63() (v int64) { l.Lock() v = l.R.Int63() l.Unlock() return }
go
func (l *Locking) Int63() (v int64) { l.Lock() v = l.R.Int63() l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Int63", "(", ")", "(", "v", "int64", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Int63", "(", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "return", "\n", "}" ]
// Int63 returns a non-negative pseudo-random 63-bit integer as an int64 // from the source in the context or the shared global source.
[ "Int63", "returns", "a", "non", "-", "negative", "pseudo", "-", "random", "63", "-", "bit", "integer", "as", "an", "int64", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L142-L147
130,045
luci/luci-go
common/data/rand/mathrand/impl.go
Uint32
func (l *Locking) Uint32() (v uint32) { l.Lock() v = l.R.Uint32() l.Unlock() return }
go
func (l *Locking) Uint32() (v uint32) { l.Lock() v = l.R.Uint32() l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Uint32", "(", ")", "(", "v", "uint32", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Uint32", "(", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "return", "\n", "}" ]
// Uint32 returns a pseudo-random 32-bit value as a uint32 from the source in // the context or the shared global source.
[ "Uint32", "returns", "a", "pseudo", "-", "random", "32", "-", "bit", "value", "as", "a", "uint32", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L151-L156
130,046
luci/luci-go
common/data/rand/mathrand/impl.go
Int31
func (l *Locking) Int31() (v int32) { l.Lock() v = l.R.Int31() l.Unlock() return }
go
func (l *Locking) Int31() (v int32) { l.Lock() v = l.R.Int31() l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Int31", "(", ")", "(", "v", "int32", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Int31", "(", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "return", "\n", "}" ]
// Int31 returns a non-negative pseudo-random 31-bit integer as an int32 from // the source in the context or the shared global source.
[ "Int31", "returns", "a", "non", "-", "negative", "pseudo", "-", "random", "31", "-", "bit", "integer", "as", "an", "int32", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L160-L165
130,047
luci/luci-go
common/data/rand/mathrand/impl.go
Int
func (l *Locking) Int() (v int) { l.Lock() v = l.R.Int() l.Unlock() return }
go
func (l *Locking) Int() (v int) { l.Lock() v = l.R.Int() l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Int", "(", ")", "(", "v", "int", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Int", "(", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "return", "\n", "}" ]
// Int returns a non-negative pseudo-random int from the source in the context // or the shared global source.
[ "Int", "returns", "a", "non", "-", "negative", "pseudo", "-", "random", "int", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L169-L174
130,048
luci/luci-go
common/data/rand/mathrand/impl.go
Int63n
func (l *Locking) Int63n(n int64) (v int64) { l.Lock() v = l.R.Int63n(n) l.Unlock() return }
go
func (l *Locking) Int63n(n int64) (v int64) { l.Lock() v = l.R.Int63n(n) l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Int63n", "(", "n", "int64", ")", "(", "v", "int64", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Int63n", "(", "n", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "retu...
// Int63n returns, as an int64, a non-negative pseudo-random number in [0,n) // from the source in the context or the shared global source. // // It panics if n <= 0.
[ "Int63n", "returns", "as", "an", "int64", "a", "non", "-", "negative", "pseudo", "-", "random", "number", "in", "[", "0", "n", ")", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", ".", "It", "panics", "if", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L180-L185
130,049
luci/luci-go
common/data/rand/mathrand/impl.go
Int31n
func (l *Locking) Int31n(n int32) (v int32) { l.Lock() v = l.R.Int31n(n) l.Unlock() return }
go
func (l *Locking) Int31n(n int32) (v int32) { l.Lock() v = l.R.Int31n(n) l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Int31n", "(", "n", "int32", ")", "(", "v", "int32", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Int31n", "(", "n", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "retu...
// Int31n returns, as an int32, a non-negative pseudo-random number in [0,n) // from the source in the context or the shared global source. // // It panics if n <= 0.
[ "Int31n", "returns", "as", "an", "int32", "a", "non", "-", "negative", "pseudo", "-", "random", "number", "in", "[", "0", "n", ")", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", ".", "It", "panics", "if", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L191-L196
130,050
luci/luci-go
common/data/rand/mathrand/impl.go
Float64
func (l *Locking) Float64() (v float64) { l.Lock() v = l.R.Float64() l.Unlock() return }
go
func (l *Locking) Float64() (v float64) { l.Lock() v = l.R.Float64() l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Float64", "(", ")", "(", "v", "float64", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Float64", "(", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "return", "\n", "}" ]
// Float64 returns, as a float64, a pseudo-random number in [0.0,1.0) from // the source in the context or the shared global source.
[ "Float64", "returns", "as", "a", "float64", "a", "pseudo", "-", "random", "number", "in", "[", "0", ".", "0", "1", ".", "0", ")", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L211-L216
130,051
luci/luci-go
common/data/rand/mathrand/impl.go
Float32
func (l *Locking) Float32() (v float32) { l.Lock() v = l.R.Float32() l.Unlock() return }
go
func (l *Locking) Float32() (v float32) { l.Lock() v = l.R.Float32() l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Float32", "(", ")", "(", "v", "float32", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Float32", "(", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", "return", "\n", "}" ]
// Float32 returns, as a float32, a pseudo-random number in [0.0,1.0) from // the source in the context or the shared global source.
[ "Float32", "returns", "as", "a", "float32", "a", "pseudo", "-", "random", "number", "in", "[", "0", ".", "0", "1", ".", "0", ")", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L220-L225
130,052
luci/luci-go
common/data/rand/mathrand/impl.go
Perm
func (l *Locking) Perm(n int) (v []int) { l.Lock() v = l.R.Perm(n) l.Unlock() return }
go
func (l *Locking) Perm(n int) (v []int) { l.Lock() v = l.R.Perm(n) l.Unlock() return }
[ "func", "(", "l", "*", "Locking", ")", "Perm", "(", "n", "int", ")", "(", "v", "[", "]", "int", ")", "{", "l", ".", "Lock", "(", ")", "\n", "v", "=", "l", ".", "R", ".", "Perm", "(", "n", ")", "\n", "l", ".", "Unlock", "(", ")", "\n", ...
// Perm returns, as a slice of n ints, a pseudo-random permutation of the // integers [0,n) from the source in the context or the shared global source.
[ "Perm", "returns", "as", "a", "slice", "of", "n", "ints", "a", "pseudo", "-", "random", "permutation", "of", "the", "integers", "[", "0", "n", ")", "from", "the", "source", "in", "the", "context", "or", "the", "shared", "global", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/impl.go#L229-L234
130,053
luci/luci-go
mp/cmd/snapshot/main.go
getService
func getService(c context.Context) *compute.Service { return c.Value(&key).(*compute.Service) }
go
func getService(c context.Context) *compute.Service { return c.Value(&key).(*compute.Service) }
[ "func", "getService", "(", "c", "context", ".", "Context", ")", "*", "compute", ".", "Service", "{", "return", "c", ".", "Value", "(", "&", "key", ")", ".", "(", "*", "compute", ".", "Service", ")", "\n", "}" ]
// getService retrieves the GCE API service embedded in the given context.
[ "getService", "retrieves", "the", "GCE", "API", "service", "embedded", "in", "the", "given", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/main.go#L38-L40
130,054
luci/luci-go
mp/cmd/snapshot/main.go
Initialize
func (b *cmdRunBase) Initialize() { opts := chromeinfra.DefaultAuthOptions() opts.Scopes = []string{"https://www.googleapis.com/auth/compute"} b.authFlags.Register(b.GetFlags(), opts) }
go
func (b *cmdRunBase) Initialize() { opts := chromeinfra.DefaultAuthOptions() opts.Scopes = []string{"https://www.googleapis.com/auth/compute"} b.authFlags.Register(b.GetFlags(), opts) }
[ "func", "(", "b", "*", "cmdRunBase", ")", "Initialize", "(", ")", "{", "opts", ":=", "chromeinfra", ".", "DefaultAuthOptions", "(", ")", "\n", "opts", ".", "Scopes", "=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "b", ".", "authFlags", ".", "...
// Initialize registers common flags.
[ "Initialize", "registers", "common", "flags", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/main.go#L50-L54
130,055
luci/luci-go
mp/cmd/snapshot/main.go
ModifyContext
func (b *cmdRunBase) ModifyContext(c context.Context) context.Context { c = logging.SetLevel(gologger.StdConfig.Use(c), logging.Debug) opts, err := b.authFlags.Options() if err != nil { logging.Errorf(c, "%s", err.Error()) panic("failed to get auth options") } http, err := auth.NewAuthenticator(c, auth.Optiona...
go
func (b *cmdRunBase) ModifyContext(c context.Context) context.Context { c = logging.SetLevel(gologger.StdConfig.Use(c), logging.Debug) opts, err := b.authFlags.Options() if err != nil { logging.Errorf(c, "%s", err.Error()) panic("failed to get auth options") } http, err := auth.NewAuthenticator(c, auth.Optiona...
[ "func", "(", "b", "*", "cmdRunBase", ")", "ModifyContext", "(", "c", "context", ".", "Context", ")", "context", ".", "Context", "{", "c", "=", "logging", ".", "SetLevel", "(", "gologger", ".", "StdConfig", ".", "Use", "(", "c", ")", ",", "logging", "...
// ModifyContext returns a new context. // Configures logging and embeds the GCE API service. // Implements cli.ContextModificator.
[ "ModifyContext", "returns", "a", "new", "context", ".", "Configures", "logging", "and", "embeds", "the", "GCE", "API", "service", ".", "Implements", "cli", ".", "ContextModificator", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/main.go#L59-L77
130,056
luci/luci-go
mp/cmd/snapshot/main.go
createService
func createService(c context.Context, opts auth.Options) (*compute.Service, error) { http, err := auth.NewAuthenticator(c, auth.OptionalLogin, opts).Client() if err != nil { return nil, err } service, err := compute.New(http) if err != nil { return nil, err } return service, nil }
go
func createService(c context.Context, opts auth.Options) (*compute.Service, error) { http, err := auth.NewAuthenticator(c, auth.OptionalLogin, opts).Client() if err != nil { return nil, err } service, err := compute.New(http) if err != nil { return nil, err } return service, nil }
[ "func", "createService", "(", "c", "context", ".", "Context", ",", "opts", "auth", ".", "Options", ")", "(", "*", "compute", ".", "Service", ",", "error", ")", "{", "http", ",", "err", ":=", "auth", ".", "NewAuthenticator", "(", "c", ",", "auth", "."...
// createService returns a new Compute Engine API service.
[ "createService", "returns", "a", "new", "Compute", "Engine", "API", "service", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/main.go#L80-L90
130,057
luci/luci-go
mp/cmd/snapshot/main.go
New
func New() *cli.Application { return &cli.Application{ Name: "snapshot", Title: "Machine Provider disk snapshot tool", Commands: []*subcommands.Command{ subcommands.CmdHelp, getCreateSnapshotCmd(), }, } }
go
func New() *cli.Application { return &cli.Application{ Name: "snapshot", Title: "Machine Provider disk snapshot tool", Commands: []*subcommands.Command{ subcommands.CmdHelp, getCreateSnapshotCmd(), }, } }
[ "func", "New", "(", ")", "*", "cli", ".", "Application", "{", "return", "&", "cli", ".", "Application", "{", "Name", ":", "\"", "\"", ",", "Title", ":", "\"", "\"", ",", "Commands", ":", "[", "]", "*", "subcommands", ".", "Command", "{", "subcomman...
// New returns a new snapshot application.
[ "New", "returns", "a", "new", "snapshot", "application", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/main.go#L93-L102
130,058
luci/luci-go
milo/common/pubsub.go
withClientFactory
func withClientFactory(c context.Context, fac pubsubClientFactory) context.Context { return context.WithValue(c, &pubsubClientFactoryKey, fac) }
go
func withClientFactory(c context.Context, fac pubsubClientFactory) context.Context { return context.WithValue(c, &pubsubClientFactoryKey, fac) }
[ "func", "withClientFactory", "(", "c", "context", ".", "Context", ",", "fac", "pubsubClientFactory", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "c", ",", "&", "pubsubClientFactoryKey", ",", "fac", ")", "\n", "}" ]
// withClientFactory returns a context with a given pubsub client factory.
[ "withClientFactory", "returns", "a", "context", "with", "a", "given", "pubsub", "client", "factory", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/pubsub.go#L101-L103
130,059
luci/luci-go
milo/common/pubsub.go
ensureBuildbucketSubscribed
func ensureBuildbucketSubscribed(c context.Context, projectID string) error { topicID := "builds" // Check the buildbucket project to see if the topic exists first. bbClient, err := newPubSubClient(c, projectID) if err != nil { return err } topic, err := bbClient.getTopic(c, topicID) switch err { case errNotE...
go
func ensureBuildbucketSubscribed(c context.Context, projectID string) error { topicID := "builds" // Check the buildbucket project to see if the topic exists first. bbClient, err := newPubSubClient(c, projectID) if err != nil { return err } topic, err := bbClient.getTopic(c, topicID) switch err { case errNotE...
[ "func", "ensureBuildbucketSubscribed", "(", "c", "context", ".", "Context", ",", "projectID", "string", ")", "error", "{", "topicID", ":=", "\"", "\"", "\n", "// Check the buildbucket project to see if the topic exists first.", "bbClient", ",", "err", ":=", "newPubSubCl...
// ensureBuildbucketSubscribedis called by a cron job and ensures that the Milo // instance is properly subscribed to the buildbucket subscription endpoint.
[ "ensureBuildbucketSubscribedis", "called", "by", "a", "cron", "job", "and", "ensures", "that", "the", "Milo", "instance", "is", "properly", "subscribed", "to", "the", "buildbucket", "subscription", "endpoint", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/pubsub.go#L126-L194
130,060
luci/luci-go
cipd/appengine/impl/admin/acl.go
checkAdminPrelude
func checkAdminPrelude(c context.Context, method string, req proto.Message) (context.Context, error) { switch yep, err := auth.IsMember(c, AdminGroup); { case err != nil: logging.WithError(err).Errorf(c, "IsMember(%q) failed", AdminGroup) return nil, status.Errorf(codes.Internal, "failed to check ACL") case !yep...
go
func checkAdminPrelude(c context.Context, method string, req proto.Message) (context.Context, error) { switch yep, err := auth.IsMember(c, AdminGroup); { case err != nil: logging.WithError(err).Errorf(c, "IsMember(%q) failed", AdminGroup) return nil, status.Errorf(codes.Internal, "failed to check ACL") case !yep...
[ "func", "checkAdminPrelude", "(", "c", "context", ".", "Context", ",", "method", "string", ",", "req", "proto", ".", "Message", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "switch", "yep", ",", "err", ":=", "auth", ".", "IsMember", "("...
// checkAdminPrelude is called before each RPC to check the caller is in // "administrators" group.
[ "checkAdminPrelude", "is", "called", "before", "each", "RPC", "to", "check", "the", "caller", "is", "in", "administrators", "group", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/admin/acl.go#L47-L58
130,061
luci/luci-go
gce/api/projects/v1/config.go
Validate
func (cfg *Config) Validate(c *validation.Context) { if cfg.GetProject() == "" { c.Errorf("project is required") } if cfg.GetRevision() != "" { c.Errorf("revision must not be specified") } }
go
func (cfg *Config) Validate(c *validation.Context) { if cfg.GetProject() == "" { c.Errorf("project is required") } if cfg.GetRevision() != "" { c.Errorf("revision must not be specified") } }
[ "func", "(", "cfg", "*", "Config", ")", "Validate", "(", "c", "*", "validation", ".", "Context", ")", "{", "if", "cfg", ".", "GetProject", "(", ")", "==", "\"", "\"", "{", "c", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "cfg", ...
// Validate validates this config.
[ "Validate", "validates", "this", "config", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/projects/v1/config.go#L41-L48
130,062
luci/luci-go
cipd/appengine/impl/admin/marked_tags.go
queryMarkedTags
func queryMarkedTags(job mapper.JobID) *datastore.Query { return datastore.NewQuery("mapper.MarkedTag").Eq("Job", job) }
go
func queryMarkedTags(job mapper.JobID) *datastore.Query { return datastore.NewQuery("mapper.MarkedTag").Eq("Job", job) }
[ "func", "queryMarkedTags", "(", "job", "mapper", ".", "JobID", ")", "*", "datastore", ".", "Query", "{", "return", "datastore", ".", "NewQuery", "(", "\"", "\"", ")", ".", "Eq", "(", "\"", "\"", ",", "job", ")", "\n", "}" ]
// queryMarkedTags returns a query for markedTags entities produced by a job.
[ "queryMarkedTags", "returns", "a", "query", "for", "markedTags", "entities", "produced", "by", "a", "job", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/admin/marked_tags.go#L67-L69
130,063
luci/luci-go
cipd/appengine/impl/admin/marked_tags.go
visitAndMarkTags
func visitAndMarkTags(c context.Context, job mapper.JobID, keys []*datastore.Key, cb func(*model.Tag) string) error { var marked []*markedTag err := multiGetTags(c, keys, func(key *datastore.Key, tag *model.Tag) error { if why := cb(tag); why != "" { mt := &markedTag{ Job: job, Key: key, Tag: tag.Tag...
go
func visitAndMarkTags(c context.Context, job mapper.JobID, keys []*datastore.Key, cb func(*model.Tag) string) error { var marked []*markedTag err := multiGetTags(c, keys, func(key *datastore.Key, tag *model.Tag) error { if why := cb(tag); why != "" { mt := &markedTag{ Job: job, Key: key, Tag: tag.Tag...
[ "func", "visitAndMarkTags", "(", "c", "context", ".", "Context", ",", "job", "mapper", ".", "JobID", ",", "keys", "[", "]", "*", "datastore", ".", "Key", ",", "cb", "func", "(", "*", "model", ".", "Tag", ")", "string", ")", "error", "{", "var", "ma...
// visitAndMarkTags fetches Tag entities given their keys and passes them to // the callback, which may choose to mark a tag by returning non-empty string // with the human-readable reason why the tag was marked. // // Such marked tags are then stored in the datastore and later can be queried.
[ "visitAndMarkTags", "fetches", "Tag", "entities", "given", "their", "keys", "and", "passes", "them", "to", "the", "callback", "which", "may", "choose", "to", "mark", "a", "tag", "by", "returning", "non", "-", "empty", "string", "with", "the", "human", "-", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/admin/marked_tags.go#L118-L141
130,064
luci/luci-go
buildbucket/deprecated/annotations.go
convertSubsteps
func (p *stepConverter) convertSubsteps(c context.Context, bbSteps *[]*pb.Step, annSubsteps []*annotpb.Step_Substep, stepPrefix string) ([]*pb.Step, error) { bbSubsteps := make([]*pb.Step, 0, len(annSubsteps)) for _, annSubstep := range annSubsteps { annStep := annSubstep.GetStep() if annStep == nil { return n...
go
func (p *stepConverter) convertSubsteps(c context.Context, bbSteps *[]*pb.Step, annSubsteps []*annotpb.Step_Substep, stepPrefix string) ([]*pb.Step, error) { bbSubsteps := make([]*pb.Step, 0, len(annSubsteps)) for _, annSubstep := range annSubsteps { annStep := annSubstep.GetStep() if annStep == nil { return n...
[ "func", "(", "p", "*", "stepConverter", ")", "convertSubsteps", "(", "c", "context", ".", "Context", ",", "bbSteps", "*", "[", "]", "*", "pb", ".", "Step", ",", "annSubsteps", "[", "]", "*", "annotpb", ".", "Step_Substep", ",", "stepPrefix", "string", ...
// convertSubsteps converts substeps, which we expect to be Steps, not Logdog // annotation streams.
[ "convertSubsteps", "converts", "substeps", "which", "we", "expect", "to", "be", "Steps", "not", "Logdog", "annotation", "streams", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/deprecated/annotations.go#L87-L104
130,065
luci/luci-go
appengine/tq/tq.go
RegisterTask
func (d *Dispatcher) RegisterTask(prototype proto.Message, cb Handler, queue string, opts *taskqueue.RetryOptions) { if queue == "" { queue = "default" // default GAE task queue name, always exists } name := proto.MessageName(prototype) if name == "" { panic(fmt.Sprintf("unregistered proto message type %T", pr...
go
func (d *Dispatcher) RegisterTask(prototype proto.Message, cb Handler, queue string, opts *taskqueue.RetryOptions) { if queue == "" { queue = "default" // default GAE task queue name, always exists } name := proto.MessageName(prototype) if name == "" { panic(fmt.Sprintf("unregistered proto message type %T", pr...
[ "func", "(", "d", "*", "Dispatcher", ")", "RegisterTask", "(", "prototype", "proto", ".", "Message", ",", "cb", "Handler", ",", "queue", "string", ",", "opts", "*", "taskqueue", ".", "RetryOptions", ")", "{", "if", "queue", "==", "\"", "\"", "{", "queu...
// RegisterTask tells the dispatcher that tasks of given proto type should be // handled by the given handler and routed through the given task queue. // // 'prototype' should be a pointer to some concrete proto message. It will be // used only for its type signature. // // Intended to be called during process startup....
[ "RegisterTask", "tells", "the", "dispatcher", "that", "tasks", "of", "given", "proto", "type", "should", "be", "handled", "by", "the", "given", "handler", "and", "routed", "through", "the", "given", "task", "queue", ".", "prototype", "should", "be", "a", "po...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/tq/tq.go#L194-L221
130,066
luci/luci-go
appengine/tq/tq.go
InstallRoutes
func (d *Dispatcher) InstallRoutes(r *router.Router, mw router.MiddlewareChain) { queues := stringset.New(0) d.mu.RLock() for _, h := range d.handlers { queues.Add(h.queue) } d.mu.RUnlock() for _, q := range queues.ToSlice() { r.POST( fmt.Sprintf("%s%s/*title", d.baseURL(), q), mw.Extend(gaemiddleware...
go
func (d *Dispatcher) InstallRoutes(r *router.Router, mw router.MiddlewareChain) { queues := stringset.New(0) d.mu.RLock() for _, h := range d.handlers { queues.Add(h.queue) } d.mu.RUnlock() for _, q := range queues.ToSlice() { r.POST( fmt.Sprintf("%s%s/*title", d.baseURL(), q), mw.Extend(gaemiddleware...
[ "func", "(", "d", "*", "Dispatcher", ")", "InstallRoutes", "(", "r", "*", "router", ".", "Router", ",", "mw", "router", ".", "MiddlewareChain", ")", "{", "queues", ":=", "stringset", ".", "New", "(", "0", ")", "\n\n", "d", ".", "mu", ".", "RLock", ...
// InstallRoutes installs appropriate HTTP routes in the router. // // Must be called only after all task handlers are registered!
[ "InstallRoutes", "installs", "appropriate", "HTTP", "routes", "in", "the", "router", ".", "Must", "be", "called", "only", "after", "all", "task", "handlers", "are", "registered!" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/tq/tq.go#L347-L362
130,067
luci/luci-go
appengine/tq/tq.go
RequestHeaders
func RequestHeaders(c context.Context) (*taskqueue.RequestHeaders, error) { if hdr, ok := c.Value(&requestHeadersKey).(*taskqueue.RequestHeaders); ok { return hdr, nil } return nil, errOutsideHandler }
go
func RequestHeaders(c context.Context) (*taskqueue.RequestHeaders, error) { if hdr, ok := c.Value(&requestHeadersKey).(*taskqueue.RequestHeaders); ok { return hdr, nil } return nil, errOutsideHandler }
[ "func", "RequestHeaders", "(", "c", "context", ".", "Context", ")", "(", "*", "taskqueue", ".", "RequestHeaders", ",", "error", ")", "{", "if", "hdr", ",", "ok", ":=", "c", ".", "Value", "(", "&", "requestHeadersKey", ")", ".", "(", "*", "taskqueue", ...
// RequestHeaders returns the special task-queue HTTP request headers for // the current task handler. // // Returns an error if called from outside of a task handler.
[ "RequestHeaders", "returns", "the", "special", "task", "-", "queue", "HTTP", "request", "headers", "for", "the", "current", "task", "handler", ".", "Returns", "an", "error", "if", "called", "from", "outside", "of", "a", "task", "handler", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/tq/tq.go#L379-L384
130,068
luci/luci-go
appengine/tq/tq.go
tqTask
func (d *Dispatcher) tqTask(task *Task) (*taskqueue.Task, string, error) { handler, err := d.handler(task.Payload) if err != nil { return nil, "", err } blob, err := serializePayload(task.Payload) if err != nil { return nil, "", err } title := handler.typeName if task.Title != "" { title = task.Title }...
go
func (d *Dispatcher) tqTask(task *Task) (*taskqueue.Task, string, error) { handler, err := d.handler(task.Payload) if err != nil { return nil, "", err } blob, err := serializePayload(task.Payload) if err != nil { return nil, "", err } title := handler.typeName if task.Title != "" { title = task.Title }...
[ "func", "(", "d", "*", "Dispatcher", ")", "tqTask", "(", "task", "*", "Task", ")", "(", "*", "taskqueue", ".", "Task", ",", "string", ",", "error", ")", "{", "handler", ",", "err", ":=", "d", ".", "handler", "(", "task", ".", "Payload", ")", "\n"...
// tqTask constructs task queue task struct.
[ "tqTask", "constructs", "task", "queue", "task", "struct", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/tq/tq.go#L396-L426
130,069
luci/luci-go
appengine/tq/tq.go
handler
func (d *Dispatcher) handler(payload proto.Message) (handler, error) { name := proto.MessageName(payload) d.mu.RLock() defer d.mu.RUnlock() handler, registered := d.handlers[name] if !registered { return handler, fmt.Errorf("handler for %q is not registered", name) } return handler, nil }
go
func (d *Dispatcher) handler(payload proto.Message) (handler, error) { name := proto.MessageName(payload) d.mu.RLock() defer d.mu.RUnlock() handler, registered := d.handlers[name] if !registered { return handler, fmt.Errorf("handler for %q is not registered", name) } return handler, nil }
[ "func", "(", "d", "*", "Dispatcher", ")", "handler", "(", "payload", "proto", ".", "Message", ")", "(", "handler", ",", "error", ")", "{", "name", ":=", "proto", ".", "MessageName", "(", "payload", ")", "\n\n", "d", ".", "mu", ".", "RLock", "(", ")...
// handler returns a handler struct registered with Register.
[ "handler", "returns", "a", "handler", "struct", "registered", "with", "Register", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/tq/tq.go#L443-L454
130,070
luci/luci-go
luci_notify/api/config/notify.go
ShouldNotify
func (n *Notification) ShouldNotify(oldStatus, newStatus buildbucketpb.Status) bool { switch { case newStatus == buildbucketpb.Status_STATUS_UNSPECIFIED: panic("new status must always be valid") case n.OnSuccess && newStatus == buildbucketpb.Status_SUCCESS: case n.OnFailure && newStatus == buildbucketpb.Status_FA...
go
func (n *Notification) ShouldNotify(oldStatus, newStatus buildbucketpb.Status) bool { switch { case newStatus == buildbucketpb.Status_STATUS_UNSPECIFIED: panic("new status must always be valid") case n.OnSuccess && newStatus == buildbucketpb.Status_SUCCESS: case n.OnFailure && newStatus == buildbucketpb.Status_FA...
[ "func", "(", "n", "*", "Notification", ")", "ShouldNotify", "(", "oldStatus", ",", "newStatus", "buildbucketpb", ".", "Status", ")", "bool", "{", "switch", "{", "case", "newStatus", "==", "buildbucketpb", ".", "Status_STATUS_UNSPECIFIED", ":", "panic", "(", "\...
// ShouldNotify is the predicate function for whether a trigger's conditions have been met.
[ "ShouldNotify", "is", "the", "predicate", "function", "for", "whether", "a", "trigger", "s", "conditions", "have", "been", "met", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/api/config/notify.go#L22-L35
130,071
luci/luci-go
luci_notify/api/config/notify.go
Filter
func (n *Notifications) Filter(oldStatus, newStatus buildbucketpb.Status) Notifications { notifications := n.GetNotifications() filtered := make([]*Notification, 0, len(notifications)) for _, notification := range notifications { if notification.ShouldNotify(oldStatus, newStatus) { filtered = append(filtered, n...
go
func (n *Notifications) Filter(oldStatus, newStatus buildbucketpb.Status) Notifications { notifications := n.GetNotifications() filtered := make([]*Notification, 0, len(notifications)) for _, notification := range notifications { if notification.ShouldNotify(oldStatus, newStatus) { filtered = append(filtered, n...
[ "func", "(", "n", "*", "Notifications", ")", "Filter", "(", "oldStatus", ",", "newStatus", "buildbucketpb", ".", "Status", ")", "Notifications", "{", "notifications", ":=", "n", ".", "GetNotifications", "(", ")", "\n", "filtered", ":=", "make", "(", "[", "...
// Filter filters out Notification objects from Notifications by checking if we ShouldNotify // based on two build statuses.
[ "Filter", "filters", "out", "Notification", "objects", "from", "Notifications", "by", "checking", "if", "we", "ShouldNotify", "based", "on", "two", "build", "statuses", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/api/config/notify.go#L39-L48
130,072
luci/luci-go
config/server/cfgclient/backend/client/client.go
GetConfigInterface
func (be *Backend) GetConfigInterface(c context.Context, a backend.Authority) config.Interface { return be.Provider.GetConfigClient(c, a) }
go
func (be *Backend) GetConfigInterface(c context.Context, a backend.Authority) config.Interface { return be.Provider.GetConfigClient(c, a) }
[ "func", "(", "be", "*", "Backend", ")", "GetConfigInterface", "(", "c", "context", ".", "Context", ",", "a", "backend", ".", "Authority", ")", "config", ".", "Interface", "{", "return", "be", ".", "Provider", ".", "GetConfigClient", "(", "c", ",", "a", ...
// GetConfigInterface implements backend.B.
[ "GetConfigInterface", "implements", "backend", ".", "B", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/client/client.go#L93-L95
130,073
luci/luci-go
config/server/cfgclient/backend/client/client.go
GetServiceURL
func (p *RemoteProvider) GetServiceURL() url.URL { u := url.URL{ Scheme: "https", Host: p.Host, Path: "/_ah/api/config/v1/", } if p.Insecure { u.Scheme = "http" } return u }
go
func (p *RemoteProvider) GetServiceURL() url.URL { u := url.URL{ Scheme: "https", Host: p.Host, Path: "/_ah/api/config/v1/", } if p.Insecure { u.Scheme = "http" } return u }
[ "func", "(", "p", "*", "RemoteProvider", ")", "GetServiceURL", "(", ")", "url", ".", "URL", "{", "u", ":=", "url", ".", "URL", "{", "Scheme", ":", "\"", "\"", ",", "Host", ":", "p", ".", "Host", ",", "Path", ":", "\"", "\"", ",", "}", "\n", "...
// GetServiceURL implements Provider.
[ "GetServiceURL", "implements", "Provider", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/client/client.go#L117-L127
130,074
luci/luci-go
config/server/cfgclient/backend/client/client.go
GetConfigClient
func (p *RemoteProvider) GetConfigClient(c context.Context, a backend.Authority) config.Interface { p.cacheLock.RLock() impl, ok := p.cache[a] p.cacheLock.RUnlock() if ok { return impl } p.cacheLock.Lock() defer p.cacheLock.Unlock() if impl, ok := p.cache[a]; ok { return impl } // Create our remote imp...
go
func (p *RemoteProvider) GetConfigClient(c context.Context, a backend.Authority) config.Interface { p.cacheLock.RLock() impl, ok := p.cache[a] p.cacheLock.RUnlock() if ok { return impl } p.cacheLock.Lock() defer p.cacheLock.Unlock() if impl, ok := p.cache[a]; ok { return impl } // Create our remote imp...
[ "func", "(", "p", "*", "RemoteProvider", ")", "GetConfigClient", "(", "c", "context", ".", "Context", ",", "a", "backend", ".", "Authority", ")", "config", ".", "Interface", "{", "p", ".", "cacheLock", ".", "RLock", "(", ")", "\n", "impl", ",", "ok", ...
// GetConfigClient implements Provider.
[ "GetConfigClient", "implements", "Provider", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/client/client.go#L130-L163
130,075
luci/luci-go
config/server/cfgclient/backend/client/client.go
rpcAuthorityKind
func rpcAuthorityKind(a backend.Authority) auth.RPCAuthorityKind { switch a { case backend.AsAnonymous: return auth.NoAuth case backend.AsService: return auth.AsSelf case backend.AsUser: return auth.AsUser default: panic(fmt.Errorf("unknown config Authority (%d)", a)) } }
go
func rpcAuthorityKind(a backend.Authority) auth.RPCAuthorityKind { switch a { case backend.AsAnonymous: return auth.NoAuth case backend.AsService: return auth.AsSelf case backend.AsUser: return auth.AsUser default: panic(fmt.Errorf("unknown config Authority (%d)", a)) } }
[ "func", "rpcAuthorityKind", "(", "a", "backend", ".", "Authority", ")", "auth", ".", "RPCAuthorityKind", "{", "switch", "a", "{", "case", "backend", ".", "AsAnonymous", ":", "return", "auth", ".", "NoAuth", "\n", "case", "backend", ".", "AsService", ":", "...
// rpcAuthorityKind returns the RPC authority associated with this authority // level.
[ "rpcAuthorityKind", "returns", "the", "RPC", "authority", "associated", "with", "this", "authority", "level", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/client/client.go#L189-L200
130,076
luci/luci-go
grpc/grpcmon/client.go
reportClientRPCMetrics
func reportClientRPCMetrics(ctx context.Context, method string, err error, dur time.Duration) { code := 0 if err != nil { code = int(grpc.Code(err)) } grpcClientCount.Add(ctx, 1, method, code) grpcClientDuration.Add(ctx, float64(dur.Nanoseconds()/1e6), method, code) }
go
func reportClientRPCMetrics(ctx context.Context, method string, err error, dur time.Duration) { code := 0 if err != nil { code = int(grpc.Code(err)) } grpcClientCount.Add(ctx, 1, method, code) grpcClientDuration.Add(ctx, float64(dur.Nanoseconds()/1e6), method, code) }
[ "func", "reportClientRPCMetrics", "(", "ctx", "context", ".", "Context", ",", "method", "string", ",", "err", "error", ",", "dur", "time", ".", "Duration", ")", "{", "code", ":=", "0", "\n", "if", "err", "!=", "nil", "{", "code", "=", "int", "(", "gr...
// reportClientRPCMetrics sends metrics after RPC call has finished.
[ "reportClientRPCMetrics", "sends", "metrics", "after", "RPC", "call", "has", "finished", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/grpcmon/client.go#L73-L80
130,077
luci/luci-go
gce/appengine/rpc/config.go
Delete
func (*Config) Delete(c context.Context, req *config.DeleteRequest) (*empty.Empty, error) { if req.GetId() == "" { return nil, status.Errorf(codes.InvalidArgument, "ID is required") } if err := datastore.Delete(c, &model.Config{ID: req.Id}); err != nil { return nil, errors.Annotate(err, "failed to delete config"...
go
func (*Config) Delete(c context.Context, req *config.DeleteRequest) (*empty.Empty, error) { if req.GetId() == "" { return nil, status.Errorf(codes.InvalidArgument, "ID is required") } if err := datastore.Delete(c, &model.Config{ID: req.Id}); err != nil { return nil, errors.Annotate(err, "failed to delete config"...
[ "func", "(", "*", "Config", ")", "Delete", "(", "c", "context", ".", "Context", ",", "req", "*", "config", ".", "DeleteRequest", ")", "(", "*", "empty", ".", "Empty", ",", "error", ")", "{", "if", "req", ".", "GetId", "(", ")", "==", "\"", "\"", ...
// Delete handles a request to delete a config. // For app-internal use only.
[ "Delete", "handles", "a", "request", "to", "delete", "a", "config", ".", "For", "app", "-", "internal", "use", "only", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/config.go#L41-L49
130,078
luci/luci-go
gce/appengine/rpc/config.go
Ensure
func (*Config) Ensure(c context.Context, req *config.EnsureRequest) (*config.Config, error) { if req.GetId() == "" { return nil, status.Errorf(codes.InvalidArgument, "ID is required") } cfg := &model.Config{ ID: req.Id, Config: *req.Config, } if err := datastore.Put(c, cfg); err != nil { return nil, er...
go
func (*Config) Ensure(c context.Context, req *config.EnsureRequest) (*config.Config, error) { if req.GetId() == "" { return nil, status.Errorf(codes.InvalidArgument, "ID is required") } cfg := &model.Config{ ID: req.Id, Config: *req.Config, } if err := datastore.Put(c, cfg); err != nil { return nil, er...
[ "func", "(", "*", "Config", ")", "Ensure", "(", "c", "context", ".", "Context", ",", "req", "*", "config", ".", "EnsureRequest", ")", "(", "*", "config", ".", "Config", ",", "error", ")", "{", "if", "req", ".", "GetId", "(", ")", "==", "\"", "\""...
// Ensure handles a request to create or update a config. // For app-internal use only.
[ "Ensure", "handles", "a", "request", "to", "create", "or", "update", "a", "config", ".", "For", "app", "-", "internal", "use", "only", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/config.go#L53-L65
130,079
luci/luci-go
gce/appengine/rpc/config.go
NewConfigurationServer
func NewConfigurationServer() config.ConfigurationServer { return &config.DecoratedConfiguration{ Prelude: readOnlyAuthPrelude, Service: &Config{}, Postlude: gRPCifyAndLogErr, } }
go
func NewConfigurationServer() config.ConfigurationServer { return &config.DecoratedConfiguration{ Prelude: readOnlyAuthPrelude, Service: &Config{}, Postlude: gRPCifyAndLogErr, } }
[ "func", "NewConfigurationServer", "(", ")", "config", ".", "ConfigurationServer", "{", "return", "&", "config", ".", "DecoratedConfiguration", "{", "Prelude", ":", "readOnlyAuthPrelude", ",", "Service", ":", "&", "Config", "{", "}", ",", "Postlude", ":", "gRPCif...
// NewConfigurationServer returns a new configuration server.
[ "NewConfigurationServer", "returns", "a", "new", "configuration", "server", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/config.go#L103-L109
130,080
luci/luci-go
config/appengine/gaeconfig/settings.go
SetIfChanged
func (s *Settings) SetIfChanged(c context.Context, who, why string) error { return settings.SetIfChanged(c, settingsKey, s, who, why) }
go
func (s *Settings) SetIfChanged(c context.Context, who, why string) error { return settings.SetIfChanged(c, settingsKey, s, who, why) }
[ "func", "(", "s", "*", "Settings", ")", "SetIfChanged", "(", "c", "context", ".", "Context", ",", "who", ",", "why", "string", ")", "error", "{", "return", "settings", ".", "SetIfChanged", "(", "c", ",", "settingsKey", ",", "s", ",", "who", ",", "why...
// SetIfChanged sets "s" to be the new Settings if it differs from the current // settings value.
[ "SetIfChanged", "sets", "s", "to", "be", "the", "new", "Settings", "if", "it", "differs", "from", "the", "current", "settings", "value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/appengine/gaeconfig/settings.go#L79-L81
130,081
luci/luci-go
config/appengine/gaeconfig/settings.go
CacheExpiration
func (s *Settings) CacheExpiration() time.Duration { if s.CacheExpirationSec > 0 { return time.Second * time.Duration(s.CacheExpirationSec) } return 0 }
go
func (s *Settings) CacheExpiration() time.Duration { if s.CacheExpirationSec > 0 { return time.Second * time.Duration(s.CacheExpirationSec) } return 0 }
[ "func", "(", "s", "*", "Settings", ")", "CacheExpiration", "(", ")", "time", ".", "Duration", "{", "if", "s", ".", "CacheExpirationSec", ">", "0", "{", "return", "time", ".", "Second", "*", "time", ".", "Duration", "(", "s", ".", "CacheExpirationSec", ...
// CacheExpiration returns a Duration representing the configured cache // expiration. If the cache expiration is not configured, CacheExpiration // will return 0.
[ "CacheExpiration", "returns", "a", "Duration", "representing", "the", "configured", "cache", "expiration", ".", "If", "the", "cache", "expiration", "is", "not", "configured", "CacheExpiration", "will", "return", "0", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/appengine/gaeconfig/settings.go#L86-L91
130,082
luci/luci-go
config/appengine/gaeconfig/settings.go
DefaultSettings
func DefaultSettings(c context.Context) Settings { // Disable local cache on devserver by default to allows changes to local // configs to propagate instantly. This is usually preferred when developing // locally. exp := 0 if !info.IsDevAppServer(c) { exp = int(DefaultExpire.Seconds()) } return Settings{ Cac...
go
func DefaultSettings(c context.Context) Settings { // Disable local cache on devserver by default to allows changes to local // configs to propagate instantly. This is usually preferred when developing // locally. exp := 0 if !info.IsDevAppServer(c) { exp = int(DefaultExpire.Seconds()) } return Settings{ Cac...
[ "func", "DefaultSettings", "(", "c", "context", ".", "Context", ")", "Settings", "{", "// Disable local cache on devserver by default to allows changes to local", "// configs to propagate instantly. This is usually preferred when developing", "// locally.", "exp", ":=", "0", "\n", ...
// DefaultSettings returns Settings to use if setting store is empty.
[ "DefaultSettings", "returns", "Settings", "to", "use", "if", "setting", "store", "is", "empty", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/appengine/gaeconfig/settings.go#L125-L138
130,083
luci/luci-go
logdog/appengine/coordinator/logPrefix.go
IsRetry
func (p *LogPrefix) IsRetry(c context.Context, nonce []byte) bool { if len(nonce) != types.OpNonceLength { logging.Infof(c, "user provided invalid nonce length (%d)", len(nonce)) return false } if len(p.OpNonce) == 0 { logging.Infof(c, "prefix %q has no associated nonce", p.Prefix) return false } if clock....
go
func (p *LogPrefix) IsRetry(c context.Context, nonce []byte) bool { if len(nonce) != types.OpNonceLength { logging.Infof(c, "user provided invalid nonce length (%d)", len(nonce)) return false } if len(p.OpNonce) == 0 { logging.Infof(c, "prefix %q has no associated nonce", p.Prefix) return false } if clock....
[ "func", "(", "p", "*", "LogPrefix", ")", "IsRetry", "(", "c", "context", ".", "Context", ",", "nonce", "[", "]", "byte", ")", "bool", "{", "if", "len", "(", "nonce", ")", "!=", "types", ".", "OpNonceLength", "{", "logging", ".", "Infof", "(", "c", ...
// IsRetry checks to see if this LogPrefix is still in the OpNonce // window, and if nonce matches the one in this LogPrefix.
[ "IsRetry", "checks", "to", "see", "if", "this", "LogPrefix", "is", "still", "in", "the", "OpNonce", "window", "and", "if", "nonce", "matches", "the", "one", "in", "this", "LogPrefix", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logPrefix.go#L124-L138
130,084
luci/luci-go
scheduler/appengine/engine/cron.go
pokeCron
func pokeCron(c context.Context, job *Job, disp *tq.Dispatcher, cb func(m *cron.Machine) error) error { assertInTransaction(c) sched, err := job.ParseSchedule() if err != nil { return errors.Annotate(err, "bad schedule %q", job.EffectiveSchedule()).Err() } now := clock.Now(c).UTC() rnd := mathrand.Get(c) ma...
go
func pokeCron(c context.Context, job *Job, disp *tq.Dispatcher, cb func(m *cron.Machine) error) error { assertInTransaction(c) sched, err := job.ParseSchedule() if err != nil { return errors.Annotate(err, "bad schedule %q", job.EffectiveSchedule()).Err() } now := clock.Now(c).UTC() rnd := mathrand.Get(c) ma...
[ "func", "pokeCron", "(", "c", "context", ".", "Context", ",", "job", "*", "Job", ",", "disp", "*", "tq", ".", "Dispatcher", ",", "cb", "func", "(", "m", "*", "cron", ".", "Machine", ")", "error", ")", "error", "{", "assertInTransaction", "(", "c", ...
// pokeCron instantiates a cron state machine and calls the callback to advance // its state. // // Should be part of a Job transaction. If the callback succeeds, job.State // is updated with the new state and all emitted actions are dispatched to the // task queue. The job entity should eventually be saved as part of ...
[ "pokeCron", "instantiates", "a", "cron", "state", "machine", "and", "calls", "the", "callback", "to", "advance", "its", "state", ".", "Should", "be", "part", "of", "a", "Job", "transaction", ".", "If", "the", "callback", "succeeds", "job", ".", "State", "i...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/cron.go#L44-L96
130,085
luci/luci-go
scheduler/appengine/engine/cron.go
cronTrigger
func cronTrigger(a cron.StartInvocationAction, now time.Time) *internal.Trigger { return &internal.Trigger{ Id: fmt.Sprintf("cron:v1:%d", a.Generation), Created: google.NewTimestamp(now), Payload: &internal.Trigger_Cron{ Cron: &api.CronTrigger{ Generation: a.Generation, }, }, } }
go
func cronTrigger(a cron.StartInvocationAction, now time.Time) *internal.Trigger { return &internal.Trigger{ Id: fmt.Sprintf("cron:v1:%d", a.Generation), Created: google.NewTimestamp(now), Payload: &internal.Trigger_Cron{ Cron: &api.CronTrigger{ Generation: a.Generation, }, }, } }
[ "func", "cronTrigger", "(", "a", "cron", ".", "StartInvocationAction", ",", "now", "time", ".", "Time", ")", "*", "internal", ".", "Trigger", "{", "return", "&", "internal", ".", "Trigger", "{", "Id", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", ...
// cronTrigger generates a trigger struct from an invocation request generated // by the cron state machine.
[ "cronTrigger", "generates", "a", "trigger", "struct", "from", "an", "invocation", "request", "generated", "by", "the", "cron", "state", "machine", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/cron.go#L100-L110
130,086
luci/luci-go
vpython/python/command_line.go
String
func (f *CommandLineFlag) String() string { return fmt.Sprintf("-%s%s", f.Flag, f.Arg) }
go
func (f *CommandLineFlag) String() string { return fmt.Sprintf("-%s%s", f.Flag, f.Arg) }
[ "func", "(", "f", "*", "CommandLineFlag", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "f", ".", "Flag", ",", "f", ".", "Arg", ")", "\n", "}" ]
// String returns a string representation of this flag, which is a command-line // suitable representation of its value.
[ "String", "returns", "a", "string", "representation", "of", "this", "flag", "which", "is", "a", "command", "-", "line", "suitable", "representation", "of", "its", "value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L34-L36
130,087
luci/luci-go
vpython/python/command_line.go
BuildArgs
func (cl *CommandLine) BuildArgs() []string { targetArgs := cl.Target.buildArgsForTarget() args := make([]string, 0, len(cl.Flags)+1+len(targetArgs)+len(cl.Args)) for _, flag := range cl.Flags { args = append(args, flag.String()) } var flagSeparator []string if cl.FlagSeparator { flagSeparator = []string{"--...
go
func (cl *CommandLine) BuildArgs() []string { targetArgs := cl.Target.buildArgsForTarget() args := make([]string, 0, len(cl.Flags)+1+len(targetArgs)+len(cl.Args)) for _, flag := range cl.Flags { args = append(args, flag.String()) } var flagSeparator []string if cl.FlagSeparator { flagSeparator = []string{"--...
[ "func", "(", "cl", "*", "CommandLine", ")", "BuildArgs", "(", ")", "[", "]", "string", "{", "targetArgs", ":=", "cl", ".", "Target", ".", "buildArgsForTarget", "(", ")", "\n", "args", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "("...
// BuildArgs returns an array of Python interpreter arguments for cl.
[ "BuildArgs", "returns", "an", "array", "of", "Python", "interpreter", "arguments", "for", "cl", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L134-L159
130,088
luci/luci-go
vpython/python/command_line.go
AddFlag
func (cl *CommandLine) AddFlag(flag CommandLineFlag) { if strings.HasPrefix(flag.Flag, "-") { panic("flag must not begin with '-'") } for _, f := range cl.Flags { if f == flag { return } } cl.Flags = append(cl.Flags, flag) }
go
func (cl *CommandLine) AddFlag(flag CommandLineFlag) { if strings.HasPrefix(flag.Flag, "-") { panic("flag must not begin with '-'") } for _, f := range cl.Flags { if f == flag { return } } cl.Flags = append(cl.Flags, flag) }
[ "func", "(", "cl", "*", "CommandLine", ")", "AddFlag", "(", "flag", "CommandLineFlag", ")", "{", "if", "strings", ".", "HasPrefix", "(", "flag", ".", "Flag", ",", "\"", "\"", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "_", "...
// AddFlag adds an interpreter flag to cl if it's not already present.
[ "AddFlag", "adds", "an", "interpreter", "flag", "to", "cl", "if", "it", "s", "not", "already", "present", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L176-L186
130,089
luci/luci-go
vpython/python/command_line.go
AddSingleFlag
func (cl *CommandLine) AddSingleFlag(flag string) { cl.AddFlag(CommandLineFlag{Flag: flag}) }
go
func (cl *CommandLine) AddSingleFlag(flag string) { cl.AddFlag(CommandLineFlag{Flag: flag}) }
[ "func", "(", "cl", "*", "CommandLine", ")", "AddSingleFlag", "(", "flag", "string", ")", "{", "cl", ".", "AddFlag", "(", "CommandLineFlag", "{", "Flag", ":", "flag", "}", ")", "\n", "}" ]
// AddSingleFlag adds a single no-argument interpreter flag to cl // if it's not already specified.
[ "AddSingleFlag", "adds", "a", "single", "no", "-", "argument", "interpreter", "flag", "to", "cl", "if", "it", "s", "not", "already", "specified", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L190-L192
130,090
luci/luci-go
vpython/python/command_line.go
RemoveFlagMatch
func (cl *CommandLine) RemoveFlagMatch(matchFn func(CommandLineFlag) bool) (found bool) { newFlags := cl.Flags[:0] for _, f := range cl.Flags { if !matchFn(f) { newFlags = append(newFlags, f) } else { found = true } } cl.Flags = newFlags return }
go
func (cl *CommandLine) RemoveFlagMatch(matchFn func(CommandLineFlag) bool) (found bool) { newFlags := cl.Flags[:0] for _, f := range cl.Flags { if !matchFn(f) { newFlags = append(newFlags, f) } else { found = true } } cl.Flags = newFlags return }
[ "func", "(", "cl", "*", "CommandLine", ")", "RemoveFlagMatch", "(", "matchFn", "func", "(", "CommandLineFlag", ")", "bool", ")", "(", "found", "bool", ")", "{", "newFlags", ":=", "cl", ".", "Flags", "[", ":", "0", "]", "\n", "for", "_", ",", "f", "...
// RemoveFlagMatch removes all instances of flags that match the selection // function. // // matchFn is a function that accepts a candidate flag and returns true if it // should be removed, false if it should not.
[ "RemoveFlagMatch", "removes", "all", "instances", "of", "flags", "that", "match", "the", "selection", "function", ".", "matchFn", "is", "a", "function", "that", "accepts", "a", "candidate", "flag", "and", "returns", "true", "if", "it", "should", "be", "removed...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L199-L210
130,091
luci/luci-go
vpython/python/command_line.go
RemoveFlag
func (cl *CommandLine) RemoveFlag(flag CommandLineFlag) (found bool) { return cl.RemoveFlagMatch(func(f CommandLineFlag) bool { return f == flag }) }
go
func (cl *CommandLine) RemoveFlag(flag CommandLineFlag) (found bool) { return cl.RemoveFlagMatch(func(f CommandLineFlag) bool { return f == flag }) }
[ "func", "(", "cl", "*", "CommandLine", ")", "RemoveFlag", "(", "flag", "CommandLineFlag", ")", "(", "found", "bool", ")", "{", "return", "cl", ".", "RemoveFlagMatch", "(", "func", "(", "f", "CommandLineFlag", ")", "bool", "{", "return", "f", "==", "flag"...
// RemoveFlag removes all instances of the specified flag from the interpreter // command line.
[ "RemoveFlag", "removes", "all", "instances", "of", "the", "specified", "flag", "from", "the", "interpreter", "command", "line", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L214-L216
130,092
luci/luci-go
vpython/python/command_line.go
RemoveAllFlag
func (cl *CommandLine) RemoveAllFlag(flag string) (found bool) { return cl.RemoveFlagMatch(func(f CommandLineFlag) bool { return f.Flag == flag }) }
go
func (cl *CommandLine) RemoveAllFlag(flag string) (found bool) { return cl.RemoveFlagMatch(func(f CommandLineFlag) bool { return f.Flag == flag }) }
[ "func", "(", "cl", "*", "CommandLine", ")", "RemoveAllFlag", "(", "flag", "string", ")", "(", "found", "bool", ")", "{", "return", "cl", ".", "RemoveFlagMatch", "(", "func", "(", "f", "CommandLineFlag", ")", "bool", "{", "return", "f", ".", "Flag", "==...
// RemoveAllFlag removes all instances of the specified flag from the interpreter // command line.
[ "RemoveAllFlag", "removes", "all", "instances", "of", "the", "specified", "flag", "from", "the", "interpreter", "command", "line", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L220-L222
130,093
luci/luci-go
vpython/python/command_line.go
Clone
func (cl *CommandLine) Clone() *CommandLine { return &CommandLine{ Target: cl.Target, Flags: append([]CommandLineFlag(nil), cl.Flags...), Args: append([]string(nil), cl.Args...), } }
go
func (cl *CommandLine) Clone() *CommandLine { return &CommandLine{ Target: cl.Target, Flags: append([]CommandLineFlag(nil), cl.Flags...), Args: append([]string(nil), cl.Args...), } }
[ "func", "(", "cl", "*", "CommandLine", ")", "Clone", "(", ")", "*", "CommandLine", "{", "return", "&", "CommandLine", "{", "Target", ":", "cl", ".", "Target", ",", "Flags", ":", "append", "(", "[", "]", "CommandLineFlag", "(", "nil", ")", ",", "cl", ...
// Clone returns an independent deep copy of cl.
[ "Clone", "returns", "an", "independent", "deep", "copy", "of", "cl", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L225-L231
130,094
luci/luci-go
vpython/python/command_line.go
parseSingleFlag
func (cl *CommandLine) parseSingleFlag(fs *parsedFlagState) error { // Consume the first character from flag into "r". "flag" is the remainder. r, l := utf8.DecodeRuneInString(fs.flag) if r == utf8.RuneError { return errors.Reason("invalid rune in flag").Err() } fs.flag = fs.flag[l:] // Retrieve the value for ...
go
func (cl *CommandLine) parseSingleFlag(fs *parsedFlagState) error { // Consume the first character from flag into "r". "flag" is the remainder. r, l := utf8.DecodeRuneInString(fs.flag) if r == utf8.RuneError { return errors.Reason("invalid rune in flag").Err() } fs.flag = fs.flag[l:] // Retrieve the value for ...
[ "func", "(", "cl", "*", "CommandLine", ")", "parseSingleFlag", "(", "fs", "*", "parsedFlagState", ")", "error", "{", "// Consume the first character from flag into \"r\". \"flag\" is the remainder.", "r", ",", "l", ":=", "utf8", ".", "DecodeRuneInString", "(", "fs", "...
// parseSingleFlag parses a single flag from a state.
[ "parseSingleFlag", "parses", "a", "single", "flag", "from", "a", "state", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L234-L322
130,095
luci/luci-go
vpython/python/command_line.go
ParseCommandLine
func ParseCommandLine(args []string) (*CommandLine, error) { noTarget := NoTarget{} cl := CommandLine{ Target: noTarget, } i := 0 for len(args) > 0 { // Stop parsing after we have a target, as Python does. if cl.Target != noTarget { break } // Consume the next argument. arg := args[0] args = arg...
go
func ParseCommandLine(args []string) (*CommandLine, error) { noTarget := NoTarget{} cl := CommandLine{ Target: noTarget, } i := 0 for len(args) > 0 { // Stop parsing after we have a target, as Python does. if cl.Target != noTarget { break } // Consume the next argument. arg := args[0] args = arg...
[ "func", "ParseCommandLine", "(", "args", "[", "]", "string", ")", "(", "*", "CommandLine", ",", "error", ")", "{", "noTarget", ":=", "NoTarget", "{", "}", "\n\n", "cl", ":=", "CommandLine", "{", "Target", ":", "noTarget", ",", "}", "\n", "i", ":=", "...
// ParseCommandLine parses Python command-line arguments and returns a // structured representation.
[ "ParseCommandLine", "parses", "Python", "command", "-", "line", "arguments", "and", "returns", "a", "structured", "representation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/command_line.go#L326-L393
130,096
luci/luci-go
logdog/api/endpoints/coordinator/logs/v1/fakelogs/stream.go
Close
func (s *Stream) Close() error { _, err := s.c.srvServ.TerminateStream(s.c.ctx, &services.TerminateStreamRequest{ Project: coordinatorTest.AllAccessProject, Id: s.streamID, Secret: s.secret, TerminalIndex: s.streamIndex - 1, }) return err }
go
func (s *Stream) Close() error { _, err := s.c.srvServ.TerminateStream(s.c.ctx, &services.TerminateStreamRequest{ Project: coordinatorTest.AllAccessProject, Id: s.streamID, Secret: s.secret, TerminalIndex: s.streamIndex - 1, }) return err }
[ "func", "(", "s", "*", "Stream", ")", "Close", "(", ")", "error", "{", "_", ",", "err", ":=", "s", ".", "c", ".", "srvServ", ".", "TerminateStream", "(", "s", ".", "c", ".", "ctx", ",", "&", "services", ".", "TerminateStreamRequest", "{", "Project"...
// Close terminates this stream.
[ "Close", "terminates", "this", "stream", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/logs/v1/fakelogs/stream.go#L100-L108
130,097
luci/luci-go
machine-db/appengine/config/vlans.go
importVLANs
func importVLANs(c context.Context, configSet config.Set) error { vlan := &configPB.VLANs{} metadata := &config.Meta{} if err := cfgclient.Get(c, cfgclient.AsService, configSet, vlansFilename, textproto.Message(vlan), metadata); err != nil { return errors.Annotate(err, "failed to load %s", vlansFilename).Err() } ...
go
func importVLANs(c context.Context, configSet config.Set) error { vlan := &configPB.VLANs{} metadata := &config.Meta{} if err := cfgclient.Get(c, cfgclient.AsService, configSet, vlansFilename, textproto.Message(vlan), metadata); err != nil { return errors.Annotate(err, "failed to load %s", vlansFilename).Err() } ...
[ "func", "importVLANs", "(", "c", "context", ".", "Context", ",", "configSet", "config", ".", "Set", ")", "error", "{", "vlan", ":=", "&", "configPB", ".", "VLANs", "{", "}", "\n", "metadata", ":=", "&", "config", ".", "Meta", "{", "}", "\n", "if", ...
// importVLANs fetches, validates, and applies VLAN configs.
[ "importVLANs", "fetches", "validates", "and", "applies", "VLAN", "configs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/config/vlans.go#L43-L65
130,098
luci/luci-go
machine-db/appengine/config/vlans.go
validateVLANs
func validateVLANs(c *validation.Context, cfg *configPB.VLANs) { // VLAN IDs must be unique. // Keep records of ones we've already seen. vlans := make(map[int64]struct{}, len(cfg.Vlan)) for _, vlan := range cfg.Vlan { switch _, ok := vlans[vlan.Id]; { case vlan.Id < 1: c.Errorf("VLAN ID %d must be positive",...
go
func validateVLANs(c *validation.Context, cfg *configPB.VLANs) { // VLAN IDs must be unique. // Keep records of ones we've already seen. vlans := make(map[int64]struct{}, len(cfg.Vlan)) for _, vlan := range cfg.Vlan { switch _, ok := vlans[vlan.Id]; { case vlan.Id < 1: c.Errorf("VLAN ID %d must be positive",...
[ "func", "validateVLANs", "(", "c", "*", "validation", ".", "Context", ",", "cfg", "*", "configPB", ".", "VLANs", ")", "{", "// VLAN IDs must be unique.", "// Keep records of ones we've already seen.", "vlans", ":=", "make", "(", "map", "[", "int64", "]", "struct",...
// validateVLANs validates vlans.cfg.
[ "validateVLANs", "validates", "vlans", ".", "cfg", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/config/vlans.go#L68-L95
130,099
luci/luci-go
common/sync/parallel/semaphore.go
TakeAll
func (s Semaphore) TakeAll() { for i := 0; i < cap(s); i++ { s.Lock() } }
go
func (s Semaphore) TakeAll() { for i := 0; i < cap(s); i++ { s.Lock() } }
[ "func", "(", "s", "Semaphore", ")", "TakeAll", "(", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "cap", "(", "s", ")", ";", "i", "++", "{", "s", ".", "Lock", "(", ")", "\n", "}", "\n", "}" ]
// TakeAll blocks until it holds all available semaphore resources. When it // returns, the caller owns all of the resources in the semaphore.
[ "TakeAll", "blocks", "until", "it", "holds", "all", "available", "semaphore", "resources", ".", "When", "it", "returns", "the", "caller", "owns", "all", "of", "the", "resources", "in", "the", "semaphore", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/sync/parallel/semaphore.go#L47-L51