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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7,900 | luci/luci-go | scheduler/appengine/engine/utils.go | structFromMap | func structFromMap(m map[string]string) *structpb.Struct {
out := &structpb.Struct{
Fields: make(map[string]*structpb.Value, len(m)),
}
for k, v := range m {
out.Fields[k] = &structpb.Value{
Kind: &structpb.Value_StringValue{StringValue: v},
}
}
return out
} | go | func structFromMap(m map[string]string) *structpb.Struct {
out := &structpb.Struct{
Fields: make(map[string]*structpb.Value, len(m)),
}
for k, v := range m {
out.Fields[k] = &structpb.Value{
Kind: &structpb.Value_StringValue{StringValue: v},
}
}
return out
} | [
"func",
"structFromMap",
"(",
"m",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"structpb",
".",
"Struct",
"{",
"out",
":=",
"&",
"structpb",
".",
"Struct",
"{",
"Fields",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"structpb",
".",
"Value",
... | // structFromMap constructs protobuf.Struct with string keys and values. | [
"structFromMap",
"constructs",
"protobuf",
".",
"Struct",
"with",
"string",
"keys",
"and",
"values",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/utils.go#L249-L259 |
7,901 | luci/luci-go | scheduler/appengine/engine/utils.go | marshalFinishedInvs | func marshalFinishedInvs(invs []*internal.FinishedInvocation) []byte {
if len(invs) == 0 {
return nil
}
blob, err := proto.Marshal(&internal.FinishedInvocationList{Invocations: invs})
if err != nil {
panic(err)
}
return blob
} | go | func marshalFinishedInvs(invs []*internal.FinishedInvocation) []byte {
if len(invs) == 0 {
return nil
}
blob, err := proto.Marshal(&internal.FinishedInvocationList{Invocations: invs})
if err != nil {
panic(err)
}
return blob
} | [
"func",
"marshalFinishedInvs",
"(",
"invs",
"[",
"]",
"*",
"internal",
".",
"FinishedInvocation",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"invs",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"blob",
",",
"err",
":=",
"proto",
".",
"... | // marshalFinishedInvs marshals list of invocations into FinishedInvocationList.
//
// Panics on errors. | [
"marshalFinishedInvs",
"marshals",
"list",
"of",
"invocations",
"into",
"FinishedInvocationList",
".",
"Panics",
"on",
"errors",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/utils.go#L264-L273 |
7,902 | luci/luci-go | scheduler/appengine/engine/utils.go | unmarshalFinishedInvs | func unmarshalFinishedInvs(raw []byte) ([]*internal.FinishedInvocation, error) {
if len(raw) == 0 {
return nil, nil
}
invs := internal.FinishedInvocationList{}
if err := proto.Unmarshal(raw, &invs); err != nil {
return nil, err
}
return invs.Invocations, nil
} | go | func unmarshalFinishedInvs(raw []byte) ([]*internal.FinishedInvocation, error) {
if len(raw) == 0 {
return nil, nil
}
invs := internal.FinishedInvocationList{}
if err := proto.Unmarshal(raw, &invs); err != nil {
return nil, err
}
return invs.Invocations, nil
} | [
"func",
"unmarshalFinishedInvs",
"(",
"raw",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"*",
"internal",
".",
"FinishedInvocation",
",",
"error",
")",
"{",
"if",
"len",
"(",
"raw",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"invs... | // unmarshalFinishedInvs unmarshals FinishedInvocationList proto message. | [
"unmarshalFinishedInvs",
"unmarshals",
"FinishedInvocationList",
"proto",
"message",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/utils.go#L276-L285 |
7,903 | luci/luci-go | scheduler/appengine/engine/utils.go | filteredFinishedInvs | func filteredFinishedInvs(raw []byte, oldest time.Time) ([]*internal.FinishedInvocation, error) {
invs, err := unmarshalFinishedInvs(raw)
if err != nil {
return nil, err
}
filtered := make([]*internal.FinishedInvocation, 0, len(invs))
for _, inv := range invs {
if google.TimeFromProto(inv.Finished).After(oldes... | go | func filteredFinishedInvs(raw []byte, oldest time.Time) ([]*internal.FinishedInvocation, error) {
invs, err := unmarshalFinishedInvs(raw)
if err != nil {
return nil, err
}
filtered := make([]*internal.FinishedInvocation, 0, len(invs))
for _, inv := range invs {
if google.TimeFromProto(inv.Finished).After(oldes... | [
"func",
"filteredFinishedInvs",
"(",
"raw",
"[",
"]",
"byte",
",",
"oldest",
"time",
".",
"Time",
")",
"(",
"[",
"]",
"*",
"internal",
".",
"FinishedInvocation",
",",
"error",
")",
"{",
"invs",
",",
"err",
":=",
"unmarshalFinishedInvs",
"(",
"raw",
")",
... | // filteredFinishedInvocations unmarshals FinishedInvocationList and filters
// it to keep only entries whose Finished timestamp is newer than 'oldest'. | [
"filteredFinishedInvocations",
"unmarshals",
"FinishedInvocationList",
"and",
"filters",
"it",
"to",
"keep",
"only",
"entries",
"whose",
"Finished",
"timestamp",
"is",
"newer",
"than",
"oldest",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/utils.go#L289-L301 |
7,904 | luci/luci-go | logdog/appengine/coordinator/endpoints/services/getConfig.go | GetConfig | func (s *server) GetConfig(c context.Context, req *empty.Empty) (*logdog.GetConfigResponse, error) {
gcfg, err := endpoints.GetServices(c).Config(c)
if err != nil {
log.WithError(err).Errorf(c, "Failed to load configuration.")
return nil, grpcutil.Internal
}
// Load our config service host from settings.
sett... | go | func (s *server) GetConfig(c context.Context, req *empty.Empty) (*logdog.GetConfigResponse, error) {
gcfg, err := endpoints.GetServices(c).Config(c)
if err != nil {
log.WithError(err).Errorf(c, "Failed to load configuration.")
return nil, grpcutil.Internal
}
// Load our config service host from settings.
sett... | [
"func",
"(",
"s",
"*",
"server",
")",
"GetConfig",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"empty",
".",
"Empty",
")",
"(",
"*",
"logdog",
".",
"GetConfigResponse",
",",
"error",
")",
"{",
"gcfg",
",",
"err",
":=",
"endpoints",
".",
"... | // GetConfig allows a service to retrieve the current service configuration
// parameters. | [
"GetConfig",
"allows",
"a",
"service",
"to",
"retrieve",
"the",
"current",
"service",
"configuration",
"parameters",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/endpoints/services/getConfig.go#L30-L53 |
7,905 | luci/luci-go | tokenserver/cmd/luci_machine_tokend/file.go | AtomicWriteFile | func AtomicWriteFile(c context.Context, path string, body []byte, perm os.FileMode) error {
// Write the body to some temp file in the same directory.
tmp := fmt.Sprintf(
"%s.%d_%d_%d.tmp", path, os.Getpid(),
atomic.AddInt32(&counter, 1), time.Now().UnixNano())
if err := ioutil.WriteFile(tmp, body, perm); err !=... | go | func AtomicWriteFile(c context.Context, path string, body []byte, perm os.FileMode) error {
// Write the body to some temp file in the same directory.
tmp := fmt.Sprintf(
"%s.%d_%d_%d.tmp", path, os.Getpid(),
atomic.AddInt32(&counter, 1), time.Now().UnixNano())
if err := ioutil.WriteFile(tmp, body, perm); err !=... | [
"func",
"AtomicWriteFile",
"(",
"c",
"context",
".",
"Context",
",",
"path",
"string",
",",
"body",
"[",
"]",
"byte",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"// Write the body to some temp file in the same directory.",
"tmp",
":=",
"fmt",
".",
... | // AtomicWriteFile atomically replaces the content of a given file.
//
// It will retry a bunch of times on permission errors on Windows, where reader
// may lock the file. | [
"AtomicWriteFile",
"atomically",
"replaces",
"the",
"content",
"of",
"a",
"given",
"file",
".",
"It",
"will",
"retry",
"a",
"bunch",
"of",
"times",
"on",
"permission",
"errors",
"on",
"Windows",
"where",
"reader",
"may",
"lock",
"the",
"file",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/file.go#L35-L68 |
7,906 | luci/luci-go | grpc/grpcutil/paniccatcher.go | NewUnaryServerPanicCatcher | func NewUnaryServerPanicCatcher(next grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
defer paniccatcher.Catch(func(p *paniccatcher.Panic) {
logging.Fields{
"panic... | go | func NewUnaryServerPanicCatcher(next grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
defer paniccatcher.Catch(func(p *paniccatcher.Panic) {
logging.Fields{
"panic... | [
"func",
"NewUnaryServerPanicCatcher",
"(",
"next",
"grpc",
".",
"UnaryServerInterceptor",
")",
"grpc",
".",
"UnaryServerInterceptor",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"interface",
"{",
"}",
",",
"info",
"*",
"grpc",
"."... | // NewUnaryServerPanicCatcher returns a unary interceptor that catches panics
// in RPC handlers, recovers them and returns codes.Internal gRPC errors
// instead.
//
// It can be optionally chained with other interceptor. | [
"NewUnaryServerPanicCatcher",
"returns",
"a",
"unary",
"interceptor",
"that",
"catches",
"panics",
"in",
"RPC",
"handlers",
"recovers",
"them",
"and",
"returns",
"codes",
".",
"Internal",
"gRPC",
"errors",
"instead",
".",
"It",
"can",
"be",
"optionally",
"chained"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/grpcutil/paniccatcher.go#L31-L44 |
7,907 | luci/luci-go | common/logging/gologger/config.go | PickStdFormat | func PickStdFormat(w io.Writer) string {
if file, _ := w.(*os.File); file != nil {
if terminal.IsTerminal(int(file.Fd())) {
return StdFormatWithColor
}
}
return StdFormat
} | go | func PickStdFormat(w io.Writer) string {
if file, _ := w.(*os.File); file != nil {
if terminal.IsTerminal(int(file.Fd())) {
return StdFormatWithColor
}
}
return StdFormat
} | [
"func",
"PickStdFormat",
"(",
"w",
"io",
".",
"Writer",
")",
"string",
"{",
"if",
"file",
",",
"_",
":=",
"w",
".",
"(",
"*",
"os",
".",
"File",
")",
";",
"file",
"!=",
"nil",
"{",
"if",
"terminal",
".",
"IsTerminal",
"(",
"int",
"(",
"file",
"... | // PickStdFormat returns StdFormat for non terminal-backed files or
// StdFormatWithColor for io.Writers that are io.Files backed by a terminal.
//
// Used by default StdConfig. | [
"PickStdFormat",
"returns",
"StdFormat",
"for",
"non",
"terminal",
"-",
"backed",
"files",
"or",
"StdFormatWithColor",
"for",
"io",
".",
"Writers",
"that",
"are",
"io",
".",
"Files",
"backed",
"by",
"a",
"terminal",
".",
"Used",
"by",
"default",
"StdConfig",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/gologger/config.go#L48-L55 |
7,908 | luci/luci-go | common/logging/gologger/config.go | Use | func (lc *LoggerConfig) Use(c context.Context) context.Context {
return logging.SetFactory(c, lc.NewLogger)
} | go | func (lc *LoggerConfig) Use(c context.Context) context.Context {
return logging.SetFactory(c, lc.NewLogger)
} | [
"func",
"(",
"lc",
"*",
"LoggerConfig",
")",
"Use",
"(",
"c",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"return",
"logging",
".",
"SetFactory",
"(",
"c",
",",
"lc",
".",
"NewLogger",
")",
"\n",
"}"
] | // Use registers go-logging based logger as default logger of the context. | [
"Use",
"registers",
"go",
"-",
"logging",
"based",
"logger",
"as",
"default",
"logger",
"of",
"the",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/gologger/config.go#L116-L118 |
7,909 | luci/luci-go | tokenserver/appengine/impl/delegation/config_validation.go | validateDelegationCfg | func validateDelegationCfg(ctx *validation.Context, cfg *admin.DelegationPermissions) {
names := stringset.New(0)
for i, rule := range cfg.Rules {
if rule.Name != "" {
if names.Has(rule.Name) {
ctx.Errorf("two rules with identical name %q", rule.Name)
}
names.Add(rule.Name)
}
validateRule(ctx, fmt.... | go | func validateDelegationCfg(ctx *validation.Context, cfg *admin.DelegationPermissions) {
names := stringset.New(0)
for i, rule := range cfg.Rules {
if rule.Name != "" {
if names.Has(rule.Name) {
ctx.Errorf("two rules with identical name %q", rule.Name)
}
names.Add(rule.Name)
}
validateRule(ctx, fmt.... | [
"func",
"validateDelegationCfg",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"cfg",
"*",
"admin",
".",
"DelegationPermissions",
")",
"{",
"names",
":=",
"stringset",
".",
"New",
"(",
"0",
")",
"\n",
"for",
"i",
",",
"rule",
":=",
"range",
"cfg",
... | // validateDelegationCfg checks deserialized delegation.cfg. | [
"validateDelegationCfg",
"checks",
"deserialized",
"delegation",
".",
"cfg",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/delegation/config_validation.go#L42-L53 |
7,910 | luci/luci-go | tokenserver/appengine/impl/delegation/config_validation.go | validateRule | func validateRule(ctx *validation.Context, title string, r *admin.DelegationRule) {
ctx.Enter(title)
defer ctx.Exit()
if r.Name == "" {
ctx.Errorf(`"name" is required`)
}
v := identitySetValidator{
Field: "requestor",
Context: ctx,
AllowGroups: true,
}
v.validate(r.Requestor)
v = identitySe... | go | func validateRule(ctx *validation.Context, title string, r *admin.DelegationRule) {
ctx.Enter(title)
defer ctx.Exit()
if r.Name == "" {
ctx.Errorf(`"name" is required`)
}
v := identitySetValidator{
Field: "requestor",
Context: ctx,
AllowGroups: true,
}
v.validate(r.Requestor)
v = identitySe... | [
"func",
"validateRule",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"title",
"string",
",",
"r",
"*",
"admin",
".",
"DelegationRule",
")",
"{",
"ctx",
".",
"Enter",
"(",
"title",
")",
"\n",
"defer",
"ctx",
".",
"Exit",
"(",
")",
"\n\n",
"if",... | // validateRule checks single DelegationRule proto.
//
// See config.proto, DelegationRule for the description of allowed values. | [
"validateRule",
"checks",
"single",
"DelegationRule",
"proto",
".",
"See",
"config",
".",
"proto",
"DelegationRule",
"for",
"the",
"description",
"of",
"allowed",
"values",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/delegation/config_validation.go#L58-L105 |
7,911 | luci/luci-go | logdog/client/cli/main.go | coordinatorClient | func (a *application) coordinatorClient(host string) (*coordinator.Client, error) {
host, err := a.resolveHost(host)
if err != nil {
return nil, errors.Annotate(err, "").Err()
}
// Get our Coordinator client instance.
prpcClient := prpc.Client{
C: a.httpClient,
Host: host,
Options: prpc.DefaultOp... | go | func (a *application) coordinatorClient(host string) (*coordinator.Client, error) {
host, err := a.resolveHost(host)
if err != nil {
return nil, errors.Annotate(err, "").Err()
}
// Get our Coordinator client instance.
prpcClient := prpc.Client{
C: a.httpClient,
Host: host,
Options: prpc.DefaultOp... | [
"func",
"(",
"a",
"*",
"application",
")",
"coordinatorClient",
"(",
"host",
"string",
")",
"(",
"*",
"coordinator",
".",
"Client",
",",
"error",
")",
"{",
"host",
",",
"err",
":=",
"a",
".",
"resolveHost",
"(",
"host",
")",
"\n",
"if",
"err",
"!=",
... | // coordinatorClient returns a Coordinator client for the specified host. If
// no host is provided, the command-line host will be used. | [
"coordinatorClient",
"returns",
"a",
"Coordinator",
"client",
"for",
"the",
"specified",
"host",
".",
"If",
"no",
"host",
"is",
"provided",
"the",
"command",
"-",
"line",
"host",
"will",
"be",
"used",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cli/main.go#L132-L146 |
7,912 | luci/luci-go | logdog/client/cli/main.go | Main | func Main(ctx context.Context, params Parameters) int {
ctx = gologger.StdConfig.Use(ctx)
authOptions := params.DefaultAuthOptions
authOptions.Scopes = coordinator.Scopes
a := application{
Application: cli.Application{
Name: "logdog",
Title: "LogDog log data access CLI",
Context: func(context.Cont... | go | func Main(ctx context.Context, params Parameters) int {
ctx = gologger.StdConfig.Use(ctx)
authOptions := params.DefaultAuthOptions
authOptions.Scopes = coordinator.Scopes
a := application{
Application: cli.Application{
Name: "logdog",
Title: "LogDog log data access CLI",
Context: func(context.Cont... | [
"func",
"Main",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"Parameters",
")",
"int",
"{",
"ctx",
"=",
"gologger",
".",
"StdConfig",
".",
"Use",
"(",
"ctx",
")",
"\n\n",
"authOptions",
":=",
"params",
".",
"DefaultAuthOptions",
"\n",
"authOptions... | // Main is the entry point for the CLI application. | [
"Main",
"is",
"the",
"entry",
"point",
"for",
"the",
"CLI",
"application",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cli/main.go#L156-L236 |
7,913 | luci/luci-go | cipd/appengine/impl/model/search.go | queryByTag | func queryByTag(c context.Context, pkg, tag string, cursor datastore.Cursor, pageSize int32) (
out []*datastore.Key,
next datastore.Cursor,
err error) {
// TODO(vadimsh): 'registered_ts' here is when the tag was attached. The
// callers likely expect results ordered by instance registration time. This
// is not ... | go | func queryByTag(c context.Context, pkg, tag string, cursor datastore.Cursor, pageSize int32) (
out []*datastore.Key,
next datastore.Cursor,
err error) {
// TODO(vadimsh): 'registered_ts' here is when the tag was attached. The
// callers likely expect results ordered by instance registration time. This
// is not ... | [
"func",
"queryByTag",
"(",
"c",
"context",
".",
"Context",
",",
"pkg",
",",
"tag",
"string",
",",
"cursor",
"datastore",
".",
"Cursor",
",",
"pageSize",
"int32",
")",
"(",
"out",
"[",
"]",
"*",
"datastore",
".",
"Key",
",",
"next",
"datastore",
".",
... | // queryByTag returns keys of Instances that have the given tag attached.
//
// Returns up to 'pageSize' of results, along with a cursor to continue the
// query or nil if it was the end of it. | [
"queryByTag",
"returns",
"keys",
"of",
"Instances",
"that",
"have",
"the",
"given",
"tag",
"attached",
".",
"Returns",
"up",
"to",
"pageSize",
"of",
"results",
"along",
"with",
"a",
"cursor",
"to",
"continue",
"the",
"query",
"or",
"nil",
"if",
"it",
"was"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/search.go#L129-L165 |
7,914 | luci/luci-go | cipd/appengine/impl/model/search.go | fetchExistingInstances | func fetchExistingInstances(c context.Context, keys []*datastore.Key) ([]*Instance, error) {
instances := make([]*Instance, len(keys))
for i, k := range keys {
instances[i] = &Instance{
InstanceID: k.StringID(),
Package: k.Parent(),
}
}
err := datastore.Get(c, instances)
if err == nil {
return inst... | go | func fetchExistingInstances(c context.Context, keys []*datastore.Key) ([]*Instance, error) {
instances := make([]*Instance, len(keys))
for i, k := range keys {
instances[i] = &Instance{
InstanceID: k.StringID(),
Package: k.Parent(),
}
}
err := datastore.Get(c, instances)
if err == nil {
return inst... | [
"func",
"fetchExistingInstances",
"(",
"c",
"context",
".",
"Context",
",",
"keys",
"[",
"]",
"*",
"datastore",
".",
"Key",
")",
"(",
"[",
"]",
"*",
"Instance",
",",
"error",
")",
"{",
"instances",
":=",
"make",
"(",
"[",
"]",
"*",
"Instance",
",",
... | // fetchExistingInstances fetches Instance entities given their keys.
//
// Skips missing ones. | [
"fetchExistingInstances",
"fetches",
"Instance",
"entities",
"given",
"their",
"keys",
".",
"Skips",
"missing",
"ones",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/search.go#L195-L224 |
7,915 | luci/luci-go | luci_notify/config/settings.go | Load | func (s *Settings) Load(props datastore.PropertyMap) error {
if pdata, ok := props["Settings"]; ok {
settings := pdata.Slice()
if len(settings) != 1 {
return fmt.Errorf("property `Settings` is a property slice")
}
settingsBytes, ok := settings[0].Value().([]byte)
if !ok {
return fmt.Errorf("expected by... | go | func (s *Settings) Load(props datastore.PropertyMap) error {
if pdata, ok := props["Settings"]; ok {
settings := pdata.Slice()
if len(settings) != 1 {
return fmt.Errorf("property `Settings` is a property slice")
}
settingsBytes, ok := settings[0].Value().([]byte)
if !ok {
return fmt.Errorf("expected by... | [
"func",
"(",
"s",
"*",
"Settings",
")",
"Load",
"(",
"props",
"datastore",
".",
"PropertyMap",
")",
"error",
"{",
"if",
"pdata",
",",
"ok",
":=",
"props",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"settings",
":=",
"pdata",
".",
"Slice",
"(",
")",
"\... | // Load loads a Settings's information from props.
//
// This implements PropertyLoadSaver. Load unmarshals the property Settings
// stored in the datastore as a binary proto into the struct's Settings field. | [
"Load",
"loads",
"a",
"Settings",
"s",
"information",
"from",
"props",
".",
"This",
"implements",
"PropertyLoadSaver",
".",
"Load",
"unmarshals",
"the",
"property",
"Settings",
"stored",
"in",
"the",
"datastore",
"as",
"a",
"binary",
"proto",
"into",
"the",
"s... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/settings.go#L48-L64 |
7,916 | luci/luci-go | luci_notify/config/settings.go | Save | func (s *Settings) Save(withMeta bool) (datastore.PropertyMap, error) {
props, err := datastore.GetPLS(s).Save(withMeta)
if err != nil {
return nil, err
}
settingsBytes, err := proto.Marshal(&s.Settings)
if err != nil {
return nil, err
}
props["Settings"] = datastore.MkProperty(settingsBytes)
return props, ... | go | func (s *Settings) Save(withMeta bool) (datastore.PropertyMap, error) {
props, err := datastore.GetPLS(s).Save(withMeta)
if err != nil {
return nil, err
}
settingsBytes, err := proto.Marshal(&s.Settings)
if err != nil {
return nil, err
}
props["Settings"] = datastore.MkProperty(settingsBytes)
return props, ... | [
"func",
"(",
"s",
"*",
"Settings",
")",
"Save",
"(",
"withMeta",
"bool",
")",
"(",
"datastore",
".",
"PropertyMap",
",",
"error",
")",
"{",
"props",
",",
"err",
":=",
"datastore",
".",
"GetPLS",
"(",
"s",
")",
".",
"Save",
"(",
"withMeta",
")",
"\n... | // Save saves a Settings's information to a property map.
//
// This implements PropertyLoadSaver. Save marshals the Settings
// field as a binary proto and stores it in the Settings property. | [
"Save",
"saves",
"a",
"Settings",
"s",
"information",
"to",
"a",
"property",
"map",
".",
"This",
"implements",
"PropertyLoadSaver",
".",
"Save",
"marshals",
"the",
"Settings",
"field",
"as",
"a",
"binary",
"proto",
"and",
"stores",
"it",
"in",
"the",
"Settin... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/settings.go#L70-L81 |
7,917 | luci/luci-go | luci_notify/config/settings.go | updateSettings | func updateSettings(c context.Context) error {
// Load the settings from luci-config.
cs := cfgclient.CurrentServiceConfigSet(c)
lucicfg := GetConfigService(c)
cfg, err := lucicfg.GetConfig(c, cs, "settings.cfg", false)
if err != nil {
return errors.Annotate(err, "loading settings.cfg from luci-config").Err()
}... | go | func updateSettings(c context.Context) error {
// Load the settings from luci-config.
cs := cfgclient.CurrentServiceConfigSet(c)
lucicfg := GetConfigService(c)
cfg, err := lucicfg.GetConfig(c, cs, "settings.cfg", false)
if err != nil {
return errors.Annotate(err, "loading settings.cfg from luci-config").Err()
}... | [
"func",
"updateSettings",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Load the settings from luci-config.",
"cs",
":=",
"cfgclient",
".",
"CurrentServiceConfigSet",
"(",
"c",
")",
"\n",
"lucicfg",
":=",
"GetConfigService",
"(",
"c",
")",
"\n",
"c... | // updateSettings fetches the service config from luci-config and then stores
// the new config into the datastore. | [
"updateSettings",
"fetches",
"the",
"service",
"config",
"from",
"luci",
"-",
"config",
"and",
"then",
"stores",
"the",
"new",
"config",
"into",
"the",
"datastore",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/config/settings.go#L85-L124 |
7,918 | luci/luci-go | server/auth/authdb/erroring.go | IsInternalService | func (db ErroringDB) IsInternalService(c context.Context, hostname string) (bool, error) {
logging.Errorf(c, "%s", db.Error)
return false, db.Error
} | go | func (db ErroringDB) IsInternalService(c context.Context, hostname string) (bool, error) {
logging.Errorf(c, "%s", db.Error)
return false, db.Error
} | [
"func",
"(",
"db",
"ErroringDB",
")",
"IsInternalService",
"(",
"c",
"context",
".",
"Context",
",",
"hostname",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"logging",
".",
"Errorf",
"(",
"c",
",",
"\"",
"\"",
",",
"db",
".",
"Error",
")",
... | // IsInternalService returns true if the given hostname belongs to a service
// that is a part of the current LUCI deployment. | [
"IsInternalService",
"returns",
"true",
"if",
"the",
"given",
"hostname",
"belongs",
"to",
"a",
"service",
"that",
"is",
"a",
"part",
"of",
"the",
"current",
"LUCI",
"deployment",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/erroring.go#L40-L43 |
7,919 | luci/luci-go | server/auth/authdb/erroring.go | IsMember | func (db ErroringDB) IsMember(c context.Context, id identity.Identity, groups []string) (bool, error) {
logging.Errorf(c, "%s", db.Error)
return false, db.Error
} | go | func (db ErroringDB) IsMember(c context.Context, id identity.Identity, groups []string) (bool, error) {
logging.Errorf(c, "%s", db.Error)
return false, db.Error
} | [
"func",
"(",
"db",
"ErroringDB",
")",
"IsMember",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"identity",
".",
"Identity",
",",
"groups",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"logging",
".",
"Errorf",
"(",
"c",
",",
"\"... | // IsMember returns true if the given identity belongs to any of the groups. | [
"IsMember",
"returns",
"true",
"if",
"the",
"given",
"identity",
"belongs",
"to",
"any",
"of",
"the",
"groups",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/erroring.go#L46-L49 |
7,920 | luci/luci-go | server/auth/authdb/erroring.go | CheckMembership | func (db ErroringDB) CheckMembership(c context.Context, id identity.Identity, groups []string) ([]string, error) {
logging.Errorf(c, "%s", db.Error)
return nil, db.Error
} | go | func (db ErroringDB) CheckMembership(c context.Context, id identity.Identity, groups []string) ([]string, error) {
logging.Errorf(c, "%s", db.Error)
return nil, db.Error
} | [
"func",
"(",
"db",
"ErroringDB",
")",
"CheckMembership",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"identity",
".",
"Identity",
",",
"groups",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"logging",
".",
"Errorf",
"... | // CheckMembership returns groups from the given list the identity belongs to. | [
"CheckMembership",
"returns",
"groups",
"from",
"the",
"given",
"list",
"the",
"identity",
"belongs",
"to",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/erroring.go#L52-L55 |
7,921 | luci/luci-go | cipd/appengine/impl/model/processing.go | ReadResult | func (p *ProcessingResult) ReadResult(r interface{}) error {
if len(p.ResultRaw) == 0 {
return nil
}
z, err := zlib.NewReader(bytes.NewReader(p.ResultRaw))
if err != nil {
return errors.Annotate(err, "failed to open the blob for zlib decompression").Err()
}
if err := json.NewDecoder(z).Decode(r); err != nil {... | go | func (p *ProcessingResult) ReadResult(r interface{}) error {
if len(p.ResultRaw) == 0 {
return nil
}
z, err := zlib.NewReader(bytes.NewReader(p.ResultRaw))
if err != nil {
return errors.Annotate(err, "failed to open the blob for zlib decompression").Err()
}
if err := json.NewDecoder(z).Decode(r); err != nil {... | [
"func",
"(",
"p",
"*",
"ProcessingResult",
")",
"ReadResult",
"(",
"r",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"p",
".",
"ResultRaw",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"z",
",",
"err",
":=",
"zlib",
".",
... | // ReadResult deserializes the result into the given variable.
//
// Does nothing if there's no results stored. | [
"ReadResult",
"deserializes",
"the",
"result",
"into",
"the",
"given",
"variable",
".",
"Does",
"nothing",
"if",
"there",
"s",
"no",
"results",
"stored",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/processing.go#L81-L97 |
7,922 | luci/luci-go | cipd/appengine/impl/model/processing.go | ReadResultIntoStruct | func (p *ProcessingResult) ReadResultIntoStruct(s *structpb.Struct) error {
if len(p.ResultRaw) == 0 {
return nil
}
z, err := zlib.NewReader(bytes.NewReader(p.ResultRaw))
if err != nil {
return errors.Annotate(err, "failed to open the blob for zlib decompression").Err()
}
if err := (&jsonpb.Unmarshaler{}).Unm... | go | func (p *ProcessingResult) ReadResultIntoStruct(s *structpb.Struct) error {
if len(p.ResultRaw) == 0 {
return nil
}
z, err := zlib.NewReader(bytes.NewReader(p.ResultRaw))
if err != nil {
return errors.Annotate(err, "failed to open the blob for zlib decompression").Err()
}
if err := (&jsonpb.Unmarshaler{}).Unm... | [
"func",
"(",
"p",
"*",
"ProcessingResult",
")",
"ReadResultIntoStruct",
"(",
"s",
"*",
"structpb",
".",
"Struct",
")",
"error",
"{",
"if",
"len",
"(",
"p",
".",
"ResultRaw",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"z",
",",
"err",
":... | // ReadResultIntoStruct deserializes the result into the protobuf.Struct.
//
// Does nothing if there's no results stored. | [
"ReadResultIntoStruct",
"deserializes",
"the",
"result",
"into",
"the",
"protobuf",
".",
"Struct",
".",
"Does",
"nothing",
"if",
"there",
"s",
"no",
"results",
"stored",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/processing.go#L102-L118 |
7,923 | luci/luci-go | cipd/appengine/impl/model/processing.go | Proto | func (p *ProcessingResult) Proto() (*api.Processor, error) {
out := &api.Processor{Id: p.ProcID}
if p.CreatedTs.IsZero() {
out.State = api.Processor_PENDING // no result yet
return out, nil
}
out.FinishedTs = google.NewTimestamp(p.CreatedTs)
if p.Success {
out.State = api.Processor_SUCCEEDED
res := &stru... | go | func (p *ProcessingResult) Proto() (*api.Processor, error) {
out := &api.Processor{Id: p.ProcID}
if p.CreatedTs.IsZero() {
out.State = api.Processor_PENDING // no result yet
return out, nil
}
out.FinishedTs = google.NewTimestamp(p.CreatedTs)
if p.Success {
out.State = api.Processor_SUCCEEDED
res := &stru... | [
"func",
"(",
"p",
"*",
"ProcessingResult",
")",
"Proto",
"(",
")",
"(",
"*",
"api",
".",
"Processor",
",",
"error",
")",
"{",
"out",
":=",
"&",
"api",
".",
"Processor",
"{",
"Id",
":",
"p",
".",
"ProcID",
"}",
"\n\n",
"if",
"p",
".",
"CreatedTs",... | // Proto returns cipd.Processor proto with information from this entity. | [
"Proto",
"returns",
"cipd",
".",
"Processor",
"proto",
"with",
"information",
"from",
"this",
"entity",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/processing.go#L121-L145 |
7,924 | luci/luci-go | machine-db/appengine/rpc/vm_slots.go | FindVMSlots | func (*Service) FindVMSlots(c context.Context, req *crimson.FindVMSlotsRequest) (*crimson.FindVMSlotsResponse, error) {
hosts, err := findVMSlots(c, database.Get(c), req)
if err != nil {
return nil, err
}
return &crimson.FindVMSlotsResponse{
Hosts: hosts,
}, nil
} | go | func (*Service) FindVMSlots(c context.Context, req *crimson.FindVMSlotsRequest) (*crimson.FindVMSlotsResponse, error) {
hosts, err := findVMSlots(c, database.Get(c), req)
if err != nil {
return nil, err
}
return &crimson.FindVMSlotsResponse{
Hosts: hosts,
}, nil
} | [
"func",
"(",
"*",
"Service",
")",
"FindVMSlots",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"crimson",
".",
"FindVMSlotsRequest",
")",
"(",
"*",
"crimson",
".",
"FindVMSlotsResponse",
",",
"error",
")",
"{",
"hosts",
",",
"err",
":=",
"findVMS... | // FindVMSlots handles a request to find available VM slots. | [
"FindVMSlots",
"handles",
"a",
"request",
"to",
"find",
"available",
"VM",
"slots",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/vm_slots.go#L29-L37 |
7,925 | luci/luci-go | machine-db/appengine/rpc/vm_slots.go | findVMSlots | func findVMSlots(c context.Context, q database.QueryerContext, req *crimson.FindVMSlotsRequest) ([]*crimson.PhysicalHost, error) {
stmt := squirrel.Select("h.name", "h.vlan_id", "ph.vm_slots - COUNT(v.physical_host_id)", "ph.virtual_datacenter", "m.state").
From("(physical_hosts ph, hostnames h, machines m)")
if le... | go | func findVMSlots(c context.Context, q database.QueryerContext, req *crimson.FindVMSlotsRequest) ([]*crimson.PhysicalHost, error) {
stmt := squirrel.Select("h.name", "h.vlan_id", "ph.vm_slots - COUNT(v.physical_host_id)", "ph.virtual_datacenter", "m.state").
From("(physical_hosts ph, hostnames h, machines m)")
if le... | [
"func",
"findVMSlots",
"(",
"c",
"context",
".",
"Context",
",",
"q",
"database",
".",
"QueryerContext",
",",
"req",
"*",
"crimson",
".",
"FindVMSlotsRequest",
")",
"(",
"[",
"]",
"*",
"crimson",
".",
"PhysicalHost",
",",
"error",
")",
"{",
"stmt",
":=",... | // findVMSlots returns a slice of physical hosts with available VM slots in the database. | [
"findVMSlots",
"returns",
"a",
"slice",
"of",
"physical",
"hosts",
"with",
"available",
"VM",
"slots",
"in",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/vm_slots.go#L40-L86 |
7,926 | luci/luci-go | vpython/run.go | Exec | func Exec(c context.Context, interp *python.Interpreter, cl *python.CommandLine, env environ.Env, dir string, setupFn func() error) error {
// Don't use cl.SetIsolatedFlags here, because they include -B and -E, which
// both turn off commonly-used aspects of the python interpreter. We do set
// '-s' though, because ... | go | func Exec(c context.Context, interp *python.Interpreter, cl *python.CommandLine, env environ.Env, dir string, setupFn func() error) error {
// Don't use cl.SetIsolatedFlags here, because they include -B and -E, which
// both turn off commonly-used aspects of the python interpreter. We do set
// '-s' though, because ... | [
"func",
"Exec",
"(",
"c",
"context",
".",
"Context",
",",
"interp",
"*",
"python",
".",
"Interpreter",
",",
"cl",
"*",
"python",
".",
"CommandLine",
",",
"env",
"environ",
".",
"Env",
",",
"dir",
"string",
",",
"setupFn",
"func",
"(",
")",
"error",
"... | // Exec runs the specified Python command.
//
// Once the process launches, Context cancellation will not have an impact.
//
// interp is the Python interperer to run.
//
// cl is the populated CommandLine to run.
//
// env is the environment to install.
//
// dir, if not empty, is the working directory of the command.... | [
"Exec",
"runs",
"the",
"specified",
"Python",
"command",
".",
"Once",
"the",
"process",
"launches",
"Context",
"cancellation",
"will",
"not",
"have",
"an",
"impact",
".",
"interp",
"is",
"the",
"Python",
"interperer",
"to",
"run",
".",
"cl",
"is",
"the",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/run.go#L105-L116 |
7,927 | luci/luci-go | tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go | MintOAuthTokenGrant | func (r *MintOAuthTokenGrantRPC) MintOAuthTokenGrant(c context.Context, req *minter.MintOAuthTokenGrantRequest) (*minter.MintOAuthTokenGrantResponse, error) {
state := auth.GetState(c)
// Don't allow delegation tokens here to reduce total number of possible
// scenarios. Proxies aren't expected to use delegation fo... | go | func (r *MintOAuthTokenGrantRPC) MintOAuthTokenGrant(c context.Context, req *minter.MintOAuthTokenGrantRequest) (*minter.MintOAuthTokenGrantResponse, error) {
state := auth.GetState(c)
// Don't allow delegation tokens here to reduce total number of possible
// scenarios. Proxies aren't expected to use delegation fo... | [
"func",
"(",
"r",
"*",
"MintOAuthTokenGrantRPC",
")",
"MintOAuthTokenGrant",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"minter",
".",
"MintOAuthTokenGrantRequest",
")",
"(",
"*",
"minter",
".",
"MintOAuthTokenGrantResponse",
",",
"error",
")",
"{",
... | // MintOAuthTokenGrant produces new OAuth token grant. | [
"MintOAuthTokenGrant",
"produces",
"new",
"OAuth",
"token",
"grant",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go#L62-L133 |
7,928 | luci/luci-go | tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go | validateRequest | func (r *MintOAuthTokenGrantRPC) validateRequest(c context.Context, req *minter.MintOAuthTokenGrantRequest, caller identity.Identity) (*Rule, error) {
// Dump the whole request and relevant auth state to the debug log.
r.logRequest(c, req, caller)
// Reject obviously bad requests.
if err := r.checkRequestFormat(re... | go | func (r *MintOAuthTokenGrantRPC) validateRequest(c context.Context, req *minter.MintOAuthTokenGrantRequest, caller identity.Identity) (*Rule, error) {
// Dump the whole request and relevant auth state to the debug log.
r.logRequest(c, req, caller)
// Reject obviously bad requests.
if err := r.checkRequestFormat(re... | [
"func",
"(",
"r",
"*",
"MintOAuthTokenGrantRPC",
")",
"validateRequest",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"minter",
".",
"MintOAuthTokenGrantRequest",
",",
"caller",
"identity",
".",
"Identity",
")",
"(",
"*",
"Rule",
",",
"error",
")",
... | // validateRequest checks that the request is allowed.
//
// Returns corresponding config rule on success or a grpc error on error. | [
"validateRequest",
"checks",
"that",
"the",
"request",
"is",
"allowed",
".",
"Returns",
"corresponding",
"config",
"rule",
"on",
"success",
"or",
"a",
"grpc",
"error",
"on",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go#L138-L154 |
7,929 | luci/luci-go | tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go | logRequest | func (r *MintOAuthTokenGrantRPC) logRequest(c context.Context, req *minter.MintOAuthTokenGrantRequest, caller identity.Identity) {
if !logging.IsLogging(c, logging.Debug) {
return
}
m := jsonpb.Marshaler{Indent: " "}
dump, _ := m.MarshalToString(req)
logging.Debugf(c, "Identity: %s", caller)
logging.Debugf(c, ... | go | func (r *MintOAuthTokenGrantRPC) logRequest(c context.Context, req *minter.MintOAuthTokenGrantRequest, caller identity.Identity) {
if !logging.IsLogging(c, logging.Debug) {
return
}
m := jsonpb.Marshaler{Indent: " "}
dump, _ := m.MarshalToString(req)
logging.Debugf(c, "Identity: %s", caller)
logging.Debugf(c, ... | [
"func",
"(",
"r",
"*",
"MintOAuthTokenGrantRPC",
")",
"logRequest",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"minter",
".",
"MintOAuthTokenGrantRequest",
",",
"caller",
"identity",
".",
"Identity",
")",
"{",
"if",
"!",
"logging",
".",
"IsLogging... | // logRequest logs the body of the request. | [
"logRequest",
"logs",
"the",
"body",
"of",
"the",
"request",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go#L157-L165 |
7,930 | luci/luci-go | tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go | checkRequestFormat | func (r *MintOAuthTokenGrantRPC) checkRequestFormat(req *minter.MintOAuthTokenGrantRequest) error {
switch {
case req.ServiceAccount == "":
return fmt.Errorf("service_account is required")
case req.ValidityDuration < 0:
return fmt.Errorf("validity_duration must be positive, not %d", req.ValidityDuration)
case r... | go | func (r *MintOAuthTokenGrantRPC) checkRequestFormat(req *minter.MintOAuthTokenGrantRequest) error {
switch {
case req.ServiceAccount == "":
return fmt.Errorf("service_account is required")
case req.ValidityDuration < 0:
return fmt.Errorf("validity_duration must be positive, not %d", req.ValidityDuration)
case r... | [
"func",
"(",
"r",
"*",
"MintOAuthTokenGrantRPC",
")",
"checkRequestFormat",
"(",
"req",
"*",
"minter",
".",
"MintOAuthTokenGrantRequest",
")",
"error",
"{",
"switch",
"{",
"case",
"req",
".",
"ServiceAccount",
"==",
"\"",
"\"",
":",
"return",
"fmt",
".",
"Er... | // checkRequestFormat returns an error if the request is obviously wrong. | [
"checkRequestFormat",
"returns",
"an",
"error",
"if",
"the",
"request",
"is",
"obviously",
"wrong",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go#L168-L184 |
7,931 | luci/luci-go | tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go | checkRules | func (r *MintOAuthTokenGrantRPC) checkRules(c context.Context, req *minter.MintOAuthTokenGrantRequest, caller identity.Identity) (*Rule, error) {
rules, err := r.Rules(c)
if err != nil {
logging.WithError(err).Errorf(c, "Failed to load service accounts rules")
return nil, status.Errorf(codes.Internal, "failed to ... | go | func (r *MintOAuthTokenGrantRPC) checkRules(c context.Context, req *minter.MintOAuthTokenGrantRequest, caller identity.Identity) (*Rule, error) {
rules, err := r.Rules(c)
if err != nil {
logging.WithError(err).Errorf(c, "Failed to load service accounts rules")
return nil, status.Errorf(codes.Internal, "failed to ... | [
"func",
"(",
"r",
"*",
"MintOAuthTokenGrantRPC",
")",
"checkRules",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"minter",
".",
"MintOAuthTokenGrantRequest",
",",
"caller",
"identity",
".",
"Identity",
")",
"(",
"*",
"Rule",
",",
"error",
")",
"{"... | // checkRules verifies the requested token is allowed by the rules.
//
// Returns the matching rule or a grpc error. | [
"checkRules",
"verifies",
"the",
"requested",
"token",
"is",
"allowed",
"by",
"the",
"rules",
".",
"Returns",
"the",
"matching",
"rule",
"or",
"a",
"grpc",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/serviceaccounts/rpc_mint_oauth_token_grant.go#L189-L215 |
7,932 | luci/luci-go | common/logging/exported.go | SetError | func SetError(c context.Context, err error) context.Context {
return SetField(c, ErrorKey, err)
} | go | func SetError(c context.Context, err error) context.Context {
return SetField(c, ErrorKey, err)
} | [
"func",
"SetError",
"(",
"c",
"context",
".",
"Context",
",",
"err",
"error",
")",
"context",
".",
"Context",
"{",
"return",
"SetField",
"(",
"c",
",",
"ErrorKey",
",",
"err",
")",
"\n",
"}"
] | // SetError returns a context with its error field set. | [
"SetError",
"returns",
"a",
"context",
"with",
"its",
"error",
"field",
"set",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/exported.go#L20-L22 |
7,933 | luci/luci-go | common/logging/exported.go | IsLogging | func IsLogging(c context.Context, l Level) bool {
return l >= GetLevel(c)
} | go | func IsLogging(c context.Context, l Level) bool {
return l >= GetLevel(c)
} | [
"func",
"IsLogging",
"(",
"c",
"context",
".",
"Context",
",",
"l",
"Level",
")",
"bool",
"{",
"return",
"l",
">=",
"GetLevel",
"(",
"c",
")",
"\n",
"}"
] | // IsLogging tests whether the context is configured to log at the specified
// level.
//
// Individual Logger implementations are supposed to call this function when
// deciding whether to log the message. | [
"IsLogging",
"tests",
"whether",
"the",
"context",
"is",
"configured",
"to",
"log",
"at",
"the",
"specified",
"level",
".",
"Individual",
"Logger",
"implementations",
"are",
"supposed",
"to",
"call",
"this",
"function",
"when",
"deciding",
"whether",
"to",
"log"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/exported.go#L29-L31 |
7,934 | luci/luci-go | common/logging/exported.go | Logf | func Logf(c context.Context, l Level, fmt string, args ...interface{}) {
Get(c).LogCall(l, 1, fmt, args)
} | go | func Logf(c context.Context, l Level, fmt string, args ...interface{}) {
Get(c).LogCall(l, 1, fmt, args)
} | [
"func",
"Logf",
"(",
"c",
"context",
".",
"Context",
",",
"l",
"Level",
",",
"fmt",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"Get",
"(",
"c",
")",
".",
"LogCall",
"(",
"l",
",",
"1",
",",
"fmt",
",",
"args",
")",
"\n",
"... | // Logf is a shorthand method to call the current logger's logging method which
// corresponds to the supplied log level. | [
"Logf",
"is",
"a",
"shorthand",
"method",
"to",
"call",
"the",
"current",
"logger",
"s",
"logging",
"method",
"which",
"corresponds",
"to",
"the",
"supplied",
"log",
"level",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/exported.go#L55-L57 |
7,935 | luci/luci-go | machine-db/client/cli/kvms.go | printKVMs | func printKVMs(tsv bool, kvms ...*crimson.KVM) {
if len(kvms) > 0 {
p := newStdoutPrinter(tsv)
defer p.Flush()
if !tsv {
p.Row("Name", "VLAN", "Platform", "Datacenter", "Rack", "Description", "MAC Address", "IP Address", "State")
}
for _, k := range kvms {
p.Row(k.Name, k.Vlan, k.Platform, k.Datacenter... | go | func printKVMs(tsv bool, kvms ...*crimson.KVM) {
if len(kvms) > 0 {
p := newStdoutPrinter(tsv)
defer p.Flush()
if !tsv {
p.Row("Name", "VLAN", "Platform", "Datacenter", "Rack", "Description", "MAC Address", "IP Address", "State")
}
for _, k := range kvms {
p.Row(k.Name, k.Vlan, k.Platform, k.Datacenter... | [
"func",
"printKVMs",
"(",
"tsv",
"bool",
",",
"kvms",
"...",
"*",
"crimson",
".",
"KVM",
")",
"{",
"if",
"len",
"(",
"kvms",
")",
">",
"0",
"{",
"p",
":=",
"newStdoutPrinter",
"(",
"tsv",
")",
"\n",
"defer",
"p",
".",
"Flush",
"(",
")",
"\n",
"... | // printKVMs prints KVM data to stdout in tab-separated columns. | [
"printKVMs",
"prints",
"KVM",
"data",
"to",
"stdout",
"in",
"tab",
"-",
"separated",
"columns",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/kvms.go#L28-L39 |
7,936 | luci/luci-go | machine-db/client/cli/kvms.go | Run | func (c *GetKVMsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
ctx := cli.GetContext(app, c, env)
client := getClient(ctx)
resp, err := client.ListKVMs(ctx, &c.req)
if err != nil {
errors.Log(ctx, err)
return 1
}
printKVMs(c.f.tsv, resp.Kvms...)
return 0
} | go | func (c *GetKVMsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
ctx := cli.GetContext(app, c, env)
client := getClient(ctx)
resp, err := client.ListKVMs(ctx, &c.req)
if err != nil {
errors.Log(ctx, err)
return 1
}
printKVMs(c.f.tsv, resp.Kvms...)
return 0
} | [
"func",
"(",
"c",
"*",
"GetKVMsCmd",
")",
"Run",
"(",
"app",
"subcommands",
".",
"Application",
",",
"args",
"[",
"]",
"string",
",",
"env",
"subcommands",
".",
"Env",
")",
"int",
"{",
"ctx",
":=",
"cli",
".",
"GetContext",
"(",
"app",
",",
"c",
",... | // Run runs the command to get KVMs. | [
"Run",
"runs",
"the",
"command",
"to",
"get",
"KVMs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/kvms.go#L48-L58 |
7,937 | luci/luci-go | machine-db/client/cli/kvms.go | getKVMsCmd | func getKVMsCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "get-kvms [-name <name>]... [-vlan <id>]... [-plat <platform>]... [-rack <rack>]... [-dc <datacenter>]... [-mac <mac address>]... [-ip <ip address>]... [-state <state>]...",
ShortDesc: "retrieves KVMs",
LongDesc: ... | go | func getKVMsCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "get-kvms [-name <name>]... [-vlan <id>]... [-plat <platform>]... [-rack <rack>]... [-dc <datacenter>]... [-mac <mac address>]... [-ip <ip address>]... [-state <state>]...",
ShortDesc: "retrieves KVMs",
LongDesc: ... | [
"func",
"getKVMsCmd",
"(",
"params",
"*",
"Parameters",
")",
"*",
"subcommands",
".",
"Command",
"{",
"return",
"&",
"subcommands",
".",
"Command",
"{",
"UsageLine",
":",
"\"",
"\"",
",",
"ShortDesc",
":",
"\"",
"\"",
",",
"LongDesc",
":",
"\"",
"\\n",
... | // getKVMsCmd returns a command to get KVMs. | [
"getKVMsCmd",
"returns",
"a",
"command",
"to",
"get",
"KVMs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/kvms.go#L61-L80 |
7,938 | luci/luci-go | auth/internal/disk_cache.go | readCacheFile | func (c *DiskTokenCache) readCacheFile() (*cacheFile, error) {
// Minimize the time the file is locked on Windows by reading it all at once
// and decoding later.
//
// We also need to open it with FILE_SHARE_DELETE sharing mode to allow
// writeCacheFile() below to replace open files (even though it tries to wait... | go | func (c *DiskTokenCache) readCacheFile() (*cacheFile, error) {
// Minimize the time the file is locked on Windows by reading it all at once
// and decoding later.
//
// We also need to open it with FILE_SHARE_DELETE sharing mode to allow
// writeCacheFile() below to replace open files (even though it tries to wait... | [
"func",
"(",
"c",
"*",
"DiskTokenCache",
")",
"readCacheFile",
"(",
")",
"(",
"*",
"cacheFile",
",",
"error",
")",
"{",
"// Minimize the time the file is locked on Windows by reading it all at once",
"// and decoding later.",
"//",
"// We also need to open it with FILE_SHARE_DE... | // readCacheFile loads the file with cached tokens. | [
"readCacheFile",
"loads",
"the",
"file",
"with",
"cached",
"tokens",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/internal/disk_cache.go#L109-L141 |
7,939 | luci/luci-go | server/portal/handlers.go | replyError | func replyError(c context.Context, rw http.ResponseWriter, err error) {
if transient.Tag.In(err) {
rw.WriteHeader(http.StatusInternalServerError)
} else {
rw.WriteHeader(http.StatusBadRequest)
}
templates.MustRender(c, rw, "pages/error.html", templates.Args{
"Error": err.Error(),
})
} | go | func replyError(c context.Context, rw http.ResponseWriter, err error) {
if transient.Tag.In(err) {
rw.WriteHeader(http.StatusInternalServerError)
} else {
rw.WriteHeader(http.StatusBadRequest)
}
templates.MustRender(c, rw, "pages/error.html", templates.Args{
"Error": err.Error(),
})
} | [
"func",
"replyError",
"(",
"c",
"context",
".",
"Context",
",",
"rw",
"http",
".",
"ResponseWriter",
",",
"err",
"error",
")",
"{",
"if",
"transient",
".",
"Tag",
".",
"In",
"(",
"err",
")",
"{",
"rw",
".",
"WriteHeader",
"(",
"http",
".",
"StatusInt... | // replyError sends HTML error page with status 500 on transient errors or 400
// on fatal ones. | [
"replyError",
"sends",
"HTML",
"error",
"page",
"with",
"status",
"500",
"on",
"transient",
"errors",
"or",
"400",
"on",
"fatal",
"ones",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/portal/handlers.go#L94-L103 |
7,940 | luci/luci-go | machine-db/client/cli/vm_slots.go | printVMSlots | func printVMSlots(tsv bool, hosts ...*crimson.PhysicalHost) {
if len(hosts) > 0 {
p := newStdoutPrinter(tsv)
defer p.Flush()
if !tsv {
p.Row("Name", "VLAN", "VM Slots", "Virtual Datacenter", "State")
}
for _, h := range hosts {
p.Row(h.Name, h.Vlan, h.VmSlots, h.VirtualDatacenter, h.State)
}
}
} | go | func printVMSlots(tsv bool, hosts ...*crimson.PhysicalHost) {
if len(hosts) > 0 {
p := newStdoutPrinter(tsv)
defer p.Flush()
if !tsv {
p.Row("Name", "VLAN", "VM Slots", "Virtual Datacenter", "State")
}
for _, h := range hosts {
p.Row(h.Name, h.Vlan, h.VmSlots, h.VirtualDatacenter, h.State)
}
}
} | [
"func",
"printVMSlots",
"(",
"tsv",
"bool",
",",
"hosts",
"...",
"*",
"crimson",
".",
"PhysicalHost",
")",
"{",
"if",
"len",
"(",
"hosts",
")",
">",
"0",
"{",
"p",
":=",
"newStdoutPrinter",
"(",
"tsv",
")",
"\n",
"defer",
"p",
".",
"Flush",
"(",
")... | // printVMSlots prints available VM slot data to stdout in tab-separated columns. | [
"printVMSlots",
"prints",
"available",
"VM",
"slot",
"data",
"to",
"stdout",
"in",
"tab",
"-",
"separated",
"columns",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/vm_slots.go#L28-L39 |
7,941 | luci/luci-go | machine-db/client/cli/vm_slots.go | getVMSlotsCmd | func getVMSlotsCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "get-slots -n <slots> [-man <manufacturer>]... [-vdc <virtual datacenter>]... [-state <state>]...",
ShortDesc: "retrieves available VM slots",
LongDesc: "Retrieves available VM slots.\n\nExample to get 5 free V... | go | func getVMSlotsCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "get-slots -n <slots> [-man <manufacturer>]... [-vdc <virtual datacenter>]... [-state <state>]...",
ShortDesc: "retrieves available VM slots",
LongDesc: "Retrieves available VM slots.\n\nExample to get 5 free V... | [
"func",
"getVMSlotsCmd",
"(",
"params",
"*",
"Parameters",
")",
"*",
"subcommands",
".",
"Command",
"{",
"return",
"&",
"subcommands",
".",
"Command",
"{",
"UsageLine",
":",
"\"",
"\"",
",",
"ShortDesc",
":",
"\"",
"\"",
",",
"LongDesc",
":",
"\"",
"\\n"... | // getVMSlotsCmd returns a command to get available VM slots. | [
"getVMSlotsCmd",
"returns",
"a",
"command",
"to",
"get",
"available",
"VM",
"slots",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/vm_slots.go#L61-L76 |
7,942 | luci/luci-go | common/data/text/templateproto/loader.go | LoadFile | func LoadFile(data string) (file *File, err error) {
file = &File{}
if err = proto.UnmarshalTextML(data, file); err != nil {
return
}
err = file.Normalize()
return
} | go | func LoadFile(data string) (file *File, err error) {
file = &File{}
if err = proto.UnmarshalTextML(data, file); err != nil {
return
}
err = file.Normalize()
return
} | [
"func",
"LoadFile",
"(",
"data",
"string",
")",
"(",
"file",
"*",
"File",
",",
"err",
"error",
")",
"{",
"file",
"=",
"&",
"File",
"{",
"}",
"\n",
"if",
"err",
"=",
"proto",
".",
"UnmarshalTextML",
"(",
"data",
",",
"file",
")",
";",
"err",
"!=",... | // LoadFile loads a File from a string containing the template text protobuf.
//
// Expects config.Interface to be in the context already. | [
"LoadFile",
"loads",
"a",
"File",
"from",
"a",
"string",
"containing",
"the",
"template",
"text",
"protobuf",
".",
"Expects",
"config",
".",
"Interface",
"to",
"be",
"in",
"the",
"context",
"already",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/loader.go#L26-L33 |
7,943 | luci/luci-go | common/data/text/templateproto/loader.go | RenderL | func (f *File) RenderL(templName string, params LiteralMap) (ret string, err error) {
spec := &Specifier{TemplateName: templName}
spec.Params, err = params.Convert()
if err != nil {
return
}
return f.Render(spec)
} | go | func (f *File) RenderL(templName string, params LiteralMap) (ret string, err error) {
spec := &Specifier{TemplateName: templName}
spec.Params, err = params.Convert()
if err != nil {
return
}
return f.Render(spec)
} | [
"func",
"(",
"f",
"*",
"File",
")",
"RenderL",
"(",
"templName",
"string",
",",
"params",
"LiteralMap",
")",
"(",
"ret",
"string",
",",
"err",
"error",
")",
"{",
"spec",
":=",
"&",
"Specifier",
"{",
"TemplateName",
":",
"templName",
"}",
"\n",
"spec",
... | // RenderL renders a specified template with go literal arguments. | [
"RenderL",
"renders",
"a",
"specified",
"template",
"with",
"go",
"literal",
"arguments",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/loader.go#L45-L52 |
7,944 | luci/luci-go | scheduler/appengine/internal/noop_trigger.go | NoopTrigger | func NoopTrigger(id, data string) Trigger {
return Trigger{
Id: id,
Payload: &Trigger_Noop{Noop: &api.NoopTrigger{Data: data}},
}
} | go | func NoopTrigger(id, data string) Trigger {
return Trigger{
Id: id,
Payload: &Trigger_Noop{Noop: &api.NoopTrigger{Data: data}},
}
} | [
"func",
"NoopTrigger",
"(",
"id",
",",
"data",
"string",
")",
"Trigger",
"{",
"return",
"Trigger",
"{",
"Id",
":",
"id",
",",
"Payload",
":",
"&",
"Trigger_Noop",
"{",
"Noop",
":",
"&",
"api",
".",
"NoopTrigger",
"{",
"Data",
":",
"data",
"}",
"}",
... | // NoopTrigger constructs a noop trigger proto with given ID and data payload.
//
// No other fields are populated. | [
"NoopTrigger",
"constructs",
"a",
"noop",
"trigger",
"proto",
"with",
"given",
"ID",
"and",
"data",
"payload",
".",
"No",
"other",
"fields",
"are",
"populated",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/internal/noop_trigger.go#L24-L29 |
7,945 | luci/luci-go | cipd/client/cli/friendly.go | optionalSiteRoot | func optionalSiteRoot(siteRoot string) (string, error) {
if siteRoot == "" {
cwd, err := os.Getwd()
if err != nil {
return "", err
}
siteRoot = findSiteRoot(cwd)
if siteRoot == "" {
return "", fmt.Errorf("directory %s is not in a site root, use 'init' to create one", cwd)
}
return siteRoot, nil
}
... | go | func optionalSiteRoot(siteRoot string) (string, error) {
if siteRoot == "" {
cwd, err := os.Getwd()
if err != nil {
return "", err
}
siteRoot = findSiteRoot(cwd)
if siteRoot == "" {
return "", fmt.Errorf("directory %s is not in a site root, use 'init' to create one", cwd)
}
return siteRoot, nil
}
... | [
"func",
"optionalSiteRoot",
"(",
"siteRoot",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"siteRoot",
"==",
"\"",
"\"",
"{",
"cwd",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
... | // optionalSiteRoot takes a path to a site root or an empty string. If some
// path is given, it normalizes it and ensures that it is indeed a site root
// directory. If empty string is given, it discovers a site root for current
// directory. | [
"optionalSiteRoot",
"takes",
"a",
"path",
"to",
"a",
"site",
"root",
"or",
"an",
"empty",
"string",
".",
"If",
"some",
"path",
"is",
"given",
"it",
"normalizes",
"it",
"and",
"ensures",
"that",
"it",
"is",
"indeed",
"a",
"site",
"root",
"directory",
".",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L66-L86 |
7,946 | luci/luci-go | cipd/client/cli/friendly.go | read | func (c *installationSiteConfig) read(path string) error {
*c = installationSiteConfig{}
r, err := os.Open(path)
if err != nil {
return err
}
defer r.Close()
return json.NewDecoder(r).Decode(c)
} | go | func (c *installationSiteConfig) read(path string) error {
*c = installationSiteConfig{}
r, err := os.Open(path)
if err != nil {
return err
}
defer r.Close()
return json.NewDecoder(r).Decode(c)
} | [
"func",
"(",
"c",
"*",
"installationSiteConfig",
")",
"read",
"(",
"path",
"string",
")",
"error",
"{",
"*",
"c",
"=",
"installationSiteConfig",
"{",
"}",
"\n",
"r",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"n... | // read loads JSON from given path. | [
"read",
"loads",
"JSON",
"from",
"given",
"path",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L110-L118 |
7,947 | luci/luci-go | cipd/client/cli/friendly.go | write | func (c *installationSiteConfig) write(path string) error {
blob, err := json.MarshalIndent(c, "", "\t")
if err != nil {
return err
}
return ioutil.WriteFile(path, blob, 0666)
} | go | func (c *installationSiteConfig) write(path string) error {
blob, err := json.MarshalIndent(c, "", "\t")
if err != nil {
return err
}
return ioutil.WriteFile(path, blob, 0666)
} | [
"func",
"(",
"c",
"*",
"installationSiteConfig",
")",
"write",
"(",
"path",
"string",
")",
"error",
"{",
"blob",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"c",
",",
"\"",
"\"",
",",
"\"",
"\\t",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // write dumps JSON to given path. | [
"write",
"dumps",
"JSON",
"to",
"given",
"path",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L121-L127 |
7,948 | luci/luci-go | cipd/client/cli/friendly.go | readConfig | func readConfig(siteRoot string) (installationSiteConfig, error) {
path := filepath.Join(siteRoot, fs.SiteServiceDir, "config.json")
c := installationSiteConfig{}
if err := c.read(path); err != nil && !os.IsNotExist(err) {
return c, err
}
return c, nil
} | go | func readConfig(siteRoot string) (installationSiteConfig, error) {
path := filepath.Join(siteRoot, fs.SiteServiceDir, "config.json")
c := installationSiteConfig{}
if err := c.read(path); err != nil && !os.IsNotExist(err) {
return c, err
}
return c, nil
} | [
"func",
"readConfig",
"(",
"siteRoot",
"string",
")",
"(",
"installationSiteConfig",
",",
"error",
")",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"siteRoot",
",",
"fs",
".",
"SiteServiceDir",
",",
"\"",
"\"",
")",
"\n",
"c",
":=",
"installationSiteC... | // readConfig reads config, returning default one if missing.
//
// The returned config may have ServiceURL set to "" due to previous buggy
// version of CIPD not setting it up correctly. | [
"readConfig",
"reads",
"config",
"returning",
"default",
"one",
"if",
"missing",
".",
"The",
"returned",
"config",
"may",
"have",
"ServiceURL",
"set",
"to",
"due",
"to",
"previous",
"buggy",
"version",
"of",
"CIPD",
"not",
"setting",
"it",
"up",
"correctly",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L133-L140 |
7,949 | luci/luci-go | cipd/client/cli/friendly.go | getInstallationSite | func getInstallationSite(siteRoot, defaultServiceURL string) (*installationSite, error) {
siteRoot, err := optionalSiteRoot(siteRoot)
if err != nil {
return nil, err
}
cfg, err := readConfig(siteRoot)
if err != nil {
return nil, err
}
if cfg.ServiceURL == "" {
cfg.ServiceURL = defaultServiceURL
}
return ... | go | func getInstallationSite(siteRoot, defaultServiceURL string) (*installationSite, error) {
siteRoot, err := optionalSiteRoot(siteRoot)
if err != nil {
return nil, err
}
cfg, err := readConfig(siteRoot)
if err != nil {
return nil, err
}
if cfg.ServiceURL == "" {
cfg.ServiceURL = defaultServiceURL
}
return ... | [
"func",
"getInstallationSite",
"(",
"siteRoot",
",",
"defaultServiceURL",
"string",
")",
"(",
"*",
"installationSite",
",",
"error",
")",
"{",
"siteRoot",
",",
"err",
":=",
"optionalSiteRoot",
"(",
"siteRoot",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // getInstallationSite finds site root directory, reads config and constructs
// installationSite object.
//
// If siteRoot is "", will find a site root based on the current directory,
// otherwise will use siteRoot. Doesn't create any new files or directories,
// just reads what's on disk. | [
"getInstallationSite",
"finds",
"site",
"root",
"directory",
"reads",
"config",
"and",
"constructs",
"installationSite",
"object",
".",
"If",
"siteRoot",
"is",
"will",
"find",
"a",
"site",
"root",
"based",
"on",
"the",
"current",
"directory",
"otherwise",
"will",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L160-L173 |
7,950 | luci/luci-go | cipd/client/cli/friendly.go | initClient | func (site *installationSite) initClient(ctx context.Context, authFlags authcli.Flags) (err error) {
if site.client != nil {
return errors.New("client is already initialized")
}
clientOpts := clientOptions{
authFlags: authFlags,
serviceURL: site.cfg.ServiceURL,
cacheDir: site.cfg.CacheDir,
rootDir: s... | go | func (site *installationSite) initClient(ctx context.Context, authFlags authcli.Flags) (err error) {
if site.client != nil {
return errors.New("client is already initialized")
}
clientOpts := clientOptions{
authFlags: authFlags,
serviceURL: site.cfg.ServiceURL,
cacheDir: site.cfg.CacheDir,
rootDir: s... | [
"func",
"(",
"site",
"*",
"installationSite",
")",
"initClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"authFlags",
"authcli",
".",
"Flags",
")",
"(",
"err",
"error",
")",
"{",
"if",
"site",
".",
"client",
"!=",
"nil",
"{",
"return",
"errors",
".... | // initClient initializes cipd.Client to use to talk to backend.
//
// Can be called only once. Use it directly via site.client. | [
"initClient",
"initializes",
"cipd",
".",
"Client",
"to",
"use",
"to",
"talk",
"to",
"backend",
".",
"Can",
"be",
"called",
"only",
"once",
".",
"Use",
"it",
"directly",
"via",
"site",
".",
"client",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L223-L235 |
7,951 | luci/luci-go | cipd/client/cli/friendly.go | modifyConfig | func (site *installationSite) modifyConfig(cb func(cfg *installationSiteConfig) error) error {
path := filepath.Join(site.siteRoot, fs.SiteServiceDir, "config.json")
c := installationSiteConfig{}
if err := c.read(path); err != nil && !os.IsNotExist(err) {
return err
}
if err := cb(&c); err != nil {
return err
... | go | func (site *installationSite) modifyConfig(cb func(cfg *installationSiteConfig) error) error {
path := filepath.Join(site.siteRoot, fs.SiteServiceDir, "config.json")
c := installationSiteConfig{}
if err := c.read(path); err != nil && !os.IsNotExist(err) {
return err
}
if err := cb(&c); err != nil {
return err
... | [
"func",
"(",
"site",
"*",
"installationSite",
")",
"modifyConfig",
"(",
"cb",
"func",
"(",
"cfg",
"*",
"installationSiteConfig",
")",
"error",
")",
"error",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"site",
".",
"siteRoot",
",",
"fs",
".",
"SiteSe... | // modifyConfig reads config file, calls callback to mutate it, then writes
// it back. | [
"modifyConfig",
"reads",
"config",
"file",
"calls",
"callback",
"to",
"mutate",
"it",
"then",
"writes",
"it",
"back",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L239-L253 |
7,952 | luci/luci-go | cipd/client/cli/friendly.go | installedPackages | func (site *installationSite) installedPackages(ctx context.Context) (map[string][]pinInfo, error) {
d := deployer.New(site.siteRoot)
allPins, err := d.FindDeployed(ctx)
if err != nil {
return nil, err
}
output := make(map[string][]pinInfo, len(allPins))
for subdir, pins := range allPins {
output[subdir] = m... | go | func (site *installationSite) installedPackages(ctx context.Context) (map[string][]pinInfo, error) {
d := deployer.New(site.siteRoot)
allPins, err := d.FindDeployed(ctx)
if err != nil {
return nil, err
}
output := make(map[string][]pinInfo, len(allPins))
for subdir, pins := range allPins {
output[subdir] = m... | [
"func",
"(",
"site",
"*",
"installationSite",
")",
"installedPackages",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"pinInfo",
",",
"error",
")",
"{",
"d",
":=",
"deployer",
".",
"New",
"(",
"site",
".",
"sit... | // installedPackages discovers versions of packages installed in the site.
//
// If pkgs is empty array, it returns list of all installed packages. | [
"installedPackages",
"discovers",
"versions",
"of",
"packages",
"installed",
"in",
"the",
"site",
".",
"If",
"pkgs",
"is",
"empty",
"array",
"it",
"returns",
"list",
"of",
"all",
"installed",
"packages",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/friendly.go#L258-L278 |
7,953 | luci/luci-go | common/api/gitiles/rest.go | getRaw | func (c *client) getRaw(ctx context.Context, urlPath string, query url.Values) (http.Header, []byte, error) {
u := fmt.Sprintf("%s/%s", strings.TrimSuffix(c.BaseURL, "/"), strings.TrimPrefix(urlPath, "/"))
if query != nil {
u = fmt.Sprintf("%s?%s", u, query.Encode())
}
r, err := ctxhttp.Get(ctx, c.Client, u)
if ... | go | func (c *client) getRaw(ctx context.Context, urlPath string, query url.Values) (http.Header, []byte, error) {
u := fmt.Sprintf("%s/%s", strings.TrimSuffix(c.BaseURL, "/"), strings.TrimPrefix(urlPath, "/"))
if query != nil {
u = fmt.Sprintf("%s?%s", u, query.Encode())
}
r, err := ctxhttp.Get(ctx, c.Client, u)
if ... | [
"func",
"(",
"c",
"*",
"client",
")",
"getRaw",
"(",
"ctx",
"context",
".",
"Context",
",",
"urlPath",
"string",
",",
"query",
"url",
".",
"Values",
")",
"(",
"http",
".",
"Header",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"u",
":=",
"fmt",... | // getRaw makes a raw HTTP get request and returns the header and body returned.
//
// In case of errors, getRaw translates the generic HTTP errors to grpc errors. | [
"getRaw",
"makes",
"a",
"raw",
"HTTP",
"get",
"request",
"and",
"returns",
"the",
"header",
"and",
"body",
"returned",
".",
"In",
"case",
"of",
"errors",
"getRaw",
"translates",
"the",
"generic",
"HTTP",
"errors",
"to",
"grpc",
"errors",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gitiles/rest.go#L209-L243 |
7,954 | luci/luci-go | cipd/appengine/impl/model/events.go | FromProto | func (e *Event) FromProto(c context.Context, p *api.Event) *Event {
blob, err := proto.Marshal(p)
if err != nil {
panic(err)
}
e.Package = PackageKey(c, p.Package)
e.Event = blob
e.Kind = p.Kind
e.Who = p.Who
e.When = google.TimeFromProto(p.When).Sub(EventsEpoch).Nanoseconds()
if p.Instance != "" {
e.Insta... | go | func (e *Event) FromProto(c context.Context, p *api.Event) *Event {
blob, err := proto.Marshal(p)
if err != nil {
panic(err)
}
e.Package = PackageKey(c, p.Package)
e.Event = blob
e.Kind = p.Kind
e.Who = p.Who
e.When = google.TimeFromProto(p.When).Sub(EventsEpoch).Nanoseconds()
if p.Instance != "" {
e.Insta... | [
"func",
"(",
"e",
"*",
"Event",
")",
"FromProto",
"(",
"c",
"context",
".",
"Context",
",",
"p",
"*",
"api",
".",
"Event",
")",
"*",
"Event",
"{",
"blob",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // FromProto fills in the entity based on the proto message.
//
// Panics if the proto can't be serialized. This should never happen.
//
// Returns the entity itself for easier chaining. | [
"FromProto",
"fills",
"in",
"the",
"entity",
"based",
"on",
"the",
"proto",
"message",
".",
"Panics",
"if",
"the",
"proto",
"can",
"t",
"be",
"serialized",
".",
"This",
"should",
"never",
"happen",
".",
"Returns",
"the",
"entity",
"itself",
"for",
"easier"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/events.go#L96-L114 |
7,955 | luci/luci-go | cipd/appengine/impl/model/events.go | Emit | func (t *Events) Emit(e *api.Event) {
t.ev = append(t.ev, e)
} | go | func (t *Events) Emit(e *api.Event) {
t.ev = append(t.ev, e)
} | [
"func",
"(",
"t",
"*",
"Events",
")",
"Emit",
"(",
"e",
"*",
"api",
".",
"Event",
")",
"{",
"t",
".",
"ev",
"=",
"append",
"(",
"t",
".",
"ev",
",",
"e",
")",
"\n",
"}"
] | // Emit adds an event to be flushed later in Flush.
//
// 'Who' and 'When' fields are populated in Flush using values from the context. | [
"Emit",
"adds",
"an",
"event",
"to",
"be",
"flushed",
"later",
"in",
"Flush",
".",
"Who",
"and",
"When",
"fields",
"are",
"populated",
"in",
"Flush",
"using",
"values",
"from",
"the",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/events.go#L148-L150 |
7,956 | luci/luci-go | cipd/appengine/impl/model/events.go | EmitEvent | func EmitEvent(c context.Context, e *api.Event) error {
ev := Events{}
ev.Emit(e)
return ev.Flush(c)
} | go | func EmitEvent(c context.Context, e *api.Event) error {
ev := Events{}
ev.Emit(e)
return ev.Flush(c)
} | [
"func",
"EmitEvent",
"(",
"c",
"context",
".",
"Context",
",",
"e",
"*",
"api",
".",
"Event",
")",
"error",
"{",
"ev",
":=",
"Events",
"{",
"}",
"\n",
"ev",
".",
"Emit",
"(",
"e",
")",
"\n",
"return",
"ev",
".",
"Flush",
"(",
"c",
")",
"\n",
... | // EmitEvent adds a single event to the event log.
//
// Prefer using Events to add multiple events at once. | [
"EmitEvent",
"adds",
"a",
"single",
"event",
"to",
"the",
"event",
"log",
".",
"Prefer",
"using",
"Events",
"to",
"add",
"multiple",
"events",
"at",
"once",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/events.go#L189-L193 |
7,957 | luci/luci-go | cipd/appengine/impl/model/events.go | EmitMetadataEvents | func EmitMetadataEvents(c context.Context, before, after *api.PrefixMetadata) error {
if before.Prefix != after.Prefix {
panic(fmt.Sprintf("comparing metadata for different prefixes: %q != %q", before.Prefix, after.Prefix))
}
prefix := after.Prefix
prev := metadata.GetACLs(before)
next := metadata.GetACLs(after... | go | func EmitMetadataEvents(c context.Context, before, after *api.PrefixMetadata) error {
if before.Prefix != after.Prefix {
panic(fmt.Sprintf("comparing metadata for different prefixes: %q != %q", before.Prefix, after.Prefix))
}
prefix := after.Prefix
prev := metadata.GetACLs(before)
next := metadata.GetACLs(after... | [
"func",
"EmitMetadataEvents",
"(",
"c",
"context",
".",
"Context",
",",
"before",
",",
"after",
"*",
"api",
".",
"PrefixMetadata",
")",
"error",
"{",
"if",
"before",
".",
"Prefix",
"!=",
"after",
".",
"Prefix",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
... | // EmitMetadataEvents compares two metadatum of a prefix and emits events for
// fields that have changed. | [
"EmitMetadataEvents",
"compares",
"two",
"metadatum",
"of",
"a",
"prefix",
"and",
"emits",
"events",
"for",
"fields",
"that",
"have",
"changed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/events.go#L222-L259 |
7,958 | luci/luci-go | common/data/recordio/writer.go | WriteFrame | func WriteFrame(w io.Writer, frame []byte) (int, error) {
count, err := writeFrameHeader(w, uint64(len(frame)))
if err != nil {
return count, err
}
amount, err := w.Write(frame)
count += amount
if err != nil {
return count, err
}
return count, nil
} | go | func WriteFrame(w io.Writer, frame []byte) (int, error) {
count, err := writeFrameHeader(w, uint64(len(frame)))
if err != nil {
return count, err
}
amount, err := w.Write(frame)
count += amount
if err != nil {
return count, err
}
return count, nil
} | [
"func",
"WriteFrame",
"(",
"w",
"io",
".",
"Writer",
",",
"frame",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"writeFrameHeader",
"(",
"w",
",",
"uint64",
"(",
"len",
"(",
"frame",
")",
")",
")",
"\n",
... | // WriteFrame writes a single frame to an io.Writer. | [
"WriteFrame",
"writes",
"a",
"single",
"frame",
"to",
"an",
"io",
".",
"Writer",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/recordio/writer.go#L29-L42 |
7,959 | luci/luci-go | common/tsmon/iface.go | SetStore | func SetStore(c context.Context, s store.Store) {
GetState(c).SetStore(s)
} | go | func SetStore(c context.Context, s store.Store) {
GetState(c).SetStore(s)
} | [
"func",
"SetStore",
"(",
"c",
"context",
".",
"Context",
",",
"s",
"store",
".",
"Store",
")",
"{",
"GetState",
"(",
"c",
")",
".",
"SetStore",
"(",
"s",
")",
"\n",
"}"
] | // SetStore changes the global metric store. All metrics that were registered
// with the old store will be re-registered on the new store. | [
"SetStore",
"changes",
"the",
"global",
"metric",
"store",
".",
"All",
"metrics",
"that",
"were",
"registered",
"with",
"the",
"old",
"store",
"will",
"be",
"re",
"-",
"registered",
"on",
"the",
"new",
"store",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/iface.go#L48-L50 |
7,960 | luci/luci-go | common/tsmon/iface.go | Initialize | func Initialize(c context.Context, m monitor.Monitor, s store.Store) {
state := GetState(c)
state.SetMonitor(m)
state.SetStore(s)
} | go | func Initialize(c context.Context, m monitor.Monitor, s store.Store) {
state := GetState(c)
state.SetMonitor(m)
state.SetStore(s)
} | [
"func",
"Initialize",
"(",
"c",
"context",
".",
"Context",
",",
"m",
"monitor",
".",
"Monitor",
",",
"s",
"store",
".",
"Store",
")",
"{",
"state",
":=",
"GetState",
"(",
"c",
")",
"\n",
"state",
".",
"SetMonitor",
"(",
"m",
")",
"\n",
"state",
"."... | // Initialize configures the tsmon library with the given monitor and store. | [
"Initialize",
"configures",
"the",
"tsmon",
"library",
"with",
"the",
"given",
"monitor",
"and",
"store",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/iface.go#L126-L130 |
7,961 | luci/luci-go | common/tsmon/iface.go | newAuthenticator | func newAuthenticator(ctx context.Context, credentials, actAs string, scopes []string) *auth.Authenticator {
// TODO(vadimsh): Don't hardcode auth options here, pass them from outside
// somehow.
authOpts := chromeinfra.DefaultAuthOptions()
authOpts.ServiceAccountJSONPath = credentials
authOpts.Scopes = scopes
au... | go | func newAuthenticator(ctx context.Context, credentials, actAs string, scopes []string) *auth.Authenticator {
// TODO(vadimsh): Don't hardcode auth options here, pass them from outside
// somehow.
authOpts := chromeinfra.DefaultAuthOptions()
authOpts.ServiceAccountJSONPath = credentials
authOpts.Scopes = scopes
au... | [
"func",
"newAuthenticator",
"(",
"ctx",
"context",
".",
"Context",
",",
"credentials",
",",
"actAs",
"string",
",",
"scopes",
"[",
"]",
"string",
")",
"*",
"auth",
".",
"Authenticator",
"{",
"// TODO(vadimsh): Don't hardcode auth options here, pass them from outside",
... | // newAuthenticator returns a new authenticator for HTTP requests. | [
"newAuthenticator",
"returns",
"a",
"new",
"authenticator",
"for",
"HTTP",
"requests",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/iface.go#L196-L204 |
7,962 | luci/luci-go | logdog/server/cmd/logdog_archivist/main.go | settingsUpdater | func settingsUpdater(c context.Context) {
for {
set := coordinator.GetSettings(c)
logging.Debugf(c, "updating settings: %v", set)
if batchSize != set.ArchivistBatchSize {
batchSize = set.ArchivistBatchSize
}
if leaseTime != set.ArchivistLeaseTime {
leaseTime = set.ArchivistLeaseTime
}
clock.Sleep(c... | go | func settingsUpdater(c context.Context) {
for {
set := coordinator.GetSettings(c)
logging.Debugf(c, "updating settings: %v", set)
if batchSize != set.ArchivistBatchSize {
batchSize = set.ArchivistBatchSize
}
if leaseTime != set.ArchivistLeaseTime {
leaseTime = set.ArchivistLeaseTime
}
clock.Sleep(c... | [
"func",
"settingsUpdater",
"(",
"c",
"context",
".",
"Context",
")",
"{",
"for",
"{",
"set",
":=",
"coordinator",
".",
"GetSettings",
"(",
"c",
")",
"\n",
"logging",
".",
"Debugf",
"(",
"c",
",",
"\"",
"\"",
",",
"set",
")",
"\n",
"if",
"batchSize",
... | // settingsUpdater updates the settings from datastore every once in a while. | [
"settingsUpdater",
"updates",
"the",
"settings",
"from",
"datastore",
"every",
"once",
"in",
"a",
"while",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/cmd/logdog_archivist/main.go#L182-L194 |
7,963 | luci/luci-go | logdog/server/cmd/logdog_archivist/main.go | GetSettingsLoader | func (a *application) GetSettingsLoader(acfg *svcconfig.Archivist) archivist.SettingsLoader {
serviceID := a.ServiceID()
return func(c context.Context, proj types.ProjectName) (*archivist.Settings, error) {
// Fold in our project-specific configuration, if valid.
pcfg, err := a.ProjectConfig(c, proj)
if err !=... | go | func (a *application) GetSettingsLoader(acfg *svcconfig.Archivist) archivist.SettingsLoader {
serviceID := a.ServiceID()
return func(c context.Context, proj types.ProjectName) (*archivist.Settings, error) {
// Fold in our project-specific configuration, if valid.
pcfg, err := a.ProjectConfig(c, proj)
if err !=... | [
"func",
"(",
"a",
"*",
"application",
")",
"GetSettingsLoader",
"(",
"acfg",
"*",
"svcconfig",
".",
"Archivist",
")",
"archivist",
".",
"SettingsLoader",
"{",
"serviceID",
":=",
"a",
".",
"ServiceID",
"(",
")",
"\n\n",
"return",
"func",
"(",
"c",
"context"... | // GetSettingsLoader is an archivist.SettingsLoader implementation that merges
// global and project-specific settings.
//
// The resulting settings object will be verified by the Archivist. | [
"GetSettingsLoader",
"is",
"an",
"archivist",
".",
"SettingsLoader",
"implementation",
"that",
"merges",
"global",
"and",
"project",
"-",
"specific",
"settings",
".",
"The",
"resulting",
"settings",
"object",
"will",
"be",
"verified",
"by",
"the",
"Archivist",
"."... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/cmd/logdog_archivist/main.go#L266-L314 |
7,964 | luci/luci-go | logdog/server/cmd/logdog_archivist/main.go | main | func main() {
mathrand.SeedRandomly()
a := application{
Service: service.Service{
Name: "archivist",
DefaultAuthOptions: chromeinfra.DefaultAuthOptions(),
},
}
a.Run(context.Background(), a.runArchivist)
} | go | func main() {
mathrand.SeedRandomly()
a := application{
Service: service.Service{
Name: "archivist",
DefaultAuthOptions: chromeinfra.DefaultAuthOptions(),
},
}
a.Run(context.Background(), a.runArchivist)
} | [
"func",
"main",
"(",
")",
"{",
"mathrand",
".",
"SeedRandomly",
"(",
")",
"\n",
"a",
":=",
"application",
"{",
"Service",
":",
"service",
".",
"Service",
"{",
"Name",
":",
"\"",
"\"",
",",
"DefaultAuthOptions",
":",
"chromeinfra",
".",
"DefaultAuthOptions"... | // Entry point. | [
"Entry",
"point",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/cmd/logdog_archivist/main.go#L317-L326 |
7,965 | luci/luci-go | dm/appengine/distributor/registry.go | WithRegistry | func WithRegistry(c context.Context, r Registry) context.Context {
if r == nil {
panic(errors.New("you may not use WithRegistry on a nil Registry"))
}
return context.WithValue(c, ®Key, r)
} | go | func WithRegistry(c context.Context, r Registry) context.Context {
if r == nil {
panic(errors.New("you may not use WithRegistry on a nil Registry"))
}
return context.WithValue(c, ®Key, r)
} | [
"func",
"WithRegistry",
"(",
"c",
"context",
".",
"Context",
",",
"r",
"Registry",
")",
"context",
".",
"Context",
"{",
"if",
"r",
"==",
"nil",
"{",
"panic",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"return",
"context"... | // WithRegistry adds the registry to the Context. | [
"WithRegistry",
"adds",
"the",
"registry",
"to",
"the",
"Context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/registry.go#L38-L43 |
7,966 | luci/luci-go | dm/appengine/distributor/registry.go | GetRegistry | func GetRegistry(c context.Context) Registry {
ret, _ := c.Value(®Key).(Registry)
return ret
} | go | func GetRegistry(c context.Context) Registry {
ret, _ := c.Value(®Key).(Registry)
return ret
} | [
"func",
"GetRegistry",
"(",
"c",
"context",
".",
"Context",
")",
"Registry",
"{",
"ret",
",",
"_",
":=",
"c",
".",
"Value",
"(",
"&",
"regKey",
")",
".",
"(",
"Registry",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetRegistry gets the registry from the Context. This will return nil if the
// Context does not contain a Registry. | [
"GetRegistry",
"gets",
"the",
"registry",
"from",
"the",
"Context",
".",
"This",
"will",
"return",
"nil",
"if",
"the",
"Context",
"does",
"not",
"contain",
"a",
"Registry",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/registry.go#L47-L50 |
7,967 | luci/luci-go | dm/appengine/distributor/registry.go | NewRegistry | func NewRegistry(mapping FactoryMap, fFn FinishExecutionFn) Registry {
ret := ®istry{fFn, make(map[reflect.Type]Factory, len(mapping))}
add := func(p proto.Message, factory Factory) {
if factory == nil {
panic("factory is nil")
}
if p == nil {
panic("proto.Message is nil")
}
typ := reflect.TypeOf(... | go | func NewRegistry(mapping FactoryMap, fFn FinishExecutionFn) Registry {
ret := ®istry{fFn, make(map[reflect.Type]Factory, len(mapping))}
add := func(p proto.Message, factory Factory) {
if factory == nil {
panic("factory is nil")
}
if p == nil {
panic("proto.Message is nil")
}
typ := reflect.TypeOf(... | [
"func",
"NewRegistry",
"(",
"mapping",
"FactoryMap",
",",
"fFn",
"FinishExecutionFn",
")",
"Registry",
"{",
"ret",
":=",
"&",
"registry",
"{",
"fFn",
",",
"make",
"(",
"map",
"[",
"reflect",
".",
"Type",
"]",
"Factory",
",",
"len",
"(",
"mapping",
")",
... | // NewRegistry builds a new implementation of Registry configured to load
// configuration data from luci-config.
//
// The mapping should hold nil-ptrs of various config protos -> respective
// Factory. When loading from luci-config, when we see a given message type,
// we'll construct the distributor instance using t... | [
"NewRegistry",
"builds",
"a",
"new",
"implementation",
"of",
"Registry",
"configured",
"to",
"load",
"configuration",
"data",
"from",
"luci",
"-",
"config",
".",
"The",
"mapping",
"should",
"hold",
"nil",
"-",
"ptrs",
"of",
"various",
"config",
"protos",
"-",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/registry.go#L81-L102 |
7,968 | luci/luci-go | dm/appengine/distributor/registry.go | loadConfig | func loadConfig(c context.Context, cfgName string) (ret *Config, err error) {
configSet := cfgclient.CurrentServiceConfigSet(c)
var (
distCfg distributor.Config
meta config.Meta
)
if err = cfgclient.Get(c, cfgclient.AsService, configSet, "distributors.cfg", textproto.Message(&distCfg), &meta); err != nil {
... | go | func loadConfig(c context.Context, cfgName string) (ret *Config, err error) {
configSet := cfgclient.CurrentServiceConfigSet(c)
var (
distCfg distributor.Config
meta config.Meta
)
if err = cfgclient.Get(c, cfgclient.AsService, configSet, "distributors.cfg", textproto.Message(&distCfg), &meta); err != nil {
... | [
"func",
"loadConfig",
"(",
"c",
"context",
".",
"Context",
",",
"cfgName",
"string",
")",
"(",
"ret",
"*",
"Config",
",",
"err",
"error",
")",
"{",
"configSet",
":=",
"cfgclient",
".",
"CurrentServiceConfigSet",
"(",
"c",
")",
"\n\n",
"var",
"(",
"distCf... | // loadConfig loads the named distributor configuration from luci-config,
// possibly using the in-memory or memcache version. | [
"loadConfig",
"loads",
"the",
"named",
"distributor",
"configuration",
"from",
"luci",
"-",
"config",
"possibly",
"using",
"the",
"in",
"-",
"memory",
"or",
"memcache",
"version",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/registry.go#L137-L184 |
7,969 | luci/luci-go | gce/appengine/rpc/memory/projects.go | Delete | func (srv *Projects) Delete(c context.Context, req *projects.DeleteRequest) (*empty.Empty, error) {
srv.cfg.Delete(req.GetId())
return &empty.Empty{}, nil
} | go | func (srv *Projects) Delete(c context.Context, req *projects.DeleteRequest) (*empty.Empty, error) {
srv.cfg.Delete(req.GetId())
return &empty.Empty{}, nil
} | [
"func",
"(",
"srv",
"*",
"Projects",
")",
"Delete",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"projects",
".",
"DeleteRequest",
")",
"(",
"*",
"empty",
".",
"Empty",
",",
"error",
")",
"{",
"srv",
".",
"cfg",
".",
"Delete",
"(",
"req",
... | // Delete handles a request to delete a project. | [
"Delete",
"handles",
"a",
"request",
"to",
"delete",
"a",
"project",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/memory/projects.go#L39-L42 |
7,970 | luci/luci-go | logdog/client/butler/output/pubsub/pubsubOutput.go | New | func New(ctx context.Context, c Config) output.Output {
o := pubSubOutput{
Config: &c,
}
o.bufferPool.New = func() interface{} { return &buffer{} }
if c.Track {
o.et = &output.EntryTracker{}
}
o.Context = log.SetField(ctx, "pubsub", &o)
return &o
} | go | func New(ctx context.Context, c Config) output.Output {
o := pubSubOutput{
Config: &c,
}
o.bufferPool.New = func() interface{} { return &buffer{} }
if c.Track {
o.et = &output.EntryTracker{}
}
o.Context = log.SetField(ctx, "pubsub", &o)
return &o
} | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"Config",
")",
"output",
".",
"Output",
"{",
"o",
":=",
"pubSubOutput",
"{",
"Config",
":",
"&",
"c",
",",
"}",
"\n",
"o",
".",
"bufferPool",
".",
"New",
"=",
"func",
"(",
")",
"inte... | // New instantiates a new GCPS output. | [
"New",
"instantiates",
"a",
"new",
"GCPS",
"output",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/output/pubsub/pubsubOutput.go#L93-L105 |
7,971 | luci/luci-go | logdog/client/butler/output/pubsub/pubsubOutput.go | publishMessage | func (o *pubSubOutput) publishMessage(message *pubsub.Message) error {
var messageID string
transientErrors := 0
err := retry.Retry(o, transient.Only(indefiniteRetry), func() (err error) {
ctx := o.Context
if o.RPCTimeout > 0 {
var cancelFunc context.CancelFunc
ctx, cancelFunc = clock.WithTimeout(o, o.RPCT... | go | func (o *pubSubOutput) publishMessage(message *pubsub.Message) error {
var messageID string
transientErrors := 0
err := retry.Retry(o, transient.Only(indefiniteRetry), func() (err error) {
ctx := o.Context
if o.RPCTimeout > 0 {
var cancelFunc context.CancelFunc
ctx, cancelFunc = clock.WithTimeout(o, o.RPCT... | [
"func",
"(",
"o",
"*",
"pubSubOutput",
")",
"publishMessage",
"(",
"message",
"*",
"pubsub",
".",
"Message",
")",
"error",
"{",
"var",
"messageID",
"string",
"\n",
"transientErrors",
":=",
"0",
"\n",
"err",
":=",
"retry",
".",
"Retry",
"(",
"o",
",",
"... | // publishMessage handles an individual publish request. It will indefinitely
// retry transient errors until the publish succeeds. | [
"publishMessage",
"handles",
"an",
"individual",
"publish",
"request",
".",
"It",
"will",
"indefinitely",
"retry",
"transient",
"errors",
"until",
"the",
"publish",
"succeeds",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/output/pubsub/pubsubOutput.go#L205-L249 |
7,972 | luci/luci-go | logdog/client/butler/output/pubsub/pubsubOutput.go | indefiniteRetry | func indefiniteRetry() retry.Iterator {
return &retry.ExponentialBackoff{
Limited: retry.Limited{
Retries: -1,
Delay: 500 * time.Millisecond,
},
MaxDelay: 30 * time.Second,
}
} | go | func indefiniteRetry() retry.Iterator {
return &retry.ExponentialBackoff{
Limited: retry.Limited{
Retries: -1,
Delay: 500 * time.Millisecond,
},
MaxDelay: 30 * time.Second,
}
} | [
"func",
"indefiniteRetry",
"(",
")",
"retry",
".",
"Iterator",
"{",
"return",
"&",
"retry",
".",
"ExponentialBackoff",
"{",
"Limited",
":",
"retry",
".",
"Limited",
"{",
"Retries",
":",
"-",
"1",
",",
"Delay",
":",
"500",
"*",
"time",
".",
"Millisecond",... | // indefiniteRetry is a retry.Iterator that will indefinitely retry errors with
// a maximum backoff. | [
"indefiniteRetry",
"is",
"a",
"retry",
".",
"Iterator",
"that",
"will",
"indefinitely",
"retry",
"errors",
"with",
"a",
"maximum",
"backoff",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/output/pubsub/pubsubOutput.go#L260-L268 |
7,973 | luci/luci-go | logdog/client/butler/butler.go | Validate | func (c *Config) Validate() error {
if c.Output == nil {
return errors.New("butler: an Output must be supplied")
}
if err := c.Project.Validate(); err != nil {
return fmt.Errorf("invalid project: %v", err)
}
if err := c.Prefix.Validate(); err != nil {
return fmt.Errorf("invalid prefix: %v", err)
}
return n... | go | func (c *Config) Validate() error {
if c.Output == nil {
return errors.New("butler: an Output must be supplied")
}
if err := c.Project.Validate(); err != nil {
return fmt.Errorf("invalid project: %v", err)
}
if err := c.Prefix.Validate(); err != nil {
return fmt.Errorf("invalid prefix: %v", err)
}
return n... | [
"func",
"(",
"c",
"*",
"Config",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Output",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Project",
".",
"Validate"... | // Validate validates that the configuration is sufficient to instantiate a
// Butler instance. | [
"Validate",
"validates",
"that",
"the",
"configuration",
"is",
"sufficient",
"to",
"instantiate",
"a",
"Butler",
"instance",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L124-L135 |
7,974 | luci/luci-go | logdog/client/butler/butler.go | Wait | func (b *Butler) Wait() error {
// Run until our stream monitor shuts down, meaning all streams have finished.
//
// A race can exist here when a stream server may add new streams after we've
// drained our streams, but before we've shut them down. Since "all streams
// are done" is the edge that we use to begin s... | go | func (b *Butler) Wait() error {
// Run until our stream monitor shuts down, meaning all streams have finished.
//
// A race can exist here when a stream server may add new streams after we've
// drained our streams, but before we've shut them down. Since "all streams
// are done" is the edge that we use to begin s... | [
"func",
"(",
"b",
"*",
"Butler",
")",
"Wait",
"(",
")",
"error",
"{",
"// Run until our stream monitor shuts down, meaning all streams have finished.",
"//",
"// A race can exist here when a stream server may add new streams after we've",
"// drained our streams, but before we've shut th... | // Wait blocks until the Butler instance has completed, returning with the
// Butler's return code. | [
"Wait",
"blocks",
"until",
"the",
"Butler",
"instance",
"has",
"completed",
"returning",
"with",
"the",
"Butler",
"s",
"return",
"code",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L291-L347 |
7,975 | luci/luci-go | logdog/client/butler/butler.go | Streams | func (b *Butler) Streams() []types.StreamName {
var streams types.StreamNameSlice
func() {
b.streamSeenLock.Lock()
defer b.streamSeenLock.Unlock()
streams = make([]types.StreamName, 0, b.streamSeen.Len())
b.streamSeen.Iter(func(s string) bool {
streams = append(streams, types.StreamName(s))
return true... | go | func (b *Butler) Streams() []types.StreamName {
var streams types.StreamNameSlice
func() {
b.streamSeenLock.Lock()
defer b.streamSeenLock.Unlock()
streams = make([]types.StreamName, 0, b.streamSeen.Len())
b.streamSeen.Iter(func(s string) bool {
streams = append(streams, types.StreamName(s))
return true... | [
"func",
"(",
"b",
"*",
"Butler",
")",
"Streams",
"(",
")",
"[",
"]",
"types",
".",
"StreamName",
"{",
"var",
"streams",
"types",
".",
"StreamNameSlice",
"\n",
"func",
"(",
")",
"{",
"b",
".",
"streamSeenLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
... | // Streams returns a sorted list of stream names that have been registered to
// the Butler. | [
"Streams",
"returns",
"a",
"sorted",
"list",
"of",
"stream",
"names",
"that",
"have",
"been",
"registered",
"to",
"the",
"Butler",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L351-L366 |
7,976 | luci/luci-go | logdog/client/butler/butler.go | AddStreamServer | func (b *Butler) AddStreamServer(streamServer streamserver.StreamServer) {
ctx := log.SetField(b.ctx, "streamServer", streamServer)
log.Debugf(ctx, "Adding stream server.")
// Pull streams from the streamserver and add them to the Butler.
streamServerFinishedC := make(chan struct{})
go func() {
defer close(str... | go | func (b *Butler) AddStreamServer(streamServer streamserver.StreamServer) {
ctx := log.SetField(b.ctx, "streamServer", streamServer)
log.Debugf(ctx, "Adding stream server.")
// Pull streams from the streamserver and add them to the Butler.
streamServerFinishedC := make(chan struct{})
go func() {
defer close(str... | [
"func",
"(",
"b",
"*",
"Butler",
")",
"AddStreamServer",
"(",
"streamServer",
"streamserver",
".",
"StreamServer",
")",
"{",
"ctx",
":=",
"log",
".",
"SetField",
"(",
"b",
".",
"ctx",
",",
"\"",
"\"",
",",
"streamServer",
")",
"\n\n",
"log",
".",
"Debu... | // AddStreamServer adds a StreamServer to the Butler. This is goroutine-safe
// and may be called anytime before or during Butler execution.
//
// After this call completes, the Butler assumes ownership of the StreamServer. | [
"AddStreamServer",
"adds",
"a",
"StreamServer",
"to",
"the",
"Butler",
".",
"This",
"is",
"goroutine",
"-",
"safe",
"and",
"may",
"be",
"called",
"anytime",
"before",
"or",
"during",
"Butler",
"execution",
".",
"After",
"this",
"call",
"completes",
"the",
"B... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L372-L424 |
7,977 | luci/luci-go | logdog/client/butler/butler.go | AddStream | func (b *Butler) AddStream(rc io.ReadCloser, p *streamproto.Properties) error {
p = p.Clone()
if p.Timestamp == nil || google.TimeFromProto(p.Timestamp).IsZero() {
p.Timestamp = google.NewTimestamp(clock.Now(b.ctx))
}
if err := p.Validate(); err != nil {
return err
}
// Build per-stream tag map.
if l := len... | go | func (b *Butler) AddStream(rc io.ReadCloser, p *streamproto.Properties) error {
p = p.Clone()
if p.Timestamp == nil || google.TimeFromProto(p.Timestamp).IsZero() {
p.Timestamp = google.NewTimestamp(clock.Now(b.ctx))
}
if err := p.Validate(); err != nil {
return err
}
// Build per-stream tag map.
if l := len... | [
"func",
"(",
"b",
"*",
"Butler",
")",
"AddStream",
"(",
"rc",
"io",
".",
"ReadCloser",
",",
"p",
"*",
"streamproto",
".",
"Properties",
")",
"error",
"{",
"p",
"=",
"p",
".",
"Clone",
"(",
")",
"\n",
"if",
"p",
".",
"Timestamp",
"==",
"nil",
"||"... | // AddStream adds a Stream to the Butler. This is goroutine-safe.
//
// If no error is returned, the Butler assumes ownership of the supplied stream.
// The stream will be closed when processing is finished.
//
// If an error is occurred, the caller is still the owner of the stream and
// is responsible for closing it. | [
"AddStream",
"adds",
"a",
"Stream",
"to",
"the",
"Butler",
".",
"This",
"is",
"goroutine",
"-",
"safe",
".",
"If",
"no",
"error",
"is",
"returned",
"the",
"Butler",
"assumes",
"ownership",
"of",
"the",
"supplied",
"stream",
".",
"The",
"stream",
"will",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L433-L521 |
7,978 | luci/luci-go | logdog/client/butler/butler.go | registerStream | func (b *Butler) registerStream(name string) error {
b.streamSeenLock.Lock()
defer b.streamSeenLock.Unlock()
if added := b.streamSeen.Add(name); added {
return nil
}
return fmt.Errorf("a stream has already been registered with name %q", name)
} | go | func (b *Butler) registerStream(name string) error {
b.streamSeenLock.Lock()
defer b.streamSeenLock.Unlock()
if added := b.streamSeen.Add(name); added {
return nil
}
return fmt.Errorf("a stream has already been registered with name %q", name)
} | [
"func",
"(",
"b",
"*",
"Butler",
")",
"registerStream",
"(",
"name",
"string",
")",
"error",
"{",
"b",
".",
"streamSeenLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"streamSeenLock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"added",
":=",
"b",... | // registerStream registers awareness of the named Stream with the Butler. An
// error will be returned if the Stream has ever been registered. | [
"registerStream",
"registers",
"awareness",
"of",
"the",
"named",
"Stream",
"with",
"the",
"Butler",
".",
"An",
"error",
"will",
"be",
"returned",
"if",
"the",
"Stream",
"has",
"ever",
"been",
"registered",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L609-L617 |
7,979 | luci/luci-go | logdog/client/butler/butler.go | shutdown | func (b *Butler) shutdown(err error) {
log.Fields{
log.ErrorKey: err,
}.Debugf(b.ctx, "Received 'shutdown()' command; shutting down streams.")
func() {
b.shutdownMu.Lock()
defer b.shutdownMu.Unlock()
if b.isShutdown {
// Already shut down.
return
}
// Signal our streams to shutdown prematurely.
... | go | func (b *Butler) shutdown(err error) {
log.Fields{
log.ErrorKey: err,
}.Debugf(b.ctx, "Received 'shutdown()' command; shutting down streams.")
func() {
b.shutdownMu.Lock()
defer b.shutdownMu.Unlock()
if b.isShutdown {
// Already shut down.
return
}
// Signal our streams to shutdown prematurely.
... | [
"func",
"(",
"b",
"*",
"Butler",
")",
"shutdown",
"(",
"err",
"error",
")",
"{",
"log",
".",
"Fields",
"{",
"log",
".",
"ErrorKey",
":",
"err",
",",
"}",
".",
"Debugf",
"(",
"b",
".",
"ctx",
",",
"\"",
"\"",
")",
"\n\n",
"func",
"(",
")",
"{"... | // shutdown is a goroutine-safe method instructing the Butler to terminate
// with the supplied error code. It may be called more than once, although
// the first supplied error message will be the one returned by Run. | [
"shutdown",
"is",
"a",
"goroutine",
"-",
"safe",
"method",
"instructing",
"the",
"Butler",
"to",
"terminate",
"with",
"the",
"supplied",
"error",
"code",
".",
"It",
"may",
"be",
"called",
"more",
"than",
"once",
"although",
"the",
"first",
"supplied",
"error... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L672-L697 |
7,980 | luci/luci-go | logdog/client/butler/butler.go | getRunErr | func (b *Butler) getRunErr() error {
b.shutdownMu.Lock()
defer b.shutdownMu.Unlock()
return b.runErr
} | go | func (b *Butler) getRunErr() error {
b.shutdownMu.Lock()
defer b.shutdownMu.Unlock()
return b.runErr
} | [
"func",
"(",
"b",
"*",
"Butler",
")",
"getRunErr",
"(",
")",
"error",
"{",
"b",
".",
"shutdownMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"shutdownMu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"b",
".",
"runErr",
"\n",
"}"
] | // Returns the configured Butler error. | [
"Returns",
"the",
"configured",
"Butler",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L700-L704 |
7,981 | luci/luci-go | logdog/client/butler/butler.go | wrapStreamRegistrationCallback | func wrapStreamRegistrationCallback(reg streamRegistrationCallback) streamRegistrationCallback {
if reg == nil {
return reg
}
return func(desc *logpb.LogStreamDescriptor) bundler.StreamChunkCallback {
cb := reg(desc)
switch desc.StreamType {
case logpb.StreamType_TEXT:
return buffered_callback.GetWrappedT... | go | func wrapStreamRegistrationCallback(reg streamRegistrationCallback) streamRegistrationCallback {
if reg == nil {
return reg
}
return func(desc *logpb.LogStreamDescriptor) bundler.StreamChunkCallback {
cb := reg(desc)
switch desc.StreamType {
case logpb.StreamType_TEXT:
return buffered_callback.GetWrappedT... | [
"func",
"wrapStreamRegistrationCallback",
"(",
"reg",
"streamRegistrationCallback",
")",
"streamRegistrationCallback",
"{",
"if",
"reg",
"==",
"nil",
"{",
"return",
"reg",
"\n",
"}",
"\n",
"return",
"func",
"(",
"desc",
"*",
"logpb",
".",
"LogStreamDescriptor",
")... | // wrapStreamRegistrationCallback wraps the given callback to dispatch on the correct stream type. | [
"wrapStreamRegistrationCallback",
"wraps",
"the",
"given",
"callback",
"to",
"dispatch",
"on",
"the",
"correct",
"stream",
"type",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/butler.go#L709-L724 |
7,982 | luci/luci-go | cipd/appengine/impl/model/package.go | PackageKey | func PackageKey(c context.Context, pkg string) *datastore.Key {
return datastore.NewKey(c, "Package", pkg, 0, nil)
} | go | func PackageKey(c context.Context, pkg string) *datastore.Key {
return datastore.NewKey(c, "Package", pkg, 0, nil)
} | [
"func",
"PackageKey",
"(",
"c",
"context",
".",
"Context",
",",
"pkg",
"string",
")",
"*",
"datastore",
".",
"Key",
"{",
"return",
"datastore",
".",
"NewKey",
"(",
"c",
",",
"\"",
"\"",
",",
"pkg",
",",
"0",
",",
"nil",
")",
"\n",
"}"
] | // PackageKey returns a datastore key of some package, given its name. | [
"PackageKey",
"returns",
"a",
"datastore",
"key",
"of",
"some",
"package",
"given",
"its",
"name",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/package.go#L61-L63 |
7,983 | luci/luci-go | cipd/appengine/impl/model/package.go | ListPackages | func ListPackages(c context.Context, prefix string, includeHidden bool) (out []string, err error) {
if prefix, err = common.ValidatePackagePrefix(prefix); err != nil {
return nil, err
}
// Note: __key__ queries are already ordered by key.
q := datastore.NewQuery("Package")
if prefix != "" {
q = q.Gt("__key__"... | go | func ListPackages(c context.Context, prefix string, includeHidden bool) (out []string, err error) {
if prefix, err = common.ValidatePackagePrefix(prefix); err != nil {
return nil, err
}
// Note: __key__ queries are already ordered by key.
q := datastore.NewQuery("Package")
if prefix != "" {
q = q.Gt("__key__"... | [
"func",
"ListPackages",
"(",
"c",
"context",
".",
"Context",
",",
"prefix",
"string",
",",
"includeHidden",
"bool",
")",
"(",
"out",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"if",
"prefix",
",",
"err",
"=",
"common",
".",
"ValidatePackagePrefix... | // ListPackages returns a list of names of packages under the given prefix.
//
// Lists all packages recursively. If there's package named as 'prefix' it is
// NOT included in the result. Only packaged under the prefix are included.
//
// The result is sorted by the package name. Returns only transient errors. | [
"ListPackages",
"returns",
"a",
"list",
"of",
"names",
"of",
"packages",
"under",
"the",
"given",
"prefix",
".",
"Lists",
"all",
"packages",
"recursively",
".",
"If",
"there",
"s",
"package",
"named",
"as",
"prefix",
"it",
"is",
"NOT",
"included",
"in",
"t... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/package.go#L71-L96 |
7,984 | 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 |
7,985 | 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 |
7,986 | 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 |
7,987 | 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 |
7,988 | 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 |
7,989 | 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 |
7,990 | 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 |
7,991 | 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 |
7,992 | 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 |
7,993 | 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 |
7,994 | 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 |
7,995 | 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 |
7,996 | 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 |
7,997 | 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 |
7,998 | 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 |
7,999 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.