id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
130,300
luci/luci-go
common/data/base128/base128.go
DecodeString
func DecodeString(s string) ([]byte, error) { src := []byte(s) dst := make([]byte, DecodedLen(len(src))) if _, err := Decode(dst, src); err != nil { return nil, err } return dst, nil }
go
func DecodeString(s string) ([]byte, error) { src := []byte(s) dst := make([]byte, DecodedLen(len(src))) if _, err := Decode(dst, src); err != nil { return nil, err } return dst, nil }
[ "func", "DecodeString", "(", "s", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "src", ":=", "[", "]", "byte", "(", "s", ")", "\n", "dst", ":=", "make", "(", "[", "]", "byte", ",", "DecodedLen", "(", "len", "(", "src", ")", ")...
// DecodeString returns the bytes represented by the base128 string s.
[ "DecodeString", "returns", "the", "bytes", "represented", "by", "the", "base128", "string", "s", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/base128/base128.go#L94-L101
130,301
luci/luci-go
logdog/client/annotee/stream.go
TextStreamFlags
func TextStreamFlags(ctx context.Context, name types.StreamName) streamproto.Flags { return streamFlagsFromArchetype(ctx, name, &textStreamArchetype) }
go
func TextStreamFlags(ctx context.Context, name types.StreamName) streamproto.Flags { return streamFlagsFromArchetype(ctx, name, &textStreamArchetype) }
[ "func", "TextStreamFlags", "(", "ctx", "context", ".", "Context", ",", "name", "types", ".", "StreamName", ")", "streamproto", ".", "Flags", "{", "return", "streamFlagsFromArchetype", "(", "ctx", ",", "name", ",", "&", "textStreamArchetype", ")", "\n", "}" ]
// TextStreamFlags returns the streamproto.Flags for a text stream using // Annotee's text stream archetype.
[ "TextStreamFlags", "returns", "the", "streamproto", ".", "Flags", "for", "a", "text", "stream", "using", "Annotee", "s", "text", "stream", "archetype", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/stream.go#L42-L44
130,302
luci/luci-go
config/validation/net_util.go
ValidateHostname
func ValidateHostname(hostname string) error { if len(hostname) > 255 { return fmt.Errorf("length exceeds 255 bytes") } if !hostnameRegexp.MatchString(hostname) { return fmt.Errorf("hostname does not match regex %q", hostnameRegexp) } for _, s := range strings.Split(hostname, ".") { if len(s) > 63 { retur...
go
func ValidateHostname(hostname string) error { if len(hostname) > 255 { return fmt.Errorf("length exceeds 255 bytes") } if !hostnameRegexp.MatchString(hostname) { return fmt.Errorf("hostname does not match regex %q", hostnameRegexp) } for _, s := range strings.Split(hostname, ".") { if len(s) > 63 { retur...
[ "func", "ValidateHostname", "(", "hostname", "string", ")", "error", "{", "if", "len", "(", "hostname", ")", ">", "255", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "!", "hostnameRegexp", ".", "MatchString", "(", ...
// ValidateHostname returns an error if the given string is not a valid // RFC1123 hostname.
[ "ValidateHostname", "returns", "an", "error", "if", "the", "given", "string", "is", "not", "a", "valid", "RFC1123", "hostname", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/net_util.go#L33-L46
130,303
luci/luci-go
machine-db/client/cli/oses.go
printOSes
func printOSes(tsv bool, oses ...*crimson.OS) { if len(oses) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "Description") } for _, os := range oses { p.Row(os.Name, os.Description) } } }
go
func printOSes(tsv bool, oses ...*crimson.OS) { if len(oses) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "Description") } for _, os := range oses { p.Row(os.Name, os.Description) } } }
[ "func", "printOSes", "(", "tsv", "bool", ",", "oses", "...", "*", "crimson", ".", "OS", ")", "{", "if", "len", "(", "oses", ")", ">", "0", "{", "p", ":=", "newStdoutPrinter", "(", "tsv", ")", "\n", "defer", "p", ".", "Flush", "(", ")", "\n", "i...
// printOSes prints operating system data to stdout in tab-separated columns.
[ "printOSes", "prints", "operating", "system", "data", "to", "stdout", "in", "tab", "-", "separated", "columns", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/oses.go#L28-L39
130,304
luci/luci-go
machine-db/client/cli/oses.go
Run
func (c *GetOSesCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListOSes(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printOSes(c.f.tsv, resp.Oses...) return 0 }
go
func (c *GetOSesCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListOSes(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printOSes(c.f.tsv, resp.Oses...) return 0 }
[ "func", "(", "c", "*", "GetOSesCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "c", ",...
// Run runs the command to get operating systems.
[ "Run", "runs", "the", "command", "to", "get", "operating", "systems", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/oses.go#L48-L58
130,305
luci/luci-go
machine-db/client/cli/oses.go
getOSesCmd
func getOSesCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-oses [-name <name>]...", ShortDesc: "retrieves operating systems", LongDesc: "Retrieves operating systems matching the given names, or all operating systems if names are omitted.\n\nExample to get all OSes:\n...
go
func getOSesCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-oses [-name <name>]...", ShortDesc: "retrieves operating systems", LongDesc: "Retrieves operating systems matching the given names, or all operating systems if names are omitted.\n\nExample to get all OSes:\n...
[ "func", "getOSesCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", "\\n", ...
// getOSesCmd returns a command to get operating systems.
[ "getOSesCmd", "returns", "a", "command", "to", "get", "operating", "systems", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/oses.go#L61-L73
130,306
luci/luci-go
logdog/appengine/coordinator/tagMap.go
tagMapFromProperties
func tagMapFromProperties(props ds.PropertySlice) (TagMap, error) { tm := TagMap{} lme := errors.NewLazyMultiError(len(props)) for idx, prop := range props { v, ok := prop.Value().(string) if !ok { lme.Assign(idx, fmt.Errorf("property is not a string (%T)", prop.Value())) continue } e, err := decodeKey...
go
func tagMapFromProperties(props ds.PropertySlice) (TagMap, error) { tm := TagMap{} lme := errors.NewLazyMultiError(len(props)) for idx, prop := range props { v, ok := prop.Value().(string) if !ok { lme.Assign(idx, fmt.Errorf("property is not a string (%T)", prop.Value())) continue } e, err := decodeKey...
[ "func", "tagMapFromProperties", "(", "props", "ds", ".", "PropertySlice", ")", "(", "TagMap", ",", "error", ")", "{", "tm", ":=", "TagMap", "{", "}", "\n", "lme", ":=", "errors", ".", "NewLazyMultiError", "(", "len", "(", "props", ")", ")", "\n", "for"...
// tagMapFromProperties converts a set of tag property objects into a TagMap. // // If an error occurs decoding a specific property, an errors.MultiError will be // returned alongside the successfully-decoded tags.
[ "tagMapFromProperties", "converts", "a", "set", "of", "tag", "property", "objects", "into", "a", "TagMap", ".", "If", "an", "error", "occurs", "decoding", "a", "specific", "property", "an", "errors", ".", "MultiError", "will", "be", "returned", "alongside", "t...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/tagMap.go#L37-L70
130,307
luci/luci-go
logdog/appengine/coordinator/tagMap.go
toProperties
func (m TagMap) toProperties() (ds.PropertySlice, error) { if len(m) == 0 { return nil, nil } // Deterministic conversion. keys := make([]string, 0, len(m)) for k := range m { keys = append(keys, k) } sort.Strings(keys) parts := make(ds.PropertySlice, 0, len(m)*2) for _, k := range keys { v := m[k] i...
go
func (m TagMap) toProperties() (ds.PropertySlice, error) { if len(m) == 0 { return nil, nil } // Deterministic conversion. keys := make([]string, 0, len(m)) for k := range m { keys = append(keys, k) } sort.Strings(keys) parts := make(ds.PropertySlice, 0, len(m)*2) for _, k := range keys { v := m[k] i...
[ "func", "(", "m", "TagMap", ")", "toProperties", "(", ")", "(", "ds", ".", "PropertySlice", ",", "error", ")", "{", "if", "len", "(", "m", ")", "==", "0", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "// Deterministic conversion.", "keys", ":...
// toProperties converts a TagMap to a set of Property objects for storage.
[ "toProperties", "converts", "a", "TagMap", "to", "a", "set", "of", "Property", "objects", "for", "storage", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/tagMap.go#L73-L99
130,308
luci/luci-go
logdog/appengine/coordinator/tagMap.go
AddLogStreamTagFilter
func AddLogStreamTagFilter(q *ds.Query, key string, value string) *ds.Query { if value == "" { return q.Eq("_Tags", encodeKey(key)) } return q.Eq("_Tags", encodeKey(fmt.Sprintf("%s=%s", key, value))) }
go
func AddLogStreamTagFilter(q *ds.Query, key string, value string) *ds.Query { if value == "" { return q.Eq("_Tags", encodeKey(key)) } return q.Eq("_Tags", encodeKey(fmt.Sprintf("%s=%s", key, value))) }
[ "func", "AddLogStreamTagFilter", "(", "q", "*", "ds", ".", "Query", ",", "key", "string", ",", "value", "string", ")", "*", "ds", ".", "Query", "{", "if", "value", "==", "\"", "\"", "{", "return", "q", ".", "Eq", "(", "\"", "\"", ",", "encodeKey", ...
// AddLogStreamTagFilter adds a tag filter to a Query object. // // This method will only add equality filters to the query. If value is empty, // a presence filter will be added; otherwise, an equality filter will be added. // // This incorporates the encoding expressed by TagMap.
[ "AddLogStreamTagFilter", "adds", "a", "tag", "filter", "to", "a", "Query", "object", ".", "This", "method", "will", "only", "add", "equality", "filters", "to", "the", "query", ".", "If", "value", "is", "empty", "a", "presence", "filter", "will", "be", "add...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/tagMap.go#L107-L112
130,309
luci/luci-go
config/server/cfgclient/backend/format/formatters.go
Register
func Register(rk string, f Formatter) { if rk == "" { panic("cannot register empty key") } registry.Lock() defer registry.Unlock() if _, ok := registry.r[rk]; ok { panic(fmt.Errorf("key %q is already registered", rk)) } if registry.r == nil { registry.r = map[string]Formatter{} } registry.r[rk] = f }
go
func Register(rk string, f Formatter) { if rk == "" { panic("cannot register empty key") } registry.Lock() defer registry.Unlock() if _, ok := registry.r[rk]; ok { panic(fmt.Errorf("key %q is already registered", rk)) } if registry.r == nil { registry.r = map[string]Formatter{} } registry.r[rk] = f }
[ "func", "Register", "(", "rk", "string", ",", "f", "Formatter", ")", "{", "if", "rk", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "registry", ".", "Lock", "(", ")", "\n", "defer", "registry", ".", "Unlock", "(", ")", ...
// Register registers a Formatter implementation for given format. // // If the supplied key is already registered, Register will panic.
[ "Register", "registers", "a", "Formatter", "implementation", "for", "given", "format", ".", "If", "the", "supplied", "key", "is", "already", "registered", "Register", "will", "panic", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/format/formatters.go#L44-L59
130,310
luci/luci-go
config/server/cfgclient/backend/format/formatters.go
getFormatter
func getFormatter(f string) (Formatter, error) { registry.RLock() defer registry.RUnlock() formatter := registry.r[f] if formatter == nil { return nil, errors.Reason("unknown formatter: %q", f).Err() } return formatter, nil }
go
func getFormatter(f string) (Formatter, error) { registry.RLock() defer registry.RUnlock() formatter := registry.r[f] if formatter == nil { return nil, errors.Reason("unknown formatter: %q", f).Err() } return formatter, nil }
[ "func", "getFormatter", "(", "f", "string", ")", "(", "Formatter", ",", "error", ")", "{", "registry", ".", "RLock", "(", ")", "\n", "defer", "registry", ".", "RUnlock", "(", ")", "\n\n", "formatter", ":=", "registry", ".", "r", "[", "f", "]", "\n", ...
// getFormatter returns the Formatter associated with the provided Format.
[ "getFormatter", "returns", "the", "Formatter", "associated", "with", "the", "provided", "Format", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/format/formatters.go#L71-L80
130,311
luci/luci-go
auth/internal/common.go
EqualTokens
func EqualTokens(a, b *Token) bool { if a == b { return true } if a == nil { a = &Token{} } if b == nil { b = &Token{} } return a.AccessToken == b.AccessToken && a.Expiry.Equal(b.Expiry) && a.Email == b.Email }
go
func EqualTokens(a, b *Token) bool { if a == b { return true } if a == nil { a = &Token{} } if b == nil { b = &Token{} } return a.AccessToken == b.AccessToken && a.Expiry.Equal(b.Expiry) && a.Email == b.Email }
[ "func", "EqualTokens", "(", "a", ",", "b", "*", "Token", ")", "bool", "{", "if", "a", "==", "b", "{", "return", "true", "\n", "}", "\n", "if", "a", "==", "nil", "{", "a", "=", "&", "Token", "{", "}", "\n", "}", "\n", "if", "b", "==", "nil",...
// EqualTokens returns true if tokens are equal. // // 'nil' token corresponds to an empty access token.
[ "EqualTokens", "returns", "true", "if", "tokens", "are", "equal", ".", "nil", "token", "corresponds", "to", "an", "empty", "access", "token", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/internal/common.go#L251-L262
130,312
luci/luci-go
auth/internal/common.go
isBadKeyError
func isBadKeyError(err error) bool { if err == nil { return false } // See https://go.googlesource.com/oauth2.git/+/197281d4/internal/oauth2.go#32 // Unfortunately, if uses fmt.Errorf. s := err.Error() return strings.Contains(s, "private key should be a PEM") || s == "private key is invalid" }
go
func isBadKeyError(err error) bool { if err == nil { return false } // See https://go.googlesource.com/oauth2.git/+/197281d4/internal/oauth2.go#32 // Unfortunately, if uses fmt.Errorf. s := err.Error() return strings.Contains(s, "private key should be a PEM") || s == "private key is invalid" }
[ "func", "isBadKeyError", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "// See https://go.googlesource.com/oauth2.git/+/197281d4/internal/oauth2.go#32", "// Unfortunately, if uses fmt.Errorf.", "s", ":=", "err", ...
// isBadKeyError sniffs out errors related to malformed private keys.
[ "isBadKeyError", "sniffs", "out", "errors", "related", "to", "malformed", "private", "keys", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/internal/common.go#L273-L282
130,313
luci/luci-go
lucictx/swarming.go
GetSwarming
func GetSwarming(ctx context.Context) *Swarming { ret := Swarming{} ok, err := Lookup(ctx, "swarming", &ret) if err != nil { panic(err) } if !ok { return nil } return &ret }
go
func GetSwarming(ctx context.Context) *Swarming { ret := Swarming{} ok, err := Lookup(ctx, "swarming", &ret) if err != nil { panic(err) } if !ok { return nil } return &ret }
[ "func", "GetSwarming", "(", "ctx", "context", ".", "Context", ")", "*", "Swarming", "{", "ret", ":=", "Swarming", "{", "}", "\n", "ok", ",", "err", ":=", "Lookup", "(", "ctx", ",", "\"", "\"", ",", "&", "ret", ")", "\n", "if", "err", "!=", "nil",...
// GetSwarming calls Lookup and returns the current Swarming from LUCI_CONTEXT // if it was present. If no Swarming is in the context, this returns nil.
[ "GetSwarming", "calls", "Lookup", "and", "returns", "the", "current", "Swarming", "from", "LUCI_CONTEXT", "if", "it", "was", "present", ".", "If", "no", "Swarming", "is", "in", "the", "context", "this", "returns", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucictx/swarming.go#L30-L40
130,314
luci/luci-go
lucictx/swarming.go
SetSwarming
func SetSwarming(ctx context.Context, swarm *Swarming) context.Context { var raw interface{} if swarm != nil { raw = swarm } ctx, err := Set(ctx, "swarming", raw) if err != nil { panic(fmt.Errorf("impossible: %s", err)) } return ctx }
go
func SetSwarming(ctx context.Context, swarm *Swarming) context.Context { var raw interface{} if swarm != nil { raw = swarm } ctx, err := Set(ctx, "swarming", raw) if err != nil { panic(fmt.Errorf("impossible: %s", err)) } return ctx }
[ "func", "SetSwarming", "(", "ctx", "context", ".", "Context", ",", "swarm", "*", "Swarming", ")", "context", ".", "Context", "{", "var", "raw", "interface", "{", "}", "\n", "if", "swarm", "!=", "nil", "{", "raw", "=", "swarm", "\n", "}", "\n", "ctx",...
// SetSwarming Sets the Swarming in the LUCI_CONTEXT.
[ "SetSwarming", "Sets", "the", "Swarming", "in", "the", "LUCI_CONTEXT", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucictx/swarming.go#L43-L53
130,315
luci/luci-go
cipd/appengine/ui/cursors.go
cursorKey
func (k cursorKind) cursorKey(pkg, cursor string) string { blob := sha256.Sum224([]byte(pkg + ":" + cursor)) return string(k) + ":" + base64.RawStdEncoding.EncodeToString(blob[:]) }
go
func (k cursorKind) cursorKey(pkg, cursor string) string { blob := sha256.Sum224([]byte(pkg + ":" + cursor)) return string(k) + ":" + base64.RawStdEncoding.EncodeToString(blob[:]) }
[ "func", "(", "k", "cursorKind", ")", "cursorKey", "(", "pkg", ",", "cursor", "string", ")", "string", "{", "blob", ":=", "sha256", ".", "Sum224", "(", "[", "]", "byte", "(", "pkg", "+", "\"", "\"", "+", "cursor", ")", ")", "\n", "return", "string",...
// cursorKey is a memcache key for items that link cursor to a previous page.
[ "cursorKey", "is", "a", "memcache", "key", "for", "items", "that", "link", "cursor", "to", "a", "previous", "page", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/ui/cursors.go#L32-L35
130,316
luci/luci-go
cipd/appengine/ui/cursors.go
storePrevCursor
func (k cursorKind) storePrevCursor(c context.Context, pkg, cursor, prev string) { itm := memcache.NewItem(c, k.cursorKey(pkg, cursor)) itm.SetValue([]byte(prev)) itm.SetExpiration(24 * time.Hour) if err := memcache.Set(c, itm); err != nil { logging.WithError(err).Errorf(c, "Failed to store prev cursor %q in memc...
go
func (k cursorKind) storePrevCursor(c context.Context, pkg, cursor, prev string) { itm := memcache.NewItem(c, k.cursorKey(pkg, cursor)) itm.SetValue([]byte(prev)) itm.SetExpiration(24 * time.Hour) if err := memcache.Set(c, itm); err != nil { logging.WithError(err).Errorf(c, "Failed to store prev cursor %q in memc...
[ "func", "(", "k", "cursorKind", ")", "storePrevCursor", "(", "c", "context", ".", "Context", ",", "pkg", ",", "cursor", ",", "prev", "string", ")", "{", "itm", ":=", "memcache", ".", "NewItem", "(", "c", ",", "k", ".", "cursorKey", "(", "pkg", ",", ...
// storePrevCursor stores mapping cursor => prev, so that prev can be fetched // later by fetchPrevCursor. // // Logs and ignores errors. Cursor mapping is non-essential functionality.
[ "storePrevCursor", "stores", "mapping", "cursor", "=", ">", "prev", "so", "that", "prev", "can", "be", "fetched", "later", "by", "fetchPrevCursor", ".", "Logs", "and", "ignores", "errors", ".", "Cursor", "mapping", "is", "non", "-", "essential", "functionality...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/ui/cursors.go#L41-L48
130,317
luci/luci-go
cipd/appengine/ui/cursors.go
fetchPrevCursor
func (k cursorKind) fetchPrevCursor(c context.Context, pkg, cursor string) string { itm, err := memcache.GetKey(c, k.cursorKey(pkg, cursor)) if err != nil { if err != memcache.ErrCacheMiss { logging.WithError(err).Errorf(c, "Failed to fetch prev cursor %q from memcache", k) } return "" } return string(itm....
go
func (k cursorKind) fetchPrevCursor(c context.Context, pkg, cursor string) string { itm, err := memcache.GetKey(c, k.cursorKey(pkg, cursor)) if err != nil { if err != memcache.ErrCacheMiss { logging.WithError(err).Errorf(c, "Failed to fetch prev cursor %q from memcache", k) } return "" } return string(itm....
[ "func", "(", "k", "cursorKind", ")", "fetchPrevCursor", "(", "c", "context", ".", "Context", ",", "pkg", ",", "cursor", "string", ")", "string", "{", "itm", ",", "err", ":=", "memcache", ".", "GetKey", "(", "c", ",", "k", ".", "cursorKey", "(", "pkg"...
// fetchPrevCursor returns a cursor stored by storePrevCursor. // // Logs and ignores errors. Cursor mapping is non-essential functionality.
[ "fetchPrevCursor", "returns", "a", "cursor", "stored", "by", "storePrevCursor", ".", "Logs", "and", "ignores", "errors", ".", "Cursor", "mapping", "is", "non", "-", "essential", "functionality", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/ui/cursors.go#L53-L62
130,318
luci/luci-go
logdog/client/butler/streamserver/tcp.go
newTCPServerImpl
func newTCPServerImpl(ctx context.Context, netType, spec string, loopback net.IP) (StreamServer, error) { tcpAddr, err := net.ResolveTCPAddr(netType, spec) if err != nil { return nil, errors.Annotate(err, "could not resolve %q address %q", netType, spec).Err() } if tcpAddr.IP == nil { tcpAddr.IP = loopback } ...
go
func newTCPServerImpl(ctx context.Context, netType, spec string, loopback net.IP) (StreamServer, error) { tcpAddr, err := net.ResolveTCPAddr(netType, spec) if err != nil { return nil, errors.Annotate(err, "could not resolve %q address %q", netType, spec).Err() } if tcpAddr.IP == nil { tcpAddr.IP = loopback } ...
[ "func", "newTCPServerImpl", "(", "ctx", "context", ".", "Context", ",", "netType", ",", "spec", "string", ",", "loopback", "net", ".", "IP", ")", "(", "StreamServer", ",", "error", ")", "{", "tcpAddr", ",", "err", ":=", "net", ".", "ResolveTCPAddr", "(",...
// Listen implements StreamServer.
[ "Listen", "implements", "StreamServer", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/streamserver/tcp.go#L66-L92
130,319
luci/luci-go
dm/appengine/model/attempt.go
MakeAttempt
func MakeAttempt(c context.Context, aid *dm.Attempt_ID) *Attempt { now := clock.Now(c).UTC() return &Attempt{ ID: *aid, Created: now, Modified: now, } }
go
func MakeAttempt(c context.Context, aid *dm.Attempt_ID) *Attempt { now := clock.Now(c).UTC() return &Attempt{ ID: *aid, Created: now, Modified: now, } }
[ "func", "MakeAttempt", "(", "c", "context", ".", "Context", ",", "aid", "*", "dm", ".", "Attempt_ID", ")", "*", "Attempt", "{", "now", ":=", "clock", ".", "Now", "(", "c", ")", ".", "UTC", "(", ")", "\n", "return", "&", "Attempt", "{", "ID", ":",...
// MakeAttempt is a convenience function to create a new Attempt model in // the NeedsExecution state.
[ "MakeAttempt", "is", "a", "convenience", "function", "to", "create", "a", "new", "Attempt", "model", "in", "the", "NeedsExecution", "state", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/model/attempt.go#L103-L110
130,320
luci/luci-go
dm/appengine/model/attempt.go
ModifyState
func (a *Attempt) ModifyState(c context.Context, newState dm.Attempt_State) error { if a.State == newState { return nil } if err := a.State.Evolve(newState); err != nil { return err } now := clock.Now(c).UTC() if now.After(a.Modified) { a.Modified = now } else { // Microsecond is the smallest granularity...
go
func (a *Attempt) ModifyState(c context.Context, newState dm.Attempt_State) error { if a.State == newState { return nil } if err := a.State.Evolve(newState); err != nil { return err } now := clock.Now(c).UTC() if now.After(a.Modified) { a.Modified = now } else { // Microsecond is the smallest granularity...
[ "func", "(", "a", "*", "Attempt", ")", "ModifyState", "(", "c", "context", ".", "Context", ",", "newState", "dm", ".", "Attempt_State", ")", "error", "{", "if", "a", ".", "State", "==", "newState", "{", "return", "nil", "\n", "}", "\n", "if", "err", ...
// ModifyState changes the current state of this Attempt and updates its // Modified timestamp.
[ "ModifyState", "changes", "the", "current", "state", "of", "this", "Attempt", "and", "updates", "its", "Modified", "timestamp", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/model/attempt.go#L114-L132
130,321
luci/luci-go
dm/appengine/model/attempt.go
ToProto
func (a *Attempt) ToProto(withData bool) *dm.Attempt { ret := dm.Attempt{Id: &a.ID} if withData { ret.Data = a.DataProto() } return &ret }
go
func (a *Attempt) ToProto(withData bool) *dm.Attempt { ret := dm.Attempt{Id: &a.ID} if withData { ret.Data = a.DataProto() } return &ret }
[ "func", "(", "a", "*", "Attempt", ")", "ToProto", "(", "withData", "bool", ")", "*", "dm", ".", "Attempt", "{", "ret", ":=", "dm", ".", "Attempt", "{", "Id", ":", "&", "a", ".", "ID", "}", "\n", "if", "withData", "{", "ret", ".", "Data", "=", ...
// ToProto returns a dm proto version of this Attempt.
[ "ToProto", "returns", "a", "dm", "proto", "version", "of", "this", "Attempt", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/model/attempt.go#L135-L141
130,322
luci/luci-go
dm/appengine/model/attempt.go
DataProto
func (a *Attempt) DataProto() (ret *dm.Attempt_Data) { switch a.State { case dm.Attempt_SCHEDULING: ret = dm.NewAttemptScheduling().Data case dm.Attempt_EXECUTING: ret = dm.NewAttemptExecuting(a.CurExecution).Data case dm.Attempt_WAITING: ret = dm.NewAttemptWaiting(a.DepMap.Size() - a.DepMap.CountSet()).Data ...
go
func (a *Attempt) DataProto() (ret *dm.Attempt_Data) { switch a.State { case dm.Attempt_SCHEDULING: ret = dm.NewAttemptScheduling().Data case dm.Attempt_EXECUTING: ret = dm.NewAttemptExecuting(a.CurExecution).Data case dm.Attempt_WAITING: ret = dm.NewAttemptWaiting(a.DepMap.Size() - a.DepMap.CountSet()).Data ...
[ "func", "(", "a", "*", "Attempt", ")", "DataProto", "(", ")", "(", "ret", "*", "dm", ".", "Attempt_Data", ")", "{", "switch", "a", ".", "State", "{", "case", "dm", ".", "Attempt_SCHEDULING", ":", "ret", "=", "dm", ".", "NewAttemptScheduling", "(", ")...
// DataProto returns an Attempt.Data message for this Attempt.
[ "DataProto", "returns", "an", "Attempt", ".", "Data", "message", "for", "this", "Attempt", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/model/attempt.go#L144-L163
130,323
luci/luci-go
logdog/client/coordinator/stream.go
State
func (s *Stream) State(ctx context.Context) (*LogStream, error) { req := logdog.GetRequest{ Project: string(s.project), Path: string(s.path), State: true, LogCount: -1, // Don't fetch any logs. } resp, err := s.c.C.Get(ctx, &req) if err != nil { return nil, normalizeError(err) } path := types....
go
func (s *Stream) State(ctx context.Context) (*LogStream, error) { req := logdog.GetRequest{ Project: string(s.project), Path: string(s.path), State: true, LogCount: -1, // Don't fetch any logs. } resp, err := s.c.C.Get(ctx, &req) if err != nil { return nil, normalizeError(err) } path := types....
[ "func", "(", "s", "*", "Stream", ")", "State", "(", "ctx", "context", ".", "Context", ")", "(", "*", "LogStream", ",", "error", ")", "{", "req", ":=", "logdog", ".", "GetRequest", "{", "Project", ":", "string", "(", "s", ".", "project", ")", ",", ...
// State fetches the LogStreamDescriptor for a given log stream.
[ "State", "fetches", "the", "LogStreamDescriptor", "for", "a", "given", "log", "stream", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/coordinator/stream.go#L116-L135
130,324
luci/luci-go
logdog/client/coordinator/stream.go
Get
func (s *Stream) Get(ctx context.Context, params ...GetParam) ([]*logpb.LogEntry, error) { p := getParamsInst{ r: logdog.GetRequest{ Project: string(s.project), Path: string(s.path), }, } for _, param := range params { param.applyGet(&p) } if p.stateP != nil { p.r.State = true } resp, err := s...
go
func (s *Stream) Get(ctx context.Context, params ...GetParam) ([]*logpb.LogEntry, error) { p := getParamsInst{ r: logdog.GetRequest{ Project: string(s.project), Path: string(s.path), }, } for _, param := range params { param.applyGet(&p) } if p.stateP != nil { p.r.State = true } resp, err := s...
[ "func", "(", "s", "*", "Stream", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "params", "...", "GetParam", ")", "(", "[", "]", "*", "logpb", ".", "LogEntry", ",", "error", ")", "{", "p", ":=", "getParamsInst", "{", "r", ":", "logdog", ...
// Get retrieves log stream entries from the Coordinator. The supplied // parameters shape which entries are requested and what information is // returned.
[ "Get", "retrieves", "log", "stream", "entries", "from", "the", "Coordinator", ".", "The", "supplied", "parameters", "shape", "which", "entries", "are", "requested", "and", "what", "information", "is", "returned", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/coordinator/stream.go#L140-L163
130,325
luci/luci-go
logdog/client/coordinator/stream.go
Tail
func (s *Stream) Tail(ctx context.Context, params ...TailParam) (*logpb.LogEntry, error) { p := tailParamsInst{ r: logdog.TailRequest{ Project: string(s.project), Path: string(s.path), }, } for _, param := range params { param.applyTail(&p) } resp, err := s.c.C.Tail(ctx, &p.r) if err != nil { re...
go
func (s *Stream) Tail(ctx context.Context, params ...TailParam) (*logpb.LogEntry, error) { p := tailParamsInst{ r: logdog.TailRequest{ Project: string(s.project), Path: string(s.path), }, } for _, param := range params { param.applyTail(&p) } resp, err := s.c.C.Tail(ctx, &p.r) if err != nil { re...
[ "func", "(", "s", "*", "Stream", ")", "Tail", "(", "ctx", "context", ".", "Context", ",", "params", "...", "TailParam", ")", "(", "*", "logpb", ".", "LogEntry", ",", "error", ")", "{", "p", ":=", "tailParamsInst", "{", "r", ":", "logdog", ".", "Tai...
// Tail performs a tail call, returning the last log entry in the stream. If // stateP is not nil, the stream's state will be requested and loaded into the // variable.
[ "Tail", "performs", "a", "tail", "call", "returning", "the", "last", "log", "entry", "in", "the", "stream", ".", "If", "stateP", "is", "not", "nil", "the", "stream", "s", "state", "will", "be", "requested", "and", "loaded", "into", "the", "variable", "."...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/coordinator/stream.go#L168-L204
130,326
luci/luci-go
machine-db/appengine/model/vlans.go
fetch
func (t *VLANsTable) fetch(c context.Context) error { db := database.Get(c) rows, err := db.QueryContext(c, ` SELECT id, alias, state, cidr_block FROM vlans `) if err != nil { return errors.Annotate(err, "failed to select VLANs").Err() } defer rows.Close() for rows.Next() { vlan := &VLAN{} if err := ro...
go
func (t *VLANsTable) fetch(c context.Context) error { db := database.Get(c) rows, err := db.QueryContext(c, ` SELECT id, alias, state, cidr_block FROM vlans `) if err != nil { return errors.Annotate(err, "failed to select VLANs").Err() } defer rows.Close() for rows.Next() { vlan := &VLAN{} if err := ro...
[ "func", "(", "t", "*", "VLANsTable", ")", "fetch", "(", "c", "context", ".", "Context", ")", "error", "{", "db", ":=", "database", ".", "Get", "(", "c", ")", "\n", "rows", ",", "err", ":=", "db", ".", "QueryContext", "(", "c", ",", "`\n\t\tSELECT i...
// fetch fetches the VLANs from the database.
[ "fetch", "fetches", "the", "VLANs", "from", "the", "database", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/vlans.go#L46-L64
130,327
luci/luci-go
machine-db/appengine/model/vlans.go
computeChanges
func (t *VLANsTable) computeChanges(c context.Context, vlans []*config.VLAN) { cfgs := make(map[int64]*VLAN, len(vlans)) for _, cfg := range vlans { cfgs[cfg.Id] = &VLAN{ VLAN: config.VLAN{ Id: cfg.Id, Alias: cfg.Alias, State: cfg.State, CidrBlock: cfg.CidrBlock, }, } } for...
go
func (t *VLANsTable) computeChanges(c context.Context, vlans []*config.VLAN) { cfgs := make(map[int64]*VLAN, len(vlans)) for _, cfg := range vlans { cfgs[cfg.Id] = &VLAN{ VLAN: config.VLAN{ Id: cfg.Id, Alias: cfg.Alias, State: cfg.State, CidrBlock: cfg.CidrBlock, }, } } for...
[ "func", "(", "t", "*", "VLANsTable", ")", "computeChanges", "(", "c", "context", ".", "Context", ",", "vlans", "[", "]", "*", "config", ".", "VLAN", ")", "{", "cfgs", ":=", "make", "(", "map", "[", "int64", "]", "*", "VLAN", ",", "len", "(", "vla...
// computeChanges computes the changes that need to be made to the VLANs in the database.
[ "computeChanges", "computes", "the", "changes", "that", "need", "to", "be", "made", "to", "the", "VLANs", "in", "the", "database", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/vlans.go#L72-L107
130,328
luci/luci-go
machine-db/appengine/model/vlans.go
add
func (t *VLANsTable) add(c context.Context) error { // Avoid using the database connection to prepare unnecessary statements. if len(t.additions) == 0 { return nil } db := database.Get(c) stmt, err := db.PrepareContext(c, ` INSERT INTO vlans (id, alias, state, cidr_block) VALUES (?, ?, ?, ?) `) if err != ...
go
func (t *VLANsTable) add(c context.Context) error { // Avoid using the database connection to prepare unnecessary statements. if len(t.additions) == 0 { return nil } db := database.Get(c) stmt, err := db.PrepareContext(c, ` INSERT INTO vlans (id, alias, state, cidr_block) VALUES (?, ?, ?, ?) `) if err != ...
[ "func", "(", "t", "*", "VLANsTable", ")", "add", "(", "c", "context", ".", "Context", ")", "error", "{", "// Avoid using the database connection to prepare unnecessary statements.", "if", "len", "(", "t", ".", "additions", ")", "==", "0", "{", "return", "nil", ...
// add adds all VLANs pending addition to the database, clearing pending additions. // No-op unless computeChanges was called first. Idempotent until computeChanges is called again.
[ "add", "adds", "all", "VLANs", "pending", "addition", "to", "the", "database", "clearing", "pending", "additions", ".", "No", "-", "op", "unless", "computeChanges", "was", "called", "first", ".", "Idempotent", "until", "computeChanges", "is", "called", "again", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/vlans.go#L111-L139
130,329
luci/luci-go
machine-db/appengine/model/vlans.go
remove
func (t *VLANsTable) remove(c context.Context) error { // Avoid using the database connection to prepare unnecessary statements. if len(t.removals) == 0 { return nil } db := database.Get(c) stmt, err := db.PrepareContext(c, ` DELETE FROM vlans WHERE id = ? `) if err != nil { return errors.Annotate(err, ...
go
func (t *VLANsTable) remove(c context.Context) error { // Avoid using the database connection to prepare unnecessary statements. if len(t.removals) == 0 { return nil } db := database.Get(c) stmt, err := db.PrepareContext(c, ` DELETE FROM vlans WHERE id = ? `) if err != nil { return errors.Annotate(err, ...
[ "func", "(", "t", "*", "VLANsTable", ")", "remove", "(", "c", "context", ".", "Context", ")", "error", "{", "// Avoid using the database connection to prepare unnecessary statements.", "if", "len", "(", "t", ".", "removals", ")", "==", "0", "{", "return", "nil",...
// remove removes all VLANs pending removal from the database, clearing pending removals. // No-op unless computeChanges was called first. Idempotent until computeChanges is called again.
[ "remove", "removes", "all", "VLANs", "pending", "removal", "from", "the", "database", "clearing", "pending", "removals", ".", "No", "-", "op", "unless", "computeChanges", "was", "called", "first", ".", "Idempotent", "until", "computeChanges", "is", "called", "ag...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/vlans.go#L143-L182
130,330
luci/luci-go
machine-db/appengine/model/vlans.go
update
func (t *VLANsTable) update(c context.Context) error { // Avoid using the database connection to prepare unnecessary statements. if len(t.updates) == 0 { return nil } db := database.Get(c) stmt, err := db.PrepareContext(c, ` UPDATE vlans SET alias = ?, state = ?, cidr_block = ? WHERE id = ? `) if err !=...
go
func (t *VLANsTable) update(c context.Context) error { // Avoid using the database connection to prepare unnecessary statements. if len(t.updates) == 0 { return nil } db := database.Get(c) stmt, err := db.PrepareContext(c, ` UPDATE vlans SET alias = ?, state = ?, cidr_block = ? WHERE id = ? `) if err !=...
[ "func", "(", "t", "*", "VLANsTable", ")", "update", "(", "c", "context", ".", "Context", ")", "error", "{", "// Avoid using the database connection to prepare unnecessary statements.", "if", "len", "(", "t", ".", "updates", ")", "==", "0", "{", "return", "nil", ...
// update updates all VLANs pending update in the database, clearing pending updates. // No-op unless computeChanges was called first. Idempotent until computeChanges is called again.
[ "update", "updates", "all", "VLANs", "pending", "update", "in", "the", "database", "clearing", "pending", "updates", ".", "No", "-", "op", "unless", "computeChanges", "was", "called", "first", ".", "Idempotent", "until", "computeChanges", "is", "called", "again"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/vlans.go#L186-L225
130,331
luci/luci-go
machine-db/appengine/model/vlans.go
EnsureVLANs
func EnsureVLANs(c context.Context, cfgs []*config.VLAN) error { t := &VLANsTable{} if err := t.fetch(c); err != nil { return errors.Annotate(err, "failed to fetch VLANs").Err() } t.computeChanges(c, cfgs) if err := t.add(c); err != nil { return errors.Annotate(err, "failed to add VLANs").Err() } if err := t...
go
func EnsureVLANs(c context.Context, cfgs []*config.VLAN) error { t := &VLANsTable{} if err := t.fetch(c); err != nil { return errors.Annotate(err, "failed to fetch VLANs").Err() } t.computeChanges(c, cfgs) if err := t.add(c); err != nil { return errors.Annotate(err, "failed to add VLANs").Err() } if err := t...
[ "func", "EnsureVLANs", "(", "c", "context", ".", "Context", ",", "cfgs", "[", "]", "*", "config", ".", "VLAN", ")", "error", "{", "t", ":=", "&", "VLANsTable", "{", "}", "\n", "if", "err", ":=", "t", ".", "fetch", "(", "c", ")", ";", "err", "!=...
// EnsureVLANs ensures the database contains exactly the given VLANs.
[ "EnsureVLANs", "ensures", "the", "database", "contains", "exactly", "the", "given", "VLANs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/vlans.go#L228-L244
130,332
luci/luci-go
lucicfg/normalize/milo.go
Milo
func Milo(c context.Context, cfg *pb.Project) error { // Sort consoles by ID. sort.Slice(cfg.Consoles, func(i, j int) bool { return cfg.Consoles[i].Id < cfg.Consoles[j].Id }) // Inline headers. headers := make(map[string]*pb.Header) for _, h := range cfg.Headers { headers[h.Id] = h h.Id = "" } for _, c :...
go
func Milo(c context.Context, cfg *pb.Project) error { // Sort consoles by ID. sort.Slice(cfg.Consoles, func(i, j int) bool { return cfg.Consoles[i].Id < cfg.Consoles[j].Id }) // Inline headers. headers := make(map[string]*pb.Header) for _, h := range cfg.Headers { headers[h.Id] = h h.Id = "" } for _, c :...
[ "func", "Milo", "(", "c", "context", ".", "Context", ",", "cfg", "*", "pb", ".", "Project", ")", "error", "{", "// Sort consoles by ID.", "sort", ".", "Slice", "(", "cfg", ".", "Consoles", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "...
// Milo normalizes luci-milo.cfg config.
[ "Milo", "normalizes", "luci", "-", "milo", ".", "cfg", "config", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/normalize/milo.go#L28-L72
130,333
luci/luci-go
milo/frontend/view_search.go
searchXMLHandler
func searchXMLHandler(c *router.Context) { c.Writer.Header().Set("Content-Type", "application/opensearchdescription+xml") c.Writer.WriteHeader(http.StatusOK) fmt.Fprintf(c.Writer, openSearchXML, c.Request.URL.Host) }
go
func searchXMLHandler(c *router.Context) { c.Writer.Header().Set("Content-Type", "application/opensearchdescription+xml") c.Writer.WriteHeader(http.StatusOK) fmt.Fprintf(c.Writer, openSearchXML, c.Request.URL.Host) }
[ "func", "searchXMLHandler", "(", "c", "*", "router", ".", "Context", ")", "{", "c", ".", "Writer", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "Writer", ".", "WriteHeader", "(", "http", ".", "Status...
// searchXMLHandler returns the opensearch document for this domain.
[ "searchXMLHandler", "returns", "the", "opensearch", "document", "for", "this", "domain", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_search.go#L74-L78
130,334
luci/luci-go
tokenserver/appengine/impl/utils/identityset/identityset.go
AddIdentity
func (s *Set) AddIdentity(id identity.Identity) { if !s.All { if s.IDs == nil { s.IDs = make(identSet, 1) } s.IDs[id] = struct{}{} } }
go
func (s *Set) AddIdentity(id identity.Identity) { if !s.All { if s.IDs == nil { s.IDs = make(identSet, 1) } s.IDs[id] = struct{}{} } }
[ "func", "(", "s", "*", "Set", ")", "AddIdentity", "(", "id", "identity", ".", "Identity", ")", "{", "if", "!", "s", ".", "All", "{", "if", "s", ".", "IDs", "==", "nil", "{", "s", ".", "IDs", "=", "make", "(", "identSet", ",", "1", ")", "\n", ...
// AddIdentity adds a single identity to the set. // // The receiver must not be nil.
[ "AddIdentity", "adds", "a", "single", "identity", "to", "the", "set", ".", "The", "receiver", "must", "not", "be", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/identityset/identityset.go#L46-L53
130,335
luci/luci-go
tokenserver/appengine/impl/utils/identityset/identityset.go
AddGroup
func (s *Set) AddGroup(group string) { if !s.All { if s.Groups == nil { s.Groups = make(groupSet, 1) } s.Groups[group] = struct{}{} } }
go
func (s *Set) AddGroup(group string) { if !s.All { if s.Groups == nil { s.Groups = make(groupSet, 1) } s.Groups[group] = struct{}{} } }
[ "func", "(", "s", "*", "Set", ")", "AddGroup", "(", "group", "string", ")", "{", "if", "!", "s", ".", "All", "{", "if", "s", ".", "Groups", "==", "nil", "{", "s", ".", "Groups", "=", "make", "(", "groupSet", ",", "1", ")", "\n", "}", "\n", ...
// AddGroup adds a single group to the set. // // The receiver must not be nil.
[ "AddGroup", "adds", "a", "single", "group", "to", "the", "set", ".", "The", "receiver", "must", "not", "be", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/identityset/identityset.go#L58-L65
130,336
luci/luci-go
tokenserver/appengine/impl/utils/identityset/identityset.go
IsEmpty
func (s *Set) IsEmpty() bool { return s == nil || (!s.All && len(s.IDs) == 0 && len(s.Groups) == 0) }
go
func (s *Set) IsEmpty() bool { return s == nil || (!s.All && len(s.IDs) == 0 && len(s.Groups) == 0) }
[ "func", "(", "s", "*", "Set", ")", "IsEmpty", "(", ")", "bool", "{", "return", "s", "==", "nil", "||", "(", "!", "s", ".", "All", "&&", "len", "(", "s", ".", "IDs", ")", "==", "0", "&&", "len", "(", "s", ".", "Groups", ")", "==", "0", ")"...
// IsEmpty returns true if this set is empty. // // 'nil' receiver value is valid and represents an empty set.
[ "IsEmpty", "returns", "true", "if", "this", "set", "is", "empty", ".", "nil", "receiver", "value", "is", "valid", "and", "represents", "an", "empty", "set", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/identityset/identityset.go#L70-L72
130,337
luci/luci-go
tokenserver/appengine/impl/utils/identityset/identityset.go
IsMember
func (s *Set) IsMember(c context.Context, id identity.Identity) (bool, error) { if s == nil { return false, nil } if s.All { return true, nil } if _, ok := s.IDs[id]; ok { return true, nil } if len(s.Groups) != 0 { groups := make([]string, 0, len(s.Groups)) for gr := range s.Groups { groups = app...
go
func (s *Set) IsMember(c context.Context, id identity.Identity) (bool, error) { if s == nil { return false, nil } if s.All { return true, nil } if _, ok := s.IDs[id]; ok { return true, nil } if len(s.Groups) != 0 { groups := make([]string, 0, len(s.Groups)) for gr := range s.Groups { groups = app...
[ "func", "(", "s", "*", "Set", ")", "IsMember", "(", "c", "context", ".", "Context", ",", "id", "identity", ".", "Identity", ")", "(", "bool", ",", "error", ")", "{", "if", "s", "==", "nil", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", ...
// IsMember returns true if the given identity is in the set. // // It looks inside the groups too. // // 'nil' receiver value is valid and represents an empty set.
[ "IsMember", "returns", "true", "if", "the", "given", "identity", "is", "in", "the", "set", ".", "It", "looks", "inside", "the", "groups", "too", ".", "nil", "receiver", "value", "is", "valid", "and", "represents", "an", "empty", "set", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/identityset/identityset.go#L79-L101
130,338
luci/luci-go
tokenserver/appengine/impl/utils/identityset/identityset.go
IsSubset
func (s *Set) IsSubset(superset *Set) bool { // An empty set is subset of any other set (including empty sets). if s.IsEmpty() { return true } // An empty set is not a superset of any non-empty set. if superset.IsEmpty() { return false } // The universal set is subset of only itself. if s.All { return s...
go
func (s *Set) IsSubset(superset *Set) bool { // An empty set is subset of any other set (including empty sets). if s.IsEmpty() { return true } // An empty set is not a superset of any non-empty set. if superset.IsEmpty() { return false } // The universal set is subset of only itself. if s.All { return s...
[ "func", "(", "s", "*", "Set", ")", "IsSubset", "(", "superset", "*", "Set", ")", "bool", "{", "// An empty set is subset of any other set (including empty sets).", "if", "s", ".", "IsEmpty", "(", ")", "{", "return", "true", "\n", "}", "\n\n", "// An empty set is...
// IsSubset returns true if this set if a subset of another set. // // Two equal sets are considered subsets of each other. // // It doesn't attempt to expand groups. Compares IDs and Groups sets separately, // as independent kinds of entities. // // 'nil' receiver and argument values are valid and represent empty sets...
[ "IsSubset", "returns", "true", "if", "this", "set", "if", "a", "subset", "of", "another", "set", ".", "Two", "equal", "sets", "are", "considered", "subsets", "of", "each", "other", ".", "It", "doesn", "t", "attempt", "to", "expand", "groups", ".", "Compa...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/identityset/identityset.go#L111-L153
130,339
luci/luci-go
tokenserver/appengine/impl/utils/identityset/identityset.go
ToStrings
func (s *Set) ToStrings() []string { if s.IsEmpty() { return nil } if s.All { return []string{"*"} } out := make([]string, 0, len(s.IDs)+len(s.Groups)) for ident := range s.IDs { out = append(out, string(ident)) } for group := range s.Groups { out = append(out, "group:"+group) } sort.Strings(out) ret...
go
func (s *Set) ToStrings() []string { if s.IsEmpty() { return nil } if s.All { return []string{"*"} } out := make([]string, 0, len(s.IDs)+len(s.Groups)) for ident := range s.IDs { out = append(out, string(ident)) } for group := range s.Groups { out = append(out, "group:"+group) } sort.Strings(out) ret...
[ "func", "(", "s", "*", "Set", ")", "ToStrings", "(", ")", "[", "]", "string", "{", "if", "s", ".", "IsEmpty", "(", ")", "{", "return", "nil", "\n", "}", "\n", "if", "s", ".", "All", "{", "return", "[", "]", "string", "{", "\"", "\"", "}", "...
// ToStrings returns a sorted list of strings representing this set. // // See 'FromStrings' for the format of this list.
[ "ToStrings", "returns", "a", "sorted", "list", "of", "strings", "representing", "this", "set", ".", "See", "FromStrings", "for", "the", "format", "of", "this", "list", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/identityset/identityset.go#L167-L183
130,340
luci/luci-go
tokenserver/appengine/impl/utils/identityset/identityset.go
Union
func Union(sets ...*Set) *Set { estimateIDs := 0 estimateGroups := 0 for _, s := range sets { if s == nil { continue } if s.All { return &Set{All: true} } if len(s.IDs) > estimateIDs { estimateIDs = len(s.IDs) } if len(s.Groups) > estimateGroups { estimateGroups = len(s.Groups) } } un...
go
func Union(sets ...*Set) *Set { estimateIDs := 0 estimateGroups := 0 for _, s := range sets { if s == nil { continue } if s.All { return &Set{All: true} } if len(s.IDs) > estimateIDs { estimateIDs = len(s.IDs) } if len(s.Groups) > estimateGroups { estimateGroups = len(s.Groups) } } un...
[ "func", "Union", "(", "sets", "...", "*", "Set", ")", "*", "Set", "{", "estimateIDs", ":=", "0", "\n", "estimateGroups", ":=", "0", "\n\n", "for", "_", ",", "s", ":=", "range", "sets", "{", "if", "s", "==", "nil", "{", "continue", "\n", "}", "\n"...
// Union returns a union of a list of sets.
[ "Union", "returns", "a", "union", "of", "a", "list", "of", "sets", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/identityset/identityset.go#L225-L265
130,341
luci/luci-go
buildbucket/cmd/run_annotations/main.go
check
func check(err error) { if err == nil { return } buildMU.Lock() defer buildMU.Unlock() build.Status = pb.Status_INFRA_FAILURE build.SummaryMarkdown = fmt.Sprintf("run_annotations failure: `%s`", err) client.WriteBuild(build) fmt.Fprintln(os.Stderr, err) os.Exit(1) }
go
func check(err error) { if err == nil { return } buildMU.Lock() defer buildMU.Unlock() build.Status = pb.Status_INFRA_FAILURE build.SummaryMarkdown = fmt.Sprintf("run_annotations failure: `%s`", err) client.WriteBuild(build) fmt.Fprintln(os.Stderr, err) os.Exit(1) }
[ "func", "check", "(", "err", "error", ")", "{", "if", "err", "==", "nil", "{", "return", "\n", "}", "\n\n", "buildMU", ".", "Lock", "(", ")", "\n", "defer", "buildMU", ".", "Unlock", "(", ")", "\n", "build", ".", "Status", "=", "pb", ".", "Status...
// check marks the build as INFRA_FAILURE and exits with code 1 if err is not nil.
[ "check", "marks", "the", "build", "as", "INFRA_FAILURE", "and", "exits", "with", "code", "1", "if", "err", "is", "not", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cmd/run_annotations/main.go#L46-L58
130,342
luci/luci-go
buildbucket/cmd/run_annotations/main.go
sendAnnotations
func sendAnnotations(ctx context.Context, ann *milo.Step) error { fullPrefix := fmt.Sprintf("%s/%s", client.Logdog.Prefix, client.Logdog.Namespace) steps, err := deprecated.ConvertBuildSteps(ctx, ann.Substep, client.Logdog.CoordinatorHost, fullPrefix) if err != nil { return errors.Annotate(err, "failed to extra st...
go
func sendAnnotations(ctx context.Context, ann *milo.Step) error { fullPrefix := fmt.Sprintf("%s/%s", client.Logdog.Prefix, client.Logdog.Namespace) steps, err := deprecated.ConvertBuildSteps(ctx, ann.Substep, client.Logdog.CoordinatorHost, fullPrefix) if err != nil { return errors.Annotate(err, "failed to extra st...
[ "func", "sendAnnotations", "(", "ctx", "context", ".", "Context", ",", "ann", "*", "milo", ".", "Step", ")", "error", "{", "fullPrefix", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "client", ".", "Logdog", ".", "Prefix", ",", "client", ".", "L...
// sendAnnotations parses steps and properties from ann, updates build and sends // to the caller.
[ "sendAnnotations", "parses", "steps", "and", "properties", "from", "ann", "updates", "build", "and", "sends", "to", "the", "caller", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cmd/run_annotations/main.go#L62-L79
130,343
luci/luci-go
machine-db/appengine/rpc/switches.go
ListSwitches
func (*Service) ListSwitches(c context.Context, req *crimson.ListSwitchesRequest) (*crimson.ListSwitchesResponse, error) { switches, err := listSwitches(c, stringset.NewFromSlice(req.Names...), stringset.NewFromSlice(req.Racks...), stringset.NewFromSlice(req.Datacenters...)) if err != nil { return nil, err } retu...
go
func (*Service) ListSwitches(c context.Context, req *crimson.ListSwitchesRequest) (*crimson.ListSwitchesResponse, error) { switches, err := listSwitches(c, stringset.NewFromSlice(req.Names...), stringset.NewFromSlice(req.Racks...), stringset.NewFromSlice(req.Datacenters...)) if err != nil { return nil, err } retu...
[ "func", "(", "*", "Service", ")", "ListSwitches", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "ListSwitchesRequest", ")", "(", "*", "crimson", ".", "ListSwitchesResponse", ",", "error", ")", "{", "switches", ",", "err", ":=", "l...
// ListSwitches handles a request to retrieve switches.
[ "ListSwitches", "handles", "a", "request", "to", "retrieve", "switches", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/switches.go#L28-L36
130,344
luci/luci-go
machine-db/appengine/rpc/switches.go
listSwitches
func listSwitches(c context.Context, names, racks, datacenters stringset.Set) ([]*crimson.Switch, error) { db := database.Get(c) rows, err := db.QueryContext(c, ` SELECT s.name, s.description, s.ports, s.state, r.name, d.name FROM switches s, racks r, datacenters d WHERE s.rack_id = r.id AND r.datacenter_id ...
go
func listSwitches(c context.Context, names, racks, datacenters stringset.Set) ([]*crimson.Switch, error) { db := database.Get(c) rows, err := db.QueryContext(c, ` SELECT s.name, s.description, s.ports, s.state, r.name, d.name FROM switches s, racks r, datacenters d WHERE s.rack_id = r.id AND r.datacenter_id ...
[ "func", "listSwitches", "(", "c", "context", ".", "Context", ",", "names", ",", "racks", ",", "datacenters", "stringset", ".", "Set", ")", "(", "[", "]", "*", "crimson", ".", "Switch", ",", "error", ")", "{", "db", ":=", "database", ".", "Get", "(", ...
// listSwitches returns a slice of switches in the database.
[ "listSwitches", "returns", "a", "slice", "of", "switches", "in", "the", "database", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/switches.go#L39-L63
130,345
luci/luci-go
server/caching/layered/layered.go
GetOrCreate
func (c *Cache) GetOrCreate(ctx context.Context, key string, fn lru.Maker, opts ...Option) (interface{}, error) { if c.GlobalNamespace == "" { panic("empty namespace is forbidden, please specify GlobalNamespace") } o := options{} for _, opt := range opts { opt.apply(&o) } now := clock.Now(ctx) lru := c.Pro...
go
func (c *Cache) GetOrCreate(ctx context.Context, key string, fn lru.Maker, opts ...Option) (interface{}, error) { if c.GlobalNamespace == "" { panic("empty namespace is forbidden, please specify GlobalNamespace") } o := options{} for _, opt := range opts { opt.apply(&o) } now := clock.Now(ctx) lru := c.Pro...
[ "func", "(", "c", "*", "Cache", ")", "GetOrCreate", "(", "ctx", "context", ".", "Context", ",", "key", "string", ",", "fn", "lru", ".", "Maker", ",", "opts", "...", "Option", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "c", "."...
// GetOrCreate attempts to grab an item from process or global cache, or create // it if it's not cached yet. // // Fetching an item from the global cache or instantiating a new item happens // under a per-key lock. // // Expiration time is used with seconds precision. Zero expiration time means // the item doesn't exp...
[ "GetOrCreate", "attempts", "to", "grab", "an", "item", "from", "process", "or", "global", "cache", "or", "create", "it", "if", "it", "s", "not", "cached", "yet", ".", "Fetching", "an", "item", "from", "the", "global", "cache", "or", "instantiating", "a", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/layered/layered.go#L102-L178
130,346
luci/luci-go
server/caching/layered/layered.go
isAcceptableTTL
func (i *itemWithExp) isAcceptableTTL(now time.Time, minTTL time.Duration) bool { if i.exp.IsZero() { return true // never expires } // Note: '>=' must not be used here, since minTTL may be 0, and we don't want // to return true on zero expiration. return i.exp.Sub(now) > minTTL }
go
func (i *itemWithExp) isAcceptableTTL(now time.Time, minTTL time.Duration) bool { if i.exp.IsZero() { return true // never expires } // Note: '>=' must not be used here, since minTTL may be 0, and we don't want // to return true on zero expiration. return i.exp.Sub(now) > minTTL }
[ "func", "(", "i", "*", "itemWithExp", ")", "isAcceptableTTL", "(", "now", "time", ".", "Time", ",", "minTTL", "time", ".", "Duration", ")", "bool", "{", "if", "i", ".", "exp", ".", "IsZero", "(", ")", "{", "return", "true", "// never expires", "\n", ...
// isAcceptableTTL returns true if item's TTL is large enough.
[ "isAcceptableTTL", "returns", "true", "if", "item", "s", "TTL", "is", "large", "enough", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/layered/layered.go#L210-L217
130,347
luci/luci-go
server/caching/layered/layered.go
randomlyExpired
func (i *itemWithExp) randomlyExpired(ctx context.Context, now time.Time, threshold time.Duration) bool { if i.exp.IsZero() { return false // never expires } ttl := i.exp.Sub(now) if ttl > threshold { return false // far from expiration, no need to enable randomization } // TODO(vadimsh): The choice of dist...
go
func (i *itemWithExp) randomlyExpired(ctx context.Context, now time.Time, threshold time.Duration) bool { if i.exp.IsZero() { return false // never expires } ttl := i.exp.Sub(now) if ttl > threshold { return false // far from expiration, no need to enable randomization } // TODO(vadimsh): The choice of dist...
[ "func", "(", "i", "*", "itemWithExp", ")", "randomlyExpired", "(", "ctx", "context", ".", "Context", ",", "now", "time", ".", "Time", ",", "threshold", "time", ".", "Duration", ")", "bool", "{", "if", "i", ".", "exp", ".", "IsZero", "(", ")", "{", ...
// randomlyExpired returns true if the item must be considered already expired. // // See WithRandomizedExpiration for the rationale. The context is used only to // grab RNG.
[ "randomlyExpired", "returns", "true", "if", "the", "item", "must", "be", "considered", "already", "expired", ".", "See", "WithRandomizedExpiration", "for", "the", "rationale", ".", "The", "context", "is", "used", "only", "to", "grab", "RNG", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/layered/layered.go#L223-L241
130,348
luci/luci-go
server/caching/layered/layered.go
maybeFetchItem
func (c *Cache) maybeFetchItem(ctx context.Context, key string) *itemWithExp { g := caching.GlobalCache(ctx, c.GlobalNamespace) if g == nil { return nil } blob, err := g.Get(ctx, key) if err != nil { if err != caching.ErrCacheMiss { logging.WithError(err).Errorf(ctx, "Failed to read item %q from the global...
go
func (c *Cache) maybeFetchItem(ctx context.Context, key string) *itemWithExp { g := caching.GlobalCache(ctx, c.GlobalNamespace) if g == nil { return nil } blob, err := g.Get(ctx, key) if err != nil { if err != caching.ErrCacheMiss { logging.WithError(err).Errorf(ctx, "Failed to read item %q from the global...
[ "func", "(", "c", "*", "Cache", ")", "maybeFetchItem", "(", "ctx", "context", ".", "Context", ",", "key", "string", ")", "*", "itemWithExp", "{", "g", ":=", "caching", ".", "GlobalCache", "(", "ctx", ",", "c", ".", "GlobalNamespace", ")", "\n", "if", ...
// maybeFetchItem attempts to fetch the item from the global cache. // // If the global cache is not available or the cached item there is broken // returns nil. Logs errors inside.
[ "maybeFetchItem", "attempts", "to", "fetch", "the", "item", "from", "the", "global", "cache", ".", "If", "the", "global", "cache", "is", "not", "available", "or", "the", "cached", "item", "there", "is", "broken", "returns", "nil", ".", "Logs", "errors", "i...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/layered/layered.go#L263-L283
130,349
luci/luci-go
server/caching/layered/layered.go
maybeStoreItem
func (c *Cache) maybeStoreItem(ctx context.Context, key string, item *itemWithExp, now time.Time) error { g := caching.GlobalCache(ctx, c.GlobalNamespace) if g == nil { return nil } blob, err := c.serializeItem(item) if err != nil { return err } if err = g.Set(ctx, key, blob, item.expiration(now)); err != ...
go
func (c *Cache) maybeStoreItem(ctx context.Context, key string, item *itemWithExp, now time.Time) error { g := caching.GlobalCache(ctx, c.GlobalNamespace) if g == nil { return nil } blob, err := c.serializeItem(item) if err != nil { return err } if err = g.Set(ctx, key, blob, item.expiration(now)); err != ...
[ "func", "(", "c", "*", "Cache", ")", "maybeStoreItem", "(", "ctx", "context", ".", "Context", ",", "key", "string", ",", "item", "*", "itemWithExp", ",", "now", "time", ".", "Time", ")", "error", "{", "g", ":=", "caching", ".", "GlobalCache", "(", "c...
// maybeStoreItem puts the item in the global cache, if possible. // // It returns an error only if the serialization fails. It generally means the // serialization code is buggy and should be adjusted. // // Global cache errors are logged and ignored.
[ "maybeStoreItem", "puts", "the", "item", "in", "the", "global", "cache", "if", "possible", ".", "It", "returns", "an", "error", "only", "if", "the", "serialization", "fails", ".", "It", "generally", "means", "the", "serialization", "code", "is", "buggy", "an...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/layered/layered.go#L291-L306
130,350
luci/luci-go
server/caching/layered/layered.go
serializeItem
func (c *Cache) serializeItem(item *itemWithExp) ([]byte, error) { blob, err := c.Marshal(item.val) if err != nil { return nil, err } var deadline uint64 if !item.exp.IsZero() { deadline = uint64(item.exp.Unix()) } // <version_byte> + <uint64 deadline timestamp> + <blob> output := make([]byte, 9+len(blob)...
go
func (c *Cache) serializeItem(item *itemWithExp) ([]byte, error) { blob, err := c.Marshal(item.val) if err != nil { return nil, err } var deadline uint64 if !item.exp.IsZero() { deadline = uint64(item.exp.Unix()) } // <version_byte> + <uint64 deadline timestamp> + <blob> output := make([]byte, 9+len(blob)...
[ "func", "(", "c", "*", "Cache", ")", "serializeItem", "(", "item", "*", "itemWithExp", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "blob", ",", "err", ":=", "c", ".", "Marshal", "(", "item", ".", "val", ")", "\n", "if", "err", "!=", "ni...
// serializeItem packs item and its expiration time into a byte blob.
[ "serializeItem", "packs", "item", "and", "its", "expiration", "time", "into", "a", "byte", "blob", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/layered/layered.go#L309-L326
130,351
luci/luci-go
server/caching/layered/layered.go
deserializeItem
func (c *Cache) deserializeItem(blob []byte) (item *itemWithExp, err error) { if len(blob) < 9 { err = fmt.Errorf("the received buffer is too small") return } if blob[0] != formatVersionByte { err = fmt.Errorf("bad format version, expecting %d, got %d", formatVersionByte, blob[0]) return } item = &itemWith...
go
func (c *Cache) deserializeItem(blob []byte) (item *itemWithExp, err error) { if len(blob) < 9 { err = fmt.Errorf("the received buffer is too small") return } if blob[0] != formatVersionByte { err = fmt.Errorf("bad format version, expecting %d, got %d", formatVersionByte, blob[0]) return } item = &itemWith...
[ "func", "(", "c", "*", "Cache", ")", "deserializeItem", "(", "blob", "[", "]", "byte", ")", "(", "item", "*", "itemWithExp", ",", "err", "error", ")", "{", "if", "len", "(", "blob", ")", "<", "9", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"...
// deserializeItem is reverse of serializeItem.
[ "deserializeItem", "is", "reverse", "of", "serializeItem", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/layered/layered.go#L329-L345
130,352
luci/luci-go
tokenserver/cmd/luci_machine_tokend/signals.go
catchInterrupt
func catchInterrupt(handler func()) { sig := make(chan os.Signal, 1) signal.Notify(sig, interruptSignals()...) go func() { stopCalled := false for range sig { if !stopCalled { stopCalled = true handler() } else { os.Exit(2) } } }() }
go
func catchInterrupt(handler func()) { sig := make(chan os.Signal, 1) signal.Notify(sig, interruptSignals()...) go func() { stopCalled := false for range sig { if !stopCalled { stopCalled = true handler() } else { os.Exit(2) } } }() }
[ "func", "catchInterrupt", "(", "handler", "func", "(", ")", ")", "{", "sig", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "sig", ",", "interruptSignals", "(", ")", "...", ")", "\n", "go", "func"...
// catchInterrupt handles SIGINT and SIGTERM signals. // // When caught for the first time, it calls the `handler`, assuming it will // gracefully shutdown the process. // // If called for the second time, it just kills the process right away.
[ "catchInterrupt", "handles", "SIGINT", "and", "SIGTERM", "signals", ".", "When", "caught", "for", "the", "first", "time", "it", "calls", "the", "handler", "assuming", "it", "will", "gracefully", "shutdown", "the", "process", ".", "If", "called", "for", "the", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/signals.go#L28-L42
130,353
luci/luci-go
cipd/appengine/impl/cas/upload/id.go
NewOpID
func NewOpID(c context.Context) (int64, error) { // Note: AllocateIDs modifies passed slice in place, by replacing the keys // there. keys := []*datastore.Key{ datastore.NewKey(c, "cas.UploadOperation", "", 0, nil), } if err := datastore.AllocateIDs(c, keys); err != nil { return 0, errors.Annotate(err, "failed...
go
func NewOpID(c context.Context) (int64, error) { // Note: AllocateIDs modifies passed slice in place, by replacing the keys // there. keys := []*datastore.Key{ datastore.NewKey(c, "cas.UploadOperation", "", 0, nil), } if err := datastore.AllocateIDs(c, keys); err != nil { return 0, errors.Annotate(err, "failed...
[ "func", "NewOpID", "(", "c", "context", ".", "Context", ")", "(", "int64", ",", "error", ")", "{", "// Note: AllocateIDs modifies passed slice in place, by replacing the keys", "// there.", "keys", ":=", "[", "]", "*", "datastore", ".", "Key", "{", "datastore", "....
// NewOpID returns new unique upload operation ID.
[ "NewOpID", "returns", "new", "unique", "upload", "operation", "ID", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/cas/upload/id.go#L39-L50
130,354
luci/luci-go
cipd/appengine/impl/cas/upload/id.go
WrapOpID
func WrapOpID(c context.Context, id int64, caller identity.Identity) (string, error) { return opToken.Generate(c, []byte(caller), map[string]string{ "id": strconv.FormatInt(id, 10), }, 0) }
go
func WrapOpID(c context.Context, id int64, caller identity.Identity) (string, error) { return opToken.Generate(c, []byte(caller), map[string]string{ "id": strconv.FormatInt(id, 10), }, 0) }
[ "func", "WrapOpID", "(", "c", "context", ".", "Context", ",", "id", "int64", ",", "caller", "identity", ".", "Identity", ")", "(", "string", ",", "error", ")", "{", "return", "opToken", ".", "Generate", "(", "c", ",", "[", "]", "byte", "(", "caller",...
// WrapOpID returns HMAC-protected string that embeds upload operation ID. // // The string is bound to the given caller, i.e UnwrapOpID will correctly // validate HMAC only if it receives the exact same caller.
[ "WrapOpID", "returns", "HMAC", "-", "protected", "string", "that", "embeds", "upload", "operation", "ID", ".", "The", "string", "is", "bound", "to", "the", "given", "caller", "i", ".", "e", "UnwrapOpID", "will", "correctly", "validate", "HMAC", "only", "if",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/cas/upload/id.go#L56-L60
130,355
luci/luci-go
cipd/appengine/impl/cas/upload/id.go
UnwrapOpID
func UnwrapOpID(c context.Context, token string, caller identity.Identity) (int64, error) { body, err := opToken.Validate(c, token, []byte(caller)) if err != nil { return 0, errors.Annotate(err, "failed to validate upload operation ID token").Err() } id, err := strconv.ParseInt(body["id"], 10, 64) if err != nil ...
go
func UnwrapOpID(c context.Context, token string, caller identity.Identity) (int64, error) { body, err := opToken.Validate(c, token, []byte(caller)) if err != nil { return 0, errors.Annotate(err, "failed to validate upload operation ID token").Err() } id, err := strconv.ParseInt(body["id"], 10, 64) if err != nil ...
[ "func", "UnwrapOpID", "(", "c", "context", ".", "Context", ",", "token", "string", ",", "caller", "identity", ".", "Identity", ")", "(", "int64", ",", "error", ")", "{", "body", ",", "err", ":=", "opToken", ".", "Validate", "(", "c", ",", "token", ",...
// UnwrapOpID extracts upload operation ID from a HMAC-protected string.
[ "UnwrapOpID", "extracts", "upload", "operation", "ID", "from", "a", "HMAC", "-", "protected", "string", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/cas/upload/id.go#L63-L73
130,356
luci/luci-go
common/bq/insertid.go
Generate
func (id *InsertIDGenerator) Generate() string { prefix := id.Prefix if prefix == "" { prefix = defaultPrefix } c := atomic.AddInt64(&id.Counter, 1) return fmt.Sprintf("%s:%d", prefix, c) }
go
func (id *InsertIDGenerator) Generate() string { prefix := id.Prefix if prefix == "" { prefix = defaultPrefix } c := atomic.AddInt64(&id.Counter, 1) return fmt.Sprintf("%s:%d", prefix, c) }
[ "func", "(", "id", "*", "InsertIDGenerator", ")", "Generate", "(", ")", "string", "{", "prefix", ":=", "id", ".", "Prefix", "\n", "if", "prefix", "==", "\"", "\"", "{", "prefix", "=", "defaultPrefix", "\n", "}", "\n", "c", ":=", "atomic", ".", "AddIn...
// Generate returns a unique Insert ID.
[ "Generate", "returns", "a", "unique", "Insert", "ID", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/bq/insertid.go#L56-L63
130,357
luci/luci-go
common/tsmon/store/inmemory.go
NewInMemory
func NewInMemory(defaultTarget types.Target) Store { return &inMemoryStore{ defaultTarget: defaultTarget, data: map[string]*metricData{}, } }
go
func NewInMemory(defaultTarget types.Target) Store { return &inMemoryStore{ defaultTarget: defaultTarget, data: map[string]*metricData{}, } }
[ "func", "NewInMemory", "(", "defaultTarget", "types", ".", "Target", ")", "Store", "{", "return", "&", "inMemoryStore", "{", "defaultTarget", ":", "defaultTarget", ",", "data", ":", "map", "[", "string", "]", "*", "metricData", "{", "}", ",", "}", "\n", ...
// NewInMemory creates a new metric store that holds metric data in this // process' memory.
[ "NewInMemory", "creates", "a", "new", "metric", "store", "that", "holds", "metric", "data", "in", "this", "process", "memory", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/store/inmemory.go#L80-L85
130,358
luci/luci-go
common/tsmon/store/inmemory.go
Get
func (s *inMemoryStore) Get(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []interface{}) interface{} { if resetTime.IsZero() { resetTime = clock.Now(ctx) } m := s.getOrCreateData(h) m.lock.Lock() defer m.lock.Unlock() return m.get(fieldVals, target.Get(ctx), resetTime).Value }
go
func (s *inMemoryStore) Get(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []interface{}) interface{} { if resetTime.IsZero() { resetTime = clock.Now(ctx) } m := s.getOrCreateData(h) m.lock.Lock() defer m.lock.Unlock() return m.get(fieldVals, target.Get(ctx), resetTime).Value }
[ "func", "(", "s", "*", "inMemoryStore", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "h", "types", ".", "Metric", ",", "resetTime", "time", ".", "Time", ",", "fieldVals", "[", "]", "interface", "{", "}", ")", "interface", "{", "}", "{", ...
// Get returns the value for a given metric cell.
[ "Get", "returns", "the", "value", "for", "a", "given", "metric", "cell", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/store/inmemory.go#L127-L137
130,359
luci/luci-go
common/tsmon/store/inmemory.go
Set
func (s *inMemoryStore) Set(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []interface{}, value interface{}) { if resetTime.IsZero() { resetTime = clock.Now(ctx) } t := target.Get(ctx) m := s.getOrCreateData(h) m.lock.Lock() defer m.lock.Unlock() c := m.get(fieldVals, t, resetTime) if ...
go
func (s *inMemoryStore) Set(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []interface{}, value interface{}) { if resetTime.IsZero() { resetTime = clock.Now(ctx) } t := target.Get(ctx) m := s.getOrCreateData(h) m.lock.Lock() defer m.lock.Unlock() c := m.get(fieldVals, t, resetTime) if ...
[ "func", "(", "s", "*", "inMemoryStore", ")", "Set", "(", "ctx", "context", ".", "Context", ",", "h", "types", ".", "Metric", ",", "resetTime", "time", ".", "Time", ",", "fieldVals", "[", "]", "interface", "{", "}", ",", "value", "interface", "{", "}"...
// Set writes the value into the given metric cell.
[ "Set", "writes", "the", "value", "into", "the", "given", "metric", "cell", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/store/inmemory.go#L153-L173
130,360
luci/luci-go
common/tsmon/store/inmemory.go
Incr
func (s *inMemoryStore) Incr(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []interface{}, delta interface{}) { if resetTime.IsZero() { resetTime = clock.Now(ctx) } t := target.Get(ctx) m := s.getOrCreateData(h) m.lock.Lock() defer m.lock.Unlock() c := m.get(fieldVals, t, resetTime) sw...
go
func (s *inMemoryStore) Incr(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []interface{}, delta interface{}) { if resetTime.IsZero() { resetTime = clock.Now(ctx) } t := target.Get(ctx) m := s.getOrCreateData(h) m.lock.Lock() defer m.lock.Unlock() c := m.get(fieldVals, t, resetTime) sw...
[ "func", "(", "s", "*", "inMemoryStore", ")", "Incr", "(", "ctx", "context", ".", "Context", ",", "h", "types", ".", "Metric", ",", "resetTime", "time", ".", "Time", ",", "fieldVals", "[", "]", "interface", "{", "}", ",", "delta", "interface", "{", "}...
// Incr increments the value in a given metric cell by the given delta.
[ "Incr", "increments", "the", "value", "in", "a", "given", "metric", "cell", "by", "the", "given", "delta", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/store/inmemory.go#L176-L218
130,361
luci/luci-go
common/tsmon/store/inmemory.go
GetAll
func (s *inMemoryStore) GetAll(ctx context.Context) []types.Cell { s.dataLock.Lock() defer s.dataLock.Unlock() defaultTarget := s.DefaultTarget() ret := []types.Cell{} for _, m := range s.data { m.lock.Lock() for _, cells := range m.cells { for _, cell := range cells { // Add the default target to the...
go
func (s *inMemoryStore) GetAll(ctx context.Context) []types.Cell { s.dataLock.Lock() defer s.dataLock.Unlock() defaultTarget := s.DefaultTarget() ret := []types.Cell{} for _, m := range s.data { m.lock.Lock() for _, cells := range m.cells { for _, cell := range cells { // Add the default target to the...
[ "func", "(", "s", "*", "inMemoryStore", ")", "GetAll", "(", "ctx", "context", ".", "Context", ")", "[", "]", "types", ".", "Cell", "{", "s", ".", "dataLock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "dataLock", ".", "Unlock", "(", ")", "\n...
// GetAll efficiently returns all cells in the store.
[ "GetAll", "efficiently", "returns", "all", "cells", "in", "the", "store", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/store/inmemory.go#L221-L243
130,362
luci/luci-go
client/cmd/isolate/batch_archive.go
batchArchive
func batchArchive(ctx context.Context, client *isolatedclient.Client, al archiveLogger, dumpJSONPath string, concurrentChecks, concurrentUploads int, genJSONPaths []string, blacklistStrings []string) error { // Set up a checker and uploader. We limit the uploader to one concurrent // upload, since the uploads are all...
go
func batchArchive(ctx context.Context, client *isolatedclient.Client, al archiveLogger, dumpJSONPath string, concurrentChecks, concurrentUploads int, genJSONPaths []string, blacklistStrings []string) error { // Set up a checker and uploader. We limit the uploader to one concurrent // upload, since the uploads are all...
[ "func", "batchArchive", "(", "ctx", "context", ".", "Context", ",", "client", "*", "isolatedclient", ".", "Client", ",", "al", "archiveLogger", ",", "dumpJSONPath", "string", ",", "concurrentChecks", ",", "concurrentUploads", "int", ",", "genJSONPaths", "[", "]"...
// batchArchive archives a series of isolates specified by genJSONPaths.
[ "batchArchive", "archives", "a", "series", "of", "isolates", "specified", "by", "genJSONPaths", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/isolate/batch_archive.go#L166-L220
130,363
luci/luci-go
client/cmd/isolate/batch_archive.go
digests
func digests(summaries []archiver.IsolatedSummary) []string { var result []string for _, summary := range summaries { result = append(result, string(summary.Digest)) } return result }
go
func digests(summaries []archiver.IsolatedSummary) []string { var result []string for _, summary := range summaries { result = append(result, string(summary.Digest)) } return result }
[ "func", "digests", "(", "summaries", "[", "]", "archiver", ".", "IsolatedSummary", ")", "[", "]", "string", "{", "var", "result", "[", "]", "string", "\n", "for", "_", ",", "summary", ":=", "range", "summaries", "{", "result", "=", "append", "(", "resu...
// digests extracts the digests from the supplied IsolatedSummarys.
[ "digests", "extracts", "the", "digests", "from", "the", "supplied", "IsolatedSummarys", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/isolate/batch_archive.go#L223-L229
130,364
luci/luci-go
client/cmd/isolate/batch_archive.go
processGenJSON
func processGenJSON(genJSONPath string) (*isolate.ArchiveOptions, error) { f, err := os.Open(genJSONPath) if err != nil { return nil, fmt.Errorf("opening %s: %s", genJSONPath, err) } defer f.Close() opts, err := processGenJSONData(f) if err != nil { return nil, fmt.Errorf("processing %s: %s", genJSONPath, er...
go
func processGenJSON(genJSONPath string) (*isolate.ArchiveOptions, error) { f, err := os.Open(genJSONPath) if err != nil { return nil, fmt.Errorf("opening %s: %s", genJSONPath, err) } defer f.Close() opts, err := processGenJSONData(f) if err != nil { return nil, fmt.Errorf("processing %s: %s", genJSONPath, er...
[ "func", "processGenJSON", "(", "genJSONPath", "string", ")", "(", "*", "isolate", ".", "ArchiveOptions", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "genJSONPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// processGenJSON validates a genJSON file and returns the contents.
[ "processGenJSON", "validates", "a", "genJSON", "file", "and", "returns", "the", "contents", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/isolate/batch_archive.go#L232-L244
130,365
luci/luci-go
client/cmd/isolate/batch_archive.go
processGenJSONData
func processGenJSONData(r io.Reader) (*isolate.ArchiveOptions, error) { data := &struct { Args []string Dir string Version int }{} if err := json.NewDecoder(r).Decode(data); err != nil { return nil, fmt.Errorf("failed to decode: %s", err) } if data.Version != isolate.IsolatedGenJSONVersion { retu...
go
func processGenJSONData(r io.Reader) (*isolate.ArchiveOptions, error) { data := &struct { Args []string Dir string Version int }{} if err := json.NewDecoder(r).Decode(data); err != nil { return nil, fmt.Errorf("failed to decode: %s", err) } if data.Version != isolate.IsolatedGenJSONVersion { retu...
[ "func", "processGenJSONData", "(", "r", "io", ".", "Reader", ")", "(", "*", "isolate", ".", "ArchiveOptions", ",", "error", ")", "{", "data", ":=", "&", "struct", "{", "Args", "[", "]", "string", "\n", "Dir", "string", "\n", "Version", "int", "\n", "...
// processGenJSONData performs the function of processGenJSON, but operates on an io.Reader.
[ "processGenJSONData", "performs", "the", "function", "of", "processGenJSON", "but", "operates", "on", "an", "io", ".", "Reader", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/isolate/batch_archive.go#L247-L270
130,366
luci/luci-go
client/cmd/isolate/batch_archive.go
writeFile
func writeFile(filePath string, data []byte) error { f, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return fmt.Errorf("opening %s: %s", filePath, err) } // NOTE: We don't defer f.Close here, because it may return an error. _, writeErr := f.Write(data) closeErr := f.Clos...
go
func writeFile(filePath string, data []byte) error { f, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return fmt.Errorf("opening %s: %s", filePath, err) } // NOTE: We don't defer f.Close here, because it may return an error. _, writeErr := f.Write(data) closeErr := f.Clos...
[ "func", "writeFile", "(", "filePath", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "OpenFile", "(", "filePath", ",", "os", ".", "O_RDWR", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_TRUNC", ",", ...
// writeFile writes data to filePath. File permission is set to user only.
[ "writeFile", "writes", "data", "to", "filePath", ".", "File", "permission", "is", "set", "to", "user", "only", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/isolate/batch_archive.go#L291-L306
130,367
luci/luci-go
milo/common/model/build_summary.go
GetBuildName
func (bs *BuildSummary) GetBuildName() string { if bs == nil { return "" } li := strings.LastIndex(bs.BuildID, "/") if li == -1 { return "" } // Don't include the "/", therefore li+1. return bs.BuildID[li+1:] }
go
func (bs *BuildSummary) GetBuildName() string { if bs == nil { return "" } li := strings.LastIndex(bs.BuildID, "/") if li == -1 { return "" } // Don't include the "/", therefore li+1. return bs.BuildID[li+1:] }
[ "func", "(", "bs", "*", "BuildSummary", ")", "GetBuildName", "(", ")", "string", "{", "if", "bs", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "li", ":=", "strings", ".", "LastIndex", "(", "bs", ".", "BuildID", ",", "\"", "\"", ")", "...
// GetBuildName returns an abridged version of the BuildID meant for human // consumption. Currently, this is always the last token of the BuildID.
[ "GetBuildName", "returns", "an", "abridged", "version", "of", "the", "BuildID", "meant", "for", "human", "consumption", ".", "Currently", "this", "is", "always", "the", "last", "token", "of", "the", "BuildID", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/model/build_summary.go#L164-L174
130,368
luci/luci-go
milo/common/model/build_summary.go
AddManifestKey
func (bs *BuildSummary) AddManifestKey(project, console, manifest, repoURL string, revision []byte) { bs.ManifestKeys = append(bs.ManifestKeys, NewPartialManifestKey(project, console, manifest, repoURL).AddRevision(revision)) }
go
func (bs *BuildSummary) AddManifestKey(project, console, manifest, repoURL string, revision []byte) { bs.ManifestKeys = append(bs.ManifestKeys, NewPartialManifestKey(project, console, manifest, repoURL).AddRevision(revision)) }
[ "func", "(", "bs", "*", "BuildSummary", ")", "AddManifestKey", "(", "project", ",", "console", ",", "manifest", ",", "repoURL", "string", ",", "revision", "[", "]", "byte", ")", "{", "bs", ".", "ManifestKeys", "=", "append", "(", "bs", ".", "ManifestKeys...
// AddManifestKey adds a new entry to ManifestKey. // // `revision` should be the hex-decoded git revision. // // It's up to the caller to ensure that entries in ManifestKey aren't // duplicated.
[ "AddManifestKey", "adds", "a", "new", "entry", "to", "ManifestKey", ".", "revision", "should", "be", "the", "hex", "-", "decoded", "git", "revision", ".", "It", "s", "up", "to", "the", "caller", "to", "ensure", "that", "entries", "in", "ManifestKey", "aren...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/model/build_summary.go#L207-L210
130,369
luci/luci-go
milo/common/model/build_summary.go
NewPartialManifestKey
func NewPartialManifestKey(project, console, manifest, repoURL string) PartialManifestKey { var buf bytes.Buffer cmpbin.WriteUint(&buf, currentManifestKeyVersion) // version cmpbin.WriteString(&buf, project) cmpbin.WriteString(&buf, console) cmpbin.WriteString(&buf, manifest) cmpbin.WriteString(&buf, repoURL) re...
go
func NewPartialManifestKey(project, console, manifest, repoURL string) PartialManifestKey { var buf bytes.Buffer cmpbin.WriteUint(&buf, currentManifestKeyVersion) // version cmpbin.WriteString(&buf, project) cmpbin.WriteString(&buf, console) cmpbin.WriteString(&buf, manifest) cmpbin.WriteString(&buf, repoURL) re...
[ "func", "NewPartialManifestKey", "(", "project", ",", "console", ",", "manifest", ",", "repoURL", "string", ")", "PartialManifestKey", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "cmpbin", ".", "WriteUint", "(", "&", "buf", ",", "currentManifestKeyVersion",...
// NewPartialManifestKey generates a ManifestKey prefix corresponding to // the given parameters.
[ "NewPartialManifestKey", "generates", "a", "ManifestKey", "prefix", "corresponding", "to", "the", "given", "parameters", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/model/build_summary.go#L227-L235
130,370
luci/luci-go
milo/common/model/build_summary.go
AddManifestKeysFromBuildSets
func (bs *BuildSummary) AddManifestKeysFromBuildSets(c context.Context) error { if bs.BuilderID == "" { return errors.New("BuilderID is empty") } for _, bsetRaw := range bs.BuildSet { commit, ok := protoutil.ParseBuildSet(bsetRaw).(*buildbucketpb.GitilesCommit) if !ok { continue } revision, err := hex...
go
func (bs *BuildSummary) AddManifestKeysFromBuildSets(c context.Context) error { if bs.BuilderID == "" { return errors.New("BuilderID is empty") } for _, bsetRaw := range bs.BuildSet { commit, ok := protoutil.ParseBuildSet(bsetRaw).(*buildbucketpb.GitilesCommit) if !ok { continue } revision, err := hex...
[ "func", "(", "bs", "*", "BuildSummary", ")", "AddManifestKeysFromBuildSets", "(", "c", "context", ".", "Context", ")", "error", "{", "if", "bs", ".", "BuilderID", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// AddManifestKeysFromBuildSets potentially adds one or more ManifestKey's to // the BuildSummary for any defined BuildSets. // // This assumes that bs.BuilderID and bs.BuildSet have already been populated. // If BuilderID is not populated, this will return an error.
[ "AddManifestKeysFromBuildSets", "potentially", "adds", "one", "or", "more", "ManifestKey", "s", "to", "the", "BuildSummary", "for", "any", "defined", "BuildSets", ".", "This", "assumes", "that", "bs", ".", "BuilderID", "and", "bs", ".", "BuildSet", "have", "alre...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/model/build_summary.go#L242-L279
130,371
luci/luci-go
milo/common/model/build_summary.go
GitilesCommit
func (bs *BuildSummary) GitilesCommit() *buildbucketpb.GitilesCommit { for _, bset := range bs.BuildSet { if gc, ok := protoutil.ParseBuildSet(bset).(*buildbucketpb.GitilesCommit); ok { return gc } } return nil }
go
func (bs *BuildSummary) GitilesCommit() *buildbucketpb.GitilesCommit { for _, bset := range bs.BuildSet { if gc, ok := protoutil.ParseBuildSet(bset).(*buildbucketpb.GitilesCommit); ok { return gc } } return nil }
[ "func", "(", "bs", "*", "BuildSummary", ")", "GitilesCommit", "(", ")", "*", "buildbucketpb", ".", "GitilesCommit", "{", "for", "_", ",", "bset", ":=", "range", "bs", ".", "BuildSet", "{", "if", "gc", ",", "ok", ":=", "protoutil", ".", "ParseBuildSet", ...
// GitilesCommit extracts the first BuildSet which is a valid GitilesCommit. // // If no such BuildSet is found, this returns nil.
[ "GitilesCommit", "extracts", "the", "first", "BuildSet", "which", "is", "a", "valid", "GitilesCommit", ".", "If", "no", "such", "BuildSet", "is", "found", "this", "returns", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/model/build_summary.go#L284-L291
130,372
luci/luci-go
milo/common/model/build_summary.go
filterBuilds
func filterBuilds(builds []*BuildSummary, without ...Status) []*BuildSummary { filtered := builds[:0] outer: for _, build := range builds { for _, status := range without { if status == build.Summary.Status { continue outer } } filtered = append(filtered, build) } return filtered }
go
func filterBuilds(builds []*BuildSummary, without ...Status) []*BuildSummary { filtered := builds[:0] outer: for _, build := range builds { for _, status := range without { if status == build.Summary.Status { continue outer } } filtered = append(filtered, build) } return filtered }
[ "func", "filterBuilds", "(", "builds", "[", "]", "*", "BuildSummary", ",", "without", "...", "Status", ")", "[", "]", "*", "BuildSummary", "{", "filtered", ":=", "builds", "[", ":", "0", "]", "\n", "outer", ":", "for", "_", ",", "build", ":=", "range...
// filterBuilds returns a truncated slice, filtering out builds with the given // statuses.
[ "filterBuilds", "returns", "a", "truncated", "slice", "filtering", "out", "builds", "with", "the", "given", "statuses", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/model/build_summary.go#L403-L415
130,373
luci/luci-go
logdog/client/butler/streamserver/base.go
Close
func (s *listenerStreamServer) Close() { if s.l == nil { panic("server is not currently serving") } // Mark that we've been closed. atomic.StoreInt32(&s.closed, 1) // Close our Listener. This will cause our 'Accept' goroutine to terminate. s.l.Close() close(s.closedC) <-s.acceptFinishedC // Close our stre...
go
func (s *listenerStreamServer) Close() { if s.l == nil { panic("server is not currently serving") } // Mark that we've been closed. atomic.StoreInt32(&s.closed, 1) // Close our Listener. This will cause our 'Accept' goroutine to terminate. s.l.Close() close(s.closedC) <-s.acceptFinishedC // Close our stre...
[ "func", "(", "s", "*", "listenerStreamServer", ")", "Close", "(", ")", "{", "if", "s", ".", "l", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Mark that we've been closed.", "atomic", ".", "StoreInt32", "(", "&", "s", ".", "...
// Implements StreamServer.Close
[ "Implements", "StreamServer", ".", "Close" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/streamserver/base.go#L110-L127
130,374
luci/luci-go
logdog/client/butler/streamserver/base.go
handle
func (c *streamClient) handle() (*streamParams, error) { log.Infof(c, "Received new connection.") // Close the connection as a failsafe. If we have already decoupled it, this // will end up being a no-op. defer c.closeConn() // Perform our handshake. We pass the connection explicitly into this method // because...
go
func (c *streamClient) handle() (*streamParams, error) { log.Infof(c, "Received new connection.") // Close the connection as a failsafe. If we have already decoupled it, this // will end up being a no-op. defer c.closeConn() // Perform our handshake. We pass the connection explicitly into this method // because...
[ "func", "(", "c", "*", "streamClient", ")", "handle", "(", ")", "(", "*", "streamParams", ",", "error", ")", "{", "log", ".", "Infof", "(", "c", ",", "\"", "\"", ")", "\n\n", "// Close the connection as a failsafe. If we have already decoupled it, this", "// wil...
// handle initializes the supplied connection. On success, it will prepare // the connection as a Butler stream and pass its parameters through the // supplied channel. // // On failure, the connection will be closed. // // This method returns the negotiated stream parameters, or nil if the // negotitation failed and t...
[ "handle", "initializes", "the", "supplied", "connection", ".", "On", "success", "it", "will", "prepare", "the", "connection", "as", "a", "Butler", "stream", "and", "pass", "its", "parameters", "through", "the", "supplied", "channel", ".", "On", "failure", "the...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/streamserver/base.go#L232-L248
130,375
luci/luci-go
logdog/client/butler/streamserver/base.go
handshake
func handshake(ctx context.Context, conn net.Conn) (*streamproto.Properties, error) { log.Infof(ctx, "Beginning handshake.") hs := handshakeProtocol{} return hs.Handshake(ctx, conn) }
go
func handshake(ctx context.Context, conn net.Conn) (*streamproto.Properties, error) { log.Infof(ctx, "Beginning handshake.") hs := handshakeProtocol{} return hs.Handshake(ctx, conn) }
[ "func", "handshake", "(", "ctx", "context", ".", "Context", ",", "conn", "net", ".", "Conn", ")", "(", "*", "streamproto", ".", "Properties", ",", "error", ")", "{", "log", ".", "Infof", "(", "ctx", ",", "\"", "\"", ")", "\n", "hs", ":=", "handshak...
// handshake handles the handshaking and registration of a single connection. If // the connection successfully handshakes, it will be registered as a stream and // supplied to the local streamParamsC; otherwise, it will be closed. // // The client connection opens with a handshake protocol. Once complete, the // conne...
[ "handshake", "handles", "the", "handshaking", "and", "registration", "of", "a", "single", "connection", ".", "If", "the", "connection", "successfully", "handshakes", "it", "will", "be", "registered", "as", "a", "stream", "and", "supplied", "to", "the", "local", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/streamserver/base.go#L256-L260
130,376
luci/luci-go
logdog/client/butler/streamserver/base.go
closeConn
func (c *streamClient) closeConn() { conn := c.decoupleConn() if conn != nil { if err := conn.Close(); err != nil { log.Fields{ log.ErrorKey: err, }.Warningf(c, "Error on connection close.") } } }
go
func (c *streamClient) closeConn() { conn := c.decoupleConn() if conn != nil { if err := conn.Close(); err != nil { log.Fields{ log.ErrorKey: err, }.Warningf(c, "Error on connection close.") } } }
[ "func", "(", "c", "*", "streamClient", ")", "closeConn", "(", ")", "{", "conn", ":=", "c", ".", "decoupleConn", "(", ")", "\n", "if", "conn", "!=", "nil", "{", "if", "err", ":=", "conn", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "lo...
// Closes the underlying connection.
[ "Closes", "the", "underlying", "connection", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/streamserver/base.go#L263-L272
130,377
luci/luci-go
logdog/client/butler/streamserver/base.go
decoupleConn
func (c *streamClient) decoupleConn() (conn net.Conn) { c.decoupleMu.Lock() defer c.decoupleMu.Unlock() conn, c.conn = c.conn, nil return }
go
func (c *streamClient) decoupleConn() (conn net.Conn) { c.decoupleMu.Lock() defer c.decoupleMu.Unlock() conn, c.conn = c.conn, nil return }
[ "func", "(", "c", "*", "streamClient", ")", "decoupleConn", "(", ")", "(", "conn", "net", ".", "Conn", ")", "{", "c", ".", "decoupleMu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "decoupleMu", ".", "Unlock", "(", ")", "\n\n", "conn", ",", "...
// Decouples the active connection, returning it and setting the connection to // nil.
[ "Decouples", "the", "active", "connection", "returning", "it", "and", "setting", "the", "connection", "to", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/streamserver/base.go#L276-L282
130,378
luci/luci-go
appengine/gaemiddleware/flex/env.go
WithGlobal
func WithGlobal(c context.Context) context.Context { return ReadOnlyFlex.With(c, &http.Request{}) }
go
func WithGlobal(c context.Context) context.Context { return ReadOnlyFlex.With(c, &http.Request{}) }
[ "func", "WithGlobal", "(", "c", "context", ".", "Context", ")", "context", ".", "Context", "{", "return", "ReadOnlyFlex", ".", "With", "(", "c", ",", "&", "http", ".", "Request", "{", "}", ")", "\n", "}" ]
// WithGlobal returns a Context that is not attached to a specific request.
[ "WithGlobal", "returns", "a", "Context", "that", "is", "not", "attached", "to", "a", "specific", "request", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaemiddleware/flex/env.go#L165-L167
130,379
luci/luci-go
tokenserver/appengine/impl/delegation/rpc_import_delegation_configs.go
ImportDelegationConfigs
func (r *ImportDelegationConfigsRPC) ImportDelegationConfigs(c context.Context, _ *empty.Empty) (*admin.ImportedConfigs, error) { rev, err := r.RulesCache.ImportConfigs(c) if err != nil { logging.WithError(err).Errorf(c, "Failed to fetch delegation configs") return nil, status.Errorf(codes.Internal, err.Error()) ...
go
func (r *ImportDelegationConfigsRPC) ImportDelegationConfigs(c context.Context, _ *empty.Empty) (*admin.ImportedConfigs, error) { rev, err := r.RulesCache.ImportConfigs(c) if err != nil { logging.WithError(err).Errorf(c, "Failed to fetch delegation configs") return nil, status.Errorf(codes.Internal, err.Error()) ...
[ "func", "(", "r", "*", "ImportDelegationConfigsRPC", ")", "ImportDelegationConfigs", "(", "c", "context", ".", "Context", ",", "_", "*", "empty", ".", "Empty", ")", "(", "*", "admin", ".", "ImportedConfigs", ",", "error", ")", "{", "rev", ",", "err", ":=...
// ImportDelegationConfigs fetches configs from from luci-config right now.
[ "ImportDelegationConfigs", "fetches", "configs", "from", "from", "luci", "-", "config", "right", "now", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/delegation/rpc_import_delegation_configs.go#L36-L43
130,380
luci/luci-go
machine-db/client/cli/ips.go
printIPs
func printIPs(tsv bool, ips ...*crimson.IP) { if len(ips) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("IPv4", "VLAN", "Hostname") } for _, ip := range ips { p.Row(ip.Ipv4, ip.Vlan, ip.Hostname) } } }
go
func printIPs(tsv bool, ips ...*crimson.IP) { if len(ips) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("IPv4", "VLAN", "Hostname") } for _, ip := range ips { p.Row(ip.Ipv4, ip.Vlan, ip.Hostname) } } }
[ "func", "printIPs", "(", "tsv", "bool", ",", "ips", "...", "*", "crimson", ".", "IP", ")", "{", "if", "len", "(", "ips", ")", ">", "0", "{", "p", ":=", "newStdoutPrinter", "(", "tsv", ")", "\n", "defer", "p", ".", "Flush", "(", ")", "\n", "if",...
// printIPs prints IP address data to stdout in tab-separated columns.
[ "printIPs", "prints", "IP", "address", "data", "to", "stdout", "in", "tab", "-", "separated", "columns", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/ips.go#L28-L39
130,381
luci/luci-go
machine-db/client/cli/ips.go
Run
func (c *GetIPsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListFreeIPs(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printIPs(c.f.tsv, resp.Ips...) return 0 }
go
func (c *GetIPsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListFreeIPs(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printIPs(c.f.tsv, resp.Ips...) return 0 }
[ "func", "(", "c", "*", "GetIPsCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "c", ","...
// Run runs the command to get free IP addresses.
[ "Run", "runs", "the", "command", "to", "get", "free", "IP", "addresses", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/ips.go#L48-L58
130,382
luci/luci-go
machine-db/client/cli/ips.go
getIPsCmd
func getIPsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-ips -vlan <id> [-n <limit>]", ShortDesc: "retrieves free IPs", LongDesc: "Retrieves free IP addresses on the given VLAN.\n\nExample to get 20 free IPs in VLAN 001:\ncrimson get-ips -vlan 001 -n 20", CommandR...
go
func getIPsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-ips -vlan <id> [-n <limit>]", ShortDesc: "retrieves free IPs", LongDesc: "Retrieves free IP addresses on the given VLAN.\n\nExample to get 20 free IPs in VLAN 001:\ncrimson get-ips -vlan 001 -n 20", CommandR...
[ "func", "getIPsCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", "\\n", ...
// getIPsCmd returns a command to get free IP addresses.
[ "getIPsCmd", "returns", "a", "command", "to", "get", "free", "IP", "addresses", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/ips.go#L61-L74
130,383
luci/luci-go
logdog/client/annotee/processor.go
New
func New(c context.Context, o Options) *Processor { p := Processor{ ctx: c, o: &o, stepHandlers: make(map[*annotation.Step]*stepHandler), } p.astate = &annotation.State{ LogNameBase: o.Base, Callbacks: &annotationCallbacks{&p}, Execution: o.Execution, Clock: clock.Get(c), Offline: o....
go
func New(c context.Context, o Options) *Processor { p := Processor{ ctx: c, o: &o, stepHandlers: make(map[*annotation.Step]*stepHandler), } p.astate = &annotation.State{ LogNameBase: o.Base, Callbacks: &annotationCallbacks{&p}, Execution: o.Execution, Clock: clock.Get(c), Offline: o....
[ "func", "New", "(", "c", "context", ".", "Context", ",", "o", "Options", ")", "*", "Processor", "{", "p", ":=", "Processor", "{", "ctx", ":", "c", ",", "o", ":", "&", "o", ",", "stepHandlers", ":", "make", "(", "map", "[", "*", "annotation", ".",...
// New instantiates a new Processor.
[ "New", "instantiates", "a", "new", "Processor", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/processor.go#L169-L184
130,384
luci/luci-go
logdog/client/annotee/processor.go
initialize
func (p *Processor) initialize() (err error) { // If we're already initialized, do nothing. if p.annotationStream != nil { return nil } annotationPath := p.o.AnnotationSubpath if annotationPath == "" { annotationPath = DefaultAnnotationSubpath } annotationPath = p.astate.RootStep().BaseStream(annotationPath...
go
func (p *Processor) initialize() (err error) { // If we're already initialized, do nothing. if p.annotationStream != nil { return nil } annotationPath := p.o.AnnotationSubpath if annotationPath == "" { annotationPath = DefaultAnnotationSubpath } annotationPath = p.astate.RootStep().BaseStream(annotationPath...
[ "func", "(", "p", "*", "Processor", ")", "initialize", "(", ")", "(", "err", "error", ")", "{", "// If we're already initialized, do nothing.", "if", "p", ".", "annotationStream", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "annotationPath", ":=", ...
// initialize initializes p's annotation stream handling system. If it is called // more than once, it is a no-op.
[ "initialize", "initializes", "p", "s", "annotation", "stream", "handling", "system", ".", "If", "it", "is", "called", "more", "than", "once", "it", "is", "a", "no", "-", "op", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/processor.go#L188-L214
130,385
luci/luci-go
logdog/client/annotee/processor.go
RunStreams
func (p *Processor) RunStreams(streams []*Stream) error { ingestMu := sync.Mutex{} ingest := func(s *Stream, l string) error { ingestMu.Lock() defer ingestMu.Unlock() return p.IngestLine(s, l) } // Read from all configured streams until they are finished. return parallel.FanOutIn(func(taskC chan<- func() e...
go
func (p *Processor) RunStreams(streams []*Stream) error { ingestMu := sync.Mutex{} ingest := func(s *Stream, l string) error { ingestMu.Lock() defer ingestMu.Unlock() return p.IngestLine(s, l) } // Read from all configured streams until they are finished. return parallel.FanOutIn(func(taskC chan<- func() e...
[ "func", "(", "p", "*", "Processor", ")", "RunStreams", "(", "streams", "[", "]", "*", "Stream", ")", "error", "{", "ingestMu", ":=", "sync", ".", "Mutex", "{", "}", "\n", "ingest", ":=", "func", "(", "s", "*", "Stream", ",", "l", "string", ")", "...
// RunStreams executes the Processor, consuming data from its configured streams // and forwarding it to LogDog. Run will block until all streams have // terminated. // // If a stream terminates with an error, or if there is an error processing the // stream data, Run will return an error. If multiple Streams fail with...
[ "RunStreams", "executes", "the", "Processor", "consuming", "data", "from", "its", "configured", "streams", "and", "forwarding", "it", "to", "LogDog", ".", "Run", "will", "block", "until", "all", "streams", "have", "terminated", ".", "If", "a", "stream", "termi...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/processor.go#L223-L261
130,386
luci/luci-go
logdog/client/annotee/processor.go
Finish
func (p *Processor) Finish() *annotation.State { // Finish our step handlers. var closeTime *timestamp.Timestamp if !p.astate.Offline { // Note: p.astate.Clock is never nil here, see astate setup in New(). closeTime = google.NewTimestamp(p.astate.Clock.Now()) } for _, h := range p.stepHandlers { p.finishStep...
go
func (p *Processor) Finish() *annotation.State { // Finish our step handlers. var closeTime *timestamp.Timestamp if !p.astate.Offline { // Note: p.astate.Clock is never nil here, see astate setup in New(). closeTime = google.NewTimestamp(p.astate.Clock.Now()) } for _, h := range p.stepHandlers { p.finishStep...
[ "func", "(", "p", "*", "Processor", ")", "Finish", "(", ")", "*", "annotation", ".", "State", "{", "// Finish our step handlers.", "var", "closeTime", "*", "timestamp", ".", "Timestamp", "\n", "if", "!", "p", ".", "astate", ".", "Offline", "{", "// Note: p...
// Finish instructs the Processor to close any outstanding state. This should be // called when all automatic state updates have completed in case any steps // didn't properly close their state. // // Finish will return the closed annotation state that was accumulated during // processing.
[ "Finish", "instructs", "the", "Processor", "to", "close", "any", "outstanding", "state", ".", "This", "should", "be", "called", "when", "all", "automatic", "state", "updates", "have", "completed", "in", "case", "any", "steps", "didn", "t", "properly", "close",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/processor.go#L425-L450
130,387
luci/luci-go
tokenserver/appengine/impl/delegation/token.go
SignToken
func SignToken(c context.Context, signer signing.Signer, subtok *messages.Subtoken) (string, error) { s := tokensigning.Signer{ Signer: signer, SigningContext: tokenSigningContext, Wrap: func(w *tokensigning.Unwrapped) proto.Message { return &messages.DelegationToken{ SerializedSubtoken: w.Body, ...
go
func SignToken(c context.Context, signer signing.Signer, subtok *messages.Subtoken) (string, error) { s := tokensigning.Signer{ Signer: signer, SigningContext: tokenSigningContext, Wrap: func(w *tokensigning.Unwrapped) proto.Message { return &messages.DelegationToken{ SerializedSubtoken: w.Body, ...
[ "func", "SignToken", "(", "c", "context", ".", "Context", ",", "signer", "signing", ".", "Signer", ",", "subtok", "*", "messages", ".", "Subtoken", ")", "(", "string", ",", "error", ")", "{", "s", ":=", "tokensigning", ".", "Signer", "{", "Signer", ":"...
// SignToken signs and serializes the delegation subtoken. // // It doesn't do any validation. Assumes the prepared subtoken is valid. // // Produces base64 URL-safe token or a transient error.
[ "SignToken", "signs", "and", "serializes", "the", "delegation", "subtoken", ".", "It", "doesn", "t", "do", "any", "validation", ".", "Assumes", "the", "prepared", "subtoken", "is", "valid", ".", "Produces", "base64", "URL", "-", "safe", "token", "or", "a", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/delegation/token.go#L43-L57
130,388
luci/luci-go
dm/appengine/distributor/pubsub.go
PubsubReceiver
func PubsubReceiver(ctx *router.Context) { c, rw, r := ctx.Context, ctx.Writer, ctx.Request defer r.Body.Close() type PubsubMessage struct { Attributes map[string]string `json:"attributes"` Data []byte `json:"data"` MessageID string `json:"message_id"` } type PubsubPushMessage s...
go
func PubsubReceiver(ctx *router.Context) { c, rw, r := ctx.Context, ctx.Writer, ctx.Request defer r.Body.Close() type PubsubMessage struct { Attributes map[string]string `json:"attributes"` Data []byte `json:"data"` MessageID string `json:"message_id"` } type PubsubPushMessage s...
[ "func", "PubsubReceiver", "(", "ctx", "*", "router", ".", "Context", ")", "{", "c", ",", "rw", ",", "r", ":=", "ctx", ".", "Context", ",", "ctx", ".", "Writer", ",", "ctx", ".", "Request", "\n", "defer", "r", ".", "Body", ".", "Close", "(", ")", ...
// PubsubReceiver is the HTTP handler that processes incoming pubsub events // delivered to topics prepared with TaskDescription.PrepareTopic, and routes // them to the appropriate distributor implementation's HandleNotification // method. // // It requires that a Registry be installed in c via WithRegistry.
[ "PubsubReceiver", "is", "the", "HTTP", "handler", "that", "processes", "incoming", "pubsub", "events", "delivered", "to", "topics", "prepared", "with", "TaskDescription", ".", "PrepareTopic", "and", "routes", "them", "to", "the", "appropriate", "distributor", "imple...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/pubsub.go#L40-L84
130,389
luci/luci-go
config/validation/handler.go
InstallHandlers
func InstallHandlers(r *router.Router, base router.MiddlewareChain, rules *RuleSet) { r.GET(metadataPath, base, metadataRequestHandler(rules)) r.POST(validationPath, base, validationRequestHandler(rules)) }
go
func InstallHandlers(r *router.Router, base router.MiddlewareChain, rules *RuleSet) { r.GET(metadataPath, base, metadataRequestHandler(rules)) r.POST(validationPath, base, validationRequestHandler(rules)) }
[ "func", "InstallHandlers", "(", "r", "*", "router", ".", "Router", ",", "base", "router", ".", "MiddlewareChain", ",", "rules", "*", "RuleSet", ")", "{", "r", ".", "GET", "(", "metadataPath", ",", "base", ",", "metadataRequestHandler", "(", "rules", ")", ...
// InstallHandlers installs the metadata and validation handlers that use // the given validation rules. // // It does not implement any authentication checks, thus the passed in // router.MiddlewareChain should implement any necessary authentication checks.
[ "InstallHandlers", "installs", "the", "metadata", "and", "validation", "handlers", "that", "use", "the", "given", "validation", "rules", ".", "It", "does", "not", "implement", "any", "authentication", "checks", "thus", "the", "passed", "in", "router", ".", "Midd...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/handler.go#L44-L47
130,390
luci/luci-go
config/validation/handler.go
validationRequestHandler
func validationRequestHandler(rules *RuleSet) router.Handler { return func(ctx *router.Context) { c, w, r := ctx.Context, ctx.Writer, ctx.Request var reqBody config.ValidationRequestMessage switch err := json.NewDecoder(r.Body).Decode(&reqBody); { case err != nil: badRequestStatus(c, w, "Validation: error ...
go
func validationRequestHandler(rules *RuleSet) router.Handler { return func(ctx *router.Context) { c, w, r := ctx.Context, ctx.Writer, ctx.Request var reqBody config.ValidationRequestMessage switch err := json.NewDecoder(r.Body).Decode(&reqBody); { case err != nil: badRequestStatus(c, w, "Validation: error ...
[ "func", "validationRequestHandler", "(", "rules", "*", "RuleSet", ")", "router", ".", "Handler", "{", "return", "func", "(", "ctx", "*", "router", ".", "Context", ")", "{", "c", ",", "w", ",", "r", ":=", "ctx", ".", "Context", ",", "ctx", ".", "Write...
// validationRequestHandler handles the validation request from luci-config and // responds with the corresponding results.
[ "validationRequestHandler", "handles", "the", "validation", "request", "from", "luci", "-", "config", "and", "responds", "with", "the", "corresponding", "results", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/handler.go#L67-L113
130,391
luci/luci-go
config/validation/handler.go
metadataRequestHandler
func metadataRequestHandler(rules *RuleSet) router.Handler { return func(ctx *router.Context) { c, w := ctx.Context, ctx.Writer patterns, err := rules.ConfigPatterns(c) if err != nil { internalErrStatus(c, w, "Metadata: failed to collect the list of validation patterns", err) return } meta := config....
go
func metadataRequestHandler(rules *RuleSet) router.Handler { return func(ctx *router.Context) { c, w := ctx.Context, ctx.Writer patterns, err := rules.ConfigPatterns(c) if err != nil { internalErrStatus(c, w, "Metadata: failed to collect the list of validation patterns", err) return } meta := config....
[ "func", "metadataRequestHandler", "(", "rules", "*", "RuleSet", ")", "router", ".", "Handler", "{", "return", "func", "(", "ctx", "*", "router", ".", "Context", ")", "{", "c", ",", "w", ":=", "ctx", ".", "Context", ",", "ctx", ".", "Writer", "\n\n", ...
// metadataRequestHandler handles the metadata request from luci-config and // responds with the necessary metadata defined by the given Validator.
[ "metadataRequestHandler", "handles", "the", "metadata", "request", "from", "luci", "-", "config", "and", "responds", "with", "the", "necessary", "metadata", "defined", "by", "the", "given", "Validator", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/handler.go#L117-L145
130,392
luci/luci-go
cipd/appengine/ui/metadata.go
fetchMetadata
func fetchMetadata(c context.Context, pfx string) (*metadataBlock, error) { meta, err := impl.PublicRepo.GetInheritedPrefixMetadata(c, &api.PrefixRequest{ Prefix: pfx, }) switch grpc.Code(err) { case codes.OK: break // handled below case codes.PermissionDenied: return fetchCallerRoles(c, pfx) default: ret...
go
func fetchMetadata(c context.Context, pfx string) (*metadataBlock, error) { meta, err := impl.PublicRepo.GetInheritedPrefixMetadata(c, &api.PrefixRequest{ Prefix: pfx, }) switch grpc.Code(err) { case codes.OK: break // handled below case codes.PermissionDenied: return fetchCallerRoles(c, pfx) default: ret...
[ "func", "fetchMetadata", "(", "c", "context", ".", "Context", ",", "pfx", "string", ")", "(", "*", "metadataBlock", ",", "error", ")", "{", "meta", ",", "err", ":=", "impl", ".", "PublicRepo", ".", "GetInheritedPrefixMetadata", "(", "c", ",", "&", "api",...
// fetchMetadata fetches and formats for UI metadata of the given prefix. // // It recognizes PermissionDenied errors and falls back to only displaying what // roles the caller has instead of the full metadata.
[ "fetchMetadata", "fetches", "and", "formats", "for", "UI", "metadata", "of", "the", "given", "prefix", ".", "It", "recognizes", "PermissionDenied", "errors", "and", "falls", "back", "to", "only", "displaying", "what", "roles", "the", "caller", "has", "instead", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/ui/metadata.go#L61-L128
130,393
luci/luci-go
scheduler/appengine/task/utils/apiclient.go
IsTransientAPIError
func IsTransientAPIError(err error) bool { if err == nil { return false } apiErr, _ := err.(*googleapi.Error) if apiErr == nil { return true // failed to get HTTP code => connectivity error => transient } return apiErr.Code >= 500 || apiErr.Code == 429 || apiErr.Code == 0 }
go
func IsTransientAPIError(err error) bool { if err == nil { return false } apiErr, _ := err.(*googleapi.Error) if apiErr == nil { return true // failed to get HTTP code => connectivity error => transient } return apiErr.Code >= 500 || apiErr.Code == 429 || apiErr.Code == 0 }
[ "func", "IsTransientAPIError", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "apiErr", ",", "_", ":=", "err", ".", "(", "*", "googleapi", ".", "Error", ")", "\n", "if", "apiErr", "==", "ni...
// IsTransientAPIError returns true if error from Google API client indicates // an error that can go away on its own in the future.
[ "IsTransientAPIError", "returns", "true", "if", "error", "from", "Google", "API", "client", "indicates", "an", "error", "that", "can", "go", "away", "on", "its", "own", "in", "the", "future", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/utils/apiclient.go#L24-L33
130,394
luci/luci-go
scheduler/appengine/task/utils/apiclient.go
WrapAPIError
func WrapAPIError(err error) error { if IsTransientAPIError(err) { return transient.Tag.Apply(err) } return err }
go
func WrapAPIError(err error) error { if IsTransientAPIError(err) { return transient.Tag.Apply(err) } return err }
[ "func", "WrapAPIError", "(", "err", "error", ")", "error", "{", "if", "IsTransientAPIError", "(", "err", ")", "{", "return", "transient", ".", "Tag", ".", "Apply", "(", "err", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// WrapAPIError wraps error from Google API client in transient wrapper if // necessary.
[ "WrapAPIError", "wraps", "error", "from", "Google", "API", "client", "in", "transient", "wrapper", "if", "necessary", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/utils/apiclient.go#L37-L42
130,395
luci/luci-go
logdog/client/annotee/annotation/annotation.go
initialize
func (s *State) initialize() { if s.stepMap != nil { return } s.stepMap = map[string]*Step{} s.stepLookup = map[*milo.Step]*Step{} name := "steps" if s.Execution != nil { name = s.Execution.Name } s.rootStep.initializeStep(s, nil, name, false) s.rootStep.LogNameBase = s.LogNameBase s.SetCurrentStep(nil)...
go
func (s *State) initialize() { if s.stepMap != nil { return } s.stepMap = map[string]*Step{} s.stepLookup = map[*milo.Step]*Step{} name := "steps" if s.Execution != nil { name = s.Execution.Name } s.rootStep.initializeStep(s, nil, name, false) s.rootStep.LogNameBase = s.LogNameBase s.SetCurrentStep(nil)...
[ "func", "(", "s", "*", "State", ")", "initialize", "(", ")", "{", "if", "s", ".", "stepMap", "!=", "nil", "{", "return", "\n", "}", "\n\n", "s", ".", "stepMap", "=", "map", "[", "string", "]", "*", "Step", "{", "}", "\n", "s", ".", "stepLookup"...
// initialize sets of the State's initial state. It will execute exactly once, // and must be called by any State methods that access internal variables.
[ "initialize", "sets", "of", "the", "State", "s", "initial", "state", ".", "It", "will", "execute", "exactly", "once", "and", "must", "be", "called", "by", "any", "State", "methods", "that", "access", "internal", "variables", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/annotation/annotation.go#L105-L135
130,396
luci/luci-go
logdog/client/annotee/annotation/annotation.go
LookupStepErr
func (s *State) LookupStepErr(name string) (*Step, error) { if as := s.LookupStep(name); as != nil { return as, nil } return nil, fmt.Errorf("no step named %q", name) }
go
func (s *State) LookupStepErr(name string) (*Step, error) { if as := s.LookupStep(name); as != nil { return as, nil } return nil, fmt.Errorf("no step named %q", name) }
[ "func", "(", "s", "*", "State", ")", "LookupStepErr", "(", "name", "string", ")", "(", "*", "Step", ",", "error", ")", "{", "if", "as", ":=", "s", ".", "LookupStep", "(", "name", ")", ";", "as", "!=", "nil", "{", "return", "as", ",", "nil", "\n...
// LookupStepErr returns the step with the supplied name, or an error if no // such step exists. // // If multiple steps share a name, this will return the latest registered step // with that name.
[ "LookupStepErr", "returns", "the", "step", "with", "the", "supplied", "name", "or", "an", "error", "if", "no", "such", "step", "exists", ".", "If", "multiple", "steps", "share", "a", "name", "this", "will", "return", "the", "latest", "registered", "step", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/annotation/annotation.go#L484-L489
130,397
luci/luci-go
logdog/client/annotee/annotation/annotation.go
SetCurrentStep
func (s *State) SetCurrentStep(v *Step) { if v == nil { v = &s.rootStep } if v.s != s { panic("step is not bound to state") } s.stepCursor = v }
go
func (s *State) SetCurrentStep(v *Step) { if v == nil { v = &s.rootStep } if v.s != s { panic("step is not bound to state") } s.stepCursor = v }
[ "func", "(", "s", "*", "State", ")", "SetCurrentStep", "(", "v", "*", "Step", ")", "{", "if", "v", "==", "nil", "{", "v", "=", "&", "s", ".", "rootStep", "\n", "}", "\n", "if", "v", ".", "s", "!=", "s", "{", "panic", "(", "\"", "\"", ")", ...
// SetCurrentStep sets the current step. If the supplied step is nil, the root // step will be used. // // The supplied step must already be registered with the State.
[ "SetCurrentStep", "sets", "the", "current", "step", ".", "If", "the", "supplied", "step", "is", "nil", "the", "root", "step", "will", "be", "used", ".", "The", "supplied", "step", "must", "already", "be", "registered", "with", "the", "State", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/annotation/annotation.go#L516-L524
130,398
luci/luci-go
logdog/client/annotee/annotation/annotation.go
now
func (s *State) now() *timestamp.Timestamp { c := s.Clock if c == nil { c = clock.GetSystemClock() } return google.NewTimestamp(c.Now()) }
go
func (s *State) now() *timestamp.Timestamp { c := s.Clock if c == nil { c = clock.GetSystemClock() } return google.NewTimestamp(c.Now()) }
[ "func", "(", "s", "*", "State", ")", "now", "(", ")", "*", "timestamp", ".", "Timestamp", "{", "c", ":=", "s", ".", "Clock", "\n", "if", "c", "==", "nil", "{", "c", "=", "clock", ".", "GetSystemClock", "(", ")", "\n", "}", "\n", "return", "goog...
// now returns current time of s.Clock. Defaults to system clock.
[ "now", "returns", "current", "time", "of", "s", ".", "Clock", ".", "Defaults", "to", "system", "clock", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/annotation/annotation.go#L549-L555
130,399
luci/luci-go
logdog/client/annotee/annotation/annotation.go
AddStep
func (as *Step) AddStep(name string, legacy bool) *Step { return (&Step{}).initializeStep(as.s, as, name, legacy) }
go
func (as *Step) AddStep(name string, legacy bool) *Step { return (&Step{}).initializeStep(as.s, as, name, legacy) }
[ "func", "(", "as", "*", "Step", ")", "AddStep", "(", "name", "string", ",", "legacy", "bool", ")", "*", "Step", "{", "return", "(", "&", "Step", "{", "}", ")", ".", "initializeStep", "(", "as", ".", "s", ",", "as", ",", "name", ",", "legacy", "...
// AddStep generates a new substep.
[ "AddStep", "generates", "a", "new", "substep", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/annotation/annotation.go#L693-L695