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