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,700 | luci/luci-go | config/set.go | Ref | func (cs Set) Ref() string {
domain, _, ref := cs.Split()
if domain == "projects" {
return ref
}
return ""
} | go | func (cs Set) Ref() string {
domain, _, ref := cs.Split()
if domain == "projects" {
return ref
}
return ""
} | [
"func",
"(",
"cs",
"Set",
")",
"Ref",
"(",
")",
"string",
"{",
"domain",
",",
"_",
",",
"ref",
":=",
"cs",
".",
"Split",
"(",
")",
"\n",
"if",
"domain",
"==",
"\"",
"\"",
"{",
"return",
"ref",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
... | // Ref returns a ref component of a project-rooted config set or empty string
// for all other sets.
//
// Use ProjectAndRef if you need to get both the project name and the ref. | [
"Ref",
"returns",
"a",
"ref",
"component",
"of",
"a",
"project",
"-",
"rooted",
"config",
"set",
"or",
"empty",
"string",
"for",
"all",
"other",
"sets",
".",
"Use",
"ProjectAndRef",
"if",
"you",
"need",
"to",
"get",
"both",
"the",
"project",
"name",
"and... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/set.go#L86-L92 |
129,701 | luci/luci-go | common/data/jsontime/jsontime.go | UnmarshalJSON | func (jt *Time) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
var err error
jt.Time, err = time.Parse(time.RFC3339Nano, s)
return err
} | go | func (jt *Time) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
var err error
jt.Time, err = time.Parse(time.RFC3339Nano, s)
return err
} | [
"func",
"(",
"jt",
"*",
"Time",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"s",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
... | // MarshalJSON implements json.Unmarshaler. | [
"MarshalJSON",
"implements",
"json",
".",
"Unmarshaler",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/jsontime/jsontime.go#L41-L50 |
129,702 | luci/luci-go | grpc/prpc/options.go | DefaultOptions | func DefaultOptions() *Options {
return &Options{
Retry: func() retry.Iterator {
return &retry.ExponentialBackoff{
Limited: retry.Limited{
Delay: time.Second,
Retries: 5,
},
}
},
}
} | go | func DefaultOptions() *Options {
return &Options{
Retry: func() retry.Iterator {
return &retry.ExponentialBackoff{
Limited: retry.Limited{
Delay: time.Second,
Retries: 5,
},
}
},
}
} | [
"func",
"DefaultOptions",
"(",
")",
"*",
"Options",
"{",
"return",
"&",
"Options",
"{",
"Retry",
":",
"func",
"(",
")",
"retry",
".",
"Iterator",
"{",
"return",
"&",
"retry",
".",
"ExponentialBackoff",
"{",
"Limited",
":",
"retry",
".",
"Limited",
"{",
... | // DefaultOptions are used if no options are specified in Client. | [
"DefaultOptions",
"are",
"used",
"if",
"no",
"options",
"are",
"specified",
"in",
"Client",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/options.go#L52-L63 |
129,703 | luci/luci-go | grpc/prpc/options.go | Header | func Header(md *metadata.MD) *CallOption {
return &CallOption{
grpc.Header(md),
func(o *Options) {
o.resHeaderMetadata = md
},
}
} | go | func Header(md *metadata.MD) *CallOption {
return &CallOption{
grpc.Header(md),
func(o *Options) {
o.resHeaderMetadata = md
},
}
} | [
"func",
"Header",
"(",
"md",
"*",
"metadata",
".",
"MD",
")",
"*",
"CallOption",
"{",
"return",
"&",
"CallOption",
"{",
"grpc",
".",
"Header",
"(",
"md",
")",
",",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"resHeaderMetadata",
"=",
"md"... | // Header returns a CallOption that retrieves the header metadata.
// Can be used instead of with grpc.Header. | [
"Header",
"returns",
"a",
"CallOption",
"that",
"retrieves",
"the",
"header",
"metadata",
".",
"Can",
"be",
"used",
"instead",
"of",
"with",
"grpc",
".",
"Header",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/options.go#L85-L92 |
129,704 | luci/luci-go | grpc/prpc/options.go | Trailer | func Trailer(md *metadata.MD) *CallOption {
return &CallOption{
grpc.Trailer(md),
func(o *Options) {
o.resTrailerMetadata = md
},
}
} | go | func Trailer(md *metadata.MD) *CallOption {
return &CallOption{
grpc.Trailer(md),
func(o *Options) {
o.resTrailerMetadata = md
},
}
} | [
"func",
"Trailer",
"(",
"md",
"*",
"metadata",
".",
"MD",
")",
"*",
"CallOption",
"{",
"return",
"&",
"CallOption",
"{",
"grpc",
".",
"Trailer",
"(",
"md",
")",
",",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"resTrailerMetadata",
"=",
"... | // Trailer returns a CallOption that retrieves the trailer metadata.
// Can be used instead of grpc.Trailer. | [
"Trailer",
"returns",
"a",
"CallOption",
"that",
"retrieves",
"the",
"trailer",
"metadata",
".",
"Can",
"be",
"used",
"instead",
"of",
"grpc",
".",
"Trailer",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/options.go#L96-L103 |
129,705 | luci/luci-go | grpc/prpc/options.go | ExpectedCode | func ExpectedCode(codes ...codes.Code) *CallOption {
return &CallOption{
grpc.EmptyCallOption{},
func(o *Options) {
o.expectedCodes = append(o.expectedCodes, codes...)
},
}
} | go | func ExpectedCode(codes ...codes.Code) *CallOption {
return &CallOption{
grpc.EmptyCallOption{},
func(o *Options) {
o.expectedCodes = append(o.expectedCodes, codes...)
},
}
} | [
"func",
"ExpectedCode",
"(",
"codes",
"...",
"codes",
".",
"Code",
")",
"*",
"CallOption",
"{",
"return",
"&",
"CallOption",
"{",
"grpc",
".",
"EmptyCallOption",
"{",
"}",
",",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"expectedCodes",
"=",... | // ExpectedCode can be used to indicate that given non-OK codes may appear
// during normal successful call flow, and thus they must not be logged as
// erroneous.
//
// Only affects local logging, nothing else. | [
"ExpectedCode",
"can",
"be",
"used",
"to",
"indicate",
"that",
"given",
"non",
"-",
"OK",
"codes",
"may",
"appear",
"during",
"normal",
"successful",
"call",
"flow",
"and",
"thus",
"they",
"must",
"not",
"be",
"logged",
"as",
"erroneous",
".",
"Only",
"aff... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/options.go#L110-L117 |
129,706 | luci/luci-go | scheduler/appengine/frontend/handler.go | fail | func (c *requestContext) fail(code int, msg string, args ...interface{}) {
body := fmt.Sprintf(msg, args...)
logging.Errorf(c.Context, "HTTP %d: %s", code, body)
http.Error(c.Writer, body, code)
} | go | func (c *requestContext) fail(code int, msg string, args ...interface{}) {
body := fmt.Sprintf(msg, args...)
logging.Errorf(c.Context, "HTTP %d: %s", code, body)
http.Error(c.Writer, body, code)
} | [
"func",
"(",
"c",
"*",
"requestContext",
")",
"fail",
"(",
"code",
"int",
",",
"msg",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"body",
":=",
"fmt",
".",
"Sprintf",
"(",
"msg",
",",
"args",
"...",
")",
"\n",
"logging",
".",
"... | // fail writes error message to the log and the response and sets status code. | [
"fail",
"writes",
"error",
"message",
"to",
"the",
"log",
"and",
"the",
"response",
"and",
"sets",
"status",
"code",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/frontend/handler.go#L95-L99 |
129,707 | luci/luci-go | scheduler/appengine/frontend/handler.go | ok | func (c *requestContext) ok() {
c.Writer.Header().Set("Content-Type", "text/plain; charset=utf-8")
c.Writer.WriteHeader(200)
fmt.Fprintln(c.Writer, "OK")
} | go | func (c *requestContext) ok() {
c.Writer.Header().Set("Content-Type", "text/plain; charset=utf-8")
c.Writer.WriteHeader(200)
fmt.Fprintln(c.Writer, "OK")
} | [
"func",
"(",
"c",
"*",
"requestContext",
")",
"ok",
"(",
")",
"{",
"c",
".",
"Writer",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"c",
".",
"Writer",
".",
"WriteHeader",
"(",
"200",
")",
"\n",
"fmt",
"."... | // ok sets status to 200 and puts "OK" in response. | [
"ok",
"sets",
"status",
"to",
"200",
"and",
"puts",
"OK",
"in",
"response",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/frontend/handler.go#L121-L125 |
129,708 | luci/luci-go | scheduler/appengine/frontend/handler.go | initializeGlobalState | func initializeGlobalState(c context.Context) {
if info.IsDevAppServer(c) {
// Dev app server doesn't preserve the state of task queues across restarts,
// need to reset datastore state accordingly, otherwise everything gets stuck.
if err := globalEngine.ResetAllJobsOnDevServer(c); err != nil {
logging.Errorf... | go | func initializeGlobalState(c context.Context) {
if info.IsDevAppServer(c) {
// Dev app server doesn't preserve the state of task queues across restarts,
// need to reset datastore state accordingly, otherwise everything gets stuck.
if err := globalEngine.ResetAllJobsOnDevServer(c); err != nil {
logging.Errorf... | [
"func",
"initializeGlobalState",
"(",
"c",
"context",
".",
"Context",
")",
"{",
"if",
"info",
".",
"IsDevAppServer",
"(",
"c",
")",
"{",
"// Dev app server doesn't preserve the state of task queues across restarts,",
"// need to reset datastore state accordingly, otherwise everyt... | // initializeGlobalState does one time initialization for stuff that needs
// active GAE context. | [
"initializeGlobalState",
"does",
"one",
"time",
"initialization",
"for",
"stuff",
"that",
"needs",
"active",
"GAE",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/frontend/handler.go#L133-L141 |
129,709 | luci/luci-go | scheduler/appengine/frontend/handler.go | pubsubPushHandler | func pubsubPushHandler(c *router.Context) {
rc := requestContext(*c)
body, err := ioutil.ReadAll(rc.Request.Body)
if err != nil {
rc.fail(500, "Failed to read the request: %s", err)
return
}
if err = globalEngine.ProcessPubSubPush(rc.Context, body); err != nil {
rc.err(err, "Failed to process incoming PubSub... | go | func pubsubPushHandler(c *router.Context) {
rc := requestContext(*c)
body, err := ioutil.ReadAll(rc.Request.Body)
if err != nil {
rc.fail(500, "Failed to read the request: %s", err)
return
}
if err = globalEngine.ProcessPubSubPush(rc.Context, body); err != nil {
rc.err(err, "Failed to process incoming PubSub... | [
"func",
"pubsubPushHandler",
"(",
"c",
"*",
"router",
".",
"Context",
")",
"{",
"rc",
":=",
"requestContext",
"(",
"*",
"c",
")",
"\n",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"rc",
".",
"Request",
".",
"Body",
")",
"\n",
"if",
"er... | // pubsubPushHandler handles incoming PubSub messages. | [
"pubsubPushHandler",
"handles",
"incoming",
"PubSub",
"messages",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/frontend/handler.go#L214-L226 |
129,710 | luci/luci-go | scheduler/appengine/frontend/handler.go | pubsubPullHandler | func pubsubPullHandler(c *router.Context) {
rc := requestContext(*c)
if !appengine.IsDevAppServer() {
rc.fail(403, "Not a dev server")
return
}
err := globalEngine.PullPubSubOnDevServer(
rc.Context, rc.Params.ByName("ManagerName"), rc.Params.ByName("Publisher"))
if err != nil {
rc.err(err, "Failed to pull ... | go | func pubsubPullHandler(c *router.Context) {
rc := requestContext(*c)
if !appengine.IsDevAppServer() {
rc.fail(403, "Not a dev server")
return
}
err := globalEngine.PullPubSubOnDevServer(
rc.Context, rc.Params.ByName("ManagerName"), rc.Params.ByName("Publisher"))
if err != nil {
rc.err(err, "Failed to pull ... | [
"func",
"pubsubPullHandler",
"(",
"c",
"*",
"router",
".",
"Context",
")",
"{",
"rc",
":=",
"requestContext",
"(",
"*",
"c",
")",
"\n",
"if",
"!",
"appengine",
".",
"IsDevAppServer",
"(",
")",
"{",
"rc",
".",
"fail",
"(",
"403",
",",
"\"",
"\"",
")... | // pubsubPullHandler is called on dev server by developer to pull pubsub
// messages from a topic created for a publisher. | [
"pubsubPullHandler",
"is",
"called",
"on",
"dev",
"server",
"by",
"developer",
"to",
"pull",
"pubsub",
"messages",
"from",
"a",
"topic",
"created",
"for",
"a",
"publisher",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/frontend/handler.go#L230-L243 |
129,711 | luci/luci-go | scheduler/appengine/frontend/handler.go | readConfigCron | func readConfigCron(c *router.Context) {
rc := requestContext(*c)
projectsToVisit := map[string]bool{}
// Visit all projects in the catalog.
ctx, _ := context.WithTimeout(rc.Context, 150*time.Second)
projects, err := globalCatalog.GetAllProjects(ctx)
if err != nil {
rc.err(err, "Failed to grab a list of projec... | go | func readConfigCron(c *router.Context) {
rc := requestContext(*c)
projectsToVisit := map[string]bool{}
// Visit all projects in the catalog.
ctx, _ := context.WithTimeout(rc.Context, 150*time.Second)
projects, err := globalCatalog.GetAllProjects(ctx)
if err != nil {
rc.err(err, "Failed to grab a list of projec... | [
"func",
"readConfigCron",
"(",
"c",
"*",
"router",
".",
"Context",
")",
"{",
"rc",
":=",
"requestContext",
"(",
"*",
"c",
")",
"\n",
"projectsToVisit",
":=",
"map",
"[",
"string",
"]",
"bool",
"{",
"}",
"\n\n",
"// Visit all projects in the catalog.",
"ctx",... | // readConfigCron grabs a list of projects from the catalog and datastore and
// dispatches task queue tasks to update each project's cron jobs. | [
"readConfigCron",
"grabs",
"a",
"list",
"of",
"projects",
"from",
"the",
"catalog",
"and",
"datastore",
"and",
"dispatches",
"task",
"queue",
"tasks",
"to",
"update",
"each",
"project",
"s",
"cron",
"jobs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/frontend/handler.go#L247-L286 |
129,712 | luci/luci-go | scheduler/appengine/frontend/handler.go | readProjectConfig | func readProjectConfig(c context.Context, task proto.Message) error {
projectID := task.(*internal.ReadProjectConfigTask).ProjectId
ctx, cancel := context.WithTimeout(c, 150*time.Second)
defer cancel()
jobs, err := globalCatalog.GetProjectJobs(ctx, projectID)
if err != nil {
logging.WithError(err).Errorf(c, "F... | go | func readProjectConfig(c context.Context, task proto.Message) error {
projectID := task.(*internal.ReadProjectConfigTask).ProjectId
ctx, cancel := context.WithTimeout(c, 150*time.Second)
defer cancel()
jobs, err := globalCatalog.GetProjectJobs(ctx, projectID)
if err != nil {
logging.WithError(err).Errorf(c, "F... | [
"func",
"readProjectConfig",
"(",
"c",
"context",
".",
"Context",
",",
"task",
"proto",
".",
"Message",
")",
"error",
"{",
"projectID",
":=",
"task",
".",
"(",
"*",
"internal",
".",
"ReadProjectConfigTask",
")",
".",
"ProjectId",
"\n\n",
"ctx",
",",
"cance... | // readProjectConfig grabs a list of jobs in a project from catalog, updates
// all changed jobs, adds new ones, disables old ones. | [
"readProjectConfig",
"grabs",
"a",
"list",
"of",
"jobs",
"in",
"a",
"project",
"from",
"catalog",
"updates",
"all",
"changed",
"jobs",
"adds",
"new",
"ones",
"disables",
"old",
"ones",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/frontend/handler.go#L290-L308 |
129,713 | luci/luci-go | grpc/prpc/server.go | RegisterService | func (s *Server) RegisterService(desc *grpc.ServiceDesc, impl interface{}) {
serv := &service{
impl: impl,
methods: make(map[string]grpc.MethodDesc, len(desc.Methods)),
}
for _, m := range desc.Methods {
serv.methods[m.MethodName] = m
}
s.mu.Lock()
defer s.mu.Unlock()
if s.services == nil {
s.servic... | go | func (s *Server) RegisterService(desc *grpc.ServiceDesc, impl interface{}) {
serv := &service{
impl: impl,
methods: make(map[string]grpc.MethodDesc, len(desc.Methods)),
}
for _, m := range desc.Methods {
serv.methods[m.MethodName] = m
}
s.mu.Lock()
defer s.mu.Unlock()
if s.services == nil {
s.servic... | [
"func",
"(",
"s",
"*",
"Server",
")",
"RegisterService",
"(",
"desc",
"*",
"grpc",
".",
"ServiceDesc",
",",
"impl",
"interface",
"{",
"}",
")",
"{",
"serv",
":=",
"&",
"service",
"{",
"impl",
":",
"impl",
",",
"methods",
":",
"make",
"(",
"map",
"[... | // RegisterService registers a service implementation.
// Called from the generated code.
//
// desc must contain description of the service, its message types
// and all transitive dependencies.
//
// Panics if a service of the same name is already registered. | [
"RegisterService",
"registers",
"a",
"service",
"implementation",
".",
"Called",
"from",
"the",
"generated",
"code",
".",
"desc",
"must",
"contain",
"description",
"of",
"the",
"service",
"its",
"message",
"types",
"and",
"all",
"transitive",
"dependencies",
".",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/server.go#L101-L120 |
129,714 | luci/luci-go | grpc/prpc/server.go | authenticate | func (s *Server) authenticate() router.Middleware {
a := s.Authenticator
if a == nil {
a = GetDefaultAuth()
if a == nil {
panic("prpc: no custom Authenticator was provided and default authenticator was not registered.\n" +
"Either explicitly set `Server.Authenticator = NoAuthentication`, or use RegisterDef... | go | func (s *Server) authenticate() router.Middleware {
a := s.Authenticator
if a == nil {
a = GetDefaultAuth()
if a == nil {
panic("prpc: no custom Authenticator was provided and default authenticator was not registered.\n" +
"Either explicitly set `Server.Authenticator = NoAuthentication`, or use RegisterDef... | [
"func",
"(",
"s",
"*",
"Server",
")",
"authenticate",
"(",
")",
"router",
".",
"Middleware",
"{",
"a",
":=",
"s",
".",
"Authenticator",
"\n",
"if",
"a",
"==",
"nil",
"{",
"a",
"=",
"GetDefaultAuth",
"(",
")",
"\n",
"if",
"a",
"==",
"nil",
"{",
"p... | // authenticate forces authentication set by RegisterDefaultAuth. | [
"authenticate",
"forces",
"authentication",
"set",
"by",
"RegisterDefaultAuth",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/server.go#L123-L144 |
129,715 | luci/luci-go | grpc/prpc/server.go | ServiceNames | func (s *Server) ServiceNames() []string {
s.mu.Lock()
defer s.mu.Unlock()
names := make([]string, 0, len(s.services))
for name := range s.services {
names = append(names, name)
}
sort.Strings(names)
return names
} | go | func (s *Server) ServiceNames() []string {
s.mu.Lock()
defer s.mu.Unlock()
names := make([]string, 0, len(s.services))
for name := range s.services {
names = append(names, name)
}
sort.Strings(names)
return names
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ServiceNames",
"(",
")",
"[",
"]",
"string",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",... | // ServiceNames returns a sorted list of full names of all registered services. | [
"ServiceNames",
"returns",
"a",
"sorted",
"list",
"of",
"full",
"names",
"of",
"all",
"registered",
"services",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/server.go#L267-L277 |
129,716 | luci/luci-go | cipd/appengine/impl/cas/signer.go | defaultSigner | func defaultSigner(c context.Context) (*signer, error) {
s := auth.GetSigner(c)
if s == nil {
return nil, errors.Reason("a default signer is not available").Err()
}
info, err := s.ServiceInfo(c)
if err != nil {
return nil, errors.Annotate(err, "failed to grab the signer info").Err()
}
return &signer{
Email... | go | func defaultSigner(c context.Context) (*signer, error) {
s := auth.GetSigner(c)
if s == nil {
return nil, errors.Reason("a default signer is not available").Err()
}
info, err := s.ServiceInfo(c)
if err != nil {
return nil, errors.Annotate(err, "failed to grab the signer info").Err()
}
return &signer{
Email... | [
"func",
"defaultSigner",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"*",
"signer",
",",
"error",
")",
"{",
"s",
":=",
"auth",
".",
"GetSigner",
"(",
"c",
")",
"\n",
"if",
"s",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Reason",
"... | // defaultSigner uses the default app account for signing. | [
"defaultSigner",
"uses",
"the",
"default",
"app",
"account",
"for",
"signing",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/cas/signer.go#L36-L49 |
129,717 | luci/luci-go | cipd/appengine/impl/cas/signer.go | iamSigner | func iamSigner(c context.Context, actAs string) (*signer, error) {
t, err := auth.GetRPCTransport(c, auth.AsSelf, auth.WithScopes(iam.OAuthScope))
if err != nil {
return nil, errors.Annotate(err, "failed to grab RPC transport").Err()
}
s := &iam.Signer{
Client: &iam.Client{Client: &http.Client{Transport... | go | func iamSigner(c context.Context, actAs string) (*signer, error) {
t, err := auth.GetRPCTransport(c, auth.AsSelf, auth.WithScopes(iam.OAuthScope))
if err != nil {
return nil, errors.Annotate(err, "failed to grab RPC transport").Err()
}
s := &iam.Signer{
Client: &iam.Client{Client: &http.Client{Transport... | [
"func",
"iamSigner",
"(",
"c",
"context",
".",
"Context",
",",
"actAs",
"string",
")",
"(",
"*",
"signer",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"auth",
".",
"GetRPCTransport",
"(",
"c",
",",
"auth",
".",
"AsSelf",
",",
"auth",
".",
"WithS... | // iamSigner uses SignBytes IAM API for signing. | [
"iamSigner",
"uses",
"SignBytes",
"IAM",
"API",
"for",
"signing",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/cas/signer.go#L52-L65 |
129,718 | luci/luci-go | dm/api/service/v1/attempt_list.go | Normalize | func (a *AttemptList) Normalize() error {
for q, vals := range a.GetTo() {
if vals == nil {
a.To[q] = &AttemptList_Nums{}
} else {
if err := vals.Normalize(); err != nil {
return err
}
}
}
return nil
} | go | func (a *AttemptList) Normalize() error {
for q, vals := range a.GetTo() {
if vals == nil {
a.To[q] = &AttemptList_Nums{}
} else {
if err := vals.Normalize(); err != nil {
return err
}
}
}
return nil
} | [
"func",
"(",
"a",
"*",
"AttemptList",
")",
"Normalize",
"(",
")",
"error",
"{",
"for",
"q",
",",
"vals",
":=",
"range",
"a",
".",
"GetTo",
"(",
")",
"{",
"if",
"vals",
"==",
"nil",
"{",
"a",
".",
"To",
"[",
"q",
"]",
"=",
"&",
"AttemptList_Nums... | // Normalize sorts and uniq's attempt nums | [
"Normalize",
"sorts",
"and",
"uniq",
"s",
"attempt",
"nums"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/attempt_list.go#L25-L36 |
129,719 | luci/luci-go | dm/api/service/v1/attempt_list.go | AddAIDs | func (a *AttemptList) AddAIDs(aids ...*Attempt_ID) {
for _, aid := range aids {
if a.To == nil {
a.To = map[string]*AttemptList_Nums{}
}
atmptNums := a.To[aid.Quest]
if atmptNums == nil {
atmptNums = &AttemptList_Nums{}
a.To[aid.Quest] = atmptNums
}
atmptNums.Nums = append(atmptNums.Nums, aid.Id)
... | go | func (a *AttemptList) AddAIDs(aids ...*Attempt_ID) {
for _, aid := range aids {
if a.To == nil {
a.To = map[string]*AttemptList_Nums{}
}
atmptNums := a.To[aid.Quest]
if atmptNums == nil {
atmptNums = &AttemptList_Nums{}
a.To[aid.Quest] = atmptNums
}
atmptNums.Nums = append(atmptNums.Nums, aid.Id)
... | [
"func",
"(",
"a",
"*",
"AttemptList",
")",
"AddAIDs",
"(",
"aids",
"...",
"*",
"Attempt_ID",
")",
"{",
"for",
"_",
",",
"aid",
":=",
"range",
"aids",
"{",
"if",
"a",
".",
"To",
"==",
"nil",
"{",
"a",
".",
"To",
"=",
"map",
"[",
"string",
"]",
... | // AddAIDs adds the given Attempt_ID to the AttemptList | [
"AddAIDs",
"adds",
"the",
"given",
"Attempt_ID",
"to",
"the",
"AttemptList"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/attempt_list.go#L81-L93 |
129,720 | luci/luci-go | dm/api/service/v1/attempt_list.go | Dup | func (a *AttemptList) Dup() *AttemptList {
ret := &AttemptList{}
for k, v := range a.To {
if ret.To == nil {
ret.To = make(map[string]*AttemptList_Nums, len(a.To))
}
vals := &AttemptList_Nums{Nums: make([]uint32, len(v.Nums))}
copy(vals.Nums, v.Nums)
ret.To[k] = vals
}
return ret
} | go | func (a *AttemptList) Dup() *AttemptList {
ret := &AttemptList{}
for k, v := range a.To {
if ret.To == nil {
ret.To = make(map[string]*AttemptList_Nums, len(a.To))
}
vals := &AttemptList_Nums{Nums: make([]uint32, len(v.Nums))}
copy(vals.Nums, v.Nums)
ret.To[k] = vals
}
return ret
} | [
"func",
"(",
"a",
"*",
"AttemptList",
")",
"Dup",
"(",
")",
"*",
"AttemptList",
"{",
"ret",
":=",
"&",
"AttemptList",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"a",
".",
"To",
"{",
"if",
"ret",
".",
"To",
"==",
"nil",
"{",
"ret",
"... | // Dup does a deep copy of this AttemptList. | [
"Dup",
"does",
"a",
"deep",
"copy",
"of",
"this",
"AttemptList",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/attempt_list.go#L96-L107 |
129,721 | luci/luci-go | dm/api/service/v1/attempt_list.go | UpdateWith | func (a *AttemptList) UpdateWith(o *AttemptList) {
for qid, atmpts := range o.To {
if curAtmpts, ok := a.To[qid]; !ok {
a.To[qid] = atmpts
} else {
curAtmpts.Nums = append(curAtmpts.Nums, atmpts.Nums...)
curAtmpts.Normalize()
}
}
} | go | func (a *AttemptList) UpdateWith(o *AttemptList) {
for qid, atmpts := range o.To {
if curAtmpts, ok := a.To[qid]; !ok {
a.To[qid] = atmpts
} else {
curAtmpts.Nums = append(curAtmpts.Nums, atmpts.Nums...)
curAtmpts.Normalize()
}
}
} | [
"func",
"(",
"a",
"*",
"AttemptList",
")",
"UpdateWith",
"(",
"o",
"*",
"AttemptList",
")",
"{",
"for",
"qid",
",",
"atmpts",
":=",
"range",
"o",
".",
"To",
"{",
"if",
"curAtmpts",
",",
"ok",
":=",
"a",
".",
"To",
"[",
"qid",
"]",
";",
"!",
"ok... | // UpdateWith updates this AttemptList with all the entries in the other
// AttemptList. | [
"UpdateWith",
"updates",
"this",
"AttemptList",
"with",
"all",
"the",
"entries",
"in",
"the",
"other",
"AttemptList",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/attempt_list.go#L111-L120 |
129,722 | luci/luci-go | cipd/client/cipd/builder/pkgdef.go | VersionFile | func (def *PackageDef) VersionFile() string {
// It is already validated by LoadPackageDef, so just return it.
for _, chunk := range def.Data {
if chunk.VersionFile != "" {
return chunk.VersionFile
}
}
return ""
} | go | func (def *PackageDef) VersionFile() string {
// It is already validated by LoadPackageDef, so just return it.
for _, chunk := range def.Data {
if chunk.VersionFile != "" {
return chunk.VersionFile
}
}
return ""
} | [
"func",
"(",
"def",
"*",
"PackageDef",
")",
"VersionFile",
"(",
")",
"string",
"{",
"// It is already validated by LoadPackageDef, so just return it.",
"for",
"_",
",",
"chunk",
":=",
"range",
"def",
".",
"Data",
"{",
"if",
"chunk",
".",
"VersionFile",
"!=",
"\"... | // VersionFile defines where to drop JSON file with package version. | [
"VersionFile",
"defines",
"where",
"to",
"drop",
"JSON",
"file",
"with",
"package",
"version",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/builder/pkgdef.go#L236-L244 |
129,723 | luci/luci-go | cipd/client/cipd/builder/pkgdef.go | makeExclusionFilter | func makeExclusionFilter(startDir string, patterns []string) (fs.ScanFilter, error) {
if len(patterns) == 0 {
return nil, nil
}
// Compile regular expressions.
exps := []*regexp.Regexp{}
for _, expr := range patterns {
if expr == "" {
continue
}
if expr[0] != '^' {
expr = "^" + expr
}
if expr[le... | go | func makeExclusionFilter(startDir string, patterns []string) (fs.ScanFilter, error) {
if len(patterns) == 0 {
return nil, nil
}
// Compile regular expressions.
exps := []*regexp.Regexp{}
for _, expr := range patterns {
if expr == "" {
continue
}
if expr[0] != '^' {
expr = "^" + expr
}
if expr[le... | [
"func",
"makeExclusionFilter",
"(",
"startDir",
"string",
",",
"patterns",
"[",
"]",
"string",
")",
"(",
"fs",
".",
"ScanFilter",
",",
"error",
")",
"{",
"if",
"len",
"(",
"patterns",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n... | // makeExclusionFilter produces a predicate that checks an absolute file path
// against a list of regexps.
//
// Regexps are defined against slash separated paths relative to 'startDir'.
// The predicate takes absolute native path, converts it to slash separated path
// relative to 'startDir' and checks against list o... | [
"makeExclusionFilter",
"produces",
"a",
"predicate",
"that",
"checks",
"an",
"absolute",
"file",
"path",
"against",
"a",
"list",
"of",
"regexps",
".",
"Regexps",
"are",
"defined",
"against",
"slash",
"separated",
"paths",
"relative",
"to",
"startDir",
".",
"The"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/builder/pkgdef.go#L253-L294 |
129,724 | luci/luci-go | server/auth/state.go | WithState | func WithState(c context.Context, s State) context.Context {
return context.WithValue(c, stateContextKey(0), s)
} | go | func WithState(c context.Context, s State) context.Context {
return context.WithValue(c, stateContextKey(0), s)
} | [
"func",
"WithState",
"(",
"c",
"context",
".",
"Context",
",",
"s",
"State",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"stateContextKey",
"(",
"0",
")",
",",
"s",
")",
"\n",
"}"
] | // WithState injects State into the context.
//
// Mostly useful from tests. Must not be normally used from production code,
// 'Authenticate' sets the state itself. | [
"WithState",
"injects",
"State",
"into",
"the",
"context",
".",
"Mostly",
"useful",
"from",
"tests",
".",
"Must",
"not",
"be",
"normally",
"used",
"from",
"production",
"code",
"Authenticate",
"sets",
"the",
"state",
"itself",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/state.go#L71-L73 |
129,725 | luci/luci-go | grpc/cmd/prpc/main.go | done | func (r *cmdRun) done(err error) int {
if err != nil {
fmt.Fprintln(os.Stderr, err)
if err, ok := err.(*exitCode); ok {
return err.code
}
return ecOtherError
}
return 0
} | go | func (r *cmdRun) done(err error) int {
if err != nil {
fmt.Fprintln(os.Stderr, err)
if err, ok := err.(*exitCode); ok {
return err.code
}
return ecOtherError
}
return 0
} | [
"func",
"(",
"r",
"*",
"cmdRun",
")",
"done",
"(",
"err",
"error",
")",
"int",
"{",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintln",
"(",
"os",
".",
"Stderr",
",",
"err",
")",
"\n",
"if",
"err",
",",
"ok",
":=",
"err",
".",
"(",
"*",
... | // done prints err to stderr if it is not nil and returns an exit code. | [
"done",
"prints",
"err",
"to",
"stderr",
"if",
"it",
"is",
"not",
"nil",
"and",
"returns",
"an",
"exit",
"code",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/main.go#L114-L123 |
129,726 | luci/luci-go | common/api/gitiles/log.go | PagingLog | func PagingLog(ctx context.Context, client gitiles.GitilesClient, req gitiles.LogRequest, limit int, opts ...grpc.CallOption) ([]*git.Commit, error) {
// Note: we intentionally receive req as struct (not pointer)
// because we need to mutate it.
switch {
case limit < 0:
return nil, errors.New("limit must not be ... | go | func PagingLog(ctx context.Context, client gitiles.GitilesClient, req gitiles.LogRequest, limit int, opts ...grpc.CallOption) ([]*git.Commit, error) {
// Note: we intentionally receive req as struct (not pointer)
// because we need to mutate it.
switch {
case limit < 0:
return nil, errors.New("limit must not be ... | [
"func",
"PagingLog",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"gitiles",
".",
"GitilesClient",
",",
"req",
"gitiles",
".",
"LogRequest",
",",
"limit",
"int",
",",
"opts",
"...",
"grpc",
".",
"CallOption",
")",
"(",
"[",
"]",
"*",
"git",
".... | // Helper functions for Gitiles.Log RPC.
// PagingLog is a wrapper around Gitiles.Log RPC that pages though commits.
// If req.PageToken is not empty, paging will continue from there.
//
// req.PageSize specifies maximum number of commits to load in each page.
//
// Limit specifies the maximum number of commits to load... | [
"Helper",
"functions",
"for",
"Gitiles",
".",
"Log",
"RPC",
".",
"PagingLog",
"is",
"a",
"wrapper",
"around",
"Gitiles",
".",
"Log",
"RPC",
"that",
"pages",
"though",
"commits",
".",
"If",
"req",
".",
"PageToken",
"is",
"not",
"empty",
"paging",
"will",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gitiles/log.go#L40-L77 |
129,727 | luci/luci-go | milo/api/buildbot/result.go | Status | func (r Result) Status() model.Status {
switch r {
case NoResult:
return model.Running
case Success:
return model.Success
case Warning:
return model.Warning
case Failure:
return model.Failure
case Skipped:
return model.NotRun
case Exception, Retry:
return model.Exception
default:
panic(fmt.Errorf(... | go | func (r Result) Status() model.Status {
switch r {
case NoResult:
return model.Running
case Success:
return model.Success
case Warning:
return model.Warning
case Failure:
return model.Failure
case Skipped:
return model.NotRun
case Exception, Retry:
return model.Exception
default:
panic(fmt.Errorf(... | [
"func",
"(",
"r",
"Result",
")",
"Status",
"(",
")",
"model",
".",
"Status",
"{",
"switch",
"r",
"{",
"case",
"NoResult",
":",
"return",
"model",
".",
"Running",
"\n",
"case",
"Success",
":",
"return",
"model",
".",
"Success",
"\n",
"case",
"Warning",
... | // Status converts r into a model.Status. | [
"Status",
"converts",
"r",
"into",
"a",
"model",
".",
"Status",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/api/buildbot/result.go#L42-L59 |
129,728 | luci/luci-go | common/flag/flagenum/flagenum.go | GetKey | func (e Enum) GetKey(value interface{}) string {
for k, v := range e {
if reflect.DeepEqual(v, value) {
return k
}
}
return ""
} | go | func (e Enum) GetKey(value interface{}) string {
for k, v := range e {
if reflect.DeepEqual(v, value) {
return k
}
}
return ""
} | [
"func",
"(",
"e",
"Enum",
")",
"GetKey",
"(",
"value",
"interface",
"{",
"}",
")",
"string",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"e",
"{",
"if",
"reflect",
".",
"DeepEqual",
"(",
"v",
",",
"value",
")",
"{",
"return",
"k",
"\n",
"}",
"\n"... | // GetKey performs reverse lookup of the enumeration value, returning the
// key that corresponds to the value.
//
// If multiple keys correspond to the same value, the result is undefined. | [
"GetKey",
"performs",
"reverse",
"lookup",
"of",
"the",
"enumeration",
"value",
"returning",
"the",
"key",
"that",
"corresponds",
"to",
"the",
"value",
".",
"If",
"multiple",
"keys",
"correspond",
"to",
"the",
"same",
"value",
"the",
"result",
"is",
"undefined... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/flagenum/flagenum.go#L39-L46 |
129,729 | luci/luci-go | common/flag/flagenum/flagenum.go | GetValue | func (e Enum) GetValue(key string) (interface{}, error) {
for k, v := range e {
if k == key {
return v, nil
}
}
return nil, fmt.Errorf("flagenum: Invalid value; must be one of [%s]", e.Choices())
} | go | func (e Enum) GetValue(key string) (interface{}, error) {
for k, v := range e {
if k == key {
return v, nil
}
}
return nil, fmt.Errorf("flagenum: Invalid value; must be one of [%s]", e.Choices())
} | [
"func",
"(",
"e",
"Enum",
")",
"GetValue",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"e",
"{",
"if",
"k",
"==",
"key",
"{",
"return",
"v",
",",
"nil",
"\n",
"}",
"\n",
... | // GetValue returns the mapped enumeration value associated with a key. | [
"GetValue",
"returns",
"the",
"mapped",
"enumeration",
"value",
"associated",
"with",
"a",
"key",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/flagenum/flagenum.go#L49-L56 |
129,730 | luci/luci-go | common/flag/flagenum/flagenum.go | Choices | func (e Enum) Choices() string {
keys := make([]string, 0, len(e))
for k := range e {
if k == "" {
k = `""`
}
keys = append(keys, k)
}
sort.Strings(keys)
return strings.Join(keys, ", ")
} | go | func (e Enum) Choices() string {
keys := make([]string, 0, len(e))
for k := range e {
if k == "" {
k = `""`
}
keys = append(keys, k)
}
sort.Strings(keys)
return strings.Join(keys, ", ")
} | [
"func",
"(",
"e",
"Enum",
")",
"Choices",
"(",
")",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"e",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"e",
"{",
"if",
"k",
"==",
"\"",
"\"",
"{",
"k",
... | // Choices returns a comma-separated string listing sorted enumeration choices. | [
"Choices",
"returns",
"a",
"comma",
"-",
"separated",
"string",
"listing",
"sorted",
"enumeration",
"choices",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/flagenum/flagenum.go#L59-L69 |
129,731 | luci/luci-go | common/flag/flagenum/flagenum.go | setValue | func (e Enum) setValue(v interface{}, key string) error {
i, err := e.GetValue(key)
if err != nil {
return err
}
vValue := reflect.ValueOf(v).Elem()
if !vValue.CanSet() {
panic(fmt.Errorf("flagenum: Cannot set supplied value, %v", vValue))
}
iValue := reflect.ValueOf(i)
if !vValue.Type().AssignableTo(iVal... | go | func (e Enum) setValue(v interface{}, key string) error {
i, err := e.GetValue(key)
if err != nil {
return err
}
vValue := reflect.ValueOf(v).Elem()
if !vValue.CanSet() {
panic(fmt.Errorf("flagenum: Cannot set supplied value, %v", vValue))
}
iValue := reflect.ValueOf(i)
if !vValue.Type().AssignableTo(iVal... | [
"func",
"(",
"e",
"Enum",
")",
"setValue",
"(",
"v",
"interface",
"{",
"}",
",",
"key",
"string",
")",
"error",
"{",
"i",
",",
"err",
":=",
"e",
".",
"GetValue",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
... | // Sets the value v to the enumeration value mapped to the supplied key. | [
"Sets",
"the",
"value",
"v",
"to",
"the",
"enumeration",
"value",
"mapped",
"to",
"the",
"supplied",
"key",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/flagenum/flagenum.go#L72-L91 |
129,732 | luci/luci-go | common/flag/flagenum/flagenum.go | FlagSet | func (e Enum) FlagSet(v interface{}, key string) error {
return e.setValue(v, key)
} | go | func (e Enum) FlagSet(v interface{}, key string) error {
return e.setValue(v, key)
} | [
"func",
"(",
"e",
"Enum",
")",
"FlagSet",
"(",
"v",
"interface",
"{",
"}",
",",
"key",
"string",
")",
"error",
"{",
"return",
"e",
".",
"setValue",
"(",
"v",
",",
"key",
")",
"\n",
"}"
] | // FlagSet implements flag.Value's Set semantics. It identifies the mapped value
// associated with the supplied key and stores it in the supplied interface.
//
// The interface, v, must be a valid pointer to the mapped enumeration type. | [
"FlagSet",
"implements",
"flag",
".",
"Value",
"s",
"Set",
"semantics",
".",
"It",
"identifies",
"the",
"mapped",
"value",
"associated",
"with",
"the",
"supplied",
"key",
"and",
"stores",
"it",
"in",
"the",
"supplied",
"interface",
".",
"The",
"interface",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/flagenum/flagenum.go#L97-L99 |
129,733 | luci/luci-go | common/flag/flagenum/flagenum.go | JSONUnmarshal | func (e Enum) JSONUnmarshal(v interface{}, data []byte) error {
s := ""
if err := json.Unmarshal(data, &s); err != nil {
return err
}
return e.FlagSet(v, s)
} | go | func (e Enum) JSONUnmarshal(v interface{}, data []byte) error {
s := ""
if err := json.Unmarshal(data, &s); err != nil {
return err
}
return e.FlagSet(v, s)
} | [
"func",
"(",
"e",
"Enum",
")",
"JSONUnmarshal",
"(",
"v",
"interface",
"{",
"}",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"s",
":=",
"\"",
"\"",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"s",
")",
";",
... | // JSONUnmarshal implements json.Unmarshaler's UnmarshalJSON semantics. It
// parses data containing a quoted string, identifies the enumeration value
// associated with that string, and stores it in the supplied interface.
//
// The interface, v, must be a valid pointer to the mapped enumeration type.
// a string corr... | [
"JSONUnmarshal",
"implements",
"json",
".",
"Unmarshaler",
"s",
"UnmarshalJSON",
"semantics",
".",
"It",
"parses",
"data",
"containing",
"a",
"quoted",
"string",
"identifies",
"the",
"enumeration",
"value",
"associated",
"with",
"that",
"string",
"and",
"stores",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/flagenum/flagenum.go#L112-L118 |
129,734 | luci/luci-go | common/flag/flagenum/flagenum.go | JSONMarshal | func (e Enum) JSONMarshal(v interface{}) ([]byte, error) {
key := e.GetKey(v)
data, err := json.Marshal(&key)
if err != nil {
return nil, err
}
return data, nil
} | go | func (e Enum) JSONMarshal(v interface{}) ([]byte, error) {
key := e.GetKey(v)
data, err := json.Marshal(&key)
if err != nil {
return nil, err
}
return data, nil
} | [
"func",
"(",
"e",
"Enum",
")",
"JSONMarshal",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"key",
":=",
"e",
".",
"GetKey",
"(",
"v",
")",
"\n",
"data",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"&... | // JSONMarshal implements json.Marshaler's MarshalJSON semantics. It marshals
// the value in the supplied interface to its associated key and emits a quoted
// string containing that key.
//
// The interface, v, must be a valid pointer to the mapped enumeration type. | [
"JSONMarshal",
"implements",
"json",
".",
"Marshaler",
"s",
"MarshalJSON",
"semantics",
".",
"It",
"marshals",
"the",
"value",
"in",
"the",
"supplied",
"interface",
"to",
"its",
"associated",
"key",
"and",
"emits",
"a",
"quoted",
"string",
"containing",
"that",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/flagenum/flagenum.go#L125-L132 |
129,735 | luci/luci-go | logdog/client/butlerlib/streamclient/client_namedPipe_windows.go | newNamedPipeClient | func newNamedPipeClient(path string, ns types.StreamName) (Client, error) {
if path == "" {
return nil, errors.New("streamclient: cannot have empty named pipe path")
}
return &clientImpl{
factory: func() (io.WriteCloser, error) {
return winio.DialPipe(LocalNamedPipePath(path), nil)
},
ns: ns,
}, nil
} | go | func newNamedPipeClient(path string, ns types.StreamName) (Client, error) {
if path == "" {
return nil, errors.New("streamclient: cannot have empty named pipe path")
}
return &clientImpl{
factory: func() (io.WriteCloser, error) {
return winio.DialPipe(LocalNamedPipePath(path), nil)
},
ns: ns,
}, nil
} | [
"func",
"newNamedPipeClient",
"(",
"path",
"string",
",",
"ns",
"types",
".",
"StreamName",
")",
"(",
"Client",
",",
"error",
")",
"{",
"if",
"path",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"... | // newNamedPipeClient creates a new Client instance bound to a named pipe stream
// server. | [
"newNamedPipeClient",
"creates",
"a",
"new",
"Client",
"instance",
"bound",
"to",
"a",
"named",
"pipe",
"stream",
"server",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butlerlib/streamclient/client_namedPipe_windows.go#L31-L42 |
129,736 | luci/luci-go | tokenserver/appengine/backend/main.go | statusFromErrs | func statusFromErrs(errs []error) int {
for _, err := range errs {
if grpc.Code(err) == codes.Internal {
return http.StatusInternalServerError
}
}
return http.StatusOK
} | go | func statusFromErrs(errs []error) int {
for _, err := range errs {
if grpc.Code(err) == codes.Internal {
return http.StatusInternalServerError
}
}
return http.StatusOK
} | [
"func",
"statusFromErrs",
"(",
"errs",
"[",
"]",
"error",
")",
"int",
"{",
"for",
"_",
",",
"err",
":=",
"range",
"errs",
"{",
"if",
"grpc",
".",
"Code",
"(",
"err",
")",
"==",
"codes",
".",
"Internal",
"{",
"return",
"http",
".",
"StatusInternalServ... | // statusFromErrs returns 500 if any of gRPC errors is codes.Internal. | [
"statusFromErrs",
"returns",
"500",
"if",
"any",
"of",
"gRPC",
"errors",
"is",
"codes",
".",
"Internal",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/backend/main.go#L188-L195 |
129,737 | luci/luci-go | milo/buildsource/buildbot/build.go | getBanner | func getBanner(c context.Context, b *buildbot.Build) *ui.LogoBanner {
osLogo := func() *ui.Logo {
result := &ui.Logo{}
switch b.OSFamily {
case "windows":
result.LogoBase = ui.Windows
case "Darwin":
result.LogoBase = ui.OSX
case "Debian":
result.LogoBase = ui.Ubuntu
default:
return nil
}
re... | go | func getBanner(c context.Context, b *buildbot.Build) *ui.LogoBanner {
osLogo := func() *ui.Logo {
result := &ui.Logo{}
switch b.OSFamily {
case "windows":
result.LogoBase = ui.Windows
case "Darwin":
result.LogoBase = ui.OSX
case "Debian":
result.LogoBase = ui.Ubuntu
default:
return nil
}
re... | [
"func",
"getBanner",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"*",
"ui",
".",
"LogoBanner",
"{",
"osLogo",
":=",
"func",
"(",
")",
"*",
"ui",
".",
"Logo",
"{",
"result",
":=",
"&",
"ui",
".",
"Logo",
"{",... | // getBanner parses the OS information from the build and maybe returns a banner. | [
"getBanner",
"parses",
"the",
"OS",
"information",
"from",
"the",
"build",
"and",
"maybe",
"returns",
"a",
"banner",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L41-L63 |
129,738 | luci/luci-go | milo/buildsource/buildbot/build.go | summary | func summary(c context.Context, b *buildbot.Build) ui.BuildComponent {
// TODO(hinoka): use b.toStatus()
// Status
var status model.Status
if b.Currentstep != nil {
status = model.Running
} else {
status = b.Results.Status()
}
// Link to bot and original build.
host := "build.chromium.org/p"
if b.Internal... | go | func summary(c context.Context, b *buildbot.Build) ui.BuildComponent {
// TODO(hinoka): use b.toStatus()
// Status
var status model.Status
if b.Currentstep != nil {
status = model.Running
} else {
status = b.Results.Status()
}
// Link to bot and original build.
host := "build.chromium.org/p"
if b.Internal... | [
"func",
"summary",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"ui",
".",
"BuildComponent",
"{",
"// TODO(hinoka): use b.toStatus()",
"// Status",
"var",
"status",
"model",
".",
"Status",
"\n",
"if",
"b",
".",
"Currents... | // summary extracts the top level summary from a buildbot build as a
// BuildComponent | [
"summary",
"extracts",
"the",
"top",
"level",
"summary",
"from",
"a",
"buildbot",
"build",
"as",
"a",
"BuildComponent"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L67-L123 |
129,739 | luci/luci-go | milo/buildsource/buildbot/build.go | parseProp | func parseProp(v interface{}) string {
// if v is a whole number, force it into an int. json.Marshal() would turn
// it into what looks like a float instead. We want this to remain and
// int instead of a number.
if vf, ok := v.(float64); ok {
if math.Floor(vf) == vf {
return fmt.Sprintf("%d", int64(vf))
}... | go | func parseProp(v interface{}) string {
// if v is a whole number, force it into an int. json.Marshal() would turn
// it into what looks like a float instead. We want this to remain and
// int instead of a number.
if vf, ok := v.(float64); ok {
if math.Floor(vf) == vf {
return fmt.Sprintf("%d", int64(vf))
}... | [
"func",
"parseProp",
"(",
"v",
"interface",
"{",
"}",
")",
"string",
"{",
"// if v is a whole number, force it into an int. json.Marshal() would turn",
"// it into what looks like a float instead. We want this to remain and",
"// int instead of a number.",
"if",
"vf",
",",
"ok",
... | // parseProp returns a string representation of v. | [
"parseProp",
"returns",
"a",
"string",
"representation",
"of",
"v",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L240-L255 |
129,740 | luci/luci-go | milo/buildsource/buildbot/build.go | properties | func properties(b *buildbot.Build) (result []*ui.PropertyGroup) {
groups := map[string]*ui.PropertyGroup{}
allProps := map[string]Prop{}
for _, prop := range b.Properties {
allProps[prop.Name] = Prop{
Value: prop.Value,
Group: prop.Source,
}
}
for key, prop := range allProps {
value := prop.Value
gro... | go | func properties(b *buildbot.Build) (result []*ui.PropertyGroup) {
groups := map[string]*ui.PropertyGroup{}
allProps := map[string]Prop{}
for _, prop := range b.Properties {
allProps[prop.Name] = Prop{
Value: prop.Value,
Group: prop.Source,
}
}
for key, prop := range allProps {
value := prop.Value
gro... | [
"func",
"properties",
"(",
"b",
"*",
"buildbot",
".",
"Build",
")",
"(",
"result",
"[",
"]",
"*",
"ui",
".",
"PropertyGroup",
")",
"{",
"groups",
":=",
"map",
"[",
"string",
"]",
"*",
"ui",
".",
"PropertyGroup",
"{",
"}",
"\n",
"allProps",
":=",
"m... | // properties extracts all properties from buildbot builds and groups them into
// property groups. | [
"properties",
"extracts",
"all",
"properties",
"from",
"buildbot",
"builds",
"and",
"groups",
"them",
"into",
"property",
"groups",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L267-L303 |
129,741 | luci/luci-go | milo/buildsource/buildbot/build.go | blame | func blame(b *buildbot.Build) (result []*ui.Commit) {
if b.Sourcestamp != nil {
for _, c := range b.Sourcestamp.Changes {
files := c.GetFiles()
result = append(result, &ui.Commit{
AuthorEmail: c.Who,
Repo: c.Repository,
CommitTime: time.Unix(int64(c.When), 0).UTC(),
Revision: ui.NewL... | go | func blame(b *buildbot.Build) (result []*ui.Commit) {
if b.Sourcestamp != nil {
for _, c := range b.Sourcestamp.Changes {
files := c.GetFiles()
result = append(result, &ui.Commit{
AuthorEmail: c.Who,
Repo: c.Repository,
CommitTime: time.Unix(int64(c.When), 0).UTC(),
Revision: ui.NewL... | [
"func",
"blame",
"(",
"b",
"*",
"buildbot",
".",
"Build",
")",
"(",
"result",
"[",
"]",
"*",
"ui",
".",
"Commit",
")",
"{",
"if",
"b",
".",
"Sourcestamp",
"!=",
"nil",
"{",
"for",
"_",
",",
"c",
":=",
"range",
"b",
".",
"Sourcestamp",
".",
"Cha... | // blame extracts the commit and blame information from a buildbot build and
// returns it as a list of Commits. | [
"blame",
"extracts",
"the",
"commit",
"and",
"blame",
"information",
"from",
"a",
"buildbot",
"build",
"and",
"returns",
"it",
"as",
"a",
"list",
"of",
"Commits",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L307-L322 |
129,742 | luci/luci-go | milo/buildsource/buildbot/build.go | sourcestamp | func sourcestamp(c context.Context, b *buildbot.Build) *ui.Trigger {
ss := &ui.Trigger{}
var rietveld url.URL
var gerrit url.URL
gotRevision := ""
repository := ""
issue := int64(-1)
patchset := int64(-1)
for _, prop := range b.Properties {
setIfIntOrStr := func(dst *int64) {
switch v := prop.Value.(type)... | go | func sourcestamp(c context.Context, b *buildbot.Build) *ui.Trigger {
ss := &ui.Trigger{}
var rietveld url.URL
var gerrit url.URL
gotRevision := ""
repository := ""
issue := int64(-1)
patchset := int64(-1)
for _, prop := range b.Properties {
setIfIntOrStr := func(dst *int64) {
switch v := prop.Value.(type)... | [
"func",
"sourcestamp",
"(",
"c",
"context",
".",
"Context",
",",
"b",
"*",
"buildbot",
".",
"Build",
")",
"*",
"ui",
".",
"Trigger",
"{",
"ss",
":=",
"&",
"ui",
".",
"Trigger",
"{",
"}",
"\n",
"var",
"rietveld",
"url",
".",
"URL",
"\n",
"var",
"g... | // sourcestamp extracts the source stamp from various parts of a buildbot build,
// including the properties. | [
"sourcestamp",
"extracts",
"the",
"source",
"stamp",
"from",
"various",
"parts",
"of",
"a",
"buildbot",
"build",
"including",
"the",
"properties",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L326-L400 |
129,743 | luci/luci-go | milo/buildsource/buildbot/build.go | DebugBuild | func DebugBuild(c context.Context, relBuildbotDir string, builder string, buildNum int) (*ui.MiloBuildLegacy, error) {
fname := fmt.Sprintf("%s.%d.json", builder, buildNum)
// ../buildbot below assumes that
// - this code is not executed by tests outside of this dir
// - this dir is a sibling of frontend dir
path ... | go | func DebugBuild(c context.Context, relBuildbotDir string, builder string, buildNum int) (*ui.MiloBuildLegacy, error) {
fname := fmt.Sprintf("%s.%d.json", builder, buildNum)
// ../buildbot below assumes that
// - this code is not executed by tests outside of this dir
// - this dir is a sibling of frontend dir
path ... | [
"func",
"DebugBuild",
"(",
"c",
"context",
".",
"Context",
",",
"relBuildbotDir",
"string",
",",
"builder",
"string",
",",
"buildNum",
"int",
")",
"(",
"*",
"ui",
".",
"MiloBuildLegacy",
",",
"error",
")",
"{",
"fname",
":=",
"fmt",
".",
"Sprintf",
"(",
... | // DebugBuild fetches a debugging build for testing. | [
"DebugBuild",
"fetches",
"a",
"debugging",
"build",
"for",
"testing",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L416-L431 |
129,744 | luci/luci-go | milo/buildsource/buildbot/build.go | GetBuild | func GetBuild(c context.Context, id buildbot.BuildID) (*ui.MiloBuildLegacy, error) {
if err := id.Validate(); err != nil {
return nil, err
}
if err := buildstore.CanAccessMaster(c, id.Master); err != nil {
return nil, err
}
switch b, err := buildstore.GetBuild(c, id); {
case err != nil:
return nil, err
ca... | go | func GetBuild(c context.Context, id buildbot.BuildID) (*ui.MiloBuildLegacy, error) {
if err := id.Validate(); err != nil {
return nil, err
}
if err := buildstore.CanAccessMaster(c, id.Master); err != nil {
return nil, err
}
switch b, err := buildstore.GetBuild(c, id); {
case err != nil:
return nil, err
ca... | [
"func",
"GetBuild",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"buildbot",
".",
"BuildID",
")",
"(",
"*",
"ui",
".",
"MiloBuildLegacy",
",",
"error",
")",
"{",
"if",
"err",
":=",
"id",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
... | // GetBuild fetches a buildbot build and translates it into a MiloBuildLegacy. | [
"GetBuild",
"fetches",
"a",
"buildbot",
"build",
"and",
"translates",
"it",
"into",
"a",
"MiloBuildLegacy",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/build.go#L434-L450 |
129,745 | luci/luci-go | common/proto/google/util.go | LoadTimestamp | func LoadTimestamp(t *timestamp.Timestamp, v time.Time) *timestamp.Timestamp {
if t == nil {
if v.IsZero() {
return nil
}
t = ×tamp.Timestamp{}
}
t.Seconds = v.Unix()
t.Nanos = int32(v.Nanosecond())
return t
} | go | func LoadTimestamp(t *timestamp.Timestamp, v time.Time) *timestamp.Timestamp {
if t == nil {
if v.IsZero() {
return nil
}
t = ×tamp.Timestamp{}
}
t.Seconds = v.Unix()
t.Nanos = int32(v.Nanosecond())
return t
} | [
"func",
"LoadTimestamp",
"(",
"t",
"*",
"timestamp",
".",
"Timestamp",
",",
"v",
"time",
".",
"Time",
")",
"*",
"timestamp",
".",
"Timestamp",
"{",
"if",
"t",
"==",
"nil",
"{",
"if",
"v",
".",
"IsZero",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
... | // LoadTimestamp replaces the value in the supplied Timestamp with the specified
// time.
//
// If the supplied Timestamp is nil and the time is non-zero, a new Timestamp
// will be generated. The populated Timestamp will be returned. | [
"LoadTimestamp",
"replaces",
"the",
"value",
"in",
"the",
"supplied",
"Timestamp",
"with",
"the",
"specified",
"time",
".",
"If",
"the",
"supplied",
"Timestamp",
"is",
"nil",
"and",
"the",
"time",
"is",
"non",
"-",
"zero",
"a",
"new",
"Timestamp",
"will",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/proto/google/util.go#L38-L50 |
129,746 | luci/luci-go | common/proto/google/util.go | TimeFromProto | func TimeFromProto(t *timestamp.Timestamp) time.Time {
if t == nil {
return time.Time{}
}
return time.Unix(t.Seconds, int64(t.Nanos)).UTC()
} | go | func TimeFromProto(t *timestamp.Timestamp) time.Time {
if t == nil {
return time.Time{}
}
return time.Unix(t.Seconds, int64(t.Nanos)).UTC()
} | [
"func",
"TimeFromProto",
"(",
"t",
"*",
"timestamp",
".",
"Timestamp",
")",
"time",
".",
"Time",
"{",
"if",
"t",
"==",
"nil",
"{",
"return",
"time",
".",
"Time",
"{",
"}",
"\n",
"}",
"\n",
"return",
"time",
".",
"Unix",
"(",
"t",
".",
"Seconds",
... | // TimeFromProto returns the time.Time associated with a Timestamp protobuf. | [
"TimeFromProto",
"returns",
"the",
"time",
".",
"Time",
"associated",
"with",
"a",
"Timestamp",
"protobuf",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/proto/google/util.go#L53-L58 |
129,747 | luci/luci-go | common/proto/google/util.go | LoadDuration | func LoadDuration(d *duration.Duration, v time.Duration) *duration.Duration {
if d == nil {
if v == 0 {
return nil
}
d = &duration.Duration{}
}
nanos := v.Nanoseconds()
d.Seconds = nanos / nanosecondsInASecond
d.Nanos = int32(nanos % nanosecondsInASecond)
return d
} | go | func LoadDuration(d *duration.Duration, v time.Duration) *duration.Duration {
if d == nil {
if v == 0 {
return nil
}
d = &duration.Duration{}
}
nanos := v.Nanoseconds()
d.Seconds = nanos / nanosecondsInASecond
d.Nanos = int32(nanos % nanosecondsInASecond)
return d
} | [
"func",
"LoadDuration",
"(",
"d",
"*",
"duration",
".",
"Duration",
",",
"v",
"time",
".",
"Duration",
")",
"*",
"duration",
".",
"Duration",
"{",
"if",
"d",
"==",
"nil",
"{",
"if",
"v",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"d",
"=... | // LoadDuration replaces the value in the supplied Duration with the specified
// value.
//
// If the supplied Duration is nil and the value is non-zero, a new Duration
// will be generated. The populated Duration will be returned. | [
"LoadDuration",
"replaces",
"the",
"value",
"in",
"the",
"supplied",
"Duration",
"with",
"the",
"specified",
"value",
".",
"If",
"the",
"supplied",
"Duration",
"is",
"nil",
"and",
"the",
"value",
"is",
"non",
"-",
"zero",
"a",
"new",
"Duration",
"will",
"b... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/proto/google/util.go#L70-L84 |
129,748 | luci/luci-go | config/server/cfgclient/backend/caching/lru.go | LRUBackend | func LRUBackend(b backend.B, cache *lru.Cache, exp time.Duration) backend.B {
// If our parameters are disabled, just return the underlying Backend.
if exp <= 0 {
return b
}
// mp is used to block concurrent accesses to the same cache key.
return &Backend{
B: b,
CacheGet: func(c context.Context, key Key, l ... | go | func LRUBackend(b backend.B, cache *lru.Cache, exp time.Duration) backend.B {
// If our parameters are disabled, just return the underlying Backend.
if exp <= 0 {
return b
}
// mp is used to block concurrent accesses to the same cache key.
return &Backend{
B: b,
CacheGet: func(c context.Context, key Key, l ... | [
"func",
"LRUBackend",
"(",
"b",
"backend",
".",
"B",
",",
"cache",
"*",
"lru",
".",
"Cache",
",",
"exp",
"time",
".",
"Duration",
")",
"backend",
".",
"B",
"{",
"// If our parameters are disabled, just return the underlying Backend.",
"if",
"exp",
"<=",
"0",
"... | // LRUBackend wraps b, applying the additional cache to its results.
//
// Do NOT chain multiple LRUBackend in the same backend chain. An LRUBackend
// holds a LRU-wide lock on its cache key when it looks up its value, and if
// a second entity attempts to lock that same key during its lookup chain, the
// lookup will ... | [
"LRUBackend",
"wraps",
"b",
"applying",
"the",
"additional",
"cache",
"to",
"its",
"results",
".",
"Do",
"NOT",
"chain",
"multiple",
"LRUBackend",
"in",
"the",
"same",
"backend",
"chain",
".",
"An",
"LRUBackend",
"holds",
"a",
"LRU",
"-",
"wide",
"lock",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/caching/lru.go#L37-L74 |
129,749 | luci/luci-go | server/auth/openid/protocol.go | signingKeys | func (d *discoveryDoc) signingKeys(c context.Context) (*JSONWebKeySet, error) {
fetcher := func() (interface{}, time.Duration, error) {
raw := &JSONWebKeySetStruct{}
req := internal.Request{
Method: "GET",
URL: d.JwksURI,
Out: raw,
}
if err := req.Do(c); err != nil {
return nil, 0, err
}
... | go | func (d *discoveryDoc) signingKeys(c context.Context) (*JSONWebKeySet, error) {
fetcher := func() (interface{}, time.Duration, error) {
raw := &JSONWebKeySetStruct{}
req := internal.Request{
Method: "GET",
URL: d.JwksURI,
Out: raw,
}
if err := req.Do(c); err != nil {
return nil, 0, err
}
... | [
"func",
"(",
"d",
"*",
"discoveryDoc",
")",
"signingKeys",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"*",
"JSONWebKeySet",
",",
"error",
")",
"{",
"fetcher",
":=",
"func",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"time",
".",
"Duration",
",",
... | // signingKeys returns a JSON Web Key set fetched from the location specified
// in the discovery document.
//
// It fetches them on the first use and then keeps them cached in the process
// cache for 6h.
//
// May return both fatal and transient errors. | [
"signingKeys",
"returns",
"a",
"JSON",
"Web",
"Key",
"set",
"fetched",
"from",
"the",
"location",
"specified",
"in",
"the",
"discovery",
"document",
".",
"It",
"fetches",
"them",
"on",
"the",
"first",
"use",
"and",
"then",
"keeps",
"them",
"cached",
"in",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/protocol.go#L61-L84 |
129,750 | luci/luci-go | server/auth/openid/protocol.go | fetchDiscoveryDoc | func fetchDiscoveryDoc(c context.Context, url string) (*discoveryDoc, error) {
if url == "" {
return nil, ErrNotConfigured
}
fetcher := func() (interface{}, time.Duration, error) {
doc := &discoveryDoc{}
req := internal.Request{
Method: "GET",
URL: url,
Out: doc,
}
if err := req.Do(c); err ... | go | func fetchDiscoveryDoc(c context.Context, url string) (*discoveryDoc, error) {
if url == "" {
return nil, ErrNotConfigured
}
fetcher := func() (interface{}, time.Duration, error) {
doc := &discoveryDoc{}
req := internal.Request{
Method: "GET",
URL: url,
Out: doc,
}
if err := req.Do(c); err ... | [
"func",
"fetchDiscoveryDoc",
"(",
"c",
"context",
".",
"Context",
",",
"url",
"string",
")",
"(",
"*",
"discoveryDoc",
",",
"error",
")",
"{",
"if",
"url",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrNotConfigured",
"\n",
"}",
"\n\n",
"fetcher",
"... | // fetchDiscoveryDoc fetches discovery document from given URL. It is cached in
// the process cache for 24 hours. | [
"fetchDiscoveryDoc",
"fetches",
"discovery",
"document",
"from",
"given",
"URL",
".",
"It",
"is",
"cached",
"in",
"the",
"process",
"cache",
"for",
"24",
"hours",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/protocol.go#L88-L112 |
129,751 | luci/luci-go | server/auth/openid/protocol.go | validateStateToken | func validateStateToken(c context.Context, stateTok string) (map[string]string, error) {
return openIDStateToken.Validate(c, stateTok, nil)
} | go | func validateStateToken(c context.Context, stateTok string) (map[string]string, error) {
return openIDStateToken.Validate(c, stateTok, nil)
} | [
"func",
"validateStateToken",
"(",
"c",
"context",
".",
"Context",
",",
"stateTok",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"openIDStateToken",
".",
"Validate",
"(",
"c",
",",
"stateTok",
",",
"nil",
")"... | // validateStateToken validates 'state' token passed to redirect_uri. Returns
// whatever `state` was passed to authenticationURI. | [
"validateStateToken",
"validates",
"state",
"token",
"passed",
"to",
"redirect_uri",
".",
"Returns",
"whatever",
"state",
"was",
"passed",
"to",
"authenticationURI",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/protocol.go#L154-L156 |
129,752 | luci/luci-go | server/auth/openid/protocol.go | handleAuthorizationCode | func handleAuthorizationCode(c context.Context, cfg *Settings, code string) (uid string, u *auth.User, err error) {
if cfg.ClientID == "" || cfg.ClientSecret == "" || cfg.RedirectURI == "" {
return "", nil, ErrNotConfigured
}
// Validate the discover doc has necessary fields to proceed.
discovery, err := fetchDi... | go | func handleAuthorizationCode(c context.Context, cfg *Settings, code string) (uid string, u *auth.User, err error) {
if cfg.ClientID == "" || cfg.ClientSecret == "" || cfg.RedirectURI == "" {
return "", nil, ErrNotConfigured
}
// Validate the discover doc has necessary fields to proceed.
discovery, err := fetchDi... | [
"func",
"handleAuthorizationCode",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Settings",
",",
"code",
"string",
")",
"(",
"uid",
"string",
",",
"u",
"*",
"auth",
".",
"User",
",",
"err",
"error",
")",
"{",
"if",
"cfg",
".",
"ClientID",
"=... | // handleAuthorizationCode exchange `code` for user ID token and user profile. | [
"handleAuthorizationCode",
"exchange",
"code",
"for",
"user",
"ID",
"token",
"and",
"user",
"profile",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/protocol.go#L159-L202 |
129,753 | luci/luci-go | server/auth/openid/protocol.go | userFromIDToken | func userFromIDToken(c context.Context, token string, cfg *Settings, discovery *discoveryDoc) (uid string, u *auth.User, err error) {
// Validate the discovery doc has necessary fields to proceed.
switch {
case discovery.Issuer == "":
return "", nil, errors.New("openid: bad discovery doc, empty issuer")
case disc... | go | func userFromIDToken(c context.Context, token string, cfg *Settings, discovery *discoveryDoc) (uid string, u *auth.User, err error) {
// Validate the discovery doc has necessary fields to proceed.
switch {
case discovery.Issuer == "":
return "", nil, errors.New("openid: bad discovery doc, empty issuer")
case disc... | [
"func",
"userFromIDToken",
"(",
"c",
"context",
".",
"Context",
",",
"token",
"string",
",",
"cfg",
"*",
"Settings",
",",
"discovery",
"*",
"discoveryDoc",
")",
"(",
"uid",
"string",
",",
"u",
"*",
"auth",
".",
"User",
",",
"err",
"error",
")",
"{",
... | // userFromIDToken validates the ID token and extracts user information from it. | [
"userFromIDToken",
"validates",
"the",
"ID",
"token",
"and",
"extracts",
"user",
"information",
"from",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/protocol.go#L205-L246 |
129,754 | luci/luci-go | lucicfg/output.go | ConfigSets | func (o Output) ConfigSets() []ConfigSet {
names := make([]string, 0, len(o.Roots))
for name := range o.Roots {
names = append(names, name)
}
sort.Strings(names) // order is important for logs
cs := make([]ConfigSet, len(names))
for i, nm := range names {
root := o.Roots[nm]
// Normalize in preparation fo... | go | func (o Output) ConfigSets() []ConfigSet {
names := make([]string, 0, len(o.Roots))
for name := range o.Roots {
names = append(names, name)
}
sort.Strings(names) // order is important for logs
cs := make([]ConfigSet, len(names))
for i, nm := range names {
root := o.Roots[nm]
// Normalize in preparation fo... | [
"func",
"(",
"o",
"Output",
")",
"ConfigSets",
"(",
")",
"[",
"]",
"ConfigSet",
"{",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"o",
".",
"Roots",
")",
")",
"\n",
"for",
"name",
":=",
"range",
"o",
".",
"Roots",
... | // ConfigSets partitions this output into 0 or more config sets based on Roots. | [
"ConfigSets",
"partitions",
"this",
"output",
"into",
"0",
"or",
"more",
"config",
"sets",
"based",
"on",
"Roots",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/output.go#L57-L88 |
129,755 | luci/luci-go | lucicfg/output.go | Write | func (o Output) Write(dir string) (changed, unchanged []string, err error) {
// First pass: populate 'changed' and 'unchanged', so we have a valid result
// even when failing midway through writes.
changed, unchanged = o.Compare(dir)
// Second pass: update changed files.
for _, name := range changed {
path := f... | go | func (o Output) Write(dir string) (changed, unchanged []string, err error) {
// First pass: populate 'changed' and 'unchanged', so we have a valid result
// even when failing midway through writes.
changed, unchanged = o.Compare(dir)
// Second pass: update changed files.
for _, name := range changed {
path := f... | [
"func",
"(",
"o",
"Output",
")",
"Write",
"(",
"dir",
"string",
")",
"(",
"changed",
",",
"unchanged",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"// First pass: populate 'changed' and 'unchanged', so we have a valid result",
"// even when failing midway through... | // Write updates files on disk to match the output.
//
// Returns a list of updated files and a list of files that are already
// up-to-date, same as Compare.
//
// Creates missing directories. Not atomic. All files have mode 0666. | [
"Write",
"updates",
"files",
"on",
"disk",
"to",
"match",
"the",
"output",
".",
"Returns",
"a",
"list",
"of",
"updated",
"files",
"and",
"a",
"list",
"of",
"files",
"that",
"are",
"already",
"up",
"-",
"to",
"-",
"date",
"same",
"as",
"Compare",
".",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/output.go#L114-L131 |
129,756 | luci/luci-go | lucicfg/output.go | Digests | func (o Output) Digests() map[string]string {
out := make(map[string]string, len(o.Data))
for file, body := range o.Data {
out[file] = hex.EncodeToString(blobDigest(body))
}
return out
} | go | func (o Output) Digests() map[string]string {
out := make(map[string]string, len(o.Data))
for file, body := range o.Data {
out[file] = hex.EncodeToString(blobDigest(body))
}
return out
} | [
"func",
"(",
"o",
"Output",
")",
"Digests",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"out",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"o",
".",
"Data",
")",
")",
"\n",
"for",
"file",
",",
"body",
":=",
... | // Digests returns a map "file name -> hex SHA256 of its body". | [
"Digests",
"returns",
"a",
"map",
"file",
"name",
"-",
">",
"hex",
"SHA256",
"of",
"its",
"body",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/output.go#L134-L140 |
129,757 | luci/luci-go | lucicfg/output.go | Files | func (o Output) Files() []string {
f := make([]string, 0, len(o.Data))
for k := range o.Data {
f = append(f, k)
}
sort.Strings(f)
return f
} | go | func (o Output) Files() []string {
f := make([]string, 0, len(o.Data))
for k := range o.Data {
f = append(f, k)
}
sort.Strings(f)
return f
} | [
"func",
"(",
"o",
"Output",
")",
"Files",
"(",
")",
"[",
"]",
"string",
"{",
"f",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"o",
".",
"Data",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"o",
".",
"Data",
"{",
"f",
"... | // Files returns a sorted list of file names in the output. | [
"Files",
"returns",
"a",
"sorted",
"list",
"of",
"file",
"names",
"in",
"the",
"output",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/output.go#L143-L150 |
129,758 | luci/luci-go | lucicfg/output.go | DebugDump | func (o Output) DebugDump() {
for _, f := range o.Files() {
fmt.Println("--------------------------------------------------")
fmt.Println(f)
fmt.Println("--------------------------------------------------")
fmt.Print(string(o.Data[f]))
fmt.Println("--------------------------------------------------")
}
} | go | func (o Output) DebugDump() {
for _, f := range o.Files() {
fmt.Println("--------------------------------------------------")
fmt.Println(f)
fmt.Println("--------------------------------------------------")
fmt.Print(string(o.Data[f]))
fmt.Println("--------------------------------------------------")
}
} | [
"func",
"(",
"o",
"Output",
")",
"DebugDump",
"(",
")",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"o",
".",
"Files",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Println",
"(",
"f",
")",
"\n",
"fmt",
".",
"... | // DebugDump writes the output to stdout in a format useful for debugging. | [
"DebugDump",
"writes",
"the",
"output",
"to",
"stdout",
"in",
"a",
"format",
"useful",
"for",
"debugging",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/output.go#L153-L161 |
129,759 | luci/luci-go | lucicfg/generator.go | Generate | func Generate(ctx context.Context, in Inputs) (*State, error) {
state := &State{Inputs: in}
ctx = withState(ctx, state)
// All available functions implemented in go.
predeclared := starlark.StringDict{
// Part of public API of the generator.
"fail": builtins.Fail,
"proto": starlarkproto.ProtoLib()... | go | func Generate(ctx context.Context, in Inputs) (*State, error) {
state := &State{Inputs: in}
ctx = withState(ctx, state)
// All available functions implemented in go.
predeclared := starlark.StringDict{
// Part of public API of the generator.
"fail": builtins.Fail,
"proto": starlarkproto.ProtoLib()... | [
"func",
"Generate",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"Inputs",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"state",
":=",
"&",
"State",
"{",
"Inputs",
":",
"in",
"}",
"\n",
"ctx",
"=",
"withState",
"(",
"ctx",
",",
"state",
"... | // Generate interprets the high-level config.
//
// Returns a multi-error with all captured errors. Some of them may implement
// BacktracableError interface. | [
"Generate",
"interprets",
"the",
"high",
"-",
"level",
"config",
".",
"Returns",
"a",
"multi",
"-",
"error",
"with",
"all",
"captured",
"errors",
".",
"Some",
"of",
"them",
"may",
"implement",
"BacktracableError",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/generator.go#L54-L143 |
129,760 | luci/luci-go | logdog/client/butlerlib/streamproto/tag.go | SortedKeys | func (t TagMap) SortedKeys() []string {
if len(t) == 0 {
return nil
}
keys := make([]string, 0, len(t))
for k := range t {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
} | go | func (t TagMap) SortedKeys() []string {
if len(t) == 0 {
return nil
}
keys := make([]string, 0, len(t))
for k := range t {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
} | [
"func",
"(",
"t",
"TagMap",
")",
"SortedKeys",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"t",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"t",
... | // SortedKeys returns a sorted slice of the keys in a TagMap. | [
"SortedKeys",
"returns",
"a",
"sorted",
"slice",
"of",
"the",
"keys",
"in",
"a",
"TagMap",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butlerlib/streamproto/tag.go#L46-L57 |
129,761 | luci/luci-go | common/proto/gitiles/gitiles.mock.pb.go | NewMockGitilesClient | func NewMockGitilesClient(ctrl *gomock.Controller) *MockGitilesClient {
mock := &MockGitilesClient{ctrl: ctrl}
mock.recorder = &MockGitilesClientMockRecorder{mock}
return mock
} | go | func NewMockGitilesClient(ctrl *gomock.Controller) *MockGitilesClient {
mock := &MockGitilesClient{ctrl: ctrl}
mock.recorder = &MockGitilesClientMockRecorder{mock}
return mock
} | [
"func",
"NewMockGitilesClient",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockGitilesClient",
"{",
"mock",
":=",
"&",
"MockGitilesClient",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockGitilesClientMockRecorder",
... | // NewMockGitilesClient creates a new mock instance | [
"NewMockGitilesClient",
"creates",
"a",
"new",
"mock",
"instance"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/proto/gitiles/gitiles.mock.pb.go#L26-L30 |
129,762 | luci/luci-go | common/proto/gitiles/gitiles.mock.pb.go | NewMockGitilesServer | func NewMockGitilesServer(ctrl *gomock.Controller) *MockGitilesServer {
mock := &MockGitilesServer{ctrl: ctrl}
mock.recorder = &MockGitilesServerMockRecorder{mock}
return mock
} | go | func NewMockGitilesServer(ctrl *gomock.Controller) *MockGitilesServer {
mock := &MockGitilesServer{ctrl: ctrl}
mock.recorder = &MockGitilesServerMockRecorder{mock}
return mock
} | [
"func",
"NewMockGitilesServer",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockGitilesServer",
"{",
"mock",
":=",
"&",
"MockGitilesServer",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockGitilesServerMockRecorder",
... | // NewMockGitilesServer creates a new mock instance | [
"NewMockGitilesServer",
"creates",
"a",
"new",
"mock",
"instance"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/proto/gitiles/gitiles.mock.pb.go#L103-L107 |
129,763 | luci/luci-go | client/flagpb/unmarshal.go | UnmarshalUntyped | func UnmarshalUntyped(flags []string, desc *descriptor.DescriptorProto, resolver Resolver) (map[string]interface{}, error) {
p := parser{resolver}
return p.parse(flags, desc)
} | go | func UnmarshalUntyped(flags []string, desc *descriptor.DescriptorProto, resolver Resolver) (map[string]interface{}, error) {
p := parser{resolver}
return p.parse(flags, desc)
} | [
"func",
"UnmarshalUntyped",
"(",
"flags",
"[",
"]",
"string",
",",
"desc",
"*",
"descriptor",
".",
"DescriptorProto",
",",
"resolver",
"Resolver",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"p",
":=",
"parser",
... | // UnmarshalUntyped unmarshals a key-value map from flags
// using a protobuf message descriptor. | [
"UnmarshalUntyped",
"unmarshals",
"a",
"key",
"-",
"value",
"map",
"from",
"flags",
"using",
"a",
"protobuf",
"message",
"descriptor",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/flagpb/unmarshal.go#L62-L65 |
129,764 | luci/luci-go | client/flagpb/unmarshal.go | splitKeyValuePair | func (p *parser) splitKeyValuePair(s string) (key, value string, hasValue bool) {
parts := strings.SplitN(s, "=", 2)
switch len(parts) {
case 1:
key = s
case 2:
key = parts[0]
value = parts[1]
hasValue = true
}
return
} | go | func (p *parser) splitKeyValuePair(s string) (key, value string, hasValue bool) {
parts := strings.SplitN(s, "=", 2)
switch len(parts) {
case 1:
key = s
case 2:
key = parts[0]
value = parts[1]
hasValue = true
}
return
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"splitKeyValuePair",
"(",
"s",
"string",
")",
"(",
"key",
",",
"value",
"string",
",",
"hasValue",
"bool",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"s",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"s... | // splitKeyValuePair splits a key value pair key=value if there is equals sign. | [
"splitKeyValuePair",
"splits",
"a",
"key",
"value",
"pair",
"key",
"=",
"value",
"if",
"there",
"is",
"equals",
"sign",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/flagpb/unmarshal.go#L361-L372 |
129,765 | luci/luci-go | client/flagpb/unmarshal.go | parseEnum | func parseEnum(enum *descriptor.EnumDescriptorProto, member string) (int32, error) {
i := descutil.FindEnumValue(enum, member)
if i < 0 {
// Is member the number?
if number, err := strconv.ParseInt(member, 10, 32); err == nil {
i = descutil.FindValueByNumber(enum, int32(number))
}
}
if i < 0 {
return 0, ... | go | func parseEnum(enum *descriptor.EnumDescriptorProto, member string) (int32, error) {
i := descutil.FindEnumValue(enum, member)
if i < 0 {
// Is member the number?
if number, err := strconv.ParseInt(member, 10, 32); err == nil {
i = descutil.FindValueByNumber(enum, int32(number))
}
}
if i < 0 {
return 0, ... | [
"func",
"parseEnum",
"(",
"enum",
"*",
"descriptor",
".",
"EnumDescriptorProto",
",",
"member",
"string",
")",
"(",
"int32",
",",
"error",
")",
"{",
"i",
":=",
"descutil",
".",
"FindEnumValue",
"(",
"enum",
",",
"member",
")",
"\n",
"if",
"i",
"<",
"0"... | // parseEnum returns the number of an enum member, which can be name or number. | [
"parseEnum",
"returns",
"the",
"number",
"of",
"an",
"enum",
"member",
"which",
"can",
"be",
"name",
"or",
"number",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/flagpb/unmarshal.go#L375-L387 |
129,766 | luci/luci-go | buildbucket/cli/log.go | getSteps | func (r *logRun) getSteps(ctx context.Context) ([]*pb.Step, error) {
r.getBuild.Fields = &field_mask.FieldMask{Paths: []string{"steps"}}
build, err := r.client.GetBuild(ctx, r.getBuild, prpc.ExpectedCode(codes.NotFound))
switch status.Code(err) {
case codes.OK:
return build.Steps, nil
case codes.NotFound:
retu... | go | func (r *logRun) getSteps(ctx context.Context) ([]*pb.Step, error) {
r.getBuild.Fields = &field_mask.FieldMask{Paths: []string{"steps"}}
build, err := r.client.GetBuild(ctx, r.getBuild, prpc.ExpectedCode(codes.NotFound))
switch status.Code(err) {
case codes.OK:
return build.Steps, nil
case codes.NotFound:
retu... | [
"func",
"(",
"r",
"*",
"logRun",
")",
"getSteps",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"*",
"pb",
".",
"Step",
",",
"error",
")",
"{",
"r",
".",
"getBuild",
".",
"Fields",
"=",
"&",
"field_mask",
".",
"FieldMask",
"{",
"Path... | // getSteps fetches steps of the build. | [
"getSteps",
"fetches",
"steps",
"of",
"the",
"build",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/log.go#L161-L172 |
129,767 | luci/luci-go | buildbucket/cli/log.go | Next | func (m *logMultiplexer) Next() (chanIndex int, log *logpb.LogEntry, err error) {
if m.heads == nil {
// initialization
m.heads = make([]logAndErr, len(m.Chans))
for i := range m.heads {
m.heads[i] = <-m.Chans[i].c
}
}
// Choose the earliest one.
// Note: using heap is overkill here.
// Most of the tim... | go | func (m *logMultiplexer) Next() (chanIndex int, log *logpb.LogEntry, err error) {
if m.heads == nil {
// initialization
m.heads = make([]logAndErr, len(m.Chans))
for i := range m.heads {
m.heads[i] = <-m.Chans[i].c
}
}
// Choose the earliest one.
// Note: using heap is overkill here.
// Most of the tim... | [
"func",
"(",
"m",
"*",
"logMultiplexer",
")",
"Next",
"(",
")",
"(",
"chanIndex",
"int",
",",
"log",
"*",
"logpb",
".",
"LogEntry",
",",
"err",
"error",
")",
"{",
"if",
"m",
".",
"heads",
"==",
"nil",
"{",
"// initialization",
"m",
".",
"heads",
"=... | // Next returns the next log entry.
// Returns io.EOF if there is no next log entry. | [
"Next",
"returns",
"the",
"next",
"log",
"entry",
".",
"Returns",
"io",
".",
"EOF",
"if",
"there",
"is",
"no",
"next",
"log",
"entry",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/log.go#L287-L336 |
129,768 | luci/luci-go | scheduler/appengine/engine/controller.go | controllerForInvocation | func controllerForInvocation(c context.Context, e *engineImpl, inv *Invocation) (*taskController, error) {
ctl := &taskController{
ctx: c,
eng: e,
saved: *inv,
}
var err error
if ctl.task, err = e.cfg.Catalog.UnmarshalTask(c, inv.Task); err != nil {
return ctl, fmt.Errorf("failed to unmarshal the task -... | go | func controllerForInvocation(c context.Context, e *engineImpl, inv *Invocation) (*taskController, error) {
ctl := &taskController{
ctx: c,
eng: e,
saved: *inv,
}
var err error
if ctl.task, err = e.cfg.Catalog.UnmarshalTask(c, inv.Task); err != nil {
return ctl, fmt.Errorf("failed to unmarshal the task -... | [
"func",
"controllerForInvocation",
"(",
"c",
"context",
".",
"Context",
",",
"e",
"*",
"engineImpl",
",",
"inv",
"*",
"Invocation",
")",
"(",
"*",
"taskController",
",",
"error",
")",
"{",
"ctl",
":=",
"&",
"taskController",
"{",
"ctx",
":",
"c",
",",
... | // controllerForInvocation returns new instance of taskController configured
// to work with given invocation.
//
// If task definition can't be deserialized, returns both controller and error. | [
"controllerForInvocation",
"returns",
"new",
"instance",
"of",
"taskController",
"configured",
"to",
"work",
"with",
"given",
"invocation",
".",
"If",
"task",
"definition",
"can",
"t",
"be",
"deserialized",
"returns",
"both",
"controller",
"and",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/controller.go#L88-L108 |
129,769 | luci/luci-go | scheduler/appengine/engine/controller.go | populateState | func (ctl *taskController) populateState() error {
ctl.state = task.State{
Status: ctl.saved.Status,
ViewURL: ctl.saved.ViewURL,
TaskData: append([]byte(nil), ctl.saved.TaskData...), // copy
}
return nil
} | go | func (ctl *taskController) populateState() error {
ctl.state = task.State{
Status: ctl.saved.Status,
ViewURL: ctl.saved.ViewURL,
TaskData: append([]byte(nil), ctl.saved.TaskData...), // copy
}
return nil
} | [
"func",
"(",
"ctl",
"*",
"taskController",
")",
"populateState",
"(",
")",
"error",
"{",
"ctl",
".",
"state",
"=",
"task",
".",
"State",
"{",
"Status",
":",
"ctl",
".",
"saved",
".",
"Status",
",",
"ViewURL",
":",
"ctl",
".",
"saved",
".",
"ViewURL",... | // populateState populates 'state' using data in 'saved'. | [
"populateState",
"populates",
"state",
"using",
"data",
"in",
"saved",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/controller.go#L111-L118 |
129,770 | luci/luci-go | scheduler/appengine/engine/controller.go | DebugLog | func (ctl *taskController) DebugLog(format string, args ...interface{}) {
logging.Infof(ctl.ctx, format, args...)
debugLog(ctl.ctx, &ctl.debugLog, format, args...)
} | go | func (ctl *taskController) DebugLog(format string, args ...interface{}) {
logging.Infof(ctl.ctx, format, args...)
debugLog(ctl.ctx, &ctl.debugLog, format, args...)
} | [
"func",
"(",
"ctl",
"*",
"taskController",
")",
"DebugLog",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logging",
".",
"Infof",
"(",
"ctl",
".",
"ctx",
",",
"format",
",",
"args",
"...",
")",
"\n",
"debugLog",
"(",
... | // DebugLog is part of task.Controller interface. | [
"DebugLog",
"is",
"part",
"of",
"task",
".",
"Controller",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/controller.go#L174-L177 |
129,771 | luci/luci-go | scheduler/appengine/engine/controller.go | AddTimer | func (ctl *taskController) AddTimer(ctx context.Context, delay time.Duration, title string, payload []byte) {
// ID for the new timer. It is guaranteed to be unique when we land the
// transaction because all ctl.saved modifications are serialized in time (see
// MutationsCount checks in Save), and we include serial... | go | func (ctl *taskController) AddTimer(ctx context.Context, delay time.Duration, title string, payload []byte) {
// ID for the new timer. It is guaranteed to be unique when we land the
// transaction because all ctl.saved modifications are serialized in time (see
// MutationsCount checks in Save), and we include serial... | [
"func",
"(",
"ctl",
"*",
"taskController",
")",
"AddTimer",
"(",
"ctx",
"context",
".",
"Context",
",",
"delay",
"time",
".",
"Duration",
",",
"title",
"string",
",",
"payload",
"[",
"]",
"byte",
")",
"{",
"// ID for the new timer. It is guaranteed to be unique ... | // AddTimer is part of Controller interface. | [
"AddTimer",
"is",
"part",
"of",
"Controller",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/controller.go#L180-L202 |
129,772 | luci/luci-go | scheduler/appengine/engine/controller.go | PrepareTopic | func (ctl *taskController) PrepareTopic(ctx context.Context, publisher string) (topic string, token string, err error) {
return ctl.eng.prepareTopic(ctx, &topicParams{
jobID: ctl.JobID(),
invID: ctl.InvocationID(),
manager: ctl.manager,
publisher: publisher,
})
} | go | func (ctl *taskController) PrepareTopic(ctx context.Context, publisher string) (topic string, token string, err error) {
return ctl.eng.prepareTopic(ctx, &topicParams{
jobID: ctl.JobID(),
invID: ctl.InvocationID(),
manager: ctl.manager,
publisher: publisher,
})
} | [
"func",
"(",
"ctl",
"*",
"taskController",
")",
"PrepareTopic",
"(",
"ctx",
"context",
".",
"Context",
",",
"publisher",
"string",
")",
"(",
"topic",
"string",
",",
"token",
"string",
",",
"err",
"error",
")",
"{",
"return",
"ctl",
".",
"eng",
".",
"pr... | // PrepareTopic is part of task.Controller interface. | [
"PrepareTopic",
"is",
"part",
"of",
"task",
".",
"Controller",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/controller.go#L205-L212 |
129,773 | luci/luci-go | scheduler/appengine/engine/controller.go | GetClient | func (ctl *taskController) GetClient(ctx context.Context, opts ...auth.RPCOption) (*http.Client, error) {
opts = append(opts, auth.WithProject(ctl.saved.GetProjectID()))
t, err := auth.GetRPCTransport(ctx, auth.AsProject, opts...)
if err != nil {
return nil, err
}
return &http.Client{Transport: t}, nil
} | go | func (ctl *taskController) GetClient(ctx context.Context, opts ...auth.RPCOption) (*http.Client, error) {
opts = append(opts, auth.WithProject(ctl.saved.GetProjectID()))
t, err := auth.GetRPCTransport(ctx, auth.AsProject, opts...)
if err != nil {
return nil, err
}
return &http.Client{Transport: t}, nil
} | [
"func",
"(",
"ctl",
"*",
"taskController",
")",
"GetClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"...",
"auth",
".",
"RPCOption",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"opts",
"=",
"append",
"(",
"opts",
",",
... | // GetClient is part of task.Controller interface | [
"GetClient",
"is",
"part",
"of",
"task",
".",
"Controller",
"interface"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/controller.go#L215-L222 |
129,774 | luci/luci-go | scheduler/appengine/engine/controller.go | EmitTrigger | func (ctl *taskController) EmitTrigger(ctx context.Context, trigger *internal.Trigger) {
ctl.DebugLog("Emitting a trigger %s", trigger.Id)
trigger.JobId = ctl.JobID()
trigger.InvocationId = ctl.InvocationID()
// See docs for internal.Trigger proto. Tuple (created, order_in_batch) used
// for casual ordering of tr... | go | func (ctl *taskController) EmitTrigger(ctx context.Context, trigger *internal.Trigger) {
ctl.DebugLog("Emitting a trigger %s", trigger.Id)
trigger.JobId = ctl.JobID()
trigger.InvocationId = ctl.InvocationID()
// See docs for internal.Trigger proto. Tuple (created, order_in_batch) used
// for casual ordering of tr... | [
"func",
"(",
"ctl",
"*",
"taskController",
")",
"EmitTrigger",
"(",
"ctx",
"context",
".",
"Context",
",",
"trigger",
"*",
"internal",
".",
"Trigger",
")",
"{",
"ctl",
".",
"DebugLog",
"(",
"\"",
"\"",
",",
"trigger",
".",
"Id",
")",
"\n",
"trigger",
... | // EmitTrigger is part of task.Controller interface. | [
"EmitTrigger",
"is",
"part",
"of",
"task",
".",
"Controller",
"interface",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/controller.go#L225-L242 |
129,775 | luci/luci-go | common/tsmon/metric/http_transport.go | RoundTrip | func (t *instrumentedHTTPRoundTripper) RoundTrip(origReq *http.Request) (*http.Response, error) {
req := *origReq
// If a request body was provided, wrap it in a CountingReader so we can see
// how big it was after it's been sent.
var requestBodyReader *iotools.CountingReader
if req.Body != nil {
requestBodyRea... | go | func (t *instrumentedHTTPRoundTripper) RoundTrip(origReq *http.Request) (*http.Response, error) {
req := *origReq
// If a request body was provided, wrap it in a CountingReader so we can see
// how big it was after it's been sent.
var requestBodyReader *iotools.CountingReader
if req.Body != nil {
requestBodyRea... | [
"func",
"(",
"t",
"*",
"instrumentedHTTPRoundTripper",
")",
"RoundTrip",
"(",
"origReq",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
":=",
"*",
"origReq",
"\n\n",
"// If a request body was provided, wrap ... | // RoundTrip implements http.RoundTripper. | [
"RoundTrip",
"implements",
"http",
".",
"RoundTripper",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/metric/http_transport.go#L38-L71 |
129,776 | luci/luci-go | logdog/server/service/config/cache.go | Get | func (mc *MessageCache) Get(c context.Context, cset config.Set, path string, msg proto.Message) (
proto.Message, error) {
// If no Lifetime is configured, bypass the cache layer.
if mc.Lifetime <= 0 {
err := mc.GetUncached(c, cset, path, msg)
return msg, err
}
key := messageCacheKey{cset, path}
// Load the... | go | func (mc *MessageCache) Get(c context.Context, cset config.Set, path string, msg proto.Message) (
proto.Message, error) {
// If no Lifetime is configured, bypass the cache layer.
if mc.Lifetime <= 0 {
err := mc.GetUncached(c, cset, path, msg)
return msg, err
}
key := messageCacheKey{cset, path}
// Load the... | [
"func",
"(",
"mc",
"*",
"MessageCache",
")",
"Get",
"(",
"c",
"context",
".",
"Context",
",",
"cset",
"config",
".",
"Set",
",",
"path",
"string",
",",
"msg",
"proto",
".",
"Message",
")",
"(",
"proto",
".",
"Message",
",",
"error",
")",
"{",
"// I... | // Get returns an unmarshalled configuration service text protobuf message.
//
// If the message is not currently in the process cache, it will be fetched from
// the config service and cached prior to being returned. | [
"Get",
"returns",
"an",
"unmarshalled",
"configuration",
"service",
"text",
"protobuf",
"message",
".",
"If",
"the",
"message",
"is",
"not",
"currently",
"in",
"the",
"process",
"cache",
"it",
"will",
"be",
"fetched",
"from",
"the",
"config",
"service",
"and",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/service/config/cache.go#L49-L76 |
129,777 | luci/luci-go | logdog/server/service/config/cache.go | GetUncached | func (mc *MessageCache) GetUncached(c context.Context, cset config.Set, path string,
msg proto.Message) error {
return cfgclient.Get(c, cfgclient.AsService, cset, path, textproto.Message(msg), nil)
} | go | func (mc *MessageCache) GetUncached(c context.Context, cset config.Set, path string,
msg proto.Message) error {
return cfgclient.Get(c, cfgclient.AsService, cset, path, textproto.Message(msg), nil)
} | [
"func",
"(",
"mc",
"*",
"MessageCache",
")",
"GetUncached",
"(",
"c",
"context",
".",
"Context",
",",
"cset",
"config",
".",
"Set",
",",
"path",
"string",
",",
"msg",
"proto",
".",
"Message",
")",
"error",
"{",
"return",
"cfgclient",
".",
"Get",
"(",
... | // GetUncached returns an unmarshalled configuration service text protobuf
// message. This bypasses the cache, and, on success, does not cache the
// resulting value. | [
"GetUncached",
"returns",
"an",
"unmarshalled",
"configuration",
"service",
"text",
"protobuf",
"message",
".",
"This",
"bypasses",
"the",
"cache",
"and",
"on",
"success",
"does",
"not",
"cache",
"the",
"resulting",
"value",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/service/config/cache.go#L81-L85 |
129,778 | luci/luci-go | logdog/common/renderer/source.go | NextLogEntry | func (s *StaticSource) NextLogEntry() (le *logpb.LogEntry, err error) {
// Pop the next entry, mutating s.
if len(*s) > 0 {
le, *s = (*s)[0], (*s)[1:]
}
if len(*s) == 0 {
err = io.EOF
}
return
} | go | func (s *StaticSource) NextLogEntry() (le *logpb.LogEntry, err error) {
// Pop the next entry, mutating s.
if len(*s) > 0 {
le, *s = (*s)[0], (*s)[1:]
}
if len(*s) == 0 {
err = io.EOF
}
return
} | [
"func",
"(",
"s",
"*",
"StaticSource",
")",
"NextLogEntry",
"(",
")",
"(",
"le",
"*",
"logpb",
".",
"LogEntry",
",",
"err",
"error",
")",
"{",
"// Pop the next entry, mutating s.",
"if",
"len",
"(",
"*",
"s",
")",
">",
"0",
"{",
"le",
",",
"*",
"s",
... | // NextLogEntry implements Source. | [
"NextLogEntry",
"implements",
"Source",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/renderer/source.go#L43-L52 |
129,779 | luci/luci-go | common/data/cmpbin/number.go | WriteInt | func WriteInt(w io.ByteWriter, val int64) (int, error) {
var inv byte
if val < 0 {
inv = 0xff
}
mag := uint64(val)
if inv != 0 {
mag = -mag
}
return writeSignMag(w, mag, inv)
} | go | func WriteInt(w io.ByteWriter, val int64) (int, error) {
var inv byte
if val < 0 {
inv = 0xff
}
mag := uint64(val)
if inv != 0 {
mag = -mag
}
return writeSignMag(w, mag, inv)
} | [
"func",
"WriteInt",
"(",
"w",
"io",
".",
"ByteWriter",
",",
"val",
"int64",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"inv",
"byte",
"\n",
"if",
"val",
"<",
"0",
"{",
"inv",
"=",
"0xff",
"\n",
"}",
"\n",
"mag",
":=",
"uint64",
"(",
"val",... | // WriteInt val as a cmpbin Int to the ByteWriter. Returns the number of bytes
// written. Only returns an error if the underlying ByteWriter returns an error. | [
"WriteInt",
"val",
"as",
"a",
"cmpbin",
"Int",
"to",
"the",
"ByteWriter",
".",
"Returns",
"the",
"number",
"of",
"bytes",
"written",
".",
"Only",
"returns",
"an",
"error",
"if",
"the",
"underlying",
"ByteWriter",
"returns",
"an",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/cmpbin/number.go#L69-L79 |
129,780 | luci/luci-go | common/data/cmpbin/number.go | WriteUint | func WriteUint(w io.ByteWriter, mag uint64) (int, error) {
return writeSignMag(w, mag, 0)
} | go | func WriteUint(w io.ByteWriter, mag uint64) (int, error) {
return writeSignMag(w, mag, 0)
} | [
"func",
"WriteUint",
"(",
"w",
"io",
".",
"ByteWriter",
",",
"mag",
"uint64",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"writeSignMag",
"(",
"w",
",",
"mag",
",",
"0",
")",
"\n",
"}"
] | // WriteUint writes mag to the ByteWriter. Returns the number of bytes written.
// Only returns an error if the underlying ByteWriter returns an error. | [
"WriteUint",
"writes",
"mag",
"to",
"the",
"ByteWriter",
".",
"Returns",
"the",
"number",
"of",
"bytes",
"written",
".",
"Only",
"returns",
"an",
"error",
"if",
"the",
"underlying",
"ByteWriter",
"returns",
"an",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/cmpbin/number.go#L83-L85 |
129,781 | luci/luci-go | server/middleware/paniccatcher.go | WithPanicCatcher | func WithPanicCatcher(c *router.Context, next router.Handler) {
ctx := c.Context
w := c.Writer
req := c.Request
defer paniccatcher.Catch(func(p *paniccatcher.Panic) {
// Log the reason before the stack in case appengine cuts entire log
// message due to size limitations.
log.Fields{
"panic.error": p.Reason... | go | func WithPanicCatcher(c *router.Context, next router.Handler) {
ctx := c.Context
w := c.Writer
req := c.Request
defer paniccatcher.Catch(func(p *paniccatcher.Panic) {
// Log the reason before the stack in case appengine cuts entire log
// message due to size limitations.
log.Fields{
"panic.error": p.Reason... | [
"func",
"WithPanicCatcher",
"(",
"c",
"*",
"router",
".",
"Context",
",",
"next",
"router",
".",
"Handler",
")",
"{",
"ctx",
":=",
"c",
".",
"Context",
"\n",
"w",
":=",
"c",
".",
"Writer",
"\n",
"req",
":=",
"c",
".",
"Request",
"\n",
"defer",
"pan... | // WithPanicCatcher is a middleware that catches panics, dumps stack trace to
// logging and returns HTTP 500. | [
"WithPanicCatcher",
"is",
"a",
"middleware",
"that",
"catches",
"panics",
"dumps",
"stack",
"trace",
"to",
"logging",
"and",
"returns",
"HTTP",
"500",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/middleware/paniccatcher.go#L27-L43 |
129,782 | luci/luci-go | common/gcloud/iam/signer.go | SignBytes | func (s *Signer) SignBytes(c context.Context, blob []byte) (string, []byte, error) {
return s.Client.SignBlob(c, s.ServiceAccount, blob)
} | go | func (s *Signer) SignBytes(c context.Context, blob []byte) (string, []byte, error) {
return s.Client.SignBlob(c, s.ServiceAccount, blob)
} | [
"func",
"(",
"s",
"*",
"Signer",
")",
"SignBytes",
"(",
"c",
"context",
".",
"Context",
",",
"blob",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"s",
".",
"Client",
".",
"SignBlob",
"(",
"c",
"... | // SignBytes signs the blob with some active private key.
//
// Hashes the blob using SHA256 and then calculates RSASSA-PKCS1-v1_5 signature
// using the currently active signing key.
//
// Returns the signature and name of the key used. | [
"SignBytes",
"signs",
"the",
"blob",
"with",
"some",
"active",
"private",
"key",
".",
"Hashes",
"the",
"blob",
"using",
"SHA256",
"and",
"then",
"calculates",
"RSASSA",
"-",
"PKCS1",
"-",
"v1_5",
"signature",
"using",
"the",
"currently",
"active",
"signing",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/iam/signer.go#L34-L36 |
129,783 | luci/luci-go | server/auth/authdb/cache.go | NewDBCache | func NewDBCache(updater DBCacheUpdater) func(c context.Context) (DB, error) {
cacheSlot := lazyslot.Slot{}
return func(c context.Context) (DB, error) {
val, err := cacheSlot.Get(c, func(prev interface{}) (db interface{}, exp time.Duration, err error) {
prevDB, _ := prev.(DB)
if db, err = updater(c, prevDB); e... | go | func NewDBCache(updater DBCacheUpdater) func(c context.Context) (DB, error) {
cacheSlot := lazyslot.Slot{}
return func(c context.Context) (DB, error) {
val, err := cacheSlot.Get(c, func(prev interface{}) (db interface{}, exp time.Duration, err error) {
prevDB, _ := prev.(DB)
if db, err = updater(c, prevDB); e... | [
"func",
"NewDBCache",
"(",
"updater",
"DBCacheUpdater",
")",
"func",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"DB",
",",
"error",
")",
"{",
"cacheSlot",
":=",
"lazyslot",
".",
"Slot",
"{",
"}",
"\n",
"return",
"func",
"(",
"c",
"context",
".",
... | // NewDBCache returns a provider of DB instances that uses local memory to
// cache DB instances for 5-10 seconds. It uses supplied callback to refetch DB
// from some permanent storage when cache expires.
//
// Even though the return value is technically a function, treat it as a heavy
// stateful object, since it has... | [
"NewDBCache",
"returns",
"a",
"provider",
"of",
"DB",
"instances",
"that",
"uses",
"local",
"memory",
"to",
"cache",
"DB",
"instances",
"for",
"5",
"-",
"10",
"seconds",
".",
"It",
"uses",
"supplied",
"callback",
"to",
"refetch",
"DB",
"from",
"some",
"per... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/authdb/cache.go#L36-L51 |
129,784 | luci/luci-go | machine-db/appengine/model/kvms.go | fetch | func (t *KVMsTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT k.id, h.id, h.name, i.ipv4, k.description, k.mac_address, k.state, k.platform_id, k.rack_id
FROM kvms k, hostnames h, ips i
WHERE k.hostname_id = h.id AND i.hostname_id = h.id
`)
if err != nil {... | go | func (t *KVMsTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT k.id, h.id, h.name, i.ipv4, k.description, k.mac_address, k.state, k.platform_id, k.rack_id
FROM kvms k, hostnames h, ips i
WHERE k.hostname_id = h.id AND i.hostname_id = h.id
`)
if err != nil {... | [
"func",
"(",
"t",
"*",
"KVMsTable",
")",
"fetch",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"db",
":=",
"database",
".",
"Get",
"(",
"c",
")",
"\n",
"rows",
",",
"err",
":=",
"db",
".",
"QueryContext",
"(",
"c",
",",
"`\n\t\tSELECT k.... | // fetch fetches the KVMs from the database. | [
"fetch",
"fetches",
"the",
"KVMs",
"from",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/kvms.go#L57-L76 |
129,785 | luci/luci-go | machine-db/appengine/model/kvms.go | computeChanges | func (t *KVMsTable) computeChanges(c context.Context, datacenters []*config.Datacenter) error {
cfgs := make(map[string]*KVM, len(datacenters))
for _, dc := range datacenters {
for _, cfg := range dc.Kvm {
ipv4, err := common.ParseIPv4(cfg.Ipv4)
if err != nil {
return errors.Reason("failed to determine IP... | go | func (t *KVMsTable) computeChanges(c context.Context, datacenters []*config.Datacenter) error {
cfgs := make(map[string]*KVM, len(datacenters))
for _, dc := range datacenters {
for _, cfg := range dc.Kvm {
ipv4, err := common.ParseIPv4(cfg.Ipv4)
if err != nil {
return errors.Reason("failed to determine IP... | [
"func",
"(",
"t",
"*",
"KVMsTable",
")",
"computeChanges",
"(",
"c",
"context",
".",
"Context",
",",
"datacenters",
"[",
"]",
"*",
"config",
".",
"Datacenter",
")",
"error",
"{",
"cfgs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"KVM",
",",
... | // computeChanges computes the changes that need to be made to the KVMs in the database. | [
"computeChanges",
"computes",
"the",
"changes",
"that",
"need",
"to",
"be",
"made",
"to",
"the",
"KVMs",
"in",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/kvms.go#L85-L145 |
129,786 | luci/luci-go | machine-db/appengine/model/kvms.go | add | func (t *KVMsTable) add(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.additions) == 0 {
return nil
}
tx, err := database.Begin(c)
if err != nil {
return errors.Annotate(err, "failed to begin transaction").Err()
}
defer tx.MaybeRollback(c)
stmt... | go | func (t *KVMsTable) add(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.additions) == 0 {
return nil
}
tx, err := database.Begin(c)
if err != nil {
return errors.Annotate(err, "failed to begin transaction").Err()
}
defer tx.MaybeRollback(c)
stmt... | [
"func",
"(",
"t",
"*",
"KVMsTable",
")",
"add",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"additions",
")",
"==",
"0",
"{",
"return",
"nil",
... | // add adds all KVMs pending addition to the database, clearing pending additions.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"add",
"adds",
"all",
"KVMs",
"pending",
"addition",
"to",
"the",
"database",
"clearing",
"pending",
"additions",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",
"again",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/kvms.go#L149-L193 |
129,787 | luci/luci-go | machine-db/appengine/model/kvms.go | remove | func (t *KVMsTable) remove(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.removals) == 0 {
return nil
}
db := database.Get(c)
// By setting kvms.hostname_id ON DELETE CASCADE when setting up the database, we can avoid
// having to explicitly delete... | go | func (t *KVMsTable) remove(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.removals) == 0 {
return nil
}
db := database.Get(c)
// By setting kvms.hostname_id ON DELETE CASCADE when setting up the database, we can avoid
// having to explicitly delete... | [
"func",
"(",
"t",
"*",
"KVMsTable",
")",
"remove",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"removals",
")",
"==",
"0",
"{",
"return",
"nil",
... | // remove removes all KVMs pending removal from the database, clearing pending removals.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"remove",
"removes",
"all",
"KVMs",
"pending",
"removal",
"from",
"the",
"database",
"clearing",
"pending",
"removals",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",
"aga... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/kvms.go#L197-L238 |
129,788 | luci/luci-go | machine-db/appengine/model/kvms.go | update | func (t *KVMsTable) update(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.updates) == 0 {
return nil
}
db := database.Get(c)
// TODO(smut): Update IP address.
stmt, err := db.PrepareContext(c, `
UPDATE kvms
SET description = ?, mac_address = ?,... | go | func (t *KVMsTable) update(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.updates) == 0 {
return nil
}
db := database.Get(c)
// TODO(smut): Update IP address.
stmt, err := db.PrepareContext(c, `
UPDATE kvms
SET description = ?, mac_address = ?,... | [
"func",
"(",
"t",
"*",
"KVMsTable",
")",
"update",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"updates",
")",
"==",
"0",
"{",
"return",
"nil",
... | // update updates all KVMs pending update in the database, clearing pending updates.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"update",
"updates",
"all",
"KVMs",
"pending",
"update",
"in",
"the",
"database",
"clearing",
"pending",
"updates",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",
"again",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/kvms.go#L242-L284 |
129,789 | luci/luci-go | machine-db/appengine/model/kvms.go | ids | func (t *KVMsTable) ids(c context.Context) map[string]int64 {
KVMs := make(map[string]int64, len(t.current))
for _, s := range t.current {
KVMs[s.Name] = s.Id
}
return KVMs
} | go | func (t *KVMsTable) ids(c context.Context) map[string]int64 {
KVMs := make(map[string]int64, len(t.current))
for _, s := range t.current {
KVMs[s.Name] = s.Id
}
return KVMs
} | [
"func",
"(",
"t",
"*",
"KVMsTable",
")",
"ids",
"(",
"c",
"context",
".",
"Context",
")",
"map",
"[",
"string",
"]",
"int64",
"{",
"KVMs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int64",
",",
"len",
"(",
"t",
".",
"current",
")",
")",
"\... | // ids returns a map of KVM names to IDs. | [
"ids",
"returns",
"a",
"map",
"of",
"KVM",
"names",
"to",
"IDs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/kvms.go#L287-L293 |
129,790 | luci/luci-go | machine-db/appengine/model/kvms.go | EnsureKVMs | func EnsureKVMs(c context.Context, cfgs []*config.Datacenter, platformIds, rackIds map[string]int64) (map[string]int64, error) {
t := &KVMsTable{}
t.platforms = platformIds
t.racks = rackIds
if err := t.fetch(c); err != nil {
return nil, errors.Annotate(err, "failed to fetch KVMs").Err()
}
if err := t.computeCh... | go | func EnsureKVMs(c context.Context, cfgs []*config.Datacenter, platformIds, rackIds map[string]int64) (map[string]int64, error) {
t := &KVMsTable{}
t.platforms = platformIds
t.racks = rackIds
if err := t.fetch(c); err != nil {
return nil, errors.Annotate(err, "failed to fetch KVMs").Err()
}
if err := t.computeCh... | [
"func",
"EnsureKVMs",
"(",
"c",
"context",
".",
"Context",
",",
"cfgs",
"[",
"]",
"*",
"config",
".",
"Datacenter",
",",
"platformIds",
",",
"rackIds",
"map",
"[",
"string",
"]",
"int64",
")",
"(",
"map",
"[",
"string",
"]",
"int64",
",",
"error",
")... | // EnsureKVMs ensures the database contains exactly the given KVMs.
// Returns a map of KVM names to IDs in the database. | [
"EnsureKVMs",
"ensures",
"the",
"database",
"contains",
"exactly",
"the",
"given",
"KVMs",
".",
"Returns",
"a",
"map",
"of",
"KVM",
"names",
"to",
"IDs",
"in",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/kvms.go#L297-L317 |
129,791 | luci/luci-go | milo/buildsource/buildbot/buildstore/encoding.go | encode | func encode(src interface{}) ([]byte, error) {
jsoninsh, err := json.Marshal(src)
if err != nil {
return nil, err
}
var buf bytes.Buffer
gsw := gzip.NewWriter(&buf)
_, err = gsw.Write(jsoninsh)
if err != nil {
return nil, err
}
err = gsw.Close()
if err != nil {
return nil, err
}
return buf.Bytes(), n... | go | func encode(src interface{}) ([]byte, error) {
jsoninsh, err := json.Marshal(src)
if err != nil {
return nil, err
}
var buf bytes.Buffer
gsw := gzip.NewWriter(&buf)
_, err = gsw.Write(jsoninsh)
if err != nil {
return nil, err
}
err = gsw.Close()
if err != nil {
return nil, err
}
return buf.Bytes(), n... | [
"func",
"encode",
"(",
"src",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"jsoninsh",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\... | // encode marshals src to JSON and compresses it. | [
"encode",
"marshals",
"src",
"to",
"JSON",
"and",
"compresses",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/encoding.go#L24-L41 |
129,792 | luci/luci-go | milo/buildsource/buildbot/buildstore/encoding.go | decode | func decode(dest interface{}, data []byte) error {
reader, err := gzip.NewReader(bytes.NewReader(data))
if err != nil {
return err
}
err = json.NewDecoder(reader).Decode(dest)
if err != nil {
return err
}
return reader.Close()
} | go | func decode(dest interface{}, data []byte) error {
reader, err := gzip.NewReader(bytes.NewReader(data))
if err != nil {
return err
}
err = json.NewDecoder(reader).Decode(dest)
if err != nil {
return err
}
return reader.Close()
} | [
"func",
"decode",
"(",
"dest",
"interface",
"{",
"}",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"reader",
",",
"err",
":=",
"gzip",
".",
"NewReader",
"(",
"bytes",
".",
"NewReader",
"(",
"data",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // decode decompresses data and unmarshals into dest as JSON. | [
"decode",
"decompresses",
"data",
"and",
"unmarshals",
"into",
"dest",
"as",
"JSON",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/buildstore/encoding.go#L44-L54 |
129,793 | luci/luci-go | lucicfg/docgen/ast/parser.go | ParseModule | func ParseModule(filename, body string) (*Module, error) {
ast, err := syntax.Parse(filename, body, syntax.RetainComments)
if err != nil {
return nil, err
}
m := &Module{docstring: extractDocstring(ast.Stmts)}
m.populateFromAST(filename, ast)
// emit adds a node to the module.
emit := func(name string, ast s... | go | func ParseModule(filename, body string) (*Module, error) {
ast, err := syntax.Parse(filename, body, syntax.RetainComments)
if err != nil {
return nil, err
}
m := &Module{docstring: extractDocstring(ast.Stmts)}
m.populateFromAST(filename, ast)
// emit adds a node to the module.
emit := func(name string, ast s... | [
"func",
"ParseModule",
"(",
"filename",
",",
"body",
"string",
")",
"(",
"*",
"Module",
",",
"error",
")",
"{",
"ast",
",",
"err",
":=",
"syntax",
".",
"Parse",
"(",
"filename",
",",
"body",
",",
"syntax",
".",
"RetainComments",
")",
"\n",
"if",
"err... | // ParseModule parses a single Starlark module.
//
// Filename is only used when recording position information. | [
"ParseModule",
"parses",
"a",
"single",
"Starlark",
"module",
".",
"Filename",
"is",
"only",
"used",
"when",
"recording",
"position",
"information",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/docgen/ast/parser.go#L207-L259 |
129,794 | luci/luci-go | lucicfg/docgen/ast/parser.go | extractDocstring | func extractDocstring(body []syntax.Stmt) string {
if len(body) == 0 {
return ""
}
expr, ok := body[0].(*syntax.ExprStmt)
if !ok {
return ""
}
literal, ok := expr.X.(*syntax.Literal)
if !ok || literal.Token != syntax.STRING {
return ""
}
return literal.Value.(string)
} | go | func extractDocstring(body []syntax.Stmt) string {
if len(body) == 0 {
return ""
}
expr, ok := body[0].(*syntax.ExprStmt)
if !ok {
return ""
}
literal, ok := expr.X.(*syntax.Literal)
if !ok || literal.Token != syntax.STRING {
return ""
}
return literal.Value.(string)
} | [
"func",
"extractDocstring",
"(",
"body",
"[",
"]",
"syntax",
".",
"Stmt",
")",
"string",
"{",
"if",
"len",
"(",
"body",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"expr",
",",
"ok",
":=",
"body",
"[",
"0",
"]",
".",
"(",
"*",
... | // extractDocstring returns a doc string for the given body.
//
// A docstring is a string literal that comes first in the body, if any. | [
"extractDocstring",
"returns",
"a",
"doc",
"string",
"for",
"the",
"given",
"body",
".",
"A",
"docstring",
"is",
"a",
"string",
"literal",
"that",
"comes",
"first",
"in",
"the",
"body",
"if",
"any",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/docgen/ast/parser.go#L310-L323 |
129,795 | luci/luci-go | milo/buildsource/buildbucket/pools.go | processBuilders | func processBuilders(c context.Context, r *swarmbucketAPI.LegacySwarmbucketApiGetBuildersResponseMessage) ([]model.PoolDescriptor, error) {
var builderPools []model.BuilderPool
var descriptors []model.PoolDescriptor
seen := stringset.New(0)
for _, bucket := range r.Buckets {
for _, builder := range bucket.Builder... | go | func processBuilders(c context.Context, r *swarmbucketAPI.LegacySwarmbucketApiGetBuildersResponseMessage) ([]model.PoolDescriptor, error) {
var builderPools []model.BuilderPool
var descriptors []model.PoolDescriptor
seen := stringset.New(0)
for _, bucket := range r.Buckets {
for _, builder := range bucket.Builder... | [
"func",
"processBuilders",
"(",
"c",
"context",
".",
"Context",
",",
"r",
"*",
"swarmbucketAPI",
".",
"LegacySwarmbucketApiGetBuildersResponseMessage",
")",
"(",
"[",
"]",
"model",
".",
"PoolDescriptor",
",",
"error",
")",
"{",
"var",
"builderPools",
"[",
"]",
... | // processBuilders parses out all of the builder pools from the Swarmbucket get_builders response,
// and saves the BuilderPool information into the datastore.
// It returns a list of PoolDescriptors that needs to be fetched and saved. | [
"processBuilders",
"parses",
"out",
"all",
"of",
"the",
"builder",
"pools",
"from",
"the",
"Swarmbucket",
"get_builders",
"response",
"and",
"saves",
"the",
"BuilderPool",
"information",
"into",
"the",
"datastore",
".",
"It",
"returns",
"a",
"list",
"of",
"PoolD... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/pools.go#L80-L107 |
129,796 | luci/luci-go | milo/buildsource/buildbucket/pools.go | processBot | func processBot(c context.Context, desc model.PoolDescriptor) error {
t, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
return err
}
sc, err := swarmingAPI.New(&http.Client{Transport: t})
if err != nil {
return err
}
sc.BasePath = fmt.Sprintf("https://%s/_ah/api/swarming/v1/", desc.Host())
var... | go | func processBot(c context.Context, desc model.PoolDescriptor) error {
t, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
return err
}
sc, err := swarmingAPI.New(&http.Client{Transport: t})
if err != nil {
return err
}
sc.BasePath = fmt.Sprintf("https://%s/_ah/api/swarming/v1/", desc.Host())
var... | [
"func",
"processBot",
"(",
"c",
"context",
".",
"Context",
",",
"desc",
"model",
".",
"PoolDescriptor",
")",
"error",
"{",
"t",
",",
"err",
":=",
"auth",
".",
"GetRPCTransport",
"(",
"c",
",",
"auth",
".",
"AsSelf",
")",
"\n",
"if",
"err",
"!=",
"nil... | // processBot retrieves the Bot pool details from Swarming for a given set of
// dimensions for its respective Swarming host, and saves the data into datastore. | [
"processBot",
"retrieves",
"the",
"Bot",
"pool",
"details",
"from",
"Swarming",
"for",
"a",
"given",
"set",
"of",
"dimensions",
"for",
"its",
"respective",
"Swarming",
"host",
"and",
"saves",
"the",
"data",
"into",
"datastore",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/pools.go#L139-L189 |
129,797 | luci/luci-go | common/clock/timer.go | Incomplete | func (tr TimerResult) Incomplete() bool {
switch tr.Err {
case nil:
return false
case context.Canceled, context.DeadlineExceeded:
return true
default:
panic(fmt.Errorf("unknown TimerResult error value: %v", tr.Err))
}
} | go | func (tr TimerResult) Incomplete() bool {
switch tr.Err {
case nil:
return false
case context.Canceled, context.DeadlineExceeded:
return true
default:
panic(fmt.Errorf("unknown TimerResult error value: %v", tr.Err))
}
} | [
"func",
"(",
"tr",
"TimerResult",
")",
"Incomplete",
"(",
")",
"bool",
"{",
"switch",
"tr",
".",
"Err",
"{",
"case",
"nil",
":",
"return",
"false",
"\n",
"case",
"context",
".",
"Canceled",
",",
"context",
".",
"DeadlineExceeded",
":",
"return",
"true",
... | // Incomplete will return true if the timer result indicates that the timer
// operation was canceled prematurely due to Context cancellation or deadline
// expiration. | [
"Incomplete",
"will",
"return",
"true",
"if",
"the",
"timer",
"result",
"indicates",
"that",
"the",
"timer",
"operation",
"was",
"canceled",
"prematurely",
"due",
"to",
"Context",
"cancellation",
"or",
"deadline",
"expiration",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/clock/timer.go#L68-L77 |
129,798 | luci/luci-go | common/data/bit_field/bf.go | MarshalBinary | func (bf *BitField) MarshalBinary() ([]byte, error) {
ret := make([]byte, binary.MaxVarintLen32+len(bf.data))
n := binary.PutUvarint(ret, uint64(bf.size))
n += copy(ret[n:], bf.data)
return ret[:n], nil
} | go | func (bf *BitField) MarshalBinary() ([]byte, error) {
ret := make([]byte, binary.MaxVarintLen32+len(bf.data))
n := binary.PutUvarint(ret, uint64(bf.size))
n += copy(ret[n:], bf.data)
return ret[:n], nil
} | [
"func",
"(",
"bf",
"*",
"BitField",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"binary",
".",
"MaxVarintLen32",
"+",
"len",
"(",
"bf",
".",
"data",
")",
")",
"... | // MarshalBinary implements encoding.BinaryMarshaller | [
"MarshalBinary",
"implements",
"encoding",
".",
"BinaryMarshaller"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/bit_field/bf.go#L50-L55 |
129,799 | luci/luci-go | common/data/bit_field/bf.go | UnmarshalBinary | func (bf *BitField) UnmarshalBinary(bs []byte) error {
buf := bytes.NewBuffer(bs)
n, err := binary.ReadUvarint(buf)
if err != nil {
return err
}
if n > math.MaxUint32 {
return fmt.Errorf("encoded number is out of range: %d > %d", n, uint32(math.MaxUint32))
}
size := uint32(n)
if size == 0 {
bf.size = 0
... | go | func (bf *BitField) UnmarshalBinary(bs []byte) error {
buf := bytes.NewBuffer(bs)
n, err := binary.ReadUvarint(buf)
if err != nil {
return err
}
if n > math.MaxUint32 {
return fmt.Errorf("encoded number is out of range: %d > %d", n, uint32(math.MaxUint32))
}
size := uint32(n)
if size == 0 {
bf.size = 0
... | [
"func",
"(",
"bf",
"*",
"BitField",
")",
"UnmarshalBinary",
"(",
"bs",
"[",
"]",
"byte",
")",
"error",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"bs",
")",
"\n",
"n",
",",
"err",
":=",
"binary",
".",
"ReadUvarint",
"(",
"buf",
")",
"\n",
... | // UnmarshalBinary implements encoding.BinaryUnmarshaler | [
"UnmarshalBinary",
"implements",
"encoding",
".",
"BinaryUnmarshaler"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/bit_field/bf.go#L58-L82 |
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.