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,100 | luci/luci-go | config/validation/validation.go | Errorf | func (v *Context) Errorf(format string, args ...interface{}) {
v.Error(errors.Reason(format, args...).Err())
} | go | func (v *Context) Errorf(format string, args ...interface{}) {
v.Error(errors.Reason(format, args...).Err())
} | [
"func",
"(",
"v",
"*",
"Context",
")",
"Errorf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"v",
".",
"Error",
"(",
"errors",
".",
"Reason",
"(",
"format",
",",
"args",
"...",
")",
".",
"Err",
"(",
")",
")",
"... | // Errorf records the given format string and args as a validation error. | [
"Errorf",
"records",
"the",
"given",
"format",
"string",
"and",
"args",
"as",
"a",
"validation",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/validation.go#L87-L89 |
129,101 | luci/luci-go | config/validation/validation.go | Error | func (v *Context) Error(err error) {
ctx := ""
if v.file != "" {
ctx = fmt.Sprintf("in %q", v.file)
} else {
ctx = "in <unspecified file>"
}
if len(v.element) != 0 {
ctx += " (" + strings.Join(v.element, " / ") + ")"
}
// Make the file and the logical path also usable through error inspection.
err = error... | go | func (v *Context) Error(err error) {
ctx := ""
if v.file != "" {
ctx = fmt.Sprintf("in %q", v.file)
} else {
ctx = "in <unspecified file>"
}
if len(v.element) != 0 {
ctx += " (" + strings.Join(v.element, " / ") + ")"
}
// Make the file and the logical path also usable through error inspection.
err = error... | [
"func",
"(",
"v",
"*",
"Context",
")",
"Error",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"\"",
"\"",
"\n",
"if",
"v",
".",
"file",
"!=",
"\"",
"\"",
"{",
"ctx",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"file",
")",
"\n... | // Error records the given error as a validation error. | [
"Error",
"records",
"the",
"given",
"error",
"as",
"a",
"validation",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/validation.go#L92-L105 |
129,102 | luci/luci-go | config/validation/validation.go | Enter | func (v *Context) Enter(title string, args ...interface{}) {
e := fmt.Sprintf(title, args...)
v.element = append(v.element, e)
} | go | func (v *Context) Enter(title string, args ...interface{}) {
e := fmt.Sprintf(title, args...)
v.element = append(v.element, e)
} | [
"func",
"(",
"v",
"*",
"Context",
")",
"Enter",
"(",
"title",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"e",
":=",
"fmt",
".",
"Sprintf",
"(",
"title",
",",
"args",
"...",
")",
"\n",
"v",
".",
"element",
"=",
"append",
"(",
... | // Enter descends into a sub-element when validating a nested structure.
//
// Useful for defining context. A current path of elements shows up in
// validation messages.
//
// The reverse is Exit. | [
"Enter",
"descends",
"into",
"a",
"sub",
"-",
"element",
"when",
"validating",
"a",
"nested",
"structure",
".",
"Useful",
"for",
"defining",
"context",
".",
"A",
"current",
"path",
"of",
"elements",
"shows",
"up",
"in",
"validation",
"messages",
".",
"The",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/validation.go#L123-L126 |
129,103 | luci/luci-go | config/validation/validation.go | Exit | func (v *Context) Exit() {
if len(v.element) != 0 {
v.element = v.element[:len(v.element)-1]
}
} | go | func (v *Context) Exit() {
if len(v.element) != 0 {
v.element = v.element[:len(v.element)-1]
}
} | [
"func",
"(",
"v",
"*",
"Context",
")",
"Exit",
"(",
")",
"{",
"if",
"len",
"(",
"v",
".",
"element",
")",
"!=",
"0",
"{",
"v",
".",
"element",
"=",
"v",
".",
"element",
"[",
":",
"len",
"(",
"v",
".",
"element",
")",
"-",
"1",
"]",
"\n",
... | // Exit pops the current element we are visiting from the stack.
//
// This is the reverse of Enter. Each Enter must have corresponding Exit. Use
// functions and defers to ensure this, if it's otherwise hard to track. | [
"Exit",
"pops",
"the",
"current",
"element",
"we",
"are",
"visiting",
"from",
"the",
"stack",
".",
"This",
"is",
"the",
"reverse",
"of",
"Enter",
".",
"Each",
"Enter",
"must",
"have",
"corresponding",
"Exit",
".",
"Use",
"functions",
"and",
"defers",
"to",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/validation/validation.go#L132-L136 |
129,104 | luci/luci-go | gce/api/config/v1/timeofday.go | toTime | func (t *TimeOfDay) toTime() (time.Time, error) {
now := time.Time{}
loc, err := time.LoadLocation(t.GetLocation())
if err != nil {
return now, errors.Reason("invalid location").Err()
}
now = now.In(loc)
// Decompose the time into a slice of [time, <hour>, <minute>].
m := regexp.MustCompile(timeRegex).FindStri... | go | func (t *TimeOfDay) toTime() (time.Time, error) {
now := time.Time{}
loc, err := time.LoadLocation(t.GetLocation())
if err != nil {
return now, errors.Reason("invalid location").Err()
}
now = now.In(loc)
// Decompose the time into a slice of [time, <hour>, <minute>].
m := regexp.MustCompile(timeRegex).FindStri... | [
"func",
"(",
"t",
"*",
"TimeOfDay",
")",
"toTime",
"(",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"now",
":=",
"time",
".",
"Time",
"{",
"}",
"\n",
"loc",
",",
"err",
":=",
"time",
".",
"LoadLocation",
"(",
"t",
".",
"GetLocation",
... | // toTime returns the time.Time representation of the time referenced by this
// time of day. | [
"toTime",
"returns",
"the",
"time",
".",
"Time",
"representation",
"of",
"the",
"time",
"referenced",
"by",
"this",
"time",
"of",
"day",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/timeofday.go#L33-L54 |
129,105 | luci/luci-go | gce/api/config/v1/timeofday.go | Validate | func (t *TimeOfDay) Validate(c *validation.Context) {
if t.GetDay() == dayofweek.DayOfWeek_DAY_OF_WEEK_UNSPECIFIED {
c.Errorf("day must be specified")
}
_, err := t.toTime()
if err != nil {
c.Errorf("%s", err)
}
} | go | func (t *TimeOfDay) Validate(c *validation.Context) {
if t.GetDay() == dayofweek.DayOfWeek_DAY_OF_WEEK_UNSPECIFIED {
c.Errorf("day must be specified")
}
_, err := t.toTime()
if err != nil {
c.Errorf("%s", err)
}
} | [
"func",
"(",
"t",
"*",
"TimeOfDay",
")",
"Validate",
"(",
"c",
"*",
"validation",
".",
"Context",
")",
"{",
"if",
"t",
".",
"GetDay",
"(",
")",
"==",
"dayofweek",
".",
"DayOfWeek_DAY_OF_WEEK_UNSPECIFIED",
"{",
"c",
".",
"Errorf",
"(",
"\"",
"\"",
")",
... | // Validate validates this time of day. | [
"Validate",
"validates",
"this",
"time",
"of",
"day",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/timeofday.go#L57-L65 |
129,106 | luci/luci-go | vpython/spec/load.go | Load | func Load(path string, spec *vpython.Spec) error {
content, err := ioutil.ReadFile(path)
if err != nil {
return errors.Annotate(err, "failed to load file from: %s", path).Err()
}
return Parse(string(content), spec)
} | go | func Load(path string, spec *vpython.Spec) error {
content, err := ioutil.ReadFile(path)
if err != nil {
return errors.Annotate(err, "failed to load file from: %s", path).Err()
}
return Parse(string(content), spec)
} | [
"func",
"Load",
"(",
"path",
"string",
",",
"spec",
"*",
"vpython",
".",
"Spec",
")",
"error",
"{",
"content",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Annotate",
... | // Load loads an specification file text protobuf from the supplied path. | [
"Load",
"loads",
"an",
"specification",
"file",
"text",
"protobuf",
"from",
"the",
"supplied",
"path",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/spec/load.go#L56-L63 |
129,107 | luci/luci-go | vpython/spec/load.go | Parse | func Parse(content string, spec *vpython.Spec) error {
if err := cproto.UnmarshalTextML(content, spec); err != nil {
return errors.Annotate(err, "failed to unmarshal vpython.Spec").Err()
}
return nil
} | go | func Parse(content string, spec *vpython.Spec) error {
if err := cproto.UnmarshalTextML(content, spec); err != nil {
return errors.Annotate(err, "failed to unmarshal vpython.Spec").Err()
}
return nil
} | [
"func",
"Parse",
"(",
"content",
"string",
",",
"spec",
"*",
"vpython",
".",
"Spec",
")",
"error",
"{",
"if",
"err",
":=",
"cproto",
".",
"UnmarshalTextML",
"(",
"content",
",",
"spec",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Ann... | // Parse loads a specification message from a content string. | [
"Parse",
"loads",
"a",
"specification",
"message",
"from",
"a",
"content",
"string",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/spec/load.go#L66-L71 |
129,108 | luci/luci-go | buildbucket/protoutil/common.go | IsEnded | func IsEnded(s pb.Status) bool {
return s&pb.Status_ENDED_MASK == pb.Status_ENDED_MASK
} | go | func IsEnded(s pb.Status) bool {
return s&pb.Status_ENDED_MASK == pb.Status_ENDED_MASK
} | [
"func",
"IsEnded",
"(",
"s",
"pb",
".",
"Status",
")",
"bool",
"{",
"return",
"s",
"&",
"pb",
".",
"Status_ENDED_MASK",
"==",
"pb",
".",
"Status_ENDED_MASK",
"\n",
"}"
] | // IsEnded returns true if s is final. | [
"IsEnded",
"returns",
"true",
"if",
"s",
"is",
"final",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/protoutil/common.go#L22-L24 |
129,109 | luci/luci-go | auth/integration/internal/localsrv/localsrv.go | serve | func (s *Server) serve(cb ServeFunc) error {
s.l.Lock()
if s.listener == nil {
s.l.Unlock()
return errors.New("already closed")
}
listener := s.listener // accessed outside the lock
ctx := s.ctx
s.l.Unlock()
err := cb(ctx, listener, &s.wg) // blocks until killServe() is called
s.wg.Wait() ... | go | func (s *Server) serve(cb ServeFunc) error {
s.l.Lock()
if s.listener == nil {
s.l.Unlock()
return errors.New("already closed")
}
listener := s.listener // accessed outside the lock
ctx := s.ctx
s.l.Unlock()
err := cb(ctx, listener, &s.wg) // blocks until killServe() is called
s.wg.Wait() ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"serve",
"(",
"cb",
"ServeFunc",
")",
"error",
"{",
"s",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"if",
"s",
".",
"listener",
"==",
"nil",
"{",
"s",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"return",
"error... | // serve runs the serving loop.
//
// It unblocks once killServe is called and all pending requests are served.
//
// Returns nil if serving was stopped by killServe or non-nil if it failed for
// some other reason. | [
"serve",
"runs",
"the",
"serving",
"loop",
".",
"It",
"unblocks",
"once",
"killServe",
"is",
"called",
"and",
"all",
"pending",
"requests",
"are",
"served",
".",
"Returns",
"nil",
"if",
"serving",
"was",
"stopped",
"by",
"killServe",
"or",
"non",
"-",
"nil... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/integration/internal/localsrv/localsrv.go#L123-L148 |
129,110 | luci/luci-go | appengine/tsmon/housekeeping.go | InstallHandlers | func InstallHandlers(r *router.Router, base router.MiddlewareChain) {
r.GET(
"/internal/cron/ts_mon/housekeeping",
base.Extend(gaemiddleware.RequireCron),
housekeepingHandler)
} | go | func InstallHandlers(r *router.Router, base router.MiddlewareChain) {
r.GET(
"/internal/cron/ts_mon/housekeeping",
base.Extend(gaemiddleware.RequireCron),
housekeepingHandler)
} | [
"func",
"InstallHandlers",
"(",
"r",
"*",
"router",
".",
"Router",
",",
"base",
"router",
".",
"MiddlewareChain",
")",
"{",
"r",
".",
"GET",
"(",
"\"",
"\"",
",",
"base",
".",
"Extend",
"(",
"gaemiddleware",
".",
"RequireCron",
")",
",",
"housekeepingHan... | // InstallHandlers installs HTTP handlers for tsmon routes. | [
"InstallHandlers",
"installs",
"HTTP",
"handlers",
"for",
"tsmon",
"routes",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/tsmon/housekeeping.go#L27-L32 |
129,111 | luci/luci-go | appengine/tsmon/housekeeping.go | housekeepingHandler | func housekeepingHandler(c *router.Context) {
tsmon.GetState(c.Context).RunGlobalCallbacks(c.Context)
if err := AssignTaskNumbers(c.Context); err != nil {
logging.WithError(err).Errorf(c.Context, "Task number assigner failed")
c.Writer.WriteHeader(http.StatusInternalServerError)
}
} | go | func housekeepingHandler(c *router.Context) {
tsmon.GetState(c.Context).RunGlobalCallbacks(c.Context)
if err := AssignTaskNumbers(c.Context); err != nil {
logging.WithError(err).Errorf(c.Context, "Task number assigner failed")
c.Writer.WriteHeader(http.StatusInternalServerError)
}
} | [
"func",
"housekeepingHandler",
"(",
"c",
"*",
"router",
".",
"Context",
")",
"{",
"tsmon",
".",
"GetState",
"(",
"c",
".",
"Context",
")",
".",
"RunGlobalCallbacks",
"(",
"c",
".",
"Context",
")",
"\n",
"if",
"err",
":=",
"AssignTaskNumbers",
"(",
"c",
... | // housekeepingHandler performs task number assignments and runs global metric
// callbacks.
//
// See DatastoreTaskNumAllocator and AssignTaskNumbers. | [
"housekeepingHandler",
"performs",
"task",
"number",
"assignments",
"and",
"runs",
"global",
"metric",
"callbacks",
".",
"See",
"DatastoreTaskNumAllocator",
"and",
"AssignTaskNumbers",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/tsmon/housekeeping.go#L38-L44 |
129,112 | luci/luci-go | mp/cmd/snapshot/create.go | validateFlags | func (cmd *createSnapshotCmd) validateFlags(c context.Context) (map[string]string, error) {
if cmd.disk == "" {
return nil, errors.New("-disk is required")
}
labels := make(map[string]string, len(cmd.labels))
for _, label := range cmd.labels {
parts := strings.SplitN(label, ":", 2)
if len(parts) != 2 {
ret... | go | func (cmd *createSnapshotCmd) validateFlags(c context.Context) (map[string]string, error) {
if cmd.disk == "" {
return nil, errors.New("-disk is required")
}
labels := make(map[string]string, len(cmd.labels))
for _, label := range cmd.labels {
parts := strings.SplitN(label, ":", 2)
if len(parts) != 2 {
ret... | [
"func",
"(",
"cmd",
"*",
"createSnapshotCmd",
")",
"validateFlags",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"if",
"cmd",
".",
"disk",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"... | // validateFlags validates parsed command line flags and returns a map of parsed labels. | [
"validateFlags",
"validates",
"parsed",
"command",
"line",
"flags",
"and",
"returns",
"a",
"map",
"of",
"parsed",
"labels",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/create.go#L50-L75 |
129,113 | luci/luci-go | mp/cmd/snapshot/create.go | Run | func (cmd *createSnapshotCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
c := cli.GetContext(app, cmd, env)
labels, err := cmd.validateFlags(c)
if err != nil {
logging.Errorf(c, "%s", err.Error())
return 1
}
srv := getService(c)
logging.Infof(c, "Creating snapshot.")
snapshot... | go | func (cmd *createSnapshotCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
c := cli.GetContext(app, cmd, env)
labels, err := cmd.validateFlags(c)
if err != nil {
logging.Errorf(c, "%s", err.Error())
return 1
}
srv := getService(c)
logging.Infof(c, "Creating snapshot.")
snapshot... | [
"func",
"(",
"cmd",
"*",
"createSnapshotCmd",
")",
"Run",
"(",
"app",
"subcommands",
".",
"Application",
",",
"args",
"[",
"]",
"string",
",",
"env",
"subcommands",
".",
"Env",
")",
"int",
"{",
"c",
":=",
"cli",
".",
"GetContext",
"(",
"app",
",",
"c... | // Run runs the command to create a disk snapshot. | [
"Run",
"runs",
"the",
"command",
"to",
"create",
"a",
"disk",
"snapshot",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/create.go#L78-L115 |
129,114 | luci/luci-go | mp/cmd/snapshot/create.go | getCreateSnapshotCmd | func getCreateSnapshotCmd() *subcommands.Command {
return &subcommands.Command{
UsageLine: "create -disk <disk> -name <name> -project <project> -zone <zone> [-label <key>:<value>]...",
ShortDesc: "creates a snapshot",
LongDesc: "Creates a disk snapshot.",
CommandRun: func() subcommands.CommandRun {
cmd := ... | go | func getCreateSnapshotCmd() *subcommands.Command {
return &subcommands.Command{
UsageLine: "create -disk <disk> -name <name> -project <project> -zone <zone> [-label <key>:<value>]...",
ShortDesc: "creates a snapshot",
LongDesc: "Creates a disk snapshot.",
CommandRun: func() subcommands.CommandRun {
cmd := ... | [
"func",
"getCreateSnapshotCmd",
"(",
")",
"*",
"subcommands",
".",
"Command",
"{",
"return",
"&",
"subcommands",
".",
"Command",
"{",
"UsageLine",
":",
"\"",
"\"",
",",
"ShortDesc",
":",
"\"",
"\"",
",",
"LongDesc",
":",
"\"",
"\"",
",",
"CommandRun",
":... | // getCreateSnapshotCmd returns a new command to create a snapshot. | [
"getCreateSnapshotCmd",
"returns",
"a",
"new",
"command",
"to",
"create",
"a",
"snapshot",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/snapshot/create.go#L118-L134 |
129,115 | luci/luci-go | dm/appengine/mutate/finish_execution.go | shouldRetry | func shouldRetry(c context.Context, a *model.Attempt, stat dm.AbnormalFinish_Status) (retry bool, err error) {
if !stat.CouldRetry() {
return
}
q := model.QuestFromID(a.ID.Quest)
if err = ds.Get(ds.WithoutTransaction(c), q); err != nil {
return
}
var cur, max uint32
switch stat {
case dm.AbnormalFinish_FAI... | go | func shouldRetry(c context.Context, a *model.Attempt, stat dm.AbnormalFinish_Status) (retry bool, err error) {
if !stat.CouldRetry() {
return
}
q := model.QuestFromID(a.ID.Quest)
if err = ds.Get(ds.WithoutTransaction(c), q); err != nil {
return
}
var cur, max uint32
switch stat {
case dm.AbnormalFinish_FAI... | [
"func",
"shouldRetry",
"(",
"c",
"context",
".",
"Context",
",",
"a",
"*",
"model",
".",
"Attempt",
",",
"stat",
"dm",
".",
"AbnormalFinish_Status",
")",
"(",
"retry",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"!",
"stat",
".",
"CouldRetry",
"(",
... | // shouldRetry loads the quest for this attempt, to determine if the attempt can
// be retried. As a side-effect, it increments the RetryState counter for the
// indicated failure type.
//
// If stat is not a retryable AbnormalFinish_Status, this will panic. | [
"shouldRetry",
"loads",
"the",
"quest",
"for",
"this",
"attempt",
"to",
"determine",
"if",
"the",
"attempt",
"can",
"be",
"retried",
".",
"As",
"a",
"side",
"-",
"effect",
"it",
"increments",
"the",
"RetryState",
"counter",
"for",
"the",
"indicated",
"failur... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/mutate/finish_execution.go#L46-L74 |
129,116 | luci/luci-go | dm/appengine/mutate/finish_execution.go | FinishExecutionFn | func FinishExecutionFn(c context.Context, eid *dm.Execution_ID, rslt *dm.Result) ([]tumble.Mutation, error) {
if rslt.Data != nil {
if normErr := rslt.Data.Normalize(); normErr != nil {
logging.WithError(normErr).Errorf(c, "Could not normalize distributor Result!")
rslt = &dm.Result{
AbnormalFinish: &dm.Ab... | go | func FinishExecutionFn(c context.Context, eid *dm.Execution_ID, rslt *dm.Result) ([]tumble.Mutation, error) {
if rslt.Data != nil {
if normErr := rslt.Data.Normalize(); normErr != nil {
logging.WithError(normErr).Errorf(c, "Could not normalize distributor Result!")
rslt = &dm.Result{
AbnormalFinish: &dm.Ab... | [
"func",
"FinishExecutionFn",
"(",
"c",
"context",
".",
"Context",
",",
"eid",
"*",
"dm",
".",
"Execution_ID",
",",
"rslt",
"*",
"dm",
".",
"Result",
")",
"(",
"[",
"]",
"tumble",
".",
"Mutation",
",",
"error",
")",
"{",
"if",
"rslt",
".",
"Data",
"... | // FinishExecutionFn is the implementation of distributor.FinishExecutionFn.
// It's defined here to avoid a circular dependency. | [
"FinishExecutionFn",
"is",
"the",
"implementation",
"of",
"distributor",
".",
"FinishExecutionFn",
".",
"It",
"s",
"defined",
"here",
"to",
"avoid",
"a",
"circular",
"dependency",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/mutate/finish_execution.go#L156-L170 |
129,117 | luci/luci-go | dm/appengine/mutate/finish_execution.go | NewFinishExecutionAbnormal | func NewFinishExecutionAbnormal(eid *dm.Execution_ID, status dm.AbnormalFinish_Status, reason string) *FinishExecution {
return &FinishExecution{
eid, &dm.Result{
AbnormalFinish: &dm.AbnormalFinish{Status: status, Reason: reason}}}
} | go | func NewFinishExecutionAbnormal(eid *dm.Execution_ID, status dm.AbnormalFinish_Status, reason string) *FinishExecution {
return &FinishExecution{
eid, &dm.Result{
AbnormalFinish: &dm.AbnormalFinish{Status: status, Reason: reason}}}
} | [
"func",
"NewFinishExecutionAbnormal",
"(",
"eid",
"*",
"dm",
".",
"Execution_ID",
",",
"status",
"dm",
".",
"AbnormalFinish_Status",
",",
"reason",
"string",
")",
"*",
"FinishExecution",
"{",
"return",
"&",
"FinishExecution",
"{",
"eid",
",",
"&",
"dm",
".",
... | // NewFinishExecutionAbnormal is a shorthand to make a FinishExecution mutation
// with some abnomal result. | [
"NewFinishExecutionAbnormal",
"is",
"a",
"shorthand",
"to",
"make",
"a",
"FinishExecution",
"mutation",
"with",
"some",
"abnomal",
"result",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/mutate/finish_execution.go#L174-L178 |
129,118 | luci/luci-go | common/data/caching/lru/lru.go | New | func New(size int) *Cache {
c := Cache{
size: size,
}
c.Reset()
return &c
} | go | func New(size int) *Cache {
c := Cache{
size: size,
}
c.Reset()
return &c
} | [
"func",
"New",
"(",
"size",
"int",
")",
"*",
"Cache",
"{",
"c",
":=",
"Cache",
"{",
"size",
":",
"size",
",",
"}",
"\n",
"c",
".",
"Reset",
"(",
")",
"\n",
"return",
"&",
"c",
"\n",
"}"
] | // New creates a new, locking LRU cache with the specified size.
//
// If size is <= 0, the LRU cache will have infinite capacity, and will never
// prune elements. | [
"New",
"creates",
"a",
"new",
"locking",
"LRU",
"cache",
"with",
"the",
"specified",
"size",
".",
"If",
"size",
"is",
"<",
"=",
"0",
"the",
"LRU",
"cache",
"will",
"have",
"infinite",
"capacity",
"and",
"will",
"never",
"prune",
"elements",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L111-L117 |
129,119 | luci/luci-go | common/data/caching/lru/lru.go | Peek | func (c *Cache) Peek(ctx context.Context, key interface{}) (interface{}, bool) {
now := clock.Now(ctx)
c.lock.RLock()
defer c.lock.RUnlock()
if e := c.cache[key]; e != nil {
ent := e.Value.(*cacheEntry)
if !c.isEntryExpired(now, ent) {
return ent.v, true
}
}
return nil, false
} | go | func (c *Cache) Peek(ctx context.Context, key interface{}) (interface{}, bool) {
now := clock.Now(ctx)
c.lock.RLock()
defer c.lock.RUnlock()
if e := c.cache[key]; e != nil {
ent := e.Value.(*cacheEntry)
if !c.isEntryExpired(now, ent) {
return ent.v, true
}
}
return nil, false
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"Peek",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"now",
":=",
"clock",
".",
"Now",
"(",
"ctx",
")",
"\n\n",
"c",
".",
... | // Peek fetches the element associated with the supplied key without updating
// the element's recently-used standing.
//
// Peek uses the cache read lock. | [
"Peek",
"fetches",
"the",
"element",
"associated",
"with",
"the",
"supplied",
"key",
"without",
"updating",
"the",
"element",
"s",
"recently",
"-",
"used",
"standing",
".",
"Peek",
"uses",
"the",
"cache",
"read",
"lock",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L123-L136 |
129,120 | luci/luci-go | common/data/caching/lru/lru.go | GetOrCreate | func (c *Cache) GetOrCreate(ctx context.Context, key interface{}, fn Maker) (v interface{}, err error) {
// First, check if the value is the cache. We don't need to hold the item's
// Mutex for this.
var ok bool
if v, ok = c.Get(ctx, key); ok {
return v, nil
}
// The value is currently not cached, so we will g... | go | func (c *Cache) GetOrCreate(ctx context.Context, key interface{}, fn Maker) (v interface{}, err error) {
// First, check if the value is the cache. We don't need to hold the item's
// Mutex for this.
var ok bool
if v, ok = c.Get(ctx, key); ok {
return v, nil
}
// The value is currently not cached, so we will g... | [
"func",
"(",
"c",
"*",
"Cache",
")",
"GetOrCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"interface",
"{",
"}",
",",
"fn",
"Maker",
")",
"(",
"v",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"// First, check if the value is the ca... | // GetOrCreate retrieves the current value of key. If no value exists for key,
// GetOrCreate will lock around key and invoke the supplied Maker to generate
// a new value.
//
// If multiple concurrent operations invoke GetOrCreate at the same time, they
// will serialize, and at most one Maker will be invoked at a tim... | [
"GetOrCreate",
"retrieves",
"the",
"current",
"value",
"of",
"key",
".",
"If",
"no",
"value",
"exists",
"for",
"key",
"GetOrCreate",
"will",
"lock",
"around",
"key",
"and",
"invoke",
"the",
"supplied",
"Maker",
"to",
"generate",
"a",
"new",
"value",
".",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L299-L325 |
129,121 | luci/luci-go | common/data/caching/lru/lru.go | Create | func (c *Cache) Create(ctx context.Context, key interface{}, fn Maker) (v interface{}, err error) {
c.mp.WithMutex(key, func() {
// Generate a new value.
var exp time.Duration
if v, exp, err = fn(); err != nil {
// The Maker returned an error, so do not add the value to the cache.
return
}
// Add the ... | go | func (c *Cache) Create(ctx context.Context, key interface{}, fn Maker) (v interface{}, err error) {
c.mp.WithMutex(key, func() {
// Generate a new value.
var exp time.Duration
if v, exp, err = fn(); err != nil {
// The Maker returned an error, so do not add the value to the cache.
return
}
// Add the ... | [
"func",
"(",
"c",
"*",
"Cache",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"interface",
"{",
"}",
",",
"fn",
"Maker",
")",
"(",
"v",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"c",
".",
"mp",
".",
"WithMutex",
... | // Create write-locks around key and invokes the supplied Maker to generate a
// new value.
//
// If multiple concurrent operations invoke GetOrCreate or Create at the same
// time, they will serialize, and at most one Maker will be invoked at a time.
// If the Maker succeeds, it is more likely that the first operation... | [
"Create",
"write",
"-",
"locks",
"around",
"key",
"and",
"invokes",
"the",
"supplied",
"Maker",
"to",
"generate",
"a",
"new",
"value",
".",
"If",
"multiple",
"concurrent",
"operations",
"invoke",
"GetOrCreate",
"or",
"Create",
"at",
"the",
"same",
"time",
"t... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L344-L357 |
129,122 | luci/luci-go | common/data/caching/lru/lru.go | Prune | func (c *Cache) Prune(ctx context.Context) {
now := clock.Now(ctx)
c.lock.Lock()
defer c.lock.Unlock()
c.pruneExpiryLocked(now)
} | go | func (c *Cache) Prune(ctx context.Context) {
now := clock.Now(ctx)
c.lock.Lock()
defer c.lock.Unlock()
c.pruneExpiryLocked(now)
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"Prune",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"now",
":=",
"clock",
".",
"Now",
"(",
"ctx",
")",
"\n\n",
"c",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"lock",
".",
"Unlock",
... | // Prune iterates through entries in the Cache and prunes any which are
// expired. | [
"Prune",
"iterates",
"through",
"entries",
"in",
"the",
"Cache",
"and",
"prunes",
"any",
"which",
"are",
"expired",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L361-L368 |
129,123 | luci/luci-go | common/data/caching/lru/lru.go | snapshot | func (c *Cache) snapshot() (ss snapshot) {
c.lock.RLock()
defer c.lock.RUnlock()
if len(c.cache) > 0 {
ss = make(snapshot)
for k, e := range c.cache {
ss[k] = e.Value.(*cacheEntry).v
}
}
return
} | go | func (c *Cache) snapshot() (ss snapshot) {
c.lock.RLock()
defer c.lock.RUnlock()
if len(c.cache) > 0 {
ss = make(snapshot)
for k, e := range c.cache {
ss[k] = e.Value.(*cacheEntry).v
}
}
return
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"snapshot",
"(",
")",
"(",
"ss",
"snapshot",
")",
"{",
"c",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"len",
"(",
"c",
".",
"cache",
")",... | // snapshot returns a snapshot map of the cache's entries. | [
"snapshot",
"returns",
"a",
"snapshot",
"map",
"of",
"the",
"cache",
"s",
"entries",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L392-L403 |
129,124 | luci/luci-go | common/data/caching/lru/lru.go | pruneSizeLocked | func (c *Cache) pruneSizeLocked() {
// There is no size constraint.
if c.size <= 0 {
return
}
// Prune the oldest entries until we're within our size constraint.
for e := c.lru.Back(); e != nil; e = c.lru.Back() {
if len(c.cache) <= c.size {
return
}
c.evictEntryLocked(e)
}
} | go | func (c *Cache) pruneSizeLocked() {
// There is no size constraint.
if c.size <= 0 {
return
}
// Prune the oldest entries until we're within our size constraint.
for e := c.lru.Back(); e != nil; e = c.lru.Back() {
if len(c.cache) <= c.size {
return
}
c.evictEntryLocked(e)
}
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"pruneSizeLocked",
"(",
")",
"{",
"// There is no size constraint.",
"if",
"c",
".",
"size",
"<=",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"// Prune the oldest entries until we're within our size constraint.",
"for",
"e",
":=",
... | // pruneSizeLocked prunes LRU elements until its heuristic is satisfied. Its
// write lock must be held by the caller. | [
"pruneSizeLocked",
"prunes",
"LRU",
"elements",
"until",
"its",
"heuristic",
"is",
"satisfied",
".",
"Its",
"write",
"lock",
"must",
"be",
"held",
"by",
"the",
"caller",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L407-L420 |
129,125 | luci/luci-go | common/data/caching/lru/lru.go | isEntryExpired | func (c *Cache) isEntryExpired(now time.Time, ent *cacheEntry) bool {
return !(ent.expiry.IsZero() || now.Before(ent.expiry))
} | go | func (c *Cache) isEntryExpired(now time.Time, ent *cacheEntry) bool {
return !(ent.expiry.IsZero() || now.Before(ent.expiry))
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"isEntryExpired",
"(",
"now",
"time",
".",
"Time",
",",
"ent",
"*",
"cacheEntry",
")",
"bool",
"{",
"return",
"!",
"(",
"ent",
".",
"expiry",
".",
"IsZero",
"(",
")",
"||",
"now",
".",
"Before",
"(",
"ent",
".... | // isEntryExpired returns whether this entry is expired given the current time.
//
// An entry is expired if it has an expiration time, and the current time is >=
// the expiration time.
//
// Will return false if the entry has no expiration, or if the entry is not
// expired. | [
"isEntryExpired",
"returns",
"whether",
"this",
"entry",
"is",
"expired",
"given",
"the",
"current",
"time",
".",
"An",
"entry",
"is",
"expired",
"if",
"it",
"has",
"an",
"expiration",
"time",
"and",
"the",
"current",
"time",
"is",
">",
"=",
"the",
"expira... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/caching/lru/lru.go#L444-L446 |
129,126 | luci/luci-go | cipd/client/cipd/digests/client_digests_file.go | Contains | func (d *ClientDigestsFile) Contains(plat string, ref *api.ObjectRef) bool {
for _, e := range d.entries {
if e.plat == plat && proto.Equal(ref, e.ref) {
return true
}
}
return false
} | go | func (d *ClientDigestsFile) Contains(plat string, ref *api.ObjectRef) bool {
for _, e := range d.entries {
if e.plat == plat && proto.Equal(ref, e.ref) {
return true
}
}
return false
} | [
"func",
"(",
"d",
"*",
"ClientDigestsFile",
")",
"Contains",
"(",
"plat",
"string",
",",
"ref",
"*",
"api",
".",
"ObjectRef",
")",
"bool",
"{",
"for",
"_",
",",
"e",
":=",
"range",
"d",
".",
"entries",
"{",
"if",
"e",
".",
"plat",
"==",
"plat",
"... | // Contains returns true if the given ref is among refs for the given platform.
//
// Compares 'ref' to all hashes corresponding to 'plat', not only the best one. | [
"Contains",
"returns",
"true",
"if",
"the",
"given",
"ref",
"is",
"among",
"refs",
"for",
"the",
"given",
"platform",
".",
"Compares",
"ref",
"to",
"all",
"hashes",
"corresponding",
"to",
"plat",
"not",
"only",
"the",
"best",
"one",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/digests/client_digests_file.go#L105-L112 |
129,127 | luci/luci-go | cipd/client/cipd/digests/client_digests_file.go | Equal | func (d *ClientDigestsFile) Equal(a *ClientDigestsFile) bool {
if len(d.entries) != len(a.entries) {
return false
}
for i, l := range d.entries {
if r := a.entries[i]; l.plat != r.plat || !proto.Equal(l.ref, r.ref) {
return false
}
}
return true
} | go | func (d *ClientDigestsFile) Equal(a *ClientDigestsFile) bool {
if len(d.entries) != len(a.entries) {
return false
}
for i, l := range d.entries {
if r := a.entries[i]; l.plat != r.plat || !proto.Equal(l.ref, r.ref) {
return false
}
}
return true
} | [
"func",
"(",
"d",
"*",
"ClientDigestsFile",
")",
"Equal",
"(",
"a",
"*",
"ClientDigestsFile",
")",
"bool",
"{",
"if",
"len",
"(",
"d",
".",
"entries",
")",
"!=",
"len",
"(",
"a",
".",
"entries",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
... | // Equal returns true if files have same entries in same order. | [
"Equal",
"returns",
"true",
"if",
"files",
"have",
"same",
"entries",
"in",
"same",
"order",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/digests/client_digests_file.go#L126-L136 |
129,128 | luci/luci-go | cipd/client/cipd/digests/client_digests_file.go | Serialize | func (d *ClientDigestsFile) Serialize(w io.Writer, version, versionFile string) error {
_, err := iotools.WriteTracker(w, func(w io.Writer) error {
fmt.Fprintf(w, "# This file was generated by\n")
fmt.Fprintf(w, "#\n")
fmt.Fprintf(w, "# cipd selfupdate-roll -version-file %s \\\n", versionFile)
fmt.Fprintf(w, ... | go | func (d *ClientDigestsFile) Serialize(w io.Writer, version, versionFile string) error {
_, err := iotools.WriteTracker(w, func(w io.Writer) error {
fmt.Fprintf(w, "# This file was generated by\n")
fmt.Fprintf(w, "#\n")
fmt.Fprintf(w, "# cipd selfupdate-roll -version-file %s \\\n", versionFile)
fmt.Fprintf(w, ... | [
"func",
"(",
"d",
"*",
"ClientDigestsFile",
")",
"Serialize",
"(",
"w",
"io",
".",
"Writer",
",",
"version",
",",
"versionFile",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"iotools",
".",
"WriteTracker",
"(",
"w",
",",
"func",
"(",
"w",
"io"... | // Serialize writes the ClientDigestsFile to an io.Writer.
//
// 'version' and 'versionFile' are used to construct a meaningful comment
// footer. | [
"Serialize",
"writes",
"the",
"ClientDigestsFile",
"to",
"an",
"io",
".",
"Writer",
".",
"version",
"and",
"versionFile",
"are",
"used",
"to",
"construct",
"a",
"meaningful",
"comment",
"footer",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/digests/client_digests_file.go#L142-L175 |
129,129 | luci/luci-go | cipd/client/cipd/digests/client_digests_file.go | ParseClientDigestsFile | func ParseClientDigestsFile(r io.Reader) (*ClientDigestsFile, error) {
res := &ClientDigestsFile{}
lineNo := 0
makeError := func(fmtStr string, args ...interface{}) error {
args = append([]interface{}{lineNo}, args...)
return fmt.Errorf("failed to parse client digests file (line %d): "+fmtStr, args...)
}
sca... | go | func ParseClientDigestsFile(r io.Reader) (*ClientDigestsFile, error) {
res := &ClientDigestsFile{}
lineNo := 0
makeError := func(fmtStr string, args ...interface{}) error {
args = append([]interface{}{lineNo}, args...)
return fmt.Errorf("failed to parse client digests file (line %d): "+fmtStr, args...)
}
sca... | [
"func",
"ParseClientDigestsFile",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"ClientDigestsFile",
",",
"error",
")",
"{",
"res",
":=",
"&",
"ClientDigestsFile",
"{",
"}",
"\n\n",
"lineNo",
":=",
"0",
"\n",
"makeError",
":=",
"func",
"(",
"fmtStr",
"st... | // ParseClientDigestsFile parses previously serialized client digests file.
//
// Unrecognized algorithms are silently skipped, to be compatible with files
// generated by the future versions of CIPD that may use different algorithms. | [
"ParseClientDigestsFile",
"parses",
"previously",
"serialized",
"client",
"digests",
"file",
".",
"Unrecognized",
"algorithms",
"are",
"silently",
"skipped",
"to",
"be",
"compatible",
"with",
"files",
"generated",
"by",
"the",
"future",
"versions",
"of",
"CIPD",
"th... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/digests/client_digests_file.go#L181-L225 |
129,130 | luci/luci-go | cipd/client/cipd/delete_on_close.go | Close | func (d deleteOnClose) Close(ctx context.Context, corrupt bool) (err error) {
name := d.File.Name()
defer func() {
if rmErr := os.Remove(name); err == nil && rmErr != nil && !os.IsNotExist(rmErr) {
err = rmErr
}
}()
return d.File.Close()
} | go | func (d deleteOnClose) Close(ctx context.Context, corrupt bool) (err error) {
name := d.File.Name()
defer func() {
if rmErr := os.Remove(name); err == nil && rmErr != nil && !os.IsNotExist(rmErr) {
err = rmErr
}
}()
return d.File.Close()
} | [
"func",
"(",
"d",
"deleteOnClose",
")",
"Close",
"(",
"ctx",
"context",
".",
"Context",
",",
"corrupt",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"name",
":=",
"d",
".",
"File",
".",
"Name",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",... | // Close closes the underlying file and then deletes it. | [
"Close",
"closes",
"the",
"underlying",
"file",
"and",
"then",
"deletes",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/delete_on_close.go#L32-L40 |
129,131 | luci/luci-go | cipd/client/cipd/delete_on_close.go | underlyingFile | func underlyingFile(i pkg.Source) *os.File {
return i.(interface {
UnderlyingFile() *os.File
}).UnderlyingFile()
} | go | func underlyingFile(i pkg.Source) *os.File {
return i.(interface {
UnderlyingFile() *os.File
}).UnderlyingFile()
} | [
"func",
"underlyingFile",
"(",
"i",
"pkg",
".",
"Source",
")",
"*",
"os",
".",
"File",
"{",
"return",
"i",
".",
"(",
"interface",
"{",
"UnderlyingFile",
"(",
")",
"*",
"os",
".",
"File",
"\n",
"}",
")",
".",
"UnderlyingFile",
"(",
")",
"\n",
"}"
] | // underlyingFile is only used by tests. | [
"underlyingFile",
"is",
"only",
"used",
"by",
"tests",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/delete_on_close.go#L48-L52 |
129,132 | luci/luci-go | common/gcloud/gs/path.go | MakePath | func MakePath(bucket, filename string) Path {
var carr [2]string
comps := carr[:0]
if b := stripTrailingSlashes(bucket); b != "" {
comps = append(comps, "gs://"+b)
}
if filename != "" {
comps = append(comps, filename)
}
return Path(strings.Join(comps, "/"))
} | go | func MakePath(bucket, filename string) Path {
var carr [2]string
comps := carr[:0]
if b := stripTrailingSlashes(bucket); b != "" {
comps = append(comps, "gs://"+b)
}
if filename != "" {
comps = append(comps, filename)
}
return Path(strings.Join(comps, "/"))
} | [
"func",
"MakePath",
"(",
"bucket",
",",
"filename",
"string",
")",
"Path",
"{",
"var",
"carr",
"[",
"2",
"]",
"string",
"\n\n",
"comps",
":=",
"carr",
"[",
":",
"0",
"]",
"\n",
"if",
"b",
":=",
"stripTrailingSlashes",
"(",
"bucket",
")",
";",
"b",
... | // MakePath constructs a Google Storage path from optional bucket and filename
// components.
//
// Trailing forward slashes will be removed from the bucket name, if present. | [
"MakePath",
"constructs",
"a",
"Google",
"Storage",
"path",
"from",
"optional",
"bucket",
"and",
"filename",
"components",
".",
"Trailing",
"forward",
"slashes",
"will",
"be",
"removed",
"from",
"the",
"bucket",
"name",
"if",
"present",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/gs/path.go#L32-L43 |
129,133 | luci/luci-go | common/gcloud/gs/path.go | IsFullPath | func (p Path) IsFullPath() bool {
bucket, filename := p.Split()
return (bucket != "" && filename != "")
} | go | func (p Path) IsFullPath() bool {
bucket, filename := p.Split()
return (bucket != "" && filename != "")
} | [
"func",
"(",
"p",
"Path",
")",
"IsFullPath",
"(",
")",
"bool",
"{",
"bucket",
",",
"filename",
":=",
"p",
".",
"Split",
"(",
")",
"\n",
"return",
"(",
"bucket",
"!=",
"\"",
"\"",
"&&",
"filename",
"!=",
"\"",
"\"",
")",
"\n",
"}"
] | // IsFullPath returns true if the Path contains both a bucket and file name. | [
"IsFullPath",
"returns",
"true",
"if",
"the",
"Path",
"contains",
"both",
"a",
"bucket",
"and",
"file",
"name",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/gs/path.go#L85-L88 |
129,134 | luci/luci-go | common/proto/multiline.go | UnmarshalTextML | func UnmarshalTextML(s string, pb proto.Message) error {
s, err := ParseMultilineStrings(s)
if err != nil {
return err
}
return proto.UnmarshalText(s, pb)
} | go | func UnmarshalTextML(s string, pb proto.Message) error {
s, err := ParseMultilineStrings(s)
if err != nil {
return err
}
return proto.UnmarshalText(s, pb)
} | [
"func",
"UnmarshalTextML",
"(",
"s",
"string",
",",
"pb",
"proto",
".",
"Message",
")",
"error",
"{",
"s",
",",
"err",
":=",
"ParseMultilineStrings",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"pro... | // UnmarshalTextML behaves the same as proto.UnmarshalText, except that it
// allows for multiline strings in the manner of ParseMultilineStrings. | [
"UnmarshalTextML",
"behaves",
"the",
"same",
"as",
"proto",
".",
"UnmarshalText",
"except",
"that",
"it",
"allows",
"for",
"multiline",
"strings",
"in",
"the",
"manner",
"of",
"ParseMultilineStrings",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/proto/multiline.go#L195-L201 |
129,135 | luci/luci-go | logdog/client/butler/output/logdog/output.go | Scopes | func Scopes() []string {
// E-mail scope needed for Coordinator authentication.
scopes := []string{auth.OAuthScopeEmail}
// Publisher scope needed to publish to Pub/Sub transport.
scopes = append(scopes, ps.PublisherScopes...)
return scopes
} | go | func Scopes() []string {
// E-mail scope needed for Coordinator authentication.
scopes := []string{auth.OAuthScopeEmail}
// Publisher scope needed to publish to Pub/Sub transport.
scopes = append(scopes, ps.PublisherScopes...)
return scopes
} | [
"func",
"Scopes",
"(",
")",
"[",
"]",
"string",
"{",
"// E-mail scope needed for Coordinator authentication.",
"scopes",
":=",
"[",
"]",
"string",
"{",
"auth",
".",
"OAuthScopeEmail",
"}",
"\n",
"// Publisher scope needed to publish to Pub/Sub transport.",
"scopes",
"=",
... | // Scopes returns the set of OAuth scopes required for this Output. | [
"Scopes",
"returns",
"the",
"set",
"of",
"OAuth",
"scopes",
"required",
"for",
"this",
"Output",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butler/output/logdog/output.go#L44-L51 |
129,136 | luci/luci-go | client/archiver/archiver.go | TotalBytesHits | func (s *Stats) TotalBytesHits() units.Size {
out := units.Size(0)
for _, i := range s.Hits {
out += i
}
return out
} | go | func (s *Stats) TotalBytesHits() units.Size {
out := units.Size(0)
for _, i := range s.Hits {
out += i
}
return out
} | [
"func",
"(",
"s",
"*",
"Stats",
")",
"TotalBytesHits",
"(",
")",
"units",
".",
"Size",
"{",
"out",
":=",
"units",
".",
"Size",
"(",
"0",
")",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
".",
"Hits",
"{",
"out",
"+=",
"i",
"\n",
"}",
"\n",... | // TotalBytesHits is the number of bytes not uploaded due to cache hits on the
// server. | [
"TotalBytesHits",
"is",
"the",
"number",
"of",
"bytes",
"not",
"uploaded",
"due",
"to",
"cache",
"hits",
"on",
"the",
"server",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L93-L99 |
129,137 | luci/luci-go | client/archiver/archiver.go | TotalBytesPushed | func (s *Stats) TotalBytesPushed() units.Size {
out := units.Size(0)
for _, i := range s.Pushed {
out += i.Size
}
return out
} | go | func (s *Stats) TotalBytesPushed() units.Size {
out := units.Size(0)
for _, i := range s.Pushed {
out += i.Size
}
return out
} | [
"func",
"(",
"s",
"*",
"Stats",
")",
"TotalBytesPushed",
"(",
")",
"units",
".",
"Size",
"{",
"out",
":=",
"units",
".",
"Size",
"(",
"0",
")",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
".",
"Pushed",
"{",
"out",
"+=",
"i",
".",
"Size",
... | // TotalBytesPushed returns the sum of bytes uploaded. | [
"TotalBytesPushed",
"returns",
"the",
"sum",
"of",
"bytes",
"uploaded",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L107-L113 |
129,138 | luci/luci-go | client/archiver/archiver.go | New | func New(ctx context.Context, c *isolatedclient.Client, out io.Writer) *Archiver {
// TODO(maruel): Cache hashes and server cache presence.
ctx2, cancel := context.WithCancel(common.CancelOnCtrlC(ctx))
a := &Archiver{
ctx: ctx2,
cancel: cancel,
progress: progress.New(headers, out),
c: c,
stag... | go | func New(ctx context.Context, c *isolatedclient.Client, out io.Writer) *Archiver {
// TODO(maruel): Cache hashes and server cache presence.
ctx2, cancel := context.WithCancel(common.CancelOnCtrlC(ctx))
a := &Archiver{
ctx: ctx2,
cancel: cancel,
progress: progress.New(headers, out),
c: c,
stag... | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"isolatedclient",
".",
"Client",
",",
"out",
"io",
".",
"Writer",
")",
"*",
"Archiver",
"{",
"// TODO(maruel): Cache hashes and server cache presence.",
"ctx2",
",",
"cancel",
":=",
"context",
... | // New returns a thread-safe Archiver instance.
//
// If not nil, out will contain tty-oriented progress information.
//
// ctx will be used for logging. | [
"New",
"returns",
"a",
"thread",
"-",
"safe",
"Archiver",
"instance",
".",
"If",
"not",
"nil",
"out",
"will",
"contain",
"tty",
"-",
"oriented",
"progress",
"information",
".",
"ctx",
"will",
"be",
"used",
"for",
"logging",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L125-L197 |
129,139 | luci/luci-go | client/archiver/archiver.go | done | func (i *PendingItem) done() error {
tracer.CounterAdd(i.a, "itemsProcessing", -1)
i.a = nil
return nil
} | go | func (i *PendingItem) done() error {
tracer.CounterAdd(i.a, "itemsProcessing", -1)
i.a = nil
return nil
} | [
"func",
"(",
"i",
"*",
"PendingItem",
")",
"done",
"(",
")",
"error",
"{",
"tracer",
".",
"CounterAdd",
"(",
"i",
".",
"a",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"i",
".",
"a",
"=",
"nil",
"\n",
"return",
"nil",
"\n",
"}"
] | // done is called when the PendingItem processing is done.
//
// It can be because there was an error, it was linked to another item, it was
// present on the server or finally it was uploaded successfully. | [
"done",
"is",
"called",
"when",
"the",
"PendingItem",
"processing",
"is",
"done",
".",
"It",
"can",
"be",
"because",
"there",
"was",
"an",
"error",
"it",
"was",
"linked",
"to",
"another",
"item",
"it",
"was",
"present",
"on",
"the",
"server",
"or",
"fina... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L232-L236 |
129,140 | luci/luci-go | client/archiver/archiver.go | Error | func (i *PendingItem) Error() error {
i.lock.Lock()
defer i.lock.Unlock()
return i.err
} | go | func (i *PendingItem) Error() error {
i.lock.Lock()
defer i.lock.Unlock()
return i.err
} | [
"func",
"(",
"i",
"*",
"PendingItem",
")",
"Error",
"(",
")",
"error",
"{",
"i",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"i",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"i",
".",
"err",
"\n",
"}"
] | // Error returns any error that occurred for this item if any. | [
"Error",
"returns",
"any",
"error",
"that",
"occurred",
"for",
"this",
"item",
"if",
"any",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L244-L248 |
129,141 | luci/luci-go | client/archiver/archiver.go | Digest | func (i *PendingItem) Digest() isolated.HexDigest {
i.lock.Lock()
defer i.lock.Unlock()
return isolated.HexDigest(i.digestItem.Digest)
} | go | func (i *PendingItem) Digest() isolated.HexDigest {
i.lock.Lock()
defer i.lock.Unlock()
return isolated.HexDigest(i.digestItem.Digest)
} | [
"func",
"(",
"i",
"*",
"PendingItem",
")",
"Digest",
"(",
")",
"isolated",
".",
"HexDigest",
"{",
"i",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"i",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"isolated",
".",
"HexDigest",
"(",
... | // Digest returns the calculated digest once calculated, empty otherwise. | [
"Digest",
"returns",
"the",
"calculated",
"digest",
"once",
"calculated",
"empty",
"otherwise",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L251-L255 |
129,142 | luci/luci-go | client/archiver/archiver.go | SetErr | func (i *PendingItem) SetErr(err error) {
if err == nil {
panic("internal error")
}
i.lock.Lock()
defer i.lock.Unlock()
if i.err == nil {
i.err = err
for _, child := range i.linked {
child.lock.Lock()
child.err = err
child.lock.Unlock()
}
}
} | go | func (i *PendingItem) SetErr(err error) {
if err == nil {
panic("internal error")
}
i.lock.Lock()
defer i.lock.Unlock()
if i.err == nil {
i.err = err
for _, child := range i.linked {
child.lock.Lock()
child.err = err
child.lock.Unlock()
}
}
} | [
"func",
"(",
"i",
"*",
"PendingItem",
")",
"SetErr",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"i",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"i",
".",
"lock",
".",
... | // SetErr forcibly set an item as failed. Normally not used by callers. | [
"SetErr",
"forcibly",
"set",
"an",
"item",
"as",
"failed",
".",
"Normally",
"not",
"used",
"by",
"callers",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L262-L276 |
129,143 | luci/luci-go | client/archiver/archiver.go | Close | func (a *Archiver) Close() error {
// This is done so asynchronously calling push() won't crash.
a.closeLock.Lock()
ok := false
if a.stage1 != nil {
close(a.stage1)
a.stage1 = nil
ok = true
}
a.closeLock.Unlock()
if !ok {
return errors.New("was already closed")
}
a.wg.Wait()
_ = a.progress.Close()
... | go | func (a *Archiver) Close() error {
// This is done so asynchronously calling push() won't crash.
a.closeLock.Lock()
ok := false
if a.stage1 != nil {
close(a.stage1)
a.stage1 = nil
ok = true
}
a.closeLock.Unlock()
if !ok {
return errors.New("was already closed")
}
a.wg.Wait()
_ = a.progress.Close()
... | [
"func",
"(",
"a",
"*",
"Archiver",
")",
"Close",
"(",
")",
"error",
"{",
"// This is done so asynchronously calling push() won't crash.",
"a",
".",
"closeLock",
".",
"Lock",
"(",
")",
"\n",
"ok",
":=",
"false",
"\n",
"if",
"a",
".",
"stage1",
"!=",
"nil",
... | // Close waits for all pending files to be done. If an error occured during
// processing, it is returned. | [
"Close",
"waits",
"for",
"all",
"pending",
"files",
"to",
"be",
"done",
".",
"If",
"an",
"error",
"occured",
"during",
"processing",
"it",
"is",
"returned",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L352-L375 |
129,144 | luci/luci-go | client/archiver/archiver.go | Push | func (a *Archiver) Push(displayName string, source isolatedclient.Source, priority int64) *PendingItem {
return a.push(newItem(a, displayName, "", source, priority))
} | go | func (a *Archiver) Push(displayName string, source isolatedclient.Source, priority int64) *PendingItem {
return a.push(newItem(a, displayName, "", source, priority))
} | [
"func",
"(",
"a",
"*",
"Archiver",
")",
"Push",
"(",
"displayName",
"string",
",",
"source",
"isolatedclient",
".",
"Source",
",",
"priority",
"int64",
")",
"*",
"PendingItem",
"{",
"return",
"a",
".",
"push",
"(",
"newItem",
"(",
"a",
",",
"displayName"... | // Push schedules item upload to the isolate server. Smaller priority value
// means earlier processing. | [
"Push",
"schedules",
"item",
"upload",
"to",
"the",
"isolate",
"server",
".",
"Smaller",
"priority",
"value",
"means",
"earlier",
"processing",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L384-L386 |
129,145 | luci/luci-go | client/archiver/archiver.go | PushFile | func (a *Archiver) PushFile(displayName, path string, priority int64) *PendingItem {
source := func() (io.ReadCloser, error) {
return os.Open(path)
}
return a.push(newItem(a, displayName, path, source, priority))
} | go | func (a *Archiver) PushFile(displayName, path string, priority int64) *PendingItem {
source := func() (io.ReadCloser, error) {
return os.Open(path)
}
return a.push(newItem(a, displayName, path, source, priority))
} | [
"func",
"(",
"a",
"*",
"Archiver",
")",
"PushFile",
"(",
"displayName",
",",
"path",
"string",
",",
"priority",
"int64",
")",
"*",
"PendingItem",
"{",
"source",
":=",
"func",
"(",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"return",
"... | // PushFile schedules file upload to the isolate server. Smaller priority
// value means earlier processing. | [
"PushFile",
"schedules",
"file",
"upload",
"to",
"the",
"isolate",
"server",
".",
"Smaller",
"priority",
"value",
"means",
"earlier",
"processing",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L390-L395 |
129,146 | luci/luci-go | client/archiver/archiver.go | Stats | func (a *Archiver) Stats() *Stats {
a.statsLock.Lock()
defer a.statsLock.Unlock()
return a.stats.deepCopy()
} | go | func (a *Archiver) Stats() *Stats {
a.statsLock.Lock()
defer a.statsLock.Unlock()
return a.stats.deepCopy()
} | [
"func",
"(",
"a",
"*",
"Archiver",
")",
"Stats",
"(",
")",
"*",
"Stats",
"{",
"a",
".",
"statsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"statsLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"a",
".",
"stats",
".",
"deepCopy",
"(",
... | // Stats returns a copy of the statistics. | [
"Stats",
"returns",
"a",
"copy",
"of",
"the",
"statistics",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L398-L402 |
129,147 | luci/luci-go | client/archiver/archiver.go | doContains | func (a *Archiver) doContains(out chan<- *PendingItem, items []*PendingItem) {
tmp := make([]*isolateservice.HandlersEndpointsV1Digest, len(items))
// No need to lock each item at that point, no mutation occurs on
// PendingItem.digestItem after stage 2.
for i, item := range items {
tmp[i] = &item.digestItem
}
... | go | func (a *Archiver) doContains(out chan<- *PendingItem, items []*PendingItem) {
tmp := make([]*isolateservice.HandlersEndpointsV1Digest, len(items))
// No need to lock each item at that point, no mutation occurs on
// PendingItem.digestItem after stage 2.
for i, item := range items {
tmp[i] = &item.digestItem
}
... | [
"func",
"(",
"a",
"*",
"Archiver",
")",
"doContains",
"(",
"out",
"chan",
"<-",
"*",
"PendingItem",
",",
"items",
"[",
"]",
"*",
"PendingItem",
")",
"{",
"tmp",
":=",
"make",
"(",
"[",
"]",
"*",
"isolateservice",
".",
"HandlersEndpointsV1Digest",
",",
... | // doContains is called by stage 3. | [
"doContains",
"is",
"called",
"by",
"stage",
"3",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L582-L616 |
129,148 | luci/luci-go | client/archiver/archiver.go | doUpload | func (a *Archiver) doUpload(item *PendingItem) {
start := time.Now()
if err := a.c.Push(a.ctx, item.state, item.source); err != nil {
err = fmt.Errorf("push(%s) failed: %s", item.path, err)
// When an error occurs, early exit the process.
a.cancel()
item.SetErr(err)
item.done()
return
}
a.progress.Updat... | go | func (a *Archiver) doUpload(item *PendingItem) {
start := time.Now()
if err := a.c.Push(a.ctx, item.state, item.source); err != nil {
err = fmt.Errorf("push(%s) failed: %s", item.path, err)
// When an error occurs, early exit the process.
a.cancel()
item.SetErr(err)
item.done()
return
}
a.progress.Updat... | [
"func",
"(",
"a",
"*",
"Archiver",
")",
"doUpload",
"(",
"item",
"*",
"PendingItem",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"if",
"err",
":=",
"a",
".",
"c",
".",
"Push",
"(",
"a",
".",
"ctx",
",",
"item",
".",
"state",
... | // doUpload is called by stage 4. | [
"doUpload",
"is",
"called",
"by",
"stage",
"4",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/archiver/archiver.go#L619-L638 |
129,149 | luci/luci-go | common/iotools/countingWriter.go | WriteByte | func (c *CountingWriter) WriteByte(b byte) error {
// If our underlying Writer is a ByteWriter, use its WriteByte directly.
if bw, ok := c.Writer.(io.ByteWriter); ok {
if err := bw.WriteByte(b); err != nil {
return err
}
c.Count++
return nil
}
c.singleByteBuf[0] = b
_, err := c.Write(c.singleByteBuf[:]... | go | func (c *CountingWriter) WriteByte(b byte) error {
// If our underlying Writer is a ByteWriter, use its WriteByte directly.
if bw, ok := c.Writer.(io.ByteWriter); ok {
if err := bw.WriteByte(b); err != nil {
return err
}
c.Count++
return nil
}
c.singleByteBuf[0] = b
_, err := c.Write(c.singleByteBuf[:]... | [
"func",
"(",
"c",
"*",
"CountingWriter",
")",
"WriteByte",
"(",
"b",
"byte",
")",
"error",
"{",
"// If our underlying Writer is a ByteWriter, use its WriteByte directly.",
"if",
"bw",
",",
"ok",
":=",
"c",
".",
"Writer",
".",
"(",
"io",
".",
"ByteWriter",
")",
... | // WriteByte implements io.ByteWriter. | [
"WriteByte",
"implements",
"io",
".",
"ByteWriter",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/iotools/countingWriter.go#L42-L55 |
129,150 | luci/luci-go | auth/client/luci_auth/luci_auth.go | GetApplication | func GetApplication(defaultAuthOpts auth.Options) *cli.Application {
return &cli.Application{
Name: "luci-auth",
Title: "LUCI Authentication Utility",
Context: func(ctx context.Context) context.Context {
return gologger.StdConfig.Use(ctx)
},
Commands: []*subcommands.Command{
subcommands.CmdHelp,
au... | go | func GetApplication(defaultAuthOpts auth.Options) *cli.Application {
return &cli.Application{
Name: "luci-auth",
Title: "LUCI Authentication Utility",
Context: func(ctx context.Context) context.Context {
return gologger.StdConfig.Use(ctx)
},
Commands: []*subcommands.Command{
subcommands.CmdHelp,
au... | [
"func",
"GetApplication",
"(",
"defaultAuthOpts",
"auth",
".",
"Options",
")",
"*",
"cli",
".",
"Application",
"{",
"return",
"&",
"cli",
".",
"Application",
"{",
"Name",
":",
"\"",
"\"",
",",
"Title",
":",
"\"",
"\"",
",",
"Context",
":",
"func",
"(",... | // GetApplication returns cli.Application that implements 'luci-auth'.
//
// It does NOT hardcode any default values. Defaults are hardcoded in
// corresponding 'main' package. | [
"GetApplication",
"returns",
"cli",
".",
"Application",
"that",
"implements",
"luci",
"-",
"auth",
".",
"It",
"does",
"NOT",
"hardcode",
"any",
"default",
"values",
".",
"Defaults",
"are",
"hardcoded",
"in",
"corresponding",
"main",
"package",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/luci_auth/luci_auth.go#L32-L69 |
129,151 | luci/luci-go | milo/buildsource/buildbot/buildstore/emulation.go | WithEmulation | func WithEmulation(c context.Context, enabled bool) context.Context {
return context.WithValue(c, &emulationEnabledKey, enabled)
} | go | func WithEmulation(c context.Context, enabled bool) context.Context {
return context.WithValue(c, &emulationEnabledKey, enabled)
} | [
"func",
"WithEmulation",
"(",
"c",
"context",
".",
"Context",
",",
"enabled",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"emulationEnabledKey",
",",
"enabled",
")",
"\n",
"}"
] | // WithEmulation enables or disables emulation. | [
"WithEmulation",
"enables",
"or",
"disables",
"emulation",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/emulation.go#L37-L39 |
129,152 | luci/luci-go | milo/buildsource/buildbot/buildstore/emulation.go | EmulationEnabled | func EmulationEnabled(c context.Context) bool {
enabled, _ := c.Value(&emulationEnabledKey).(bool)
return enabled
} | go | func EmulationEnabled(c context.Context) bool {
enabled, _ := c.Value(&emulationEnabledKey).(bool)
return enabled
} | [
"func",
"EmulationEnabled",
"(",
"c",
"context",
".",
"Context",
")",
"bool",
"{",
"enabled",
",",
"_",
":=",
"c",
".",
"Value",
"(",
"&",
"emulationEnabledKey",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"enabled",
"\n",
"}"
] | // EmulationEnabled returns true if emulation is enabled in c. | [
"EmulationEnabled",
"returns",
"true",
"if",
"emulation",
"is",
"enabled",
"in",
"c",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/emulation.go#L42-L45 |
129,153 | luci/luci-go | milo/buildsource/buildbot/buildstore/emulation.go | BucketOf | func BucketOf(c context.Context, master string) (string, error) {
v, err := bucketCache.GetOrCreate(c, master, func() (v interface{}, exp time.Duration, err error) {
transport, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
return nil, 0, err
}
u := fmt.Sprintf("https://luci-migration.appspot.c... | go | func BucketOf(c context.Context, master string) (string, error) {
v, err := bucketCache.GetOrCreate(c, master, func() (v interface{}, exp time.Duration, err error) {
transport, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
return nil, 0, err
}
u := fmt.Sprintf("https://luci-migration.appspot.c... | [
"func",
"BucketOf",
"(",
"c",
"context",
".",
"Context",
",",
"master",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"bucketCache",
".",
"GetOrCreate",
"(",
"c",
",",
"master",
",",
"func",
"(",
")",
"(",
"v",
"inter... | // BucketOf returns LUCI bucket that the given buildbot master is migrating to.
// Returns "" if it is unknown. | [
"BucketOf",
"returns",
"LUCI",
"bucket",
"that",
"the",
"given",
"buildbot",
"master",
"is",
"migrating",
"to",
".",
"Returns",
"if",
"it",
"is",
"unknown",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/emulation.go#L60-L101 |
129,154 | luci/luci-go | milo/buildsource/console.go | GetConsoleRows | func GetConsoleRows(c context.Context, project string, console *config.Console, commits []string) ([]*ConsoleRow, error) {
rawCommits := make([][]byte, len(commits))
for i, c := range commits {
var err error
if rawCommits[i], err = hex.DecodeString(c); err != nil {
return nil, errors.Annotate(err, "bad commit[... | go | func GetConsoleRows(c context.Context, project string, console *config.Console, commits []string) ([]*ConsoleRow, error) {
rawCommits := make([][]byte, len(commits))
for i, c := range commits {
var err error
if rawCommits[i], err = hex.DecodeString(c); err != nil {
return nil, errors.Annotate(err, "bad commit[... | [
"func",
"GetConsoleRows",
"(",
"c",
"context",
".",
"Context",
",",
"project",
"string",
",",
"console",
"*",
"config",
".",
"Console",
",",
"commits",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"ConsoleRow",
",",
"error",
")",
"{",
"rawCommits",
":=... | // GetConsoleRows returns a row-oriented collection of BuildSummary
// objects. Each row corresponds to the similarly-indexed commit in the
// `commits` slice. | [
"GetConsoleRows",
"returns",
"a",
"row",
"-",
"oriented",
"collection",
"of",
"BuildSummary",
"objects",
".",
"Each",
"row",
"corresponds",
"to",
"the",
"similarly",
"-",
"indexed",
"commit",
"in",
"the",
"commits",
"slice",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/console.go#L51-L103 |
129,155 | luci/luci-go | dm/appengine/mutate/filter_existing.go | filterExisting | func filterExisting(c context.Context, fwdDeps []*model.FwdDep) ([]*model.FwdDep, error) {
ret := make([]*model.FwdDep, 0, len(fwdDeps))
err := ds.Get(c, fwdDeps)
if err == nil {
return nil, nil
}
merr, ok := err.(errors.MultiError)
if !ok {
return nil, err
}
for i, err := range merr {
if err == nil {
... | go | func filterExisting(c context.Context, fwdDeps []*model.FwdDep) ([]*model.FwdDep, error) {
ret := make([]*model.FwdDep, 0, len(fwdDeps))
err := ds.Get(c, fwdDeps)
if err == nil {
return nil, nil
}
merr, ok := err.(errors.MultiError)
if !ok {
return nil, err
}
for i, err := range merr {
if err == nil {
... | [
"func",
"filterExisting",
"(",
"c",
"context",
".",
"Context",
",",
"fwdDeps",
"[",
"]",
"*",
"model",
".",
"FwdDep",
")",
"(",
"[",
"]",
"*",
"model",
".",
"FwdDep",
",",
"error",
")",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"*",
"model",
".",
... | // filterExisting removes the FwdDep objects which already exist.
//
// returns gRPC code error. | [
"filterExisting",
"removes",
"the",
"FwdDep",
"objects",
"which",
"already",
"exist",
".",
"returns",
"gRPC",
"code",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/mutate/filter_existing.go#L28-L49 |
129,156 | luci/luci-go | tumble/process.go | processShard | func processShard(c context.Context, cfg *Config, timestamp time.Time, shard uint64, loop bool) error {
logging.Fields{
"shard": shard,
}.Infof(c, "Processing tumble shard.")
q := processShardQuery(c, cfg, shard)
if q == nil {
logging.Warningf(c, "dead shard, quitting")
return nil
}
// Calculate our end ... | go | func processShard(c context.Context, cfg *Config, timestamp time.Time, shard uint64, loop bool) error {
logging.Fields{
"shard": shard,
}.Infof(c, "Processing tumble shard.")
q := processShardQuery(c, cfg, shard)
if q == nil {
logging.Warningf(c, "dead shard, quitting")
return nil
}
// Calculate our end ... | [
"func",
"processShard",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Config",
",",
"timestamp",
"time",
".",
"Time",
",",
"shard",
"uint64",
",",
"loop",
"bool",
")",
"error",
"{",
"logging",
".",
"Fields",
"{",
"\"",
"\"",
":",
"shard",
",... | // processShard is the tumble backend endpoint. This accepts a shard number
// which is expected to be < GlobalConfig.NumShards. | [
"processShard",
"is",
"the",
"tumble",
"backend",
"endpoint",
".",
"This",
"accepts",
"a",
"shard",
"number",
"which",
"is",
"expected",
"to",
"be",
"<",
"GlobalConfig",
".",
"NumShards",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tumble/process.go#L106-L143 |
129,157 | luci/luci-go | machine-db/client/cli/hosts.go | Run | func (c *DeleteHostCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
ctx := cli.GetContext(app, c, env)
// TODO(smut): Validate required fields client-side.
client := getClient(ctx)
_, err := client.DeleteHost(ctx, &c.req)
if err != nil {
errors.Log(ctx, err)
return 1
}
return 0... | go | func (c *DeleteHostCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
ctx := cli.GetContext(app, c, env)
// TODO(smut): Validate required fields client-side.
client := getClient(ctx)
_, err := client.DeleteHost(ctx, &c.req)
if err != nil {
errors.Log(ctx, err)
return 1
}
return 0... | [
"func",
"(",
"c",
"*",
"DeleteHostCmd",
")",
"Run",
"(",
"app",
"subcommands",
".",
"Application",
",",
"args",
"[",
"]",
"string",
",",
"env",
"subcommands",
".",
"Env",
")",
"int",
"{",
"ctx",
":=",
"cli",
".",
"GetContext",
"(",
"app",
",",
"c",
... | // Run runs the command to delete a host. | [
"Run",
"runs",
"the",
"command",
"to",
"delete",
"a",
"host",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/hosts.go#L33-L43 |
129,158 | luci/luci-go | machine-db/client/cli/hosts.go | deleteHostCmd | func deleteHostCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "del-host -name name",
ShortDesc: "deletes a host",
LongDesc: "Deletes a physical or virtual host from the database.\n\nExample:\ncrimson del-host -name vm100-y1",
CommandRun: func() subcommands.CommandRun {
... | go | func deleteHostCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "del-host -name name",
ShortDesc: "deletes a host",
LongDesc: "Deletes a physical or virtual host from the database.\n\nExample:\ncrimson del-host -name vm100-y1",
CommandRun: func() subcommands.CommandRun {
... | [
"func",
"deleteHostCmd",
"(",
"params",
"*",
"Parameters",
")",
"*",
"subcommands",
".",
"Command",
"{",
"return",
"&",
"subcommands",
".",
"Command",
"{",
"UsageLine",
":",
"\"",
"\"",
",",
"ShortDesc",
":",
"\"",
"\"",
",",
"LongDesc",
":",
"\"",
"\\n"... | // deleteHostCmd returns a command to delete a host. | [
"deleteHostCmd",
"returns",
"a",
"command",
"to",
"delete",
"a",
"host",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/hosts.go#L46-L59 |
129,159 | luci/luci-go | logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go | Get | func (c *Client) Get(_ context.Context, in *logs_api.GetRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error) {
realIn := *in
realIn.Project = coordinatorTest.AllAccessProject
return c.logsServ.Get(c.ctx, &realIn)
} | go | func (c *Client) Get(_ context.Context, in *logs_api.GetRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error) {
realIn := *in
realIn.Project = coordinatorTest.AllAccessProject
return c.logsServ.Get(c.ctx, &realIn)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Get",
"(",
"_",
"context",
".",
"Context",
",",
"in",
"*",
"logs_api",
".",
"GetRequest",
",",
"_",
"...",
"grpc",
".",
"CallOption",
")",
"(",
"*",
"logs_api",
".",
"GetResponse",
",",
"error",
")",
"{",
"rea... | // Get implements logs.Get. | [
"Get",
"implements",
"logs",
".",
"Get",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go#L89-L93 |
129,160 | luci/luci-go | logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go | Query | func (c *Client) Query(_ context.Context, in *logs_api.QueryRequest, _ ...grpc.CallOption) (*logs_api.QueryResponse, error) {
realIn := *in
realIn.Project = coordinatorTest.AllAccessProject
return c.logsServ.Query(c.ctx, &realIn)
} | go | func (c *Client) Query(_ context.Context, in *logs_api.QueryRequest, _ ...grpc.CallOption) (*logs_api.QueryResponse, error) {
realIn := *in
realIn.Project = coordinatorTest.AllAccessProject
return c.logsServ.Query(c.ctx, &realIn)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Query",
"(",
"_",
"context",
".",
"Context",
",",
"in",
"*",
"logs_api",
".",
"QueryRequest",
",",
"_",
"...",
"grpc",
".",
"CallOption",
")",
"(",
"*",
"logs_api",
".",
"QueryResponse",
",",
"error",
")",
"{",
... | // Query implements logs.Query. | [
"Query",
"implements",
"logs",
".",
"Query",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go#L103-L107 |
129,161 | luci/luci-go | logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go | OpenDatagramStream | func (c *Client) OpenDatagramStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error) {
return c.open(logpb.StreamType_DATAGRAM, prefix, path, flags...)
} | go | func (c *Client) OpenDatagramStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error) {
return c.open(logpb.StreamType_DATAGRAM, prefix, path, flags...)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OpenDatagramStream",
"(",
"prefix",
",",
"path",
"logdog_types",
".",
"StreamName",
",",
"flags",
"...",
"*",
"streamproto",
".",
"Flags",
")",
"(",
"*",
"Stream",
",",
"error",
")",
"{",
"return",
"c",
".",
"open... | // OpenDatagramStream returns a stream for datagrams.
//
// Each Write will produce a single complete datagram in the stream. | [
"OpenDatagramStream",
"returns",
"a",
"stream",
"for",
"datagrams",
".",
"Each",
"Write",
"will",
"produce",
"a",
"single",
"complete",
"datagram",
"in",
"the",
"stream",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go#L122-L124 |
129,162 | luci/luci-go | logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go | OpenBinaryStream | func (c *Client) OpenBinaryStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error) {
return c.open(logpb.StreamType_BINARY, prefix, path, flags...)
} | go | func (c *Client) OpenBinaryStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error) {
return c.open(logpb.StreamType_BINARY, prefix, path, flags...)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OpenBinaryStream",
"(",
"prefix",
",",
"path",
"logdog_types",
".",
"StreamName",
",",
"flags",
"...",
"*",
"streamproto",
".",
"Flags",
")",
"(",
"*",
"Stream",
",",
"error",
")",
"{",
"return",
"c",
".",
"open",... | // OpenBinaryStream returns a stream for binary data.
//
// Each Write will append to the binary data like a normal raw file. | [
"OpenBinaryStream",
"returns",
"a",
"stream",
"for",
"binary",
"data",
".",
"Each",
"Write",
"will",
"append",
"to",
"the",
"binary",
"data",
"like",
"a",
"normal",
"raw",
"file",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go#L129-L131 |
129,163 | luci/luci-go | logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go | GetSignedURLs | func (s storageclient) GetSignedURLs(context.Context, *coordinator.URLSigningRequest) (*coordinator.URLSigningResponse, error) {
return nil, errors.New("NOT IMPLEMENTED")
} | go | func (s storageclient) GetSignedURLs(context.Context, *coordinator.URLSigningRequest) (*coordinator.URLSigningResponse, error) {
return nil, errors.New("NOT IMPLEMENTED")
} | [
"func",
"(",
"s",
"storageclient",
")",
"GetSignedURLs",
"(",
"context",
".",
"Context",
",",
"*",
"coordinator",
".",
"URLSigningRequest",
")",
"(",
"*",
"coordinator",
".",
"URLSigningResponse",
",",
"error",
")",
"{",
"return",
"nil",
",",
"errors",
".",
... | // GetSignedURLs is implemented to fill out the coordinator.Storage interface. | [
"GetSignedURLs",
"is",
"implemented",
"to",
"fill",
"out",
"the",
"coordinator",
".",
"Storage",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/logs/v1/fakelogs/client.go#L235-L237 |
129,164 | luci/luci-go | grpc/cmd/prpc/descriptor.go | resolveInputMessage | func (d *serverDescription) resolveInputMessage(service, method string) (*descriptor.DescriptorProto, error) {
_, obj, _ := descutil.Resolve(d.Description, service)
serviceDesc, ok := obj.(*descriptor.ServiceDescriptorProto)
if !ok {
return nil, fmt.Errorf("service %q not found", service)
}
mi := descutil.FindM... | go | func (d *serverDescription) resolveInputMessage(service, method string) (*descriptor.DescriptorProto, error) {
_, obj, _ := descutil.Resolve(d.Description, service)
serviceDesc, ok := obj.(*descriptor.ServiceDescriptorProto)
if !ok {
return nil, fmt.Errorf("service %q not found", service)
}
mi := descutil.FindM... | [
"func",
"(",
"d",
"*",
"serverDescription",
")",
"resolveInputMessage",
"(",
"service",
",",
"method",
"string",
")",
"(",
"*",
"descriptor",
".",
"DescriptorProto",
",",
"error",
")",
"{",
"_",
",",
"obj",
",",
"_",
":=",
"descutil",
".",
"Resolve",
"("... | // resolveInputMessage resolves input message type of a method. | [
"resolveInputMessage",
"resolves",
"input",
"message",
"type",
"of",
"a",
"method",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/descriptor.go#L44-L59 |
129,165 | luci/luci-go | mmutex/lib/exclusive.go | RunExclusive | func RunExclusive(ctx context.Context, env subcommands.Env, command func(context.Context) error) error {
lockFilePath, drainFilePath, err := computeMutexPaths(env)
if err != nil {
return err
}
if len(lockFilePath) == 0 {
return command(ctx)
}
file, err := os.OpenFile(drainFilePath, os.O_RDONLY|os.O_CREATE, ... | go | func RunExclusive(ctx context.Context, env subcommands.Env, command func(context.Context) error) error {
lockFilePath, drainFilePath, err := computeMutexPaths(env)
if err != nil {
return err
}
if len(lockFilePath) == 0 {
return command(ctx)
}
file, err := os.OpenFile(drainFilePath, os.O_RDONLY|os.O_CREATE, ... | [
"func",
"RunExclusive",
"(",
"ctx",
"context",
".",
"Context",
",",
"env",
"subcommands",
".",
"Env",
",",
"command",
"func",
"(",
"context",
".",
"Context",
")",
"error",
")",
"error",
"{",
"lockFilePath",
",",
"drainFilePath",
",",
"err",
":=",
"computeM... | // RunExclusive runs the command with the specified context and environment while
// holding an exclusive mmutex lock. | [
"RunExclusive",
"runs",
"the",
"command",
"with",
"the",
"specified",
"context",
"and",
"environment",
"while",
"holding",
"an",
"exclusive",
"mmutex",
"lock",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mmutex/lib/exclusive.go#L27-L59 |
129,166 | luci/luci-go | dm/appengine/mutate/finish_attempt.go | RollForward | func (f *FinishAttempt) RollForward(c context.Context) (muts []tumble.Mutation, err error) {
atmpt, ex, err := model.InvalidateExecution(c, f.Auth)
if err != nil {
logging.WithError(err).Errorf(c, "could not invalidate execution")
return
}
if err = ResetExecutionTimeout(c, ex); err != nil {
logging.WithError... | go | func (f *FinishAttempt) RollForward(c context.Context) (muts []tumble.Mutation, err error) {
atmpt, ex, err := model.InvalidateExecution(c, f.Auth)
if err != nil {
logging.WithError(err).Errorf(c, "could not invalidate execution")
return
}
if err = ResetExecutionTimeout(c, ex); err != nil {
logging.WithError... | [
"func",
"(",
"f",
"*",
"FinishAttempt",
")",
"RollForward",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"muts",
"[",
"]",
"tumble",
".",
"Mutation",
",",
"err",
"error",
")",
"{",
"atmpt",
",",
"ex",
",",
"err",
":=",
"model",
".",
"InvalidateExec... | // RollForward implements tumble.Mutation
//
// This mutation is called directly from FinishAttempt. | [
"RollForward",
"implements",
"tumble",
".",
"Mutation",
"This",
"mutation",
"is",
"called",
"directly",
"from",
"FinishAttempt",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/mutate/finish_attempt.go#L48-L71 |
129,167 | luci/luci-go | config/server/cfgclient/textproto/resolver.go | Message | func Message(out proto.Message) interface {
cfgclient.Resolver
cfgclient.FormattingResolver
} {
if out == nil {
panic("cannot pass a nil proto.Message instance")
}
return &resolver{
messageName: proto.MessageName(out),
single: out,
singleType: reflect.TypeOf(out),
}
} | go | func Message(out proto.Message) interface {
cfgclient.Resolver
cfgclient.FormattingResolver
} {
if out == nil {
panic("cannot pass a nil proto.Message instance")
}
return &resolver{
messageName: proto.MessageName(out),
single: out,
singleType: reflect.TypeOf(out),
}
} | [
"func",
"Message",
"(",
"out",
"proto",
".",
"Message",
")",
"interface",
"{",
"cfgclient",
".",
"Resolver",
"\n",
"cfgclient",
".",
"FormattingResolver",
"\n",
"}",
"{",
"if",
"out",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
... | // Message is a cfgclient.Resolver that resolves config data into proto.Message
// instances by parsing the config data as a text protobuf. | [
"Message",
"is",
"a",
"cfgclient",
".",
"Resolver",
"that",
"resolves",
"config",
"data",
"into",
"proto",
".",
"Message",
"instances",
"by",
"parsing",
"the",
"config",
"data",
"as",
"a",
"text",
"protobuf",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/textproto/resolver.go#L62-L74 |
129,168 | luci/luci-go | config/server/cfgclient/textproto/resolver.go | Resolve | func (r *resolver) Resolve(it *config.Config) error {
return r.resolveItem(r.single, it.Content, it.FormatSpec.Formatter)
} | go | func (r *resolver) Resolve(it *config.Config) error {
return r.resolveItem(r.single, it.Content, it.FormatSpec.Formatter)
} | [
"func",
"(",
"r",
"*",
"resolver",
")",
"Resolve",
"(",
"it",
"*",
"config",
".",
"Config",
")",
"error",
"{",
"return",
"r",
".",
"resolveItem",
"(",
"r",
".",
"single",
",",
"it",
".",
"Content",
",",
"it",
".",
"FormatSpec",
".",
"Formatter",
")... | // Resolve implements cfgclient.MultiResolver. | [
"Resolve",
"implements",
"cfgclient",
".",
"MultiResolver",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/textproto/resolver.go#L132-L134 |
129,169 | luci/luci-go | config/server/cfgclient/textproto/resolver.go | PrepareMulti | func (r *resolver) PrepareMulti(size int) {
slice := reflect.MakeSlice(r.multiDest.Type(), size, size)
r.multiDest.Set(slice)
} | go | func (r *resolver) PrepareMulti(size int) {
slice := reflect.MakeSlice(r.multiDest.Type(), size, size)
r.multiDest.Set(slice)
} | [
"func",
"(",
"r",
"*",
"resolver",
")",
"PrepareMulti",
"(",
"size",
"int",
")",
"{",
"slice",
":=",
"reflect",
".",
"MakeSlice",
"(",
"r",
".",
"multiDest",
".",
"Type",
"(",
")",
",",
"size",
",",
"size",
")",
"\n",
"r",
".",
"multiDest",
".",
... | // PrepareMulti implements cfgclient.MultiResolver. | [
"PrepareMulti",
"implements",
"cfgclient",
".",
"MultiResolver",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/textproto/resolver.go#L137-L140 |
129,170 | luci/luci-go | config/server/cfgclient/textproto/resolver.go | ResolveItemAt | func (r *resolver) ResolveItemAt(i int, it *config.Config) error {
msgV := archetypeInstance(r.singleType)
if err := r.resolveItem(msgV.Interface().(proto.Message), it.Content, it.FormatSpec.Formatter); err != nil {
return err
}
r.multiDest.Index(i).Set(msgV)
return nil
} | go | func (r *resolver) ResolveItemAt(i int, it *config.Config) error {
msgV := archetypeInstance(r.singleType)
if err := r.resolveItem(msgV.Interface().(proto.Message), it.Content, it.FormatSpec.Formatter); err != nil {
return err
}
r.multiDest.Index(i).Set(msgV)
return nil
} | [
"func",
"(",
"r",
"*",
"resolver",
")",
"ResolveItemAt",
"(",
"i",
"int",
",",
"it",
"*",
"config",
".",
"Config",
")",
"error",
"{",
"msgV",
":=",
"archetypeInstance",
"(",
"r",
".",
"singleType",
")",
"\n",
"if",
"err",
":=",
"r",
".",
"resolveItem... | // ResolveItemAt implements cfgclient.MultiResolver. | [
"ResolveItemAt",
"implements",
"cfgclient",
".",
"MultiResolver",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/textproto/resolver.go#L143-L150 |
129,171 | luci/luci-go | config/server/cfgclient/textproto/resolver.go | FormatItem | func (f *Formatter) FormatItem(c, fd string) (string, error) {
archetype := proto.MessageType(fd)
if archetype == nil {
return "", errors.Reason("unknown proto.Message type %q in formatter data", fd).Err()
}
msg := archetypeMessage(archetype)
// Convert from config to protobuf.
if err := luciProto.UnmarshalTex... | go | func (f *Formatter) FormatItem(c, fd string) (string, error) {
archetype := proto.MessageType(fd)
if archetype == nil {
return "", errors.Reason("unknown proto.Message type %q in formatter data", fd).Err()
}
msg := archetypeMessage(archetype)
// Convert from config to protobuf.
if err := luciProto.UnmarshalTex... | [
"func",
"(",
"f",
"*",
"Formatter",
")",
"FormatItem",
"(",
"c",
",",
"fd",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"archetype",
":=",
"proto",
".",
"MessageType",
"(",
"fd",
")",
"\n",
"if",
"archetype",
"==",
"nil",
"{",
"return",
"... | // FormatItem implements cfgclient.Formatter. | [
"FormatItem",
"implements",
"cfgclient",
".",
"Formatter",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/textproto/resolver.go#L184-L202 |
129,172 | luci/luci-go | config/server/cfgclient/textproto/resolver.go | archetypeInstance | func archetypeInstance(t reflect.Type) reflect.Value {
return reflect.New(t.Elem())
} | go | func archetypeInstance(t reflect.Type) reflect.Value {
return reflect.New(t.Elem())
} | [
"func",
"archetypeInstance",
"(",
"t",
"reflect",
".",
"Type",
")",
"reflect",
".",
"Value",
"{",
"return",
"reflect",
".",
"New",
"(",
"t",
".",
"Elem",
"(",
")",
")",
"\n",
"}"
] | // t is a pointer to a proto.Message instance. | [
"t",
"is",
"a",
"pointer",
"to",
"a",
"proto",
".",
"Message",
"instance",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/textproto/resolver.go#L205-L207 |
129,173 | luci/luci-go | config/server/cfgclient/textproto/resolver.go | parseBinaryContent | func parseBinaryContent(v string, msg proto.Message) error {
r := strings.NewReader(v)
encName, _, err := cmpbin.ReadString(r)
if err != nil {
return errors.Annotate(err, "failed to read message name").Err()
}
// Construct a message for this.
if name := proto.MessageName(msg); name != encName {
return errors... | go | func parseBinaryContent(v string, msg proto.Message) error {
r := strings.NewReader(v)
encName, _, err := cmpbin.ReadString(r)
if err != nil {
return errors.Annotate(err, "failed to read message name").Err()
}
// Construct a message for this.
if name := proto.MessageName(msg); name != encName {
return errors... | [
"func",
"parseBinaryContent",
"(",
"v",
"string",
",",
"msg",
"proto",
".",
"Message",
")",
"error",
"{",
"r",
":=",
"strings",
".",
"NewReader",
"(",
"v",
")",
"\n",
"encName",
",",
"_",
",",
"err",
":=",
"cmpbin",
".",
"ReadString",
"(",
"r",
")",
... | // parseBinaryContent parses a binary content string, pulling out the message
// type and marshalled message data. It then unmarshals the specified type into
// a new message based on the archetype.
//
// If the binary content's declared type doesn't match the archetype, or if the
// binary content is invalid, an error... | [
"parseBinaryContent",
"parses",
"a",
"binary",
"content",
"string",
"pulling",
"out",
"the",
"message",
"type",
"and",
"marshalled",
"message",
"data",
".",
"It",
"then",
"unmarshals",
"the",
"specified",
"type",
"into",
"a",
"new",
"message",
"based",
"on",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/textproto/resolver.go#L241-L262 |
129,174 | luci/luci-go | common/runtime/paniccatcher/catch.go | Catch | func Catch(cb func(p *Panic)) {
if reason := recover(); reason != nil && cb != nil {
stack := make([]byte, maxStackBufferSize)
count := runtime.Stack(stack, true)
cb(&Panic{
Reason: reason,
Stack: string(stack[:count]),
})
}
} | go | func Catch(cb func(p *Panic)) {
if reason := recover(); reason != nil && cb != nil {
stack := make([]byte, maxStackBufferSize)
count := runtime.Stack(stack, true)
cb(&Panic{
Reason: reason,
Stack: string(stack[:count]),
})
}
} | [
"func",
"Catch",
"(",
"cb",
"func",
"(",
"p",
"*",
"Panic",
")",
")",
"{",
"if",
"reason",
":=",
"recover",
"(",
")",
";",
"reason",
"!=",
"nil",
"&&",
"cb",
"!=",
"nil",
"{",
"stack",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"maxStackBufferSize... | // Catch recovers from panic. It should be used as a deferred call.
//
// If the supplied panic callback is nil, the panic will be silently discarded.
// Otherwise, the callback will be invoked with the panic's information. | [
"Catch",
"recovers",
"from",
"panic",
".",
"It",
"should",
"be",
"used",
"as",
"a",
"deferred",
"call",
".",
"If",
"the",
"supplied",
"panic",
"callback",
"is",
"nil",
"the",
"panic",
"will",
"be",
"silently",
"discarded",
".",
"Otherwise",
"the",
"callbac... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/runtime/paniccatcher/catch.go#L38-L47 |
129,175 | luci/luci-go | milo/git/log.go | Log | func (p *implementation) Log(c context.Context, host, project, commitish string, inputOptions *LogOptions) (commits []*gitpb.Commit, err error) {
defer func() { err = common.TagGRPC(c, err) }()
allowed, err := p.acls.IsAllowed(c, host, project)
switch {
case err != nil:
return
case !allowed:
logging.Warningf(... | go | func (p *implementation) Log(c context.Context, host, project, commitish string, inputOptions *LogOptions) (commits []*gitpb.Commit, err error) {
defer func() { err = common.TagGRPC(c, err) }()
allowed, err := p.acls.IsAllowed(c, host, project)
switch {
case err != nil:
return
case !allowed:
logging.Warningf(... | [
"func",
"(",
"p",
"*",
"implementation",
")",
"Log",
"(",
"c",
"context",
".",
"Context",
",",
"host",
",",
"project",
",",
"commitish",
"string",
",",
"inputOptions",
"*",
"LogOptions",
")",
"(",
"commits",
"[",
"]",
"*",
"gitpb",
".",
"Commit",
",",
... | // Log implements Client interface. | [
"Log",
"implements",
"Client",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/log.go#L50-L64 |
129,176 | luci/luci-go | cipd/client/cipd/ensure/versions_file.go | ResolveVersion | func (v VersionsFile) ResolveVersion(pkg, ver string) (common.Pin, error) {
if common.ValidateInstanceID(ver, common.AnyHash) == nil {
return common.Pin{PackageName: pkg, InstanceID: ver}, nil
}
if iid, ok := v[unresolvedVer{pkg, ver}]; ok {
return common.Pin{PackageName: pkg, InstanceID: iid}, nil
}
return co... | go | func (v VersionsFile) ResolveVersion(pkg, ver string) (common.Pin, error) {
if common.ValidateInstanceID(ver, common.AnyHash) == nil {
return common.Pin{PackageName: pkg, InstanceID: ver}, nil
}
if iid, ok := v[unresolvedVer{pkg, ver}]; ok {
return common.Pin{PackageName: pkg, InstanceID: iid}, nil
}
return co... | [
"func",
"(",
"v",
"VersionsFile",
")",
"ResolveVersion",
"(",
"pkg",
",",
"ver",
"string",
")",
"(",
"common",
".",
"Pin",
",",
"error",
")",
"{",
"if",
"common",
".",
"ValidateInstanceID",
"(",
"ver",
",",
"common",
".",
"AnyHash",
")",
"==",
"nil",
... | // ResolveVersion returns a pin matching the given version or an error if such
// version is not in the map.
//
// If 'ver' is already an instance ID, returns it right away. | [
"ResolveVersion",
"returns",
"a",
"pin",
"matching",
"the",
"given",
"version",
"or",
"an",
"error",
"if",
"such",
"version",
"is",
"not",
"in",
"the",
"map",
".",
"If",
"ver",
"is",
"already",
"an",
"instance",
"ID",
"returns",
"it",
"right",
"away",
".... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/ensure/versions_file.go#L95-L103 |
129,177 | luci/luci-go | cipd/client/cipd/ensure/versions_file.go | Equal | func (v VersionsFile) Equal(a VersionsFile) bool {
if len(v) != len(a) {
return false
}
for ver, iid := range v {
if a[ver] != iid {
return false
}
}
return true
} | go | func (v VersionsFile) Equal(a VersionsFile) bool {
if len(v) != len(a) {
return false
}
for ver, iid := range v {
if a[ver] != iid {
return false
}
}
return true
} | [
"func",
"(",
"v",
"VersionsFile",
")",
"Equal",
"(",
"a",
"VersionsFile",
")",
"bool",
"{",
"if",
"len",
"(",
"v",
")",
"!=",
"len",
"(",
"a",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"ver",
",",
"iid",
":=",
"range",
"v",
"{",
"if"... | // Equal returns true if version files have same entries. | [
"Equal",
"returns",
"true",
"if",
"version",
"files",
"have",
"same",
"entries",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/ensure/versions_file.go#L106-L116 |
129,178 | luci/luci-go | cipd/client/cipd/ensure/versions_file.go | Serialize | func (v VersionsFile) Serialize(w io.Writer) error {
keys := make([]unresolvedVer, 0, len(v))
for k := range v {
keys = append(keys, k)
}
sort.Slice(keys, func(i, j int) bool {
l, r := keys[i], keys[j]
if l.pkg != r.pkg {
return l.pkg < r.pkg
}
return l.ver < r.ver
})
_, err := iotools.WriteTracker(... | go | func (v VersionsFile) Serialize(w io.Writer) error {
keys := make([]unresolvedVer, 0, len(v))
for k := range v {
keys = append(keys, k)
}
sort.Slice(keys, func(i, j int) bool {
l, r := keys[i], keys[j]
if l.pkg != r.pkg {
return l.pkg < r.pkg
}
return l.ver < r.ver
})
_, err := iotools.WriteTracker(... | [
"func",
"(",
"v",
"VersionsFile",
")",
"Serialize",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"unresolvedVer",
",",
"0",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"v",
"{",
"ke... | // Serialize writes the VersionsFile to an io.Writer in canonical order. | [
"Serialize",
"writes",
"the",
"VersionsFile",
"to",
"an",
"io",
".",
"Writer",
"in",
"canonical",
"order",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/ensure/versions_file.go#L119-L141 |
129,179 | luci/luci-go | cipd/client/cipd/ensure/versions_file.go | ParseVersionsFile | func ParseVersionsFile(r io.Reader) (VersionsFile, error) {
res := VersionsFile{}
lineNo := 0
makeError := func(fmtStr string, args ...interface{}) error {
args = append([]interface{}{lineNo}, args...)
return fmt.Errorf("failed to parse versions file (line %d): "+fmtStr, args...)
}
const (
stWaitingPkg = "... | go | func ParseVersionsFile(r io.Reader) (VersionsFile, error) {
res := VersionsFile{}
lineNo := 0
makeError := func(fmtStr string, args ...interface{}) error {
args = append([]interface{}{lineNo}, args...)
return fmt.Errorf("failed to parse versions file (line %d): "+fmtStr, args...)
}
const (
stWaitingPkg = "... | [
"func",
"ParseVersionsFile",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"VersionsFile",
",",
"error",
")",
"{",
"res",
":=",
"VersionsFile",
"{",
"}",
"\n\n",
"lineNo",
":=",
"0",
"\n",
"makeError",
":=",
"func",
"(",
"fmtStr",
"string",
",",
"args",
"..... | // ParseVersionsFile parses previously serialized versions file. | [
"ParseVersionsFile",
"parses",
"previously",
"serialized",
"versions",
"file",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/ensure/versions_file.go#L144-L228 |
129,180 | luci/luci-go | logdog/api/endpoints/coordinator/services/v1/util.go | Complete | func (ar *ArchiveStreamRequest) Complete() bool {
tidx := ar.TerminalIndex
if tidx < 0 {
tidx = -1
}
return (ar.LogEntryCount == (tidx + 1))
} | go | func (ar *ArchiveStreamRequest) Complete() bool {
tidx := ar.TerminalIndex
if tidx < 0 {
tidx = -1
}
return (ar.LogEntryCount == (tidx + 1))
} | [
"func",
"(",
"ar",
"*",
"ArchiveStreamRequest",
")",
"Complete",
"(",
")",
"bool",
"{",
"tidx",
":=",
"ar",
".",
"TerminalIndex",
"\n",
"if",
"tidx",
"<",
"0",
"{",
"tidx",
"=",
"-",
"1",
"\n",
"}",
"\n",
"return",
"(",
"ar",
".",
"LogEntryCount",
... | // Complete returns true if the archive request expresses that the archived
// log stream was complete.
//
// A log stream is complete if every entry between zero and its terminal index
// is included. | [
"Complete",
"returns",
"true",
"if",
"the",
"archive",
"request",
"expresses",
"that",
"the",
"archived",
"log",
"stream",
"was",
"complete",
".",
"A",
"log",
"stream",
"is",
"complete",
"if",
"every",
"entry",
"between",
"zero",
"and",
"its",
"terminal",
"i... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/services/v1/util.go#L42-L48 |
129,181 | luci/luci-go | logdog/api/endpoints/coordinator/services/v1/util.go | MakeError | func MakeError(err error) *Error {
if err == nil {
return nil
}
return &Error{
GrpcCode: int32(grpcutil.Code(err)),
Transient: transient.Tag.In(err),
}
} | go | func MakeError(err error) *Error {
if err == nil {
return nil
}
return &Error{
GrpcCode: int32(grpcutil.Code(err)),
Transient: transient.Tag.In(err),
}
} | [
"func",
"MakeError",
"(",
"err",
"error",
")",
"*",
"Error",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"&",
"Error",
"{",
"GrpcCode",
":",
"int32",
"(",
"grpcutil",
".",
"Code",
"(",
"err",
")",
")",
",",
"... | // MakeError returns an Error object for err. If err is a wrapped gRPC error,
// its code will be extracted and embedded in the returned Error.
//
// The Msg field will not be populated. | [
"MakeError",
"returns",
"an",
"Error",
"object",
"for",
"err",
".",
"If",
"err",
"is",
"a",
"wrapped",
"gRPC",
"error",
"its",
"code",
"will",
"be",
"extracted",
"and",
"embedded",
"in",
"the",
"returned",
"Error",
".",
"The",
"Msg",
"field",
"will",
"no... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/services/v1/util.go#L54-L63 |
129,182 | luci/luci-go | logdog/api/endpoints/coordinator/services/v1/util.go | ToError | func (e *Error) ToError() error {
if e == nil {
return nil
}
code := codes.Code(e.GrpcCode)
err := status.Errorf(code, "%s", e.Msg)
if e.Transient || grpcutil.IsTransientCode(code) {
err = transient.Tag.Apply(err)
}
return err
} | go | func (e *Error) ToError() error {
if e == nil {
return nil
}
code := codes.Code(e.GrpcCode)
err := status.Errorf(code, "%s", e.Msg)
if e.Transient || grpcutil.IsTransientCode(code) {
err = transient.Tag.Apply(err)
}
return err
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"ToError",
"(",
")",
"error",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"code",
":=",
"codes",
".",
"Code",
"(",
"e",
".",
"GrpcCode",
")",
"\n",
"err",
":=",
"status",
".",
"Erro... | // ToError converts an Error into a gRPC error. If e is nil, a nil error will
// be returned. | [
"ToError",
"converts",
"an",
"Error",
"into",
"a",
"gRPC",
"error",
".",
"If",
"e",
"is",
"nil",
"a",
"nil",
"error",
"will",
"be",
"returned",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/endpoints/coordinator/services/v1/util.go#L67-L78 |
129,183 | luci/luci-go | common/errors/walk.go | Walk | func Walk(err error, fn func(error) bool) {
_ = walkVisit(err, fn, false)
} | go | func Walk(err error, fn func(error) bool) {
_ = walkVisit(err, fn, false)
} | [
"func",
"Walk",
"(",
"err",
"error",
",",
"fn",
"func",
"(",
"error",
")",
"bool",
")",
"{",
"_",
"=",
"walkVisit",
"(",
"err",
",",
"fn",
",",
"false",
")",
"\n",
"}"
] | // Walk performs a depth-first traversal of the supplied error, unfolding it and
// invoke the supplied callback for each layered error recursively. If the
// callback returns true, Walk will continue its traversal.
//
// - If walk encounters a MultiError, the callback is called once for the
// outer MultiError, then... | [
"Walk",
"performs",
"a",
"depth",
"-",
"first",
"traversal",
"of",
"the",
"supplied",
"error",
"unfolding",
"it",
"and",
"invoke",
"the",
"supplied",
"callback",
"for",
"each",
"layered",
"error",
"recursively",
".",
"If",
"the",
"callback",
"returns",
"true",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/errors/walk.go#L28-L30 |
129,184 | luci/luci-go | common/errors/walk.go | WalkLeaves | func WalkLeaves(err error, fn func(error) bool) {
_ = walkVisit(err, fn, true)
} | go | func WalkLeaves(err error, fn func(error) bool) {
_ = walkVisit(err, fn, true)
} | [
"func",
"WalkLeaves",
"(",
"err",
"error",
",",
"fn",
"func",
"(",
"error",
")",
"bool",
")",
"{",
"_",
"=",
"walkVisit",
"(",
"err",
",",
"fn",
",",
"true",
")",
"\n",
"}"
] | // WalkLeaves is like Walk, but only calls fn on leaf nodes. | [
"WalkLeaves",
"is",
"like",
"Walk",
"but",
"only",
"calls",
"fn",
"on",
"leaf",
"nodes",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/errors/walk.go#L33-L35 |
129,185 | luci/luci-go | logdog/common/storage/entry.go | MakeEntry | func MakeEntry(d []byte, idx types.MessageIndex) *Entry {
return &Entry{
D: d,
streamIndex: idx,
}
} | go | func MakeEntry(d []byte, idx types.MessageIndex) *Entry {
return &Entry{
D: d,
streamIndex: idx,
}
} | [
"func",
"MakeEntry",
"(",
"d",
"[",
"]",
"byte",
",",
"idx",
"types",
".",
"MessageIndex",
")",
"*",
"Entry",
"{",
"return",
"&",
"Entry",
"{",
"D",
":",
"d",
",",
"streamIndex",
":",
"idx",
",",
"}",
"\n",
"}"
] | // MakeEntry creates a new Entry.
//
// All Entry must be backed by data. The index, "idx", is optional. If <0, it
// will be calculated by unmarshalling the data into a LogEntry and pulling the
// value from there. | [
"MakeEntry",
"creates",
"a",
"new",
"Entry",
".",
"All",
"Entry",
"must",
"be",
"backed",
"by",
"data",
".",
"The",
"index",
"idx",
"is",
"optional",
".",
"If",
"<0",
"it",
"will",
"be",
"calculated",
"by",
"unmarshalling",
"the",
"data",
"into",
"a",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/entry.go#L41-L46 |
129,186 | luci/luci-go | logdog/common/storage/entry.go | GetStreamIndex | func (e *Entry) GetStreamIndex() (types.MessageIndex, error) {
if e.streamIndex < 0 {
le, err := e.GetLogEntry()
if err != nil {
return -1, err
}
e.streamIndex = types.MessageIndex(le.StreamIndex)
}
return e.streamIndex, nil
} | go | func (e *Entry) GetStreamIndex() (types.MessageIndex, error) {
if e.streamIndex < 0 {
le, err := e.GetLogEntry()
if err != nil {
return -1, err
}
e.streamIndex = types.MessageIndex(le.StreamIndex)
}
return e.streamIndex, nil
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"GetStreamIndex",
"(",
")",
"(",
"types",
".",
"MessageIndex",
",",
"error",
")",
"{",
"if",
"e",
".",
"streamIndex",
"<",
"0",
"{",
"le",
",",
"err",
":=",
"e",
".",
"GetLogEntry",
"(",
")",
"\n",
"if",
"err"... | // GetStreamIndex returns the LogEntry's stream index.
//
// If this needs to be calculated by unmarshalling the LogEntry, this will be
// done. If this fails, an error will be returned.
//
// If GetLogEntry has succeeded, subsequent GetStreamIndex calls will always
// be fast and succeed. | [
"GetStreamIndex",
"returns",
"the",
"LogEntry",
"s",
"stream",
"index",
".",
"If",
"this",
"needs",
"to",
"be",
"calculated",
"by",
"unmarshalling",
"the",
"LogEntry",
"this",
"will",
"be",
"done",
".",
"If",
"this",
"fails",
"an",
"error",
"will",
"be",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/entry.go#L55-L66 |
129,187 | luci/luci-go | logdog/common/storage/entry.go | GetLogEntry | func (e *Entry) GetLogEntry() (*logpb.LogEntry, error) {
if e.le == nil {
if e.D == nil {
// This can happen with keys-only results.
return nil, errors.New("no log entry data")
}
var le logpb.LogEntry
if err := proto.Unmarshal(e.D, &le); err != nil {
return nil, errors.Annotate(err, "failed to unmars... | go | func (e *Entry) GetLogEntry() (*logpb.LogEntry, error) {
if e.le == nil {
if e.D == nil {
// This can happen with keys-only results.
return nil, errors.New("no log entry data")
}
var le logpb.LogEntry
if err := proto.Unmarshal(e.D, &le); err != nil {
return nil, errors.Annotate(err, "failed to unmars... | [
"func",
"(",
"e",
"*",
"Entry",
")",
"GetLogEntry",
"(",
")",
"(",
"*",
"logpb",
".",
"LogEntry",
",",
"error",
")",
"{",
"if",
"e",
".",
"le",
"==",
"nil",
"{",
"if",
"e",
".",
"D",
"==",
"nil",
"{",
"// This can happen with keys-only results.",
"re... | // GetLogEntry returns the unmarshalled LogEntry data.
//
// The first time this is called, the LogEntry will be unmarshalled from its
// underlying data. | [
"GetLogEntry",
"returns",
"the",
"unmarshalled",
"LogEntry",
"data",
".",
"The",
"first",
"time",
"this",
"is",
"called",
"the",
"LogEntry",
"will",
"be",
"unmarshalled",
"from",
"its",
"underlying",
"data",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/entry.go#L72-L87 |
129,188 | luci/luci-go | tumble/tumble.go | RunUnbuffered | func RunUnbuffered(c context.Context, root *ds.Key, fn func(context.Context) ([]Mutation, error)) error {
cfg := getConfig(c)
shardSet, _, _, err := enterTransactionInternal(c, cfg, root, fn, 0)
if err != nil {
return err
}
fireTasks(c, cfg, shardSet, true)
return nil
} | go | func RunUnbuffered(c context.Context, root *ds.Key, fn func(context.Context) ([]Mutation, error)) error {
cfg := getConfig(c)
shardSet, _, _, err := enterTransactionInternal(c, cfg, root, fn, 0)
if err != nil {
return err
}
fireTasks(c, cfg, shardSet, true)
return nil
} | [
"func",
"RunUnbuffered",
"(",
"c",
"context",
".",
"Context",
",",
"root",
"*",
"ds",
".",
"Key",
",",
"fn",
"func",
"(",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"Mutation",
",",
"error",
")",
")",
"error",
"{",
"cfg",
":=",
"getConfig",
"("... | // RunUnbuffered opens a lightweight unbuffered transaction on "root"
// runs "fn" inside of it. Any mutations returned by "fn" will be registered
// at the end of the transaction if "fn" doesn't return an error.
//
// This is useful as an initial starting point without incurring any of the
// overhead of spinning up a... | [
"RunUnbuffered",
"opens",
"a",
"lightweight",
"unbuffered",
"transaction",
"on",
"root",
"runs",
"fn",
"inside",
"of",
"it",
".",
"Any",
"mutations",
"returned",
"by",
"fn",
"will",
"be",
"registered",
"at",
"the",
"end",
"of",
"the",
"transaction",
"if",
"f... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tumble/tumble.go#L55-L63 |
129,189 | luci/luci-go | tumble/tumble.go | CancelNamedMutations | func CancelNamedMutations(c context.Context, parent *ds.Key, names ...string) error {
toDel := make([]*ds.Key, 0, len(names))
nameSet := stringset.NewFromSlice(names...)
nameSet.Iter(func(name string) bool {
toDel = append(toDel, ds.NewKey(c, "tumble.Mutation", "n:"+name, 0, parent))
return true
})
err := ds.D... | go | func CancelNamedMutations(c context.Context, parent *ds.Key, names ...string) error {
toDel := make([]*ds.Key, 0, len(names))
nameSet := stringset.NewFromSlice(names...)
nameSet.Iter(func(name string) bool {
toDel = append(toDel, ds.NewKey(c, "tumble.Mutation", "n:"+name, 0, parent))
return true
})
err := ds.D... | [
"func",
"CancelNamedMutations",
"(",
"c",
"context",
".",
"Context",
",",
"parent",
"*",
"ds",
".",
"Key",
",",
"names",
"...",
"string",
")",
"error",
"{",
"toDel",
":=",
"make",
"(",
"[",
"]",
"*",
"ds",
".",
"Key",
",",
"0",
",",
"len",
"(",
"... | // CancelNamedMutations does a best-effort cancellation of the named mutations. | [
"CancelNamedMutations",
"does",
"a",
"best",
"-",
"effort",
"cancellation",
"of",
"the",
"named",
"mutations",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tumble/tumble.go#L152-L166 |
129,190 | luci/luci-go | buildbucket/deprecated/build.go | RunDuration | func (b *Build) RunDuration() (duration time.Duration, ok bool) {
if b.StartTime.IsZero() || b.CompletionTime.IsZero() {
return 0, false
}
return b.CompletionTime.Sub(b.StartTime), true
} | go | func (b *Build) RunDuration() (duration time.Duration, ok bool) {
if b.StartTime.IsZero() || b.CompletionTime.IsZero() {
return 0, false
}
return b.CompletionTime.Sub(b.StartTime), true
} | [
"func",
"(",
"b",
"*",
"Build",
")",
"RunDuration",
"(",
")",
"(",
"duration",
"time",
".",
"Duration",
",",
"ok",
"bool",
")",
"{",
"if",
"b",
".",
"StartTime",
".",
"IsZero",
"(",
")",
"||",
"b",
".",
"CompletionTime",
".",
"IsZero",
"(",
")",
... | // RunDuration returns duration between build start and completion. | [
"RunDuration",
"returns",
"duration",
"between",
"build",
"start",
"and",
"completion",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/deprecated/build.go#L85-L90 |
129,191 | luci/luci-go | buildbucket/deprecated/build.go | PutRequest | func (b *Build) PutRequest() (*v1.ApiPutRequestMessage, error) {
tags := b.Tags.Copy()
tags.Del(v1.TagBuilder) // buildbucket adds it automatically
for _, bs := range b.Tags[v1.TagBuildSet] {
if !tags.Contains(v1.TagBuildSet, bs) {
tags.Add(v1.TagBuildSet, bs)
}
}
msg := &v1.ApiPutRequestMessage{
Bucket:... | go | func (b *Build) PutRequest() (*v1.ApiPutRequestMessage, error) {
tags := b.Tags.Copy()
tags.Del(v1.TagBuilder) // buildbucket adds it automatically
for _, bs := range b.Tags[v1.TagBuildSet] {
if !tags.Contains(v1.TagBuildSet, bs) {
tags.Add(v1.TagBuildSet, bs)
}
}
msg := &v1.ApiPutRequestMessage{
Bucket:... | [
"func",
"(",
"b",
"*",
"Build",
")",
"PutRequest",
"(",
")",
"(",
"*",
"v1",
".",
"ApiPutRequestMessage",
",",
"error",
")",
"{",
"tags",
":=",
"b",
".",
"Tags",
".",
"Copy",
"(",
")",
"\n",
"tags",
".",
"Del",
"(",
"v1",
".",
"TagBuilder",
")",
... | // PutRequest converts b to a build creation request.
//
// If a buildset is present in both b.BuildSets and b.Map, it is deduped.
// Returned value has zero ClientOperationId.
// Returns an error if properties could not be marshaled to JSON. | [
"PutRequest",
"converts",
"b",
"to",
"a",
"build",
"creation",
"request",
".",
"If",
"a",
"buildset",
"is",
"present",
"in",
"both",
"b",
".",
"BuildSets",
"and",
"b",
".",
"Map",
"it",
"is",
"deduped",
".",
"Returned",
"value",
"has",
"zero",
"ClientOpe... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/deprecated/build.go#L258-L285 |
129,192 | luci/luci-go | config/server/cfgclient/config.go | Refs | func Refs(c context.Context, a Authority, path string, r MultiResolver, meta *[]*config.Meta) error {
return getAll(c, a, backend.GetAllRef, path, r, meta)
} | go | func Refs(c context.Context, a Authority, path string, r MultiResolver, meta *[]*config.Meta) error {
return getAll(c, a, backend.GetAllRef, path, r, meta)
} | [
"func",
"Refs",
"(",
"c",
"context",
".",
"Context",
",",
"a",
"Authority",
",",
"path",
"string",
",",
"r",
"MultiResolver",
",",
"meta",
"*",
"[",
"]",
"*",
"config",
".",
"Meta",
")",
"error",
"{",
"return",
"getAll",
"(",
"c",
",",
"a",
",",
... | // Refs retrieves all named ref configurations.
//
// See Projects for individual argument descriptions. | [
"Refs",
"retrieves",
"all",
"named",
"ref",
"configurations",
".",
"See",
"Projects",
"for",
"individual",
"argument",
"descriptions",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/config.go#L109-L111 |
129,193 | luci/luci-go | dm/api/service/v1/id_helpers.go | Equals | func (q *Quest_ID) Equals(o *Quest_ID) bool {
return q.Id == o.Id
} | go | func (q *Quest_ID) Equals(o *Quest_ID) bool {
return q.Id == o.Id
} | [
"func",
"(",
"q",
"*",
"Quest_ID",
")",
"Equals",
"(",
"o",
"*",
"Quest_ID",
")",
"bool",
"{",
"return",
"q",
".",
"Id",
"==",
"o",
".",
"Id",
"\n",
"}"
] | // Equals returns true iff the two Quest_IDs are equivalent. | [
"Equals",
"returns",
"true",
"iff",
"the",
"two",
"Quest_IDs",
"are",
"equivalent",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/id_helpers.go#L18-L20 |
129,194 | luci/luci-go | dm/api/service/v1/id_helpers.go | Equals | func (a *Attempt_ID) Equals(o *Attempt_ID) bool {
return a.Quest == o.Quest && a.Id == o.Id
} | go | func (a *Attempt_ID) Equals(o *Attempt_ID) bool {
return a.Quest == o.Quest && a.Id == o.Id
} | [
"func",
"(",
"a",
"*",
"Attempt_ID",
")",
"Equals",
"(",
"o",
"*",
"Attempt_ID",
")",
"bool",
"{",
"return",
"a",
".",
"Quest",
"==",
"o",
".",
"Quest",
"&&",
"a",
".",
"Id",
"==",
"o",
".",
"Id",
"\n",
"}"
] | // Equals returns true iff the two Attempt_IDs are equivalent. | [
"Equals",
"returns",
"true",
"iff",
"the",
"two",
"Attempt_IDs",
"are",
"equivalent",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/id_helpers.go#L28-L30 |
129,195 | luci/luci-go | dm/api/service/v1/id_helpers.go | Execution | func (a *Attempt_ID) Execution(eid uint32) *Execution_ID {
return &Execution_ID{Quest: a.Quest, Attempt: a.Id, Id: eid}
} | go | func (a *Attempt_ID) Execution(eid uint32) *Execution_ID {
return &Execution_ID{Quest: a.Quest, Attempt: a.Id, Id: eid}
} | [
"func",
"(",
"a",
"*",
"Attempt_ID",
")",
"Execution",
"(",
"eid",
"uint32",
")",
"*",
"Execution_ID",
"{",
"return",
"&",
"Execution_ID",
"{",
"Quest",
":",
"a",
".",
"Quest",
",",
"Attempt",
":",
"a",
".",
"Id",
",",
"Id",
":",
"eid",
"}",
"\n",
... | // Execution returns an Execution_ID for this Attempt. | [
"Execution",
"returns",
"an",
"Execution_ID",
"for",
"this",
"Attempt",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/id_helpers.go#L33-L35 |
129,196 | luci/luci-go | dm/api/service/v1/id_helpers.go | Equals | func (e *Execution_ID) Equals(o *Execution_ID) bool {
return e.Quest == o.Quest && e.Attempt == o.Attempt && e.Id == o.Id
} | go | func (e *Execution_ID) Equals(o *Execution_ID) bool {
return e.Quest == o.Quest && e.Attempt == o.Attempt && e.Id == o.Id
} | [
"func",
"(",
"e",
"*",
"Execution_ID",
")",
"Equals",
"(",
"o",
"*",
"Execution_ID",
")",
"bool",
"{",
"return",
"e",
".",
"Quest",
"==",
"o",
".",
"Quest",
"&&",
"e",
".",
"Attempt",
"==",
"o",
".",
"Attempt",
"&&",
"e",
".",
"Id",
"==",
"o",
... | // Equals returns true iff the two Execution_IDs are equivalent. | [
"Equals",
"returns",
"true",
"iff",
"the",
"two",
"Execution_IDs",
"are",
"equivalent",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/id_helpers.go#L49-L51 |
129,197 | luci/luci-go | cipd/client/cipd/internal/tagcache.go | makeFileKey | func makeFileKey(pkg, instance, file string) fileKey {
return fileKey(pkg + ":" + instance + ":" + file)
} | go | func makeFileKey(pkg, instance, file string) fileKey {
return fileKey(pkg + ":" + instance + ":" + file)
} | [
"func",
"makeFileKey",
"(",
"pkg",
",",
"instance",
",",
"file",
"string",
")",
"fileKey",
"{",
"return",
"fileKey",
"(",
"pkg",
"+",
"\"",
"\"",
"+",
"instance",
"+",
"\"",
"\"",
"+",
"file",
")",
"\n",
"}"
] | // makeFileKey constructs key for the TagCache.addedFiles map.
//
// It is distinct from tagKey structurally, thus uses different type. | [
"makeFileKey",
"constructs",
"key",
"for",
"the",
"TagCache",
".",
"addedFiles",
"map",
".",
"It",
"is",
"distinct",
"from",
"tagKey",
"structurally",
"thus",
"uses",
"different",
"type",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/tagcache.go#L83-L85 |
129,198 | luci/luci-go | cipd/client/cipd/internal/tagcache.go | NewTagCache | func NewTagCache(fs fs.FileSystem, service string) *TagCache {
return &TagCache{fs: fs, service: service}
} | go | func NewTagCache(fs fs.FileSystem, service string) *TagCache {
return &TagCache{fs: fs, service: service}
} | [
"func",
"NewTagCache",
"(",
"fs",
"fs",
".",
"FileSystem",
",",
"service",
"string",
")",
"*",
"TagCache",
"{",
"return",
"&",
"TagCache",
"{",
"fs",
":",
"fs",
",",
"service",
":",
"service",
"}",
"\n",
"}"
] | // NewTagCache initializes TagCache.
//
// fs will be the root of the cache. It will be searched for tagcache.db file. | [
"NewTagCache",
"initializes",
"TagCache",
".",
"fs",
"will",
"be",
"the",
"root",
"of",
"the",
"cache",
".",
"It",
"will",
"be",
"searched",
"for",
"tagcache",
".",
"db",
"file",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/tagcache.go#L90-L92 |
129,199 | luci/luci-go | cipd/client/cipd/internal/tagcache.go | ResolveExtractedObjectRef | func (c *TagCache) ResolveExtractedObjectRef(ctx context.Context, pin common.Pin, fileName string) (*api.ObjectRef, error) {
if err := common.ValidatePin(pin, common.AnyHash); err != nil {
return nil, err
}
ignoreBrokenObjectRef := func(iid string) *api.ObjectRef {
if err := common.ValidateInstanceID(iid, commo... | go | func (c *TagCache) ResolveExtractedObjectRef(ctx context.Context, pin common.Pin, fileName string) (*api.ObjectRef, error) {
if err := common.ValidatePin(pin, common.AnyHash); err != nil {
return nil, err
}
ignoreBrokenObjectRef := func(iid string) *api.ObjectRef {
if err := common.ValidateInstanceID(iid, commo... | [
"func",
"(",
"c",
"*",
"TagCache",
")",
"ResolveExtractedObjectRef",
"(",
"ctx",
"context",
".",
"Context",
",",
"pin",
"common",
".",
"Pin",
",",
"fileName",
"string",
")",
"(",
"*",
"api",
".",
"ObjectRef",
",",
"error",
")",
"{",
"if",
"err",
":=",
... | // ResolveExtractedObjectRef returns ObjectRef or nil if that file is not in the
// cache.
//
// Returns error if the cache can't be read. | [
"ResolveExtractedObjectRef",
"returns",
"ObjectRef",
"or",
"nil",
"if",
"that",
"file",
"is",
"not",
"in",
"the",
"cache",
".",
"Returns",
"error",
"if",
"the",
"cache",
"can",
"t",
"be",
"read",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/internal/tagcache.go#L152-L186 |
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.