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