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,300 | luci/luci-go | lucicfg/state.go | clear | func (s *State) clear() {
*s = State{Inputs: s.Inputs, vars: s.vars}
s.vars.ClearValues()
} | go | func (s *State) clear() {
*s = State{Inputs: s.Inputs, vars: s.vars}
s.vars.ClearValues()
} | [
"func",
"(",
"s",
"*",
"State",
")",
"clear",
"(",
")",
"{",
"*",
"s",
"=",
"State",
"{",
"Inputs",
":",
"s",
".",
"Inputs",
",",
"vars",
":",
"s",
".",
"vars",
"}",
"\n",
"s",
".",
"vars",
".",
"ClearValues",
"(",
")",
"\n",
"}"
] | // clear resets the state. | [
"clear",
"resets",
"the",
"state",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/state.go#L55-L58 |
129,301 | luci/luci-go | lucicfg/state.go | err | func (s *State) err(err ...error) error {
if s.seenErrs == nil {
s.seenErrs = stringset.New(len(err))
}
for _, e := range err {
if bt, _ := e.(BacktracableError); bt == nil || s.seenErrs.Add(bt.Backtrace()) {
s.errors = append(s.errors, e)
}
}
return s.errors
} | go | func (s *State) err(err ...error) error {
if s.seenErrs == nil {
s.seenErrs = stringset.New(len(err))
}
for _, e := range err {
if bt, _ := e.(BacktracableError); bt == nil || s.seenErrs.Add(bt.Backtrace()) {
s.errors = append(s.errors, e)
}
}
return s.errors
} | [
"func",
"(",
"s",
"*",
"State",
")",
"err",
"(",
"err",
"...",
"error",
")",
"error",
"{",
"if",
"s",
".",
"seenErrs",
"==",
"nil",
"{",
"s",
".",
"seenErrs",
"=",
"stringset",
".",
"New",
"(",
"len",
"(",
"err",
")",
")",
"\n",
"}",
"\n",
"f... | // err adds errors to the list of errors and returns the list as MultiError,
// deduplicating errors with identical backtraces. | [
"err",
"adds",
"errors",
"to",
"the",
"list",
"of",
"errors",
"and",
"returns",
"the",
"list",
"as",
"MultiError",
"deduplicating",
"errors",
"with",
"identical",
"backtraces",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/state.go#L62-L72 |
129,302 | luci/luci-go | tokenserver/appengine/impl/certchecker/rpc_check_certificate.go | CheckCertificate | func (r *CheckCertificateRPC) CheckCertificate(c context.Context, req *admin.CheckCertificateRequest) (*admin.CheckCertificateResponse, error) {
// Deserialize the cert.
der, err := utils.ParsePEM(req.CertPem, "CERTIFICATE")
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "can't parse 'cert_pem' -... | go | func (r *CheckCertificateRPC) CheckCertificate(c context.Context, req *admin.CheckCertificateRequest) (*admin.CheckCertificateResponse, error) {
// Deserialize the cert.
der, err := utils.ParsePEM(req.CertPem, "CERTIFICATE")
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "can't parse 'cert_pem' -... | [
"func",
"(",
"r",
"*",
"CheckCertificateRPC",
")",
"CheckCertificate",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"admin",
".",
"CheckCertificateRequest",
")",
"(",
"*",
"admin",
".",
"CheckCertificateResponse",
",",
"error",
")",
"{",
"// Deseriali... | // CheckCertificate says whether a certificate is valid or not. | [
"CheckCertificate",
"says",
"whether",
"a",
"certificate",
"is",
"valid",
"or",
"not",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certchecker/rpc_check_certificate.go#L34-L65 |
129,303 | luci/luci-go | common/data/text/sanitizehtml/sanitize.go | p | func (s *sanitizer) p(safeMarkup string) {
if s.err == nil {
_, s.err = s.sw.WriteString(safeMarkup)
}
} | go | func (s *sanitizer) p(safeMarkup string) {
if s.err == nil {
_, s.err = s.sw.WriteString(safeMarkup)
}
} | [
"func",
"(",
"s",
"*",
"sanitizer",
")",
"p",
"(",
"safeMarkup",
"string",
")",
"{",
"if",
"s",
".",
"err",
"==",
"nil",
"{",
"_",
",",
"s",
".",
"err",
"=",
"s",
".",
"sw",
".",
"WriteString",
"(",
"safeMarkup",
")",
"\n",
"}",
"\n",
"}"
] | // p prints the text, unless there was an error before. | [
"p",
"prints",
"the",
"text",
"unless",
"there",
"was",
"an",
"error",
"before",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/sanitizehtml/sanitize.go#L58-L62 |
129,304 | luci/luci-go | common/data/text/sanitizehtml/sanitize.go | printAttr | func (s *sanitizer) printAttr(key, value string) {
s.p(" ")
s.p(key)
s.p("=\"")
s.p(html.EscapeString(value))
s.p("\"")
} | go | func (s *sanitizer) printAttr(key, value string) {
s.p(" ")
s.p(key)
s.p("=\"")
s.p(html.EscapeString(value))
s.p("\"")
} | [
"func",
"(",
"s",
"*",
"sanitizer",
")",
"printAttr",
"(",
"key",
",",
"value",
"string",
")",
"{",
"s",
".",
"p",
"(",
"\"",
"\"",
")",
"\n",
"s",
".",
"p",
"(",
"key",
")",
"\n",
"s",
".",
"p",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"s",
"... | // printAttr prints a space and then an HTML attribute node. | [
"printAttr",
"prints",
"a",
"space",
"and",
"then",
"an",
"HTML",
"attribute",
"node",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/sanitizehtml/sanitize.go#L65-L71 |
129,305 | luci/luci-go | config/server/cfgclient/backend/erroring/erroring.go | New | func New(err error) backend.B {
if err == nil {
panic("the error must not be nil")
}
return erroringImpl{err}
} | go | func New(err error) backend.B {
if err == nil {
panic("the error must not be nil")
}
return erroringImpl{err}
} | [
"func",
"New",
"(",
"err",
"error",
")",
"backend",
".",
"B",
"{",
"if",
"err",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"erroringImpl",
"{",
"err",
"}",
"\n",
"}"
] | // New produces backend.B instance that returns the given error for all calls.
//
// Panics if given err is nil. | [
"New",
"produces",
"backend",
".",
"B",
"instance",
"that",
"returns",
"the",
"given",
"error",
"for",
"all",
"calls",
".",
"Panics",
"if",
"given",
"err",
"is",
"nil",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/erroring/erroring.go#L33-L38 |
129,306 | luci/luci-go | logdog/appengine/coordinator/logStreamState.go | NewLogStreamState | func NewLogStreamState(c context.Context, id HashID) *LogStreamState {
return &LogStreamState{Parent: ds.NewKey(c, "LogStream", string(id), 0, nil)}
} | go | func NewLogStreamState(c context.Context, id HashID) *LogStreamState {
return &LogStreamState{Parent: ds.NewKey(c, "LogStream", string(id), 0, nil)}
} | [
"func",
"NewLogStreamState",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"HashID",
")",
"*",
"LogStreamState",
"{",
"return",
"&",
"LogStreamState",
"{",
"Parent",
":",
"ds",
".",
"NewKey",
"(",
"c",
",",
"\"",
"\"",
",",
"string",
"(",
"id",
")",
... | // NewLogStreamState returns a LogStreamState with its parent key populated to
// the LogStream with the supplied ID. | [
"NewLogStreamState",
"returns",
"a",
"LogStreamState",
"with",
"its",
"parent",
"key",
"populated",
"to",
"the",
"LogStream",
"with",
"the",
"supplied",
"ID",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStreamState.go#L147-L149 |
129,307 | luci/luci-go | logdog/appengine/coordinator/logStreamState.go | Validate | func (lst *LogStreamState) Validate() error {
if lst.Created.IsZero() {
return errors.New("missing created time")
}
if lst.Updated.IsZero() {
return errors.New("missing updated time")
}
if lst.Terminated() && lst.TerminatedTime.IsZero() {
return errors.New("log stream is terminated, but missing terminated t... | go | func (lst *LogStreamState) Validate() error {
if lst.Created.IsZero() {
return errors.New("missing created time")
}
if lst.Updated.IsZero() {
return errors.New("missing updated time")
}
if lst.Terminated() && lst.TerminatedTime.IsZero() {
return errors.New("log stream is terminated, but missing terminated t... | [
"func",
"(",
"lst",
"*",
"LogStreamState",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"lst",
".",
"Created",
".",
"IsZero",
"(",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"lst",
".",
"Updated",
"."... | // Validate evaluates the state and data contents of the LogStreamState and
// returns an error if it is invalid. | [
"Validate",
"evaluates",
"the",
"state",
"and",
"data",
"contents",
"of",
"the",
"LogStreamState",
"and",
"returns",
"an",
"error",
"if",
"it",
"is",
"invalid",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStreamState.go#L183-L199 |
129,308 | luci/luci-go | logdog/appengine/coordinator/logStreamState.go | Terminated | func (lst *LogStreamState) Terminated() bool {
if lst.ArchivalState().Archived() {
return true
}
return lst.TerminalIndex >= 0
} | go | func (lst *LogStreamState) Terminated() bool {
if lst.ArchivalState().Archived() {
return true
}
return lst.TerminalIndex >= 0
} | [
"func",
"(",
"lst",
"*",
"LogStreamState",
")",
"Terminated",
"(",
")",
"bool",
"{",
"if",
"lst",
".",
"ArchivalState",
"(",
")",
".",
"Archived",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"lst",
".",
"TerminalIndex",
">=",
"0",
"\n... | // Terminated returns true if this stream has been terminated. | [
"Terminated",
"returns",
"true",
"if",
"this",
"stream",
"has",
"been",
"terminated",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStreamState.go#L202-L207 |
129,309 | luci/luci-go | logdog/appengine/coordinator/logStreamState.go | ArchivalState | func (lst *LogStreamState) ArchivalState() ArchivalState {
if lst.ArchivedTime.IsZero() {
// Not archived, have we dispatched an archival?
if len(lst.ArchivalKey) > 0 {
return ArchiveTasked
}
return NotArchived
}
if lst.ArchiveLogEntryCount > lst.TerminalIndex {
return ArchivedComplete
}
return Archi... | go | func (lst *LogStreamState) ArchivalState() ArchivalState {
if lst.ArchivedTime.IsZero() {
// Not archived, have we dispatched an archival?
if len(lst.ArchivalKey) > 0 {
return ArchiveTasked
}
return NotArchived
}
if lst.ArchiveLogEntryCount > lst.TerminalIndex {
return ArchivedComplete
}
return Archi... | [
"func",
"(",
"lst",
"*",
"LogStreamState",
")",
"ArchivalState",
"(",
")",
"ArchivalState",
"{",
"if",
"lst",
".",
"ArchivedTime",
".",
"IsZero",
"(",
")",
"{",
"// Not archived, have we dispatched an archival?",
"if",
"len",
"(",
"lst",
".",
"ArchivalKey",
")",... | // ArchivalState returns the archival state of the log stream. | [
"ArchivalState",
"returns",
"the",
"archival",
"state",
"of",
"the",
"log",
"stream",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStreamState.go#L210-L223 |
129,310 | luci/luci-go | scheduler/appengine/task/gitiles/state.go | loadStateEntry | func loadStateEntry(c context.Context, jobID, repo string) (*Repository, error) {
id, err := repositoryID(jobID, repo)
if err != nil {
return nil, err
}
entry := &Repository{ID: id}
if err := ds.Get(c, entry); err == ds.ErrNoSuchEntity {
return nil, err
} else {
return entry, transient.Tag.Apply(err)
}
} | go | func loadStateEntry(c context.Context, jobID, repo string) (*Repository, error) {
id, err := repositoryID(jobID, repo)
if err != nil {
return nil, err
}
entry := &Repository{ID: id}
if err := ds.Get(c, entry); err == ds.ErrNoSuchEntity {
return nil, err
} else {
return entry, transient.Tag.Apply(err)
}
} | [
"func",
"loadStateEntry",
"(",
"c",
"context",
".",
"Context",
",",
"jobID",
",",
"repo",
"string",
")",
"(",
"*",
"Repository",
",",
"error",
")",
"{",
"id",
",",
"err",
":=",
"repositoryID",
"(",
"jobID",
",",
"repo",
")",
"\n",
"if",
"err",
"!=",
... | // loadStateEntry loads Repository instance from datastore. | [
"loadStateEntry",
"loads",
"Repository",
"instance",
"from",
"datastore",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/gitiles/state.go#L75-L86 |
129,311 | luci/luci-go | milo/frontend/view_build_legacy.go | handleBuildbotBuild | func handleBuildbotBuild(c *router.Context) error {
buildNum, err := strconv.Atoi(c.Params.ByName("number"))
if err != nil {
return errors.Annotate(err, "build number is not a number").
Tag(grpcutil.InvalidArgumentTag).
Err()
}
id := buildbotapi.BuildID{
Master: c.Params.ByName("master"),
Builder: c.Pa... | go | func handleBuildbotBuild(c *router.Context) error {
buildNum, err := strconv.Atoi(c.Params.ByName("number"))
if err != nil {
return errors.Annotate(err, "build number is not a number").
Tag(grpcutil.InvalidArgumentTag).
Err()
}
id := buildbotapi.BuildID{
Master: c.Params.ByName("master"),
Builder: c.Pa... | [
"func",
"handleBuildbotBuild",
"(",
"c",
"*",
"router",
".",
"Context",
")",
"error",
"{",
"buildNum",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"c",
".",
"Params",
".",
"ByName",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // handleBuildbotBuild renders a buildbot build.
// Requires emulationMiddleware. | [
"handleBuildbotBuild",
"renders",
"a",
"buildbot",
"build",
".",
"Requires",
"emulationMiddleware",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_build_legacy.go#L47-L77 |
129,312 | luci/luci-go | milo/frontend/view_build_legacy.go | handleLUCIBuildLegacy | func handleLUCIBuildLegacy(c *router.Context, bucket, builder, numberOrId string) error {
var address string
if strings.HasPrefix(numberOrId, "b") {
address = numberOrId[1:]
} else {
address = fmt.Sprintf("%s/%s/%s", bucket, builder, numberOrId)
}
build, err := buildbucket.GetBuildLegacy(c.Context, address, t... | go | func handleLUCIBuildLegacy(c *router.Context, bucket, builder, numberOrId string) error {
var address string
if strings.HasPrefix(numberOrId, "b") {
address = numberOrId[1:]
} else {
address = fmt.Sprintf("%s/%s/%s", bucket, builder, numberOrId)
}
build, err := buildbucket.GetBuildLegacy(c.Context, address, t... | [
"func",
"handleLUCIBuildLegacy",
"(",
"c",
"*",
"router",
".",
"Context",
",",
"bucket",
",",
"builder",
",",
"numberOrId",
"string",
")",
"error",
"{",
"var",
"address",
"string",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"numberOrId",
",",
"\"",
"\""... | // handleLUCIBuildLegacy renders a LUCI build. | [
"handleLUCIBuildLegacy",
"renders",
"a",
"LUCI",
"build",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_build_legacy.go#L80-L90 |
129,313 | luci/luci-go | milo/frontend/view_build_legacy.go | makeFeedbackLink | func makeFeedbackLink(c *router.Context, build *ui.MiloBuildLegacy) string {
project, err := common.GetProject(c.Context, c.Params.ByName("project"))
if err != nil || proto.Equal(&project.BuildBugTemplate, &config.BugTemplate{}) {
return ""
}
buildURL := c.Request.URL
var builderURL *url.URL
if build.Summary.P... | go | func makeFeedbackLink(c *router.Context, build *ui.MiloBuildLegacy) string {
project, err := common.GetProject(c.Context, c.Params.ByName("project"))
if err != nil || proto.Equal(&project.BuildBugTemplate, &config.BugTemplate{}) {
return ""
}
buildURL := c.Request.URL
var builderURL *url.URL
if build.Summary.P... | [
"func",
"makeFeedbackLink",
"(",
"c",
"*",
"router",
".",
"Context",
",",
"build",
"*",
"ui",
".",
"MiloBuildLegacy",
")",
"string",
"{",
"project",
",",
"err",
":=",
"common",
".",
"GetProject",
"(",
"c",
".",
"Context",
",",
"c",
".",
"Params",
".",
... | // makeFeedbackLink attempts to create the feedback link for the build page. If the
// project is not configured for a custom feedback link or an interpolation placeholder
// cannot be satisfied an empty string is returned. | [
"makeFeedbackLink",
"attempts",
"to",
"create",
"the",
"feedback",
"link",
"for",
"the",
"build",
"page",
".",
"If",
"the",
"project",
"is",
"not",
"configured",
"for",
"a",
"custom",
"feedback",
"link",
"or",
"an",
"interpolation",
"placeholder",
"cannot",
"b... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_build_legacy.go#L129-L157 |
129,314 | luci/luci-go | milo/frontend/view_build_legacy.go | makeBuild | func makeBuild(params httprouter.Params, build *ui.MiloBuildLegacy) *buildbucketpb.Build {
return &buildbucketpb.Build{
Builder: &buildbucketpb.BuilderID{
Project: build.Trigger.Project, // equivalent params.ByName("project")
Bucket: params.ByName("bucket"), // way to get from ui.MiloBuildLe... | go | func makeBuild(params httprouter.Params, build *ui.MiloBuildLegacy) *buildbucketpb.Build {
return &buildbucketpb.Build{
Builder: &buildbucketpb.BuilderID{
Project: build.Trigger.Project, // equivalent params.ByName("project")
Bucket: params.ByName("bucket"), // way to get from ui.MiloBuildLe... | [
"func",
"makeBuild",
"(",
"params",
"httprouter",
".",
"Params",
",",
"build",
"*",
"ui",
".",
"MiloBuildLegacy",
")",
"*",
"buildbucketpb",
".",
"Build",
"{",
"return",
"&",
"buildbucketpb",
".",
"Build",
"{",
"Builder",
":",
"&",
"buildbucketpb",
".",
"B... | // makeBuild partially populates a buildbucketpb.Build. Currently it attempts to
// make available .Builder.Project, .Builder.Bucket, and .Builder.Builder. | [
"makeBuild",
"partially",
"populates",
"a",
"buildbucketpb",
".",
"Build",
".",
"Currently",
"it",
"attempts",
"to",
"make",
"available",
".",
"Builder",
".",
"Project",
".",
"Builder",
".",
"Bucket",
"and",
".",
"Builder",
".",
"Builder",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_build_legacy.go#L161-L169 |
129,315 | luci/luci-go | lucicfg/graph/key.go | Less | func (k *Key) Less(an *Key) bool {
return k.cmp < an.cmp
} | go | func (k *Key) Less(an *Key) bool {
return k.cmp < an.cmp
} | [
"func",
"(",
"k",
"*",
"Key",
")",
"Less",
"(",
"an",
"*",
"Key",
")",
"bool",
"{",
"return",
"k",
".",
"cmp",
"<",
"an",
".",
"cmp",
"\n",
"}"
] | // Less returns true if this key is lexicographically before another key. | [
"Less",
"returns",
"true",
"if",
"this",
"key",
"is",
"lexicographically",
"before",
"another",
"key",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/graph/key.go#L72-L74 |
129,316 | luci/luci-go | grpc/logging/grpc_logger.go | translateLevel | func translateLevel(l logging.Level) int {
switch l {
case Suppress:
return -1
case logging.Error:
return 0
case logging.Warning, logging.Info:
return 1
default:
return 2
}
} | go | func translateLevel(l logging.Level) int {
switch l {
case Suppress:
return -1
case logging.Error:
return 0
case logging.Warning, logging.Info:
return 1
default:
return 2
}
} | [
"func",
"translateLevel",
"(",
"l",
"logging",
".",
"Level",
")",
"int",
"{",
"switch",
"l",
"{",
"case",
"Suppress",
":",
"return",
"-",
"1",
"\n",
"case",
"logging",
".",
"Error",
":",
"return",
"0",
"\n",
"case",
"logging",
".",
"Warning",
",",
"l... | // translateLevel translates a "verbose level" to a logging level. | [
"translateLevel",
"translates",
"a",
"verbose",
"level",
"to",
"a",
"logging",
"level",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/logging/grpc_logger.go#L176-L187 |
129,317 | luci/luci-go | appengine/gaeauth/server/default.go | InstallHandlers | func InstallHandlers(r *router.Router, base router.MiddlewareChain) {
m := CookieAuth.(cookieAuthMethod)
if oid, ok := m.Method.(*openid.AuthMethod); ok {
oid.InstallHandlers(r, base)
}
auth.InstallHandlers(r, base)
authdbimpl.InstallHandlers(r, base)
} | go | func InstallHandlers(r *router.Router, base router.MiddlewareChain) {
m := CookieAuth.(cookieAuthMethod)
if oid, ok := m.Method.(*openid.AuthMethod); ok {
oid.InstallHandlers(r, base)
}
auth.InstallHandlers(r, base)
authdbimpl.InstallHandlers(r, base)
} | [
"func",
"InstallHandlers",
"(",
"r",
"*",
"router",
".",
"Router",
",",
"base",
"router",
".",
"MiddlewareChain",
")",
"{",
"m",
":=",
"CookieAuth",
".",
"(",
"cookieAuthMethod",
")",
"\n",
"if",
"oid",
",",
"ok",
":=",
"m",
".",
"Method",
".",
"(",
... | // InstallHandlers installs HTTP handlers for various default routes related
// to authentication system.
//
// Must be installed in server HTTP router for authentication to work. | [
"InstallHandlers",
"installs",
"HTTP",
"handlers",
"for",
"various",
"default",
"routes",
"related",
"to",
"authentication",
"system",
".",
"Must",
"be",
"installed",
"in",
"server",
"HTTP",
"router",
"for",
"authentication",
"to",
"work",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/default.go#L41-L48 |
129,318 | luci/luci-go | dm/api/distributor/swarming/v1/cipd.go | ToCipdPackage | func (c *CipdPackage) ToCipdPackage() *swarm.SwarmingRpcsCipdPackage {
if c == nil {
return nil
}
return &swarm.SwarmingRpcsCipdPackage{PackageName: c.Name, Version: c.Version}
} | go | func (c *CipdPackage) ToCipdPackage() *swarm.SwarmingRpcsCipdPackage {
if c == nil {
return nil
}
return &swarm.SwarmingRpcsCipdPackage{PackageName: c.Name, Version: c.Version}
} | [
"func",
"(",
"c",
"*",
"CipdPackage",
")",
"ToCipdPackage",
"(",
")",
"*",
"swarm",
".",
"SwarmingRpcsCipdPackage",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"swarm",
".",
"SwarmingRpcsCipdPackage",
"{",
"PackageNam... | // ToCipdPackage converts this to a swarming api SwarmingRpcsCipdPackage. | [
"ToCipdPackage",
"converts",
"this",
"to",
"a",
"swarming",
"api",
"SwarmingRpcsCipdPackage",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/swarming/v1/cipd.go#L24-L29 |
129,319 | luci/luci-go | dm/api/distributor/swarming/v1/cipd.go | ToCipdInput | func (c *CipdSpec) ToCipdInput() *swarm.SwarmingRpcsCipdInput {
if c == nil || c.Client == nil && len(c.ByPath) == 0 {
return nil
}
ret := &swarm.SwarmingRpcsCipdInput{
ClientPackage: c.Client.ToCipdPackage(),
}
if len(c.ByPath) > 0 {
count := 0
paths := make(sort.StringSlice, 0, len(c.ByPath))
for path,... | go | func (c *CipdSpec) ToCipdInput() *swarm.SwarmingRpcsCipdInput {
if c == nil || c.Client == nil && len(c.ByPath) == 0 {
return nil
}
ret := &swarm.SwarmingRpcsCipdInput{
ClientPackage: c.Client.ToCipdPackage(),
}
if len(c.ByPath) > 0 {
count := 0
paths := make(sort.StringSlice, 0, len(c.ByPath))
for path,... | [
"func",
"(",
"c",
"*",
"CipdSpec",
")",
"ToCipdInput",
"(",
")",
"*",
"swarm",
".",
"SwarmingRpcsCipdInput",
"{",
"if",
"c",
"==",
"nil",
"||",
"c",
".",
"Client",
"==",
"nil",
"&&",
"len",
"(",
"c",
".",
"ByPath",
")",
"==",
"0",
"{",
"return",
... | // ToCipdInput converts this to a swarming api SwarmingRpcsCipdInput. | [
"ToCipdInput",
"converts",
"this",
"to",
"a",
"swarming",
"api",
"SwarmingRpcsCipdInput",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/swarming/v1/cipd.go#L32-L56 |
129,320 | luci/luci-go | auth/identity/identity.go | MakeIdentity | func MakeIdentity(identity string) (Identity, error) {
id := Identity(identity)
if err := id.Validate(); err != nil {
return "", err
}
return id, nil
} | go | func MakeIdentity(identity string) (Identity, error) {
id := Identity(identity)
if err := id.Validate(); err != nil {
return "", err
}
return id, nil
} | [
"func",
"MakeIdentity",
"(",
"identity",
"string",
")",
"(",
"Identity",
",",
"error",
")",
"{",
"id",
":=",
"Identity",
"(",
"identity",
")",
"\n",
"if",
"err",
":=",
"id",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"... | // MakeIdentity ensures 'identity' string looks like a valid identity and
// returns it as Identity value. | [
"MakeIdentity",
"ensures",
"identity",
"string",
"looks",
"like",
"a",
"valid",
"identity",
"and",
"returns",
"it",
"as",
"Identity",
"value",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/identity/identity.go#L68-L74 |
129,321 | luci/luci-go | auth/identity/identity.go | Validate | func (id Identity) Validate() error {
chunks := strings.SplitN(string(id), ":", 2)
if len(chunks) != 2 {
return fmt.Errorf("auth: bad identity string %q", id)
}
re := knownKinds[Kind(chunks[0])]
if re == nil {
return fmt.Errorf("auth: bad identity kind %q", chunks[0])
}
if !re.MatchString(chunks[1]) {
retu... | go | func (id Identity) Validate() error {
chunks := strings.SplitN(string(id), ":", 2)
if len(chunks) != 2 {
return fmt.Errorf("auth: bad identity string %q", id)
}
re := knownKinds[Kind(chunks[0])]
if re == nil {
return fmt.Errorf("auth: bad identity kind %q", chunks[0])
}
if !re.MatchString(chunks[1]) {
retu... | [
"func",
"(",
"id",
"Identity",
")",
"Validate",
"(",
")",
"error",
"{",
"chunks",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"id",
")",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"chunks",
")",
"!=",
"2",
"{",
"return",
"f... | // Validate checks that the identity string is well-formed. | [
"Validate",
"checks",
"that",
"the",
"identity",
"string",
"is",
"well",
"-",
"formed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/identity/identity.go#L77-L90 |
129,322 | luci/luci-go | auth/identity/identity.go | Kind | func (id Identity) Kind() Kind {
chunks := strings.SplitN(string(id), ":", 2)
if len(chunks) != 2 {
return Anonymous
}
return Kind(chunks[0])
} | go | func (id Identity) Kind() Kind {
chunks := strings.SplitN(string(id), ":", 2)
if len(chunks) != 2 {
return Anonymous
}
return Kind(chunks[0])
} | [
"func",
"(",
"id",
"Identity",
")",
"Kind",
"(",
")",
"Kind",
"{",
"chunks",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"id",
")",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"chunks",
")",
"!=",
"2",
"{",
"return",
"Anonym... | // Kind returns identity kind. If identity string is invalid returns Anonymous. | [
"Kind",
"returns",
"identity",
"kind",
".",
"If",
"identity",
"string",
"is",
"invalid",
"returns",
"Anonymous",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/identity/identity.go#L93-L99 |
129,323 | luci/luci-go | auth/identity/identity.go | Email | func (id Identity) Email() string {
chunks := strings.SplitN(string(id), ":", 2)
if len(chunks) != 2 {
return ""
}
if Kind(chunks[0]) == User {
return chunks[1]
}
return ""
} | go | func (id Identity) Email() string {
chunks := strings.SplitN(string(id), ":", 2)
if len(chunks) != 2 {
return ""
}
if Kind(chunks[0]) == User {
return chunks[1]
}
return ""
} | [
"func",
"(",
"id",
"Identity",
")",
"Email",
"(",
")",
"string",
"{",
"chunks",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"id",
")",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"chunks",
")",
"!=",
"2",
"{",
"return",
"\""... | // Email returns user's email for identity with kind User or empty string for
// all other identity kinds. If identity string is undefined returns "". | [
"Email",
"returns",
"user",
"s",
"email",
"for",
"identity",
"with",
"kind",
"User",
"or",
"empty",
"string",
"for",
"all",
"other",
"identity",
"kinds",
".",
"If",
"identity",
"string",
"is",
"undefined",
"returns",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/identity/identity.go#L113-L122 |
129,324 | luci/luci-go | common/errors/tags.go | TagValueIn | func TagValueIn(t TagKey, err error) (value interface{}, ok bool) {
Walk(err, func(err error) bool {
if sc, isSC := err.(stackContexter); isSC {
if value, ok = sc.stackContext().tags[t]; ok {
return false
}
}
return true
})
return
} | go | func TagValueIn(t TagKey, err error) (value interface{}, ok bool) {
Walk(err, func(err error) bool {
if sc, isSC := err.(stackContexter); isSC {
if value, ok = sc.stackContext().tags[t]; ok {
return false
}
}
return true
})
return
} | [
"func",
"TagValueIn",
"(",
"t",
"TagKey",
",",
"err",
"error",
")",
"(",
"value",
"interface",
"{",
"}",
",",
"ok",
"bool",
")",
"{",
"Walk",
"(",
"err",
",",
"func",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"sc",
",",
"isSC",
":=",
"err",
... | // TagValueIn will retrieve the tagged value from the error that's associated
// with this key, and a boolean indicating if the tag was present or not. | [
"TagValueIn",
"will",
"retrieve",
"the",
"tagged",
"value",
"from",
"the",
"error",
"that",
"s",
"associated",
"with",
"this",
"key",
"and",
"a",
"boolean",
"indicating",
"if",
"the",
"tag",
"was",
"present",
"or",
"not",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/errors/tags.go#L56-L66 |
129,325 | luci/luci-go | common/errors/tags.go | In | func (b BoolTag) In(err error) bool {
v, ok := TagValueIn(b.Key, err)
if !ok {
return false
}
return v.(bool)
} | go | func (b BoolTag) In(err error) bool {
v, ok := TagValueIn(b.Key, err)
if !ok {
return false
}
return v.(bool)
} | [
"func",
"(",
"b",
"BoolTag",
")",
"In",
"(",
"err",
"error",
")",
"bool",
"{",
"v",
",",
"ok",
":=",
"TagValueIn",
"(",
"b",
".",
"Key",
",",
"err",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"v",
".",
"(",... | // In returns true iff this tag value has been set to true on this error. | [
"In",
"returns",
"true",
"iff",
"this",
"tag",
"value",
"has",
"been",
"set",
"to",
"true",
"on",
"this",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/errors/tags.go#L106-L112 |
129,326 | luci/luci-go | common/errors/tags.go | GetTags | func GetTags(err error) map[TagKey]interface{} {
ret := map[TagKey]interface{}{}
Walk(err, func(err error) bool {
if sc, ok := err.(stackContexter); ok {
ctx := sc.stackContext()
for k, v := range ctx.tags {
if _, ok := ret[k]; !ok {
ret[k] = v
}
}
}
return true
})
return ret
} | go | func GetTags(err error) map[TagKey]interface{} {
ret := map[TagKey]interface{}{}
Walk(err, func(err error) bool {
if sc, ok := err.(stackContexter); ok {
ctx := sc.stackContext()
for k, v := range ctx.tags {
if _, ok := ret[k]; !ok {
ret[k] = v
}
}
}
return true
})
return ret
} | [
"func",
"GetTags",
"(",
"err",
"error",
")",
"map",
"[",
"TagKey",
"]",
"interface",
"{",
"}",
"{",
"ret",
":=",
"map",
"[",
"TagKey",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"Walk",
"(",
"err",
",",
"func",
"(",
"err",
"error",
")",
"bool",
... | // GetTags returns a map of all TagKeys set in this error to their value.
//
// A nil value means that the tag is present, but has a nil associated value.
//
// This is done in a depth-first traversal of the error stack, with the
// most-recently-set value of the tag taking precendence. | [
"GetTags",
"returns",
"a",
"map",
"of",
"all",
"TagKeys",
"set",
"in",
"this",
"error",
"to",
"their",
"value",
".",
"A",
"nil",
"value",
"means",
"that",
"the",
"tag",
"is",
"present",
"but",
"has",
"a",
"nil",
"associated",
"value",
".",
"This",
"is"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/errors/tags.go#L156-L170 |
129,327 | luci/luci-go | tools/cmd/bqschemaupdater/main.go | schemaFromMessage | func schemaFromMessage(desc *descriptor.FileDescriptorSet, messageName string) (schema bigquery.Schema, description string, err error) {
conv := schemaConverter{
desc: desc,
sourceCodeInfo: make(map[*descriptor.FileDescriptorProto]sourceCodeInfoMap, len(desc.File)),
}
for _, f := range desc.File {
co... | go | func schemaFromMessage(desc *descriptor.FileDescriptorSet, messageName string) (schema bigquery.Schema, description string, err error) {
conv := schemaConverter{
desc: desc,
sourceCodeInfo: make(map[*descriptor.FileDescriptorProto]sourceCodeInfoMap, len(desc.File)),
}
for _, f := range desc.File {
co... | [
"func",
"schemaFromMessage",
"(",
"desc",
"*",
"descriptor",
".",
"FileDescriptorSet",
",",
"messageName",
"string",
")",
"(",
"schema",
"bigquery",
".",
"Schema",
",",
"description",
"string",
",",
"err",
"error",
")",
"{",
"conv",
":=",
"schemaConverter",
"{... | // schemaFromMessage loads a message by name from .proto files in dir
// and converts the message to a bigquery schema. | [
"schemaFromMessage",
"loads",
"a",
"message",
"by",
"name",
"from",
".",
"proto",
"files",
"in",
"dir",
"and",
"converts",
"the",
"message",
"to",
"a",
"bigquery",
"schema",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/cmd/bqschemaupdater/main.go#L235-L247 |
129,328 | luci/luci-go | tools/cmd/bqschemaupdater/main.go | loadProtoDescription | func loadProtoDescription(dir string, importPaths []string) (*descriptor.FileDescriptorSet, error) {
dir, err := filepath.Abs(dir)
if err != nil {
return nil, errors.Annotate(err, "could make path %q absolute", dir).Err()
}
tempDir, err := ioutil.TempDir("", "")
if err != nil {
return nil, err
}
defer os.Re... | go | func loadProtoDescription(dir string, importPaths []string) (*descriptor.FileDescriptorSet, error) {
dir, err := filepath.Abs(dir)
if err != nil {
return nil, errors.Annotate(err, "could make path %q absolute", dir).Err()
}
tempDir, err := ioutil.TempDir("", "")
if err != nil {
return nil, err
}
defer os.Re... | [
"func",
"loadProtoDescription",
"(",
"dir",
"string",
",",
"importPaths",
"[",
"]",
"string",
")",
"(",
"*",
"descriptor",
".",
"FileDescriptorSet",
",",
"error",
")",
"{",
"dir",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"dir",
")",
"\n",
"if",
"... | // loadProtoDescription compiles .proto files in the dir
// and returns their descriptor. | [
"loadProtoDescription",
"compiles",
".",
"proto",
"files",
"in",
"the",
"dir",
"and",
"returns",
"their",
"descriptor",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/cmd/bqschemaupdater/main.go#L306-L354 |
129,329 | luci/luci-go | tools/cmd/bqschemaupdater/main.go | confirm | func confirm(action string) (response bool) {
fmt.Printf("%s? [y/N] ", action)
var res string
fmt.Scanln(&res)
return res == "y" || res == "Y"
} | go | func confirm(action string) (response bool) {
fmt.Printf("%s? [y/N] ", action)
var res string
fmt.Scanln(&res)
return res == "y" || res == "Y"
} | [
"func",
"confirm",
"(",
"action",
"string",
")",
"(",
"response",
"bool",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"action",
")",
"\n",
"var",
"res",
"string",
"\n",
"fmt",
".",
"Scanln",
"(",
"&",
"res",
")",
"\n",
"return",
"res",
... | // confirm asks for a user confirmation for an action, with No as default.
// Only "y" or "Y" responses is treated as yes. | [
"confirm",
"asks",
"for",
"a",
"user",
"confirmation",
"for",
"an",
"action",
"with",
"No",
"as",
"default",
".",
"Only",
"y",
"or",
"Y",
"responses",
"is",
"treated",
"as",
"yes",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/cmd/bqschemaupdater/main.go#L366-L371 |
129,330 | luci/luci-go | cipd/appengine/impl/model/ref.go | Proto | func (e *Ref) Proto() *api.Ref {
return &api.Ref{
Name: e.Name,
Package: e.Package.StringID(),
Instance: common.InstanceIDToObjectRef(e.InstanceID),
ModifiedBy: e.ModifiedBy,
ModifiedTs: google.NewTimestamp(e.ModifiedTs),
}
} | go | func (e *Ref) Proto() *api.Ref {
return &api.Ref{
Name: e.Name,
Package: e.Package.StringID(),
Instance: common.InstanceIDToObjectRef(e.InstanceID),
ModifiedBy: e.ModifiedBy,
ModifiedTs: google.NewTimestamp(e.ModifiedTs),
}
} | [
"func",
"(",
"e",
"*",
"Ref",
")",
"Proto",
"(",
")",
"*",
"api",
".",
"Ref",
"{",
"return",
"&",
"api",
".",
"Ref",
"{",
"Name",
":",
"e",
".",
"Name",
",",
"Package",
":",
"e",
".",
"Package",
".",
"StringID",
"(",
")",
",",
"Instance",
":"... | // Proto returns cipd.Ref proto with information from this entity. | [
"Proto",
"returns",
"cipd",
".",
"Ref",
"proto",
"with",
"information",
"from",
"this",
"entity",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/ref.go#L53-L61 |
129,331 | luci/luci-go | cipd/appengine/impl/model/ref.go | GetRef | func GetRef(c context.Context, pkg, ref string) (*Ref, error) {
r := &Ref{Name: ref, Package: PackageKey(c, pkg)}
switch err := datastore.Get(c, r); {
case err == datastore.ErrNoSuchEntity:
return nil, errors.Reason("no such ref").Tag(grpcutil.NotFoundTag).Err()
case err != nil:
return nil, errors.Annotate(err,... | go | func GetRef(c context.Context, pkg, ref string) (*Ref, error) {
r := &Ref{Name: ref, Package: PackageKey(c, pkg)}
switch err := datastore.Get(c, r); {
case err == datastore.ErrNoSuchEntity:
return nil, errors.Reason("no such ref").Tag(grpcutil.NotFoundTag).Err()
case err != nil:
return nil, errors.Annotate(err,... | [
"func",
"GetRef",
"(",
"c",
"context",
".",
"Context",
",",
"pkg",
",",
"ref",
"string",
")",
"(",
"*",
"Ref",
",",
"error",
")",
"{",
"r",
":=",
"&",
"Ref",
"{",
"Name",
":",
"ref",
",",
"Package",
":",
"PackageKey",
"(",
"c",
",",
"pkg",
")",... | // GetRef fetches the given ref.
//
// Returns gRPC-tagged NotFound error if there's no such ref. | [
"GetRef",
"fetches",
"the",
"given",
"ref",
".",
"Returns",
"gRPC",
"-",
"tagged",
"NotFound",
"error",
"if",
"there",
"s",
"no",
"such",
"ref",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/ref.go#L124-L133 |
129,332 | luci/luci-go | cipd/appengine/impl/model/ref.go | DeleteRef | func DeleteRef(c context.Context, pkg, ref string) error {
return Txn(c, "DeleteRef", func(c context.Context) error {
r, err := GetRef(c, pkg, ref)
switch {
case grpcutil.Code(err) == codes.NotFound:
return nil
case err != nil:
return err // transient
}
err = datastore.Delete(c, &Ref{
Name: re... | go | func DeleteRef(c context.Context, pkg, ref string) error {
return Txn(c, "DeleteRef", func(c context.Context) error {
r, err := GetRef(c, pkg, ref)
switch {
case grpcutil.Code(err) == codes.NotFound:
return nil
case err != nil:
return err // transient
}
err = datastore.Delete(c, &Ref{
Name: re... | [
"func",
"DeleteRef",
"(",
"c",
"context",
".",
"Context",
",",
"pkg",
",",
"ref",
"string",
")",
"error",
"{",
"return",
"Txn",
"(",
"c",
",",
"\"",
"\"",
",",
"func",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"r",
",",
"err",
":=",... | // DeleteRef removes the ref if it exists.
//
// Does nothing if there's no such ref or package. | [
"DeleteRef",
"removes",
"the",
"ref",
"if",
"it",
"exists",
".",
"Does",
"nothing",
"if",
"there",
"s",
"no",
"such",
"ref",
"or",
"package",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/ref.go#L138-L163 |
129,333 | luci/luci-go | cipd/appengine/impl/model/ref.go | ListPackageRefs | func ListPackageRefs(c context.Context, pkg string) (out []*Ref, err error) {
q := datastore.NewQuery("PackageRef").
Ancestor(PackageKey(c, pkg)).
Order("-modified_ts")
if err := datastore.GetAll(c, q, &out); err != nil {
return nil, errors.Annotate(err, "datastore query failed").Tag(transient.Tag).Err()
}
re... | go | func ListPackageRefs(c context.Context, pkg string) (out []*Ref, err error) {
q := datastore.NewQuery("PackageRef").
Ancestor(PackageKey(c, pkg)).
Order("-modified_ts")
if err := datastore.GetAll(c, q, &out); err != nil {
return nil, errors.Annotate(err, "datastore query failed").Tag(transient.Tag).Err()
}
re... | [
"func",
"ListPackageRefs",
"(",
"c",
"context",
".",
"Context",
",",
"pkg",
"string",
")",
"(",
"out",
"[",
"]",
"*",
"Ref",
",",
"err",
"error",
")",
"{",
"q",
":=",
"datastore",
".",
"NewQuery",
"(",
"\"",
"\"",
")",
".",
"Ancestor",
"(",
"Packag... | // ListPackageRefs returns all refs in a package, most recently modified first.
//
// Returns an empty list if there's no such package at all. | [
"ListPackageRefs",
"returns",
"all",
"refs",
"in",
"a",
"package",
"most",
"recently",
"modified",
"first",
".",
"Returns",
"an",
"empty",
"list",
"if",
"there",
"s",
"no",
"such",
"package",
"at",
"all",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/ref.go#L168-L176 |
129,334 | luci/luci-go | cipd/appengine/impl/model/ref.go | ListInstanceRefs | func ListInstanceRefs(c context.Context, inst *Instance) (out []*Ref, err error) {
if inst.Package == nil {
panic("bad Instance")
}
q := datastore.NewQuery("PackageRef").
Ancestor(inst.Package).
Eq("instance_id", inst.InstanceID).
Order("-modified_ts")
if err := datastore.GetAll(c, q, &out); err != nil {
... | go | func ListInstanceRefs(c context.Context, inst *Instance) (out []*Ref, err error) {
if inst.Package == nil {
panic("bad Instance")
}
q := datastore.NewQuery("PackageRef").
Ancestor(inst.Package).
Eq("instance_id", inst.InstanceID).
Order("-modified_ts")
if err := datastore.GetAll(c, q, &out); err != nil {
... | [
"func",
"ListInstanceRefs",
"(",
"c",
"context",
".",
"Context",
",",
"inst",
"*",
"Instance",
")",
"(",
"out",
"[",
"]",
"*",
"Ref",
",",
"err",
"error",
")",
"{",
"if",
"inst",
".",
"Package",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\... | // ListInstanceRefs returns all refs that point to a particular instance, most
// recently modified first.
//
// This is a subset of the output of ListPackageRefs for the corresponding
// package.
//
// Assumes 'inst' is a valid Instance, panics otherwise.
//
// Returns an empty list if there's no such instance at all. | [
"ListInstanceRefs",
"returns",
"all",
"refs",
"that",
"point",
"to",
"a",
"particular",
"instance",
"most",
"recently",
"modified",
"first",
".",
"This",
"is",
"a",
"subset",
"of",
"the",
"output",
"of",
"ListPackageRefs",
"for",
"the",
"corresponding",
"package... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/ref.go#L187-L199 |
129,335 | luci/luci-go | scheduler/appengine/engine/triage.go | prepare | func (op *triageOp) prepare(c context.Context) error {
op.started = clock.Now(c).UTC() // used to derive relative time in the debug log
op.debugInfoLog(c, "Starting")
op.finishedSet = recentlyFinishedSet(c, op.jobID)
op.triggersSet = pendingTriggersSet(c, op.jobID)
wg := sync.WaitGroup{}
wg.Add(2)
// Grab all... | go | func (op *triageOp) prepare(c context.Context) error {
op.started = clock.Now(c).UTC() // used to derive relative time in the debug log
op.debugInfoLog(c, "Starting")
op.finishedSet = recentlyFinishedSet(c, op.jobID)
op.triggersSet = pendingTriggersSet(c, op.jobID)
wg := sync.WaitGroup{}
wg.Add(2)
// Grab all... | [
"func",
"(",
"op",
"*",
"triageOp",
")",
"prepare",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"op",
".",
"started",
"=",
"clock",
".",
"Now",
"(",
"c",
")",
".",
"UTC",
"(",
")",
"// used to derive relative time in the debug log",
"\n",
"op... | // prepare fetches all pending triggers and events from dsset structs. | [
"prepare",
"fetches",
"all",
"pending",
"triggers",
"and",
"events",
"from",
"dsset",
"structs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/triage.go#L101-L154 |
129,336 | luci/luci-go | scheduler/appengine/engine/triage.go | debugErrLog | func (op *triageOp) debugErrLog(c context.Context, err error, format string, args ...interface{}) {
if err == nil {
logging.Errorf(c, format, args...)
op.appendToLog(c, fmt.Sprintf("Error: "+format, args...))
} else {
logging.WithError(err).Errorf(c, format, args...)
op.appendToLog(c, fmt.Sprintf("Error: "+fo... | go | func (op *triageOp) debugErrLog(c context.Context, err error, format string, args ...interface{}) {
if err == nil {
logging.Errorf(c, format, args...)
op.appendToLog(c, fmt.Sprintf("Error: "+format, args...))
} else {
logging.WithError(err).Errorf(c, format, args...)
op.appendToLog(c, fmt.Sprintf("Error: "+fo... | [
"func",
"(",
"op",
"*",
"triageOp",
")",
"debugErrLog",
"(",
"c",
"context",
".",
"Context",
",",
"err",
"error",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"logging",
".",
"Errorf",
... | // debugErrLog adds a line to the triage debug log and Errorf log. | [
"debugErrLog",
"adds",
"a",
"line",
"to",
"the",
"triage",
"debug",
"log",
"and",
"Errorf",
"log",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/triage.go#L270-L278 |
129,337 | luci/luci-go | scheduler/appengine/engine/triage.go | appendToLog | func (op *triageOp) appendToLog(c context.Context, msg string) {
const maxMessageCount = 1000
ms := clock.Now(c).Sub(op.started).Nanoseconds() / 1e6
op.debugLogLock.Lock()
if op.debugLogMsgs <= maxMessageCount {
if op.debugLogMsgs < maxMessageCount {
fmt.Fprintf(&op.debugLog, "[%03d ms] %s\n", ms, msg)
} e... | go | func (op *triageOp) appendToLog(c context.Context, msg string) {
const maxMessageCount = 1000
ms := clock.Now(c).Sub(op.started).Nanoseconds() / 1e6
op.debugLogLock.Lock()
if op.debugLogMsgs <= maxMessageCount {
if op.debugLogMsgs < maxMessageCount {
fmt.Fprintf(&op.debugLog, "[%03d ms] %s\n", ms, msg)
} e... | [
"func",
"(",
"op",
"*",
"triageOp",
")",
"appendToLog",
"(",
"c",
"context",
".",
"Context",
",",
"msg",
"string",
")",
"{",
"const",
"maxMessageCount",
"=",
"1000",
"\n\n",
"ms",
":=",
"clock",
".",
"Now",
"(",
"c",
")",
".",
"Sub",
"(",
"op",
"."... | // appendToLog adds a line to the debug log, prefixing it with current time. | [
"appendToLog",
"adds",
"a",
"line",
"to",
"the",
"debug",
"log",
"prefixing",
"it",
"with",
"current",
"time",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/triage.go#L281-L296 |
129,338 | luci/luci-go | scheduler/appengine/engine/triage.go | tidyActiveInvocations | func (op *triageOp) tidyActiveInvocations(c context.Context, job *Job) (*dsset.PopOp, error) {
now := clock.Now(c).UTC()
// Deserialize the list of recently finished invocations, as stored in the
// entity. Discard old items right away. If it is broken, log, but proceed.
// It is ~OK to loose it (this will tempora... | go | func (op *triageOp) tidyActiveInvocations(c context.Context, job *Job) (*dsset.PopOp, error) {
now := clock.Now(c).UTC()
// Deserialize the list of recently finished invocations, as stored in the
// entity. Discard old items right away. If it is broken, log, but proceed.
// It is ~OK to loose it (this will tempora... | [
"func",
"(",
"op",
"*",
"triageOp",
")",
"tidyActiveInvocations",
"(",
"c",
"context",
".",
"Context",
",",
"job",
"*",
"Job",
")",
"(",
"*",
"dsset",
".",
"PopOp",
",",
"error",
")",
"{",
"now",
":=",
"clock",
".",
"Now",
"(",
"c",
")",
".",
"UT... | // tidyActiveInvocations removes finished invocations from ActiveInvocations,
// and adds them to FinishedInvocations.
//
// Called within a transaction. Mutates job. Returns an open dsset.PopOp that
// must be eventually submitted with dsset.FinishPop. | [
"tidyActiveInvocations",
"removes",
"finished",
"invocations",
"from",
"ActiveInvocations",
"and",
"adds",
"them",
"to",
"FinishedInvocations",
".",
"Called",
"within",
"a",
"transaction",
".",
"Mutates",
"job",
".",
"Returns",
"an",
"open",
"dsset",
".",
"PopOp",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/triage.go#L303-L362 |
129,339 | luci/luci-go | scheduler/appengine/engine/triage.go | processTriggers | func (op *triageOp) processTriggers(c context.Context, job *Job) (*dsset.PopOp, error) {
popOp, err := op.triggersSet.BeginPop(c, op.triggersList)
if err != nil {
op.debugErrLog(c, err, "Failed to pop from pending triggers set")
return nil, err
}
// Filter out all triggers already popped by some other transact... | go | func (op *triageOp) processTriggers(c context.Context, job *Job) (*dsset.PopOp, error) {
popOp, err := op.triggersSet.BeginPop(c, op.triggersList)
if err != nil {
op.debugErrLog(c, err, "Failed to pop from pending triggers set")
return nil, err
}
// Filter out all triggers already popped by some other transact... | [
"func",
"(",
"op",
"*",
"triageOp",
")",
"processTriggers",
"(",
"c",
"context",
".",
"Context",
",",
"job",
"*",
"Job",
")",
"(",
"*",
"dsset",
".",
"PopOp",
",",
"error",
")",
"{",
"popOp",
",",
"err",
":=",
"op",
".",
"triggersSet",
".",
"BeginP... | // processTriggers pops pending triggers, converting them into invocations. | [
"processTriggers",
"pops",
"pending",
"triggers",
"converting",
"them",
"into",
"invocations",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/triage.go#L365-L430 |
129,340 | luci/luci-go | scheduler/appengine/engine/triage.go | triggeringPolicy | func (op *triageOp) triggeringPolicy(c context.Context, job *Job, triggers []*internal.Trigger) policy.Out {
var policyFunc policy.Func
p, err := policy.UnmarshalDefinition(job.TriggeringPolicyRaw)
if err == nil {
policyFunc, err = op.policyFactory(p)
}
if err != nil {
op.debugErrLog(c, err, "Failed to instant... | go | func (op *triageOp) triggeringPolicy(c context.Context, job *Job, triggers []*internal.Trigger) policy.Out {
var policyFunc policy.Func
p, err := policy.UnmarshalDefinition(job.TriggeringPolicyRaw)
if err == nil {
policyFunc, err = op.policyFactory(p)
}
if err != nil {
op.debugErrLog(c, err, "Failed to instant... | [
"func",
"(",
"op",
"*",
"triageOp",
")",
"triggeringPolicy",
"(",
"c",
"context",
".",
"Context",
",",
"job",
"*",
"Job",
",",
"triggers",
"[",
"]",
"*",
"internal",
".",
"Trigger",
")",
"policy",
".",
"Out",
"{",
"var",
"policyFunc",
"policy",
".",
... | // triggeringPolicy decides how to convert a set of pending triggers into
// a bunch of new invocations.
//
// Called within a job transaction. Must not do any expensive calls. | [
"triggeringPolicy",
"decides",
"how",
"to",
"convert",
"a",
"set",
"of",
"pending",
"triggers",
"into",
"a",
"bunch",
"of",
"new",
"invocations",
".",
"Called",
"within",
"a",
"job",
"transaction",
".",
"Must",
"not",
"do",
"any",
"expensive",
"calls",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/triage.go#L436-L451 |
129,341 | luci/luci-go | common/sync/cancelcond/cancelCond.go | New | func New(l sync.Locker) *Cond {
return &Cond{
Cond: sync.NewCond(l),
}
} | go | func New(l sync.Locker) *Cond {
return &Cond{
Cond: sync.NewCond(l),
}
} | [
"func",
"New",
"(",
"l",
"sync",
".",
"Locker",
")",
"*",
"Cond",
"{",
"return",
"&",
"Cond",
"{",
"Cond",
":",
"sync",
".",
"NewCond",
"(",
"l",
")",
",",
"}",
"\n",
"}"
] | // New creates a new Context-cancellable Cond. | [
"New",
"creates",
"a",
"new",
"Context",
"-",
"cancellable",
"Cond",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/sync/cancelcond/cancelCond.go#L31-L35 |
129,342 | luci/luci-go | config/appengine/gaeconfig/default.go | UseFlex | func UseFlex(c context.Context) context.Context {
// TODO: Install a path to load configurations from datastore cache. ATM,
// it can't be done because using datastore cache requires the ability to
// write to datastore.
ccfg := cacheConfig{
GlobalCache: func(c context.Context, be backend.B, s *Settings) backend.... | go | func UseFlex(c context.Context) context.Context {
// TODO: Install a path to load configurations from datastore cache. ATM,
// it can't be done because using datastore cache requires the ability to
// write to datastore.
ccfg := cacheConfig{
GlobalCache: func(c context.Context, be backend.B, s *Settings) backend.... | [
"func",
"UseFlex",
"(",
"c",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"// TODO: Install a path to load configurations from datastore cache. ATM,",
"// it can't be done because using datastore cache requires the ability to",
"// write to datastore.",
"ccfg",
":=... | // UseFlex installs the default luci-config client for an AppEngine Flex
// environment.
//
// UseFlex has the same effect as Use, except that the backing cache is
// a process-local cache instead of the AppEngine memcache service. | [
"UseFlex",
"installs",
"the",
"default",
"luci",
"-",
"config",
"client",
"for",
"an",
"AppEngine",
"Flex",
"environment",
".",
"UseFlex",
"has",
"the",
"same",
"effect",
"as",
"Use",
"except",
"that",
"the",
"backing",
"cache",
"is",
"a",
"process",
"-",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/appengine/gaeconfig/default.go#L162-L172 |
129,343 | luci/luci-go | config/appengine/gaeconfig/default.go | devServerBackend | func devServerBackend() backend.B {
pwd := os.Getenv("PWD") // os.Getwd works funny with symlinks, use PWD
candidates := []string{
filepath.Join(pwd, devCfgDir),
filepath.Join(filepath.Dir(pwd), devCfgDir),
}
for _, dir := range candidates {
if _, err := os.Stat(dir); err == nil {
fs, err := filesystem.New... | go | func devServerBackend() backend.B {
pwd := os.Getenv("PWD") // os.Getwd works funny with symlinks, use PWD
candidates := []string{
filepath.Join(pwd, devCfgDir),
filepath.Join(filepath.Dir(pwd), devCfgDir),
}
for _, dir := range candidates {
if _, err := os.Stat(dir); err == nil {
fs, err := filesystem.New... | [
"func",
"devServerBackend",
"(",
")",
"backend",
".",
"B",
"{",
"pwd",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"// os.Getwd works funny with symlinks, use PWD",
"\n",
"candidates",
":=",
"[",
"]",
"string",
"{",
"filepath",
".",
"Join",
"(",
"pwd",
... | // devServerConfig returns backend.B to use on a devserver.
//
// See New for details. | [
"devServerConfig",
"returns",
"backend",
".",
"B",
"to",
"use",
"on",
"a",
"devserver",
".",
"See",
"New",
"for",
"details",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/appengine/gaeconfig/default.go#L247-L265 |
129,344 | luci/luci-go | client/isolated/archive.go | Archive | func Archive(ctx context.Context, arch *archiver.Archiver, opts *ArchiveOptions) *archiver.PendingItem {
item, err := archive(ctx, arch, opts)
if err != nil {
i := &archiver.PendingItem{DisplayName: opts.Isolated}
i.SetErr(err)
return i
}
return item
} | go | func Archive(ctx context.Context, arch *archiver.Archiver, opts *ArchiveOptions) *archiver.PendingItem {
item, err := archive(ctx, arch, opts)
if err != nil {
i := &archiver.PendingItem{DisplayName: opts.Isolated}
i.SetErr(err)
return i
}
return item
} | [
"func",
"Archive",
"(",
"ctx",
"context",
".",
"Context",
",",
"arch",
"*",
"archiver",
".",
"Archiver",
",",
"opts",
"*",
"ArchiveOptions",
")",
"*",
"archiver",
".",
"PendingItem",
"{",
"item",
",",
"err",
":=",
"archive",
"(",
"ctx",
",",
"arch",
",... | // Archive uses the given archiver and options to constructed an isolated file, and
// uploads it and its dependencies.
//
// Archive returns the digest of the composite isolated file. | [
"Archive",
"uses",
"the",
"given",
"archiver",
"and",
"options",
"to",
"constructed",
"an",
"isolated",
"file",
"and",
"uploads",
"it",
"and",
"its",
"dependencies",
".",
"Archive",
"returns",
"the",
"digest",
"of",
"the",
"composite",
"isolated",
"file",
"."
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolated/archive.go#L65-L73 |
129,345 | luci/luci-go | logdog/appengine/coordinator/endpoints/services/service.go | maybeEnterProjectNamespace | func maybeEnterProjectNamespace(c context.Context, req proto.Message) (context.Context, error) {
if pbm, ok := req.(endpoints.ProjectBoundMessage); ok {
project := types.ProjectName(pbm.GetMessageProject())
log.Fields{
"project": project,
}.Debugf(c, "Request is entering project namespace.")
if err := coord... | go | func maybeEnterProjectNamespace(c context.Context, req proto.Message) (context.Context, error) {
if pbm, ok := req.(endpoints.ProjectBoundMessage); ok {
project := types.ProjectName(pbm.GetMessageProject())
log.Fields{
"project": project,
}.Debugf(c, "Request is entering project namespace.")
if err := coord... | [
"func",
"maybeEnterProjectNamespace",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"proto",
".",
"Message",
")",
"(",
"context",
".",
"Context",
",",
"error",
")",
"{",
"if",
"pbm",
",",
"ok",
":=",
"req",
".",
"(",
"endpoints",
".",
"ProjectBoundMes... | // maybeEnterProjectNamespace enters a datastore namespace based on the request
// message type. | [
"maybeEnterProjectNamespace",
"enters",
"a",
"datastore",
"namespace",
"based",
"on",
"the",
"request",
"message",
"type",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/endpoints/services/service.go#L57-L68 |
129,346 | luci/luci-go | dm/appengine/model/backdep.go | Edge | func (b *BackDep) Edge() *FwdEdge {
ret := &FwdEdge{From: &b.Depender, To: &dm.Attempt_ID{}}
if err := ret.To.SetDMEncoded(b.DependeeGroup.StringID()); err != nil {
panic(err)
}
return ret
} | go | func (b *BackDep) Edge() *FwdEdge {
ret := &FwdEdge{From: &b.Depender, To: &dm.Attempt_ID{}}
if err := ret.To.SetDMEncoded(b.DependeeGroup.StringID()); err != nil {
panic(err)
}
return ret
} | [
"func",
"(",
"b",
"*",
"BackDep",
")",
"Edge",
"(",
")",
"*",
"FwdEdge",
"{",
"ret",
":=",
"&",
"FwdEdge",
"{",
"From",
":",
"&",
"b",
".",
"Depender",
",",
"To",
":",
"&",
"dm",
".",
"Attempt_ID",
"{",
"}",
"}",
"\n",
"if",
"err",
":=",
"ret... | // Edge produces a fwdedge object which points from the depending attempt to
// the depended-on attempt. | [
"Edge",
"produces",
"a",
"fwdedge",
"object",
"which",
"points",
"from",
"the",
"depending",
"attempt",
"to",
"the",
"depended",
"-",
"on",
"attempt",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/model/backdep.go#L67-L73 |
129,347 | luci/luci-go | lucicfg/cli/app.go | Main | func Main(params base.Parameters, args []string) int {
// Enable not-yet-standard Starlark features.
resolve.AllowLambda = true
resolve.AllowNestedDef = true
resolve.AllowFloat = true
resolve.AllowSet = true
// A hack to allow '#!/usr/bin/env lucicfg'. On Linux the shebang line can
// have at most two arguments... | go | func Main(params base.Parameters, args []string) int {
// Enable not-yet-standard Starlark features.
resolve.AllowLambda = true
resolve.AllowNestedDef = true
resolve.AllowFloat = true
resolve.AllowSet = true
// A hack to allow '#!/usr/bin/env lucicfg'. On Linux the shebang line can
// have at most two arguments... | [
"func",
"Main",
"(",
"params",
"base",
".",
"Parameters",
",",
"args",
"[",
"]",
"string",
")",
"int",
"{",
"// Enable not-yet-standard Starlark features.",
"resolve",
".",
"AllowLambda",
"=",
"true",
"\n",
"resolve",
".",
"AllowNestedDef",
"=",
"true",
"\n",
... | // Main runs the lucicfg CLI. | [
"Main",
"runs",
"the",
"lucicfg",
"CLI",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/cli/app.go#L39-L55 |
129,348 | luci/luci-go | lucicfg/cli/app.go | GetApplication | func GetApplication(params base.Parameters) *cli.Application {
return &cli.Application{
Name: "lucicfg",
Title: "LUCI config generator (" + lucicfg.UserAgent + ")",
Context: func(ctx context.Context) context.Context {
loggerConfig := gologger.LoggerConfig{
Format: `[P%{pid} %{time:15:04:05.000} %{shortf... | go | func GetApplication(params base.Parameters) *cli.Application {
return &cli.Application{
Name: "lucicfg",
Title: "LUCI config generator (" + lucicfg.UserAgent + ")",
Context: func(ctx context.Context) context.Context {
loggerConfig := gologger.LoggerConfig{
Format: `[P%{pid} %{time:15:04:05.000} %{shortf... | [
"func",
"GetApplication",
"(",
"params",
"base",
".",
"Parameters",
")",
"*",
"cli",
".",
"Application",
"{",
"return",
"&",
"cli",
".",
"Application",
"{",
"Name",
":",
"\"",
"\"",
",",
"Title",
":",
"\"",
"\"",
"+",
"lucicfg",
".",
"UserAgent",
"+",
... | // GetApplication returns lucicfg cli.Application. | [
"GetApplication",
"returns",
"lucicfg",
"cli",
".",
"Application",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/cli/app.go#L58-L89 |
129,349 | luci/luci-go | server/auth/openid/cookie.go | makeSessionCookie | func makeSessionCookie(c context.Context, sid string, secure bool) (*http.Cookie, error) {
tok, err := sessionCookieToken.Generate(c, nil, map[string]string{"sid": sid}, 0)
if err != nil {
return nil, err
}
// Make cookie expire a bit earlier, to avoid weird "bad token" errors if
// clocks are out of sync.
exp ... | go | func makeSessionCookie(c context.Context, sid string, secure bool) (*http.Cookie, error) {
tok, err := sessionCookieToken.Generate(c, nil, map[string]string{"sid": sid}, 0)
if err != nil {
return nil, err
}
// Make cookie expire a bit earlier, to avoid weird "bad token" errors if
// clocks are out of sync.
exp ... | [
"func",
"makeSessionCookie",
"(",
"c",
"context",
".",
"Context",
",",
"sid",
"string",
",",
"secure",
"bool",
")",
"(",
"*",
"http",
".",
"Cookie",
",",
"error",
")",
"{",
"tok",
",",
"err",
":=",
"sessionCookieToken",
".",
"Generate",
"(",
"c",
",",
... | // makeSessionCookie takes a session ID and makes a signed cookie that can be
// put in a response. | [
"makeSessionCookie",
"takes",
"a",
"session",
"ID",
"and",
"makes",
"a",
"signed",
"cookie",
"that",
"can",
"be",
"put",
"in",
"a",
"response",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/cookie.go#L41-L58 |
129,350 | luci/luci-go | server/auth/openid/cookie.go | decodeSessionCookie | func decodeSessionCookie(c context.Context, r *http.Request) (string, error) {
cookie, err := r.Cookie(sessionCookieName)
if err != nil {
return "", nil // no such cookie
}
payload, err := sessionCookieToken.Validate(c, cookie.Value, nil)
switch {
case transient.Tag.In(err):
return "", err
case err != nil:
... | go | func decodeSessionCookie(c context.Context, r *http.Request) (string, error) {
cookie, err := r.Cookie(sessionCookieName)
if err != nil {
return "", nil // no such cookie
}
payload, err := sessionCookieToken.Validate(c, cookie.Value, nil)
switch {
case transient.Tag.In(err):
return "", err
case err != nil:
... | [
"func",
"decodeSessionCookie",
"(",
"c",
"context",
".",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"string",
",",
"error",
")",
"{",
"cookie",
",",
"err",
":=",
"r",
".",
"Cookie",
"(",
"sessionCookieName",
")",
"\n",
"if",
"err",
"... | // decodeSessionCookie takes an incoming request and returns a session ID stored
// in a session cookie, or "" if not there, invalid or expired. Returns errors
// on transient errors only. | [
"decodeSessionCookie",
"takes",
"an",
"incoming",
"request",
"and",
"returns",
"a",
"session",
"ID",
"stored",
"in",
"a",
"session",
"cookie",
"or",
"if",
"not",
"there",
"invalid",
"or",
"expired",
".",
"Returns",
"errors",
"on",
"transient",
"errors",
"only"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/cookie.go#L63-L80 |
129,351 | luci/luci-go | grpc/discovery/discovery.go | Enable | func Enable(server *prpc.Server) {
serviceNames := append(server.ServiceNames(), "discovery.Discovery")
service, err := New(serviceNames...)
if err != nil {
panic(err)
}
RegisterDiscoveryServer(server, service)
} | go | func Enable(server *prpc.Server) {
serviceNames := append(server.ServiceNames(), "discovery.Discovery")
service, err := New(serviceNames...)
if err != nil {
panic(err)
}
RegisterDiscoveryServer(server, service)
} | [
"func",
"Enable",
"(",
"server",
"*",
"prpc",
".",
"Server",
")",
"{",
"serviceNames",
":=",
"append",
"(",
"server",
".",
"ServiceNames",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"service",
",",
"err",
":=",
"New",
"(",
"serviceNames",
"...",
")",
"\n"... | // Enable registers a discovery service on the server.
// It makes all currently registered services and the discovery service
// discoverable. | [
"Enable",
"registers",
"a",
"discovery",
"service",
"on",
"the",
"server",
".",
"It",
"makes",
"all",
"currently",
"registered",
"services",
"and",
"the",
"discovery",
"service",
"discoverable",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/discovery/discovery.go#L48-L55 |
129,352 | luci/luci-go | grpc/discovery/discovery.go | combineDescriptors | func combineDescriptors(serviceNames []string) (*descriptor.FileDescriptorSet, error) {
result := &descriptor.FileDescriptorSet{}
// seenFiles is a set of descriptor files keyed by SHA256 of their contents.
seenFiles := map[[sha256.Size]byte]bool{}
for _, s := range serviceNames {
desc, err := GetDescriptorSet(s... | go | func combineDescriptors(serviceNames []string) (*descriptor.FileDescriptorSet, error) {
result := &descriptor.FileDescriptorSet{}
// seenFiles is a set of descriptor files keyed by SHA256 of their contents.
seenFiles := map[[sha256.Size]byte]bool{}
for _, s := range serviceNames {
desc, err := GetDescriptorSet(s... | [
"func",
"combineDescriptors",
"(",
"serviceNames",
"[",
"]",
"string",
")",
"(",
"*",
"descriptor",
".",
"FileDescriptorSet",
",",
"error",
")",
"{",
"result",
":=",
"&",
"descriptor",
".",
"FileDescriptorSet",
"{",
"}",
"\n",
"// seenFiles is a set of descriptor ... | // combineDescriptors creates one FileDescriptorSet that covers all services
// and their dependencies. | [
"combineDescriptors",
"creates",
"one",
"FileDescriptorSet",
"that",
"covers",
"all",
"services",
"and",
"their",
"dependencies",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/discovery/discovery.go#L71-L101 |
129,353 | luci/luci-go | common/logging/fields.go | NewFields | func NewFields(v map[string]interface{}) Fields {
fields := make(Fields)
for k, v := range v {
fields[k] = v
}
return fields
} | go | func NewFields(v map[string]interface{}) Fields {
fields := make(Fields)
for k, v := range v {
fields[k] = v
}
return fields
} | [
"func",
"NewFields",
"(",
"v",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"Fields",
"{",
"fields",
":=",
"make",
"(",
"Fields",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"v",
"{",
"fields",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
... | // NewFields instantiates a new Fields instance by duplicating the supplied map. | [
"NewFields",
"instantiates",
"a",
"new",
"Fields",
"instance",
"by",
"duplicating",
"the",
"supplied",
"map",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/fields.go#L41-L47 |
129,354 | luci/luci-go | common/logging/fields.go | Copy | func (f Fields) Copy(other Fields) Fields {
if len(f) == 0 && len(other) == 0 {
return nil
}
ret := make(Fields, len(f)+len(other))
for k, v := range f {
ret[k] = v
}
for k, v := range other {
ret[k] = v
}
return ret
} | go | func (f Fields) Copy(other Fields) Fields {
if len(f) == 0 && len(other) == 0 {
return nil
}
ret := make(Fields, len(f)+len(other))
for k, v := range f {
ret[k] = v
}
for k, v := range other {
ret[k] = v
}
return ret
} | [
"func",
"(",
"f",
"Fields",
")",
"Copy",
"(",
"other",
"Fields",
")",
"Fields",
"{",
"if",
"len",
"(",
"f",
")",
"==",
"0",
"&&",
"len",
"(",
"other",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"ret",
":=",
"make",
"(",
"Fields",
... | // Copy returns a copy of this Fields with the keys from other overlaid on top
// of this one's. | [
"Copy",
"returns",
"a",
"copy",
"of",
"this",
"Fields",
"with",
"the",
"keys",
"from",
"other",
"overlaid",
"on",
"top",
"of",
"this",
"one",
"s",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/fields.go#L58-L71 |
129,355 | luci/luci-go | common/logging/fields.go | SortedEntries | func (f Fields) SortedEntries() (s []*FieldEntry) {
if len(f) == 0 {
return nil
}
s = make([]*FieldEntry, 0, len(f))
for k, v := range f {
s = append(s, &FieldEntry{k, v})
}
sort.Sort(fieldEntrySlice(s))
return
} | go | func (f Fields) SortedEntries() (s []*FieldEntry) {
if len(f) == 0 {
return nil
}
s = make([]*FieldEntry, 0, len(f))
for k, v := range f {
s = append(s, &FieldEntry{k, v})
}
sort.Sort(fieldEntrySlice(s))
return
} | [
"func",
"(",
"f",
"Fields",
")",
"SortedEntries",
"(",
")",
"(",
"s",
"[",
"]",
"*",
"FieldEntry",
")",
"{",
"if",
"len",
"(",
"f",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"s",
"=",
"make",
"(",
"[",
"]",
"*",
"FieldEntry",
","... | // SortedEntries processes a Fields object, pruning invisible fields, placing
// the ErrorKey field first, and then sorting the remaining fields by key. | [
"SortedEntries",
"processes",
"a",
"Fields",
"object",
"pruning",
"invisible",
"fields",
"placing",
"the",
"ErrorKey",
"field",
"first",
"and",
"then",
"sorting",
"the",
"remaining",
"fields",
"by",
"key",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/fields.go#L75-L85 |
129,356 | luci/luci-go | common/logging/fields.go | String | func (f Fields) String() string {
b := bytes.Buffer{}
b.WriteRune('{')
for idx, e := range f.SortedEntries() {
if idx > 0 {
b.WriteString(", ")
}
b.WriteString(e.String())
}
b.WriteRune('}')
return b.String()
} | go | func (f Fields) String() string {
b := bytes.Buffer{}
b.WriteRune('{')
for idx, e := range f.SortedEntries() {
if idx > 0 {
b.WriteString(", ")
}
b.WriteString(e.String())
}
b.WriteRune('}')
return b.String()
} | [
"func",
"(",
"f",
"Fields",
")",
"String",
"(",
")",
"string",
"{",
"b",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"b",
".",
"WriteRune",
"(",
"'{'",
")",
"\n",
"for",
"idx",
",",
"e",
":=",
"range",
"f",
".",
"SortedEntries",
"(",
")",
"{"... | // String returns a string describing the contents of f in a sorted,
// dictionary-like format. | [
"String",
"returns",
"a",
"string",
"describing",
"the",
"contents",
"of",
"f",
"in",
"a",
"sorted",
"dictionary",
"-",
"like",
"format",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/fields.go#L89-L100 |
129,357 | luci/luci-go | common/logging/fields.go | GetFields | func GetFields(c context.Context) Fields {
if ret, ok := c.Value(fieldsKey).(Fields); ok {
return ret
}
return nil
} | go | func GetFields(c context.Context) Fields {
if ret, ok := c.Value(fieldsKey).(Fields); ok {
return ret
}
return nil
} | [
"func",
"GetFields",
"(",
"c",
"context",
".",
"Context",
")",
"Fields",
"{",
"if",
"ret",
",",
"ok",
":=",
"c",
".",
"Value",
"(",
"fieldsKey",
")",
".",
"(",
"Fields",
")",
";",
"ok",
"{",
"return",
"ret",
"\n",
"}",
"\n",
"return",
"nil",
"\n"... | // GetFields returns the current Fields.
//
// This method is used for logger implementations with the understanding that
// the returned fields must not be mutated. | [
"GetFields",
"returns",
"the",
"current",
"Fields",
".",
"This",
"method",
"is",
"used",
"for",
"logger",
"implementations",
"with",
"the",
"understanding",
"that",
"the",
"returned",
"fields",
"must",
"not",
"be",
"mutated",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/fields.go#L193-L198 |
129,358 | luci/luci-go | milo/git/context.go | WithProject | func WithProject(ctx context.Context, project string) context.Context {
return context.WithValue(ctx, &luciProjectKey, project)
} | go | func WithProject(ctx context.Context, project string) context.Context {
return context.WithValue(ctx, &luciProjectKey, project)
} | [
"func",
"WithProject",
"(",
"ctx",
"context",
".",
"Context",
",",
"project",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"&",
"luciProjectKey",
",",
"project",
")",
"\n",
"}"
] | // WithProject annotates the context object with the LUCI project that
// a request is handled for. | [
"WithProject",
"annotates",
"the",
"context",
"object",
"with",
"the",
"LUCI",
"project",
"that",
"a",
"request",
"is",
"handled",
"for",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/context.go#L27-L29 |
129,359 | luci/luci-go | milo/git/context.go | ProjectFromContext | func ProjectFromContext(ctx context.Context) (string, error) {
project, ok := ctx.Value(&luciProjectKey).(string)
if !ok {
return "", errors.Reason("LUCI project not available in context").Err()
}
if project == "" {
return "", errors.Reason("LUCI project is empty string").Err()
}
return project, nil
} | go | func ProjectFromContext(ctx context.Context) (string, error) {
project, ok := ctx.Value(&luciProjectKey).(string)
if !ok {
return "", errors.Reason("LUCI project not available in context").Err()
}
if project == "" {
return "", errors.Reason("LUCI project is empty string").Err()
}
return project, nil
} | [
"func",
"ProjectFromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"project",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"&",
"luciProjectKey",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
... | // ProjectFromContext is the opposite of WithProject, is extracts the
// LUCI project which the current call stack is handling a request for. | [
"ProjectFromContext",
"is",
"the",
"opposite",
"of",
"WithProject",
"is",
"extracts",
"the",
"LUCI",
"project",
"which",
"the",
"current",
"call",
"stack",
"is",
"handling",
"a",
"request",
"for",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/context.go#L33-L42 |
129,360 | luci/luci-go | logdog/appengine/coordinator/logStreamEncoding.go | decodeKey | func decodeKey(k string) (string, error) {
if !strings.HasPrefix(k, encodedKeyPrefix) {
return "", fmt.Errorf("encoded key missing prefix (%s)", encodedKeyPrefix)
}
data, err := keyEncoding.DecodeString(k[len(encodedKeyPrefix):])
if err != nil {
return "", fmt.Errorf("failed to decode key: %v", err)
}
return... | go | func decodeKey(k string) (string, error) {
if !strings.HasPrefix(k, encodedKeyPrefix) {
return "", fmt.Errorf("encoded key missing prefix (%s)", encodedKeyPrefix)
}
data, err := keyEncoding.DecodeString(k[len(encodedKeyPrefix):])
if err != nil {
return "", fmt.Errorf("failed to decode key: %v", err)
}
return... | [
"func",
"decodeKey",
"(",
"k",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"k",
",",
"encodedKeyPrefix",
")",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"encode... | // decodeKey converts an encoded key into its original key string. | [
"decodeKey",
"converts",
"an",
"encoded",
"key",
"into",
"its",
"original",
"key",
"string",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStreamEncoding.go#L40-L50 |
129,361 | luci/luci-go | logdog/appengine/coordinator/hashID.go | Normalize | func (id *HashID) Normalize() error {
// encoding/hex encodes using lower-case hexadecimal. Note that this is a
// no-op if the ID is already lowercase.
idv := strings.ToLower(string(*id))
if decodeSize := hex.DecodedLen(len(idv)); decodeSize != sha256.Size {
return fmt.Errorf("invalid SHA256 hash size (%d != %d... | go | func (id *HashID) Normalize() error {
// encoding/hex encodes using lower-case hexadecimal. Note that this is a
// no-op if the ID is already lowercase.
idv := strings.ToLower(string(*id))
if decodeSize := hex.DecodedLen(len(idv)); decodeSize != sha256.Size {
return fmt.Errorf("invalid SHA256 hash size (%d != %d... | [
"func",
"(",
"id",
"*",
"HashID",
")",
"Normalize",
"(",
")",
"error",
"{",
"// encoding/hex encodes using lower-case hexadecimal. Note that this is a",
"// no-op if the ID is already lowercase.",
"idv",
":=",
"strings",
".",
"ToLower",
"(",
"string",
"(",
"*",
"id",
")... | // Normalize normalizes the hash ID and verifies its integrity. | [
"Normalize",
"normalizes",
"the",
"hash",
"ID",
"and",
"verifies",
"its",
"integrity",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/hashID.go#L35-L50 |
129,362 | luci/luci-go | appengine/bqlog/bqlog.go | projID | func (l *Log) projID(ctx context.Context) string {
if l.ProjectID == "" {
return info.TrimmedAppID(ctx)
}
return l.ProjectID
} | go | func (l *Log) projID(ctx context.Context) string {
if l.ProjectID == "" {
return info.TrimmedAppID(ctx)
}
return l.ProjectID
} | [
"func",
"(",
"l",
"*",
"Log",
")",
"projID",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"if",
"l",
".",
"ProjectID",
"==",
"\"",
"\"",
"{",
"return",
"info",
".",
"TrimmedAppID",
"(",
"ctx",
")",
"\n",
"}",
"\n",
"return",
"l",
".... | // projID returns ProjectID or a GAE app ID if ProjectID is "". | [
"projID",
"returns",
"ProjectID",
"or",
"a",
"GAE",
"app",
"ID",
"if",
"ProjectID",
"is",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L443-L448 |
129,363 | luci/luci-go | appengine/bqlog/bqlog.go | tableRef | func (l *Log) tableRef(ctx context.Context) (string, error) {
projID := l.projID(ctx)
if projID == "" || strings.ContainsRune(projID, '/') {
return "", fmt.Errorf("invalid project ID %q", projID)
}
if l.DatasetID == "" || strings.ContainsRune(l.DatasetID, '/') {
return "", fmt.Errorf("invalid dataset ID %q", l.... | go | func (l *Log) tableRef(ctx context.Context) (string, error) {
projID := l.projID(ctx)
if projID == "" || strings.ContainsRune(projID, '/') {
return "", fmt.Errorf("invalid project ID %q", projID)
}
if l.DatasetID == "" || strings.ContainsRune(l.DatasetID, '/') {
return "", fmt.Errorf("invalid dataset ID %q", l.... | [
"func",
"(",
"l",
"*",
"Log",
")",
"tableRef",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"projID",
":=",
"l",
".",
"projID",
"(",
"ctx",
")",
"\n",
"if",
"projID",
"==",
"\"",
"\"",
"||",
"strings",
".",
... | // tableRef returns an identifier of the table in BigQuery.
//
// Returns an error if Log is misconfigred. | [
"tableRef",
"returns",
"an",
"identifier",
"of",
"the",
"table",
"in",
"BigQuery",
".",
"Returns",
"an",
"error",
"if",
"Log",
"is",
"misconfigred",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L453-L465 |
129,364 | luci/luci-go | appengine/bqlog/bqlog.go | bigQuery | func (l *Log) bigQuery(ctx context.Context) (*bqapi.Service, error) {
tr, err := auth.GetRPCTransport(ctx, auth.AsSelf, auth.WithScopes(bqapi.BigqueryScope))
if err != nil {
return nil, err
}
return bqapi.New(&http.Client{Transport: tr})
} | go | func (l *Log) bigQuery(ctx context.Context) (*bqapi.Service, error) {
tr, err := auth.GetRPCTransport(ctx, auth.AsSelf, auth.WithScopes(bqapi.BigqueryScope))
if err != nil {
return nil, err
}
return bqapi.New(&http.Client{Transport: tr})
} | [
"func",
"(",
"l",
"*",
"Log",
")",
"bigQuery",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"bqapi",
".",
"Service",
",",
"error",
")",
"{",
"tr",
",",
"err",
":=",
"auth",
".",
"GetRPCTransport",
"(",
"ctx",
",",
"auth",
".",
"AsSelf",
... | // bigQuery constructs an instance of BigQuery API client with proper auth. | [
"bigQuery",
"constructs",
"an",
"instance",
"of",
"BigQuery",
"API",
"client",
"with",
"proper",
"auth",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L468-L474 |
129,365 | luci/luci-go | appengine/bqlog/bqlog.go | doInsert | func (l *Log) doInsert(ctx context.Context, req *bqapi.TableDataInsertAllRequest) (*bqapi.TableDataInsertAllResponse, error) {
ctx, _ = clock.WithTimeout(ctx, 30*time.Second)
logging.Infof(ctx, "Sending %d rows to BigQuery", len(req.Rows))
bq, err := l.bigQuery(ctx)
if err != nil {
return nil, err
}
call := bq.... | go | func (l *Log) doInsert(ctx context.Context, req *bqapi.TableDataInsertAllRequest) (*bqapi.TableDataInsertAllResponse, error) {
ctx, _ = clock.WithTimeout(ctx, 30*time.Second)
logging.Infof(ctx, "Sending %d rows to BigQuery", len(req.Rows))
bq, err := l.bigQuery(ctx)
if err != nil {
return nil, err
}
call := bq.... | [
"func",
"(",
"l",
"*",
"Log",
")",
"doInsert",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"bqapi",
".",
"TableDataInsertAllRequest",
")",
"(",
"*",
"bqapi",
".",
"TableDataInsertAllResponse",
",",
"error",
")",
"{",
"ctx",
",",
"_",
"=",
"... | // doInsert does the actual BigQuery call.
//
// It is mocked in tests. | [
"doInsert",
"does",
"the",
"actual",
"BigQuery",
"call",
".",
"It",
"is",
"mocked",
"in",
"tests",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L479-L488 |
129,366 | luci/luci-go | appengine/bqlog/bqlog.go | start | func (f *asyncFlusher) start(numParallel int) {
f.chunks = make(chan chunk)
for i := 0; i < numParallel; i++ {
f.wg.Add(1)
go func() {
defer f.wg.Done()
f.uploaderLoop()
}()
}
} | go | func (f *asyncFlusher) start(numParallel int) {
f.chunks = make(chan chunk)
for i := 0; i < numParallel; i++ {
f.wg.Add(1)
go func() {
defer f.wg.Done()
f.uploaderLoop()
}()
}
} | [
"func",
"(",
"f",
"*",
"asyncFlusher",
")",
"start",
"(",
"numParallel",
"int",
")",
"{",
"f",
".",
"chunks",
"=",
"make",
"(",
"chan",
"chunk",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"numParallel",
";",
"i",
"++",
"{",
"f",
".",
"wg"... | // start launches internal goroutines that upload data. | [
"start",
"launches",
"internal",
"goroutines",
"that",
"upload",
"data",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L515-L524 |
129,367 | luci/luci-go | appengine/bqlog/bqlog.go | waitAll | func (f *asyncFlusher) waitAll() (int, error) {
close(f.chunks)
f.wg.Wait()
if len(f.errs) == 0 {
return f.rowsSent, nil
}
return f.rowsSent, f.errs
} | go | func (f *asyncFlusher) waitAll() (int, error) {
close(f.chunks)
f.wg.Wait()
if len(f.errs) == 0 {
return f.rowsSent, nil
}
return f.rowsSent, f.errs
} | [
"func",
"(",
"f",
"*",
"asyncFlusher",
")",
"waitAll",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"close",
"(",
"f",
".",
"chunks",
")",
"\n",
"f",
".",
"wg",
".",
"Wait",
"(",
")",
"\n",
"if",
"len",
"(",
"f",
".",
"errs",
")",
"==",
"0... | // waitAll waits for completion of all pending 'sendChunk' calls and stops all
// internal goroutines.
//
// Returns total number of rows sent and all the errors. | [
"waitAll",
"waits",
"for",
"completion",
"of",
"all",
"pending",
"sendChunk",
"calls",
"and",
"stops",
"all",
"internal",
"goroutines",
".",
"Returns",
"total",
"number",
"of",
"rows",
"sent",
"and",
"all",
"the",
"errors",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L530-L537 |
129,368 | luci/luci-go | appengine/bqlog/bqlog.go | ctx | func (f *asyncFlusher) ctx(chunkIndex int32) context.Context {
return logging.SetField(f.Context, "chunk", chunkIndex)
} | go | func (f *asyncFlusher) ctx(chunkIndex int32) context.Context {
return logging.SetField(f.Context, "chunk", chunkIndex)
} | [
"func",
"(",
"f",
"*",
"asyncFlusher",
")",
"ctx",
"(",
"chunkIndex",
"int32",
")",
"context",
".",
"Context",
"{",
"return",
"logging",
".",
"SetField",
"(",
"f",
".",
"Context",
",",
"\"",
"\"",
",",
"chunkIndex",
")",
"\n",
"}"
] | // ctx returns a context to use for logging operations happening to some chunk. | [
"ctx",
"returns",
"a",
"context",
"to",
"use",
"for",
"logging",
"operations",
"happening",
"to",
"some",
"chunk",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L540-L542 |
129,369 | luci/luci-go | appengine/bqlog/bqlog.go | sendChunk | func (f *asyncFlusher) sendChunk(c chunk) {
c.index = atomic.AddInt32(&f.index, 1)
logging.Infof(f.ctx(c.index), "Chunk with %d batches queued", len(c.Tasks))
f.chunks <- c
} | go | func (f *asyncFlusher) sendChunk(c chunk) {
c.index = atomic.AddInt32(&f.index, 1)
logging.Infof(f.ctx(c.index), "Chunk with %d batches queued", len(c.Tasks))
f.chunks <- c
} | [
"func",
"(",
"f",
"*",
"asyncFlusher",
")",
"sendChunk",
"(",
"c",
"chunk",
")",
"{",
"c",
".",
"index",
"=",
"atomic",
".",
"AddInt32",
"(",
"&",
"f",
".",
"index",
",",
"1",
")",
"\n",
"logging",
".",
"Infof",
"(",
"f",
".",
"ctx",
"(",
"c",
... | // sendChunk starts an asynchronous operation to upload data to BigQuery.
//
// Can block if too many parallel uploads are already underway. Panics if called
// before 'start' or after 'waitAll'.
//
// On successful upload it deletes the tasks from Pull Queue. | [
"sendChunk",
"starts",
"an",
"asynchronous",
"operation",
"to",
"upload",
"data",
"to",
"BigQuery",
".",
"Can",
"block",
"if",
"too",
"many",
"parallel",
"uploads",
"are",
"already",
"underway",
".",
"Panics",
"if",
"called",
"before",
"start",
"or",
"after",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L550-L554 |
129,370 | luci/luci-go | appengine/bqlog/bqlog.go | uploaderLoop | func (f *asyncFlusher) uploaderLoop() {
for chunk := range f.chunks {
ctx := f.ctx(chunk.index)
logging.Infof(ctx, "Chunk flush starting")
sent, err := f.upload(ctx, chunk)
f.mu.Lock()
if err == nil {
f.rowsSent += sent
} else {
f.errs = append(f.errs, err)
}
f.mu.Unlock()
logging.Infof(ctx, "C... | go | func (f *asyncFlusher) uploaderLoop() {
for chunk := range f.chunks {
ctx := f.ctx(chunk.index)
logging.Infof(ctx, "Chunk flush starting")
sent, err := f.upload(ctx, chunk)
f.mu.Lock()
if err == nil {
f.rowsSent += sent
} else {
f.errs = append(f.errs, err)
}
f.mu.Unlock()
logging.Infof(ctx, "C... | [
"func",
"(",
"f",
"*",
"asyncFlusher",
")",
"uploaderLoop",
"(",
")",
"{",
"for",
"chunk",
":=",
"range",
"f",
".",
"chunks",
"{",
"ctx",
":=",
"f",
".",
"ctx",
"(",
"chunk",
".",
"index",
")",
"\n",
"logging",
".",
"Infof",
"(",
"ctx",
",",
"\""... | // uploaderLoop runs in a separate goroutine. | [
"uploaderLoop",
"runs",
"in",
"a",
"separate",
"goroutine",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/bqlog/bqlog.go#L557-L571 |
129,371 | luci/luci-go | server/secrets/secrets.go | Clone | func (b NamedBlob) Clone() NamedBlob {
return NamedBlob{
ID: b.ID,
Blob: append([]byte(nil), b.Blob...),
}
} | go | func (b NamedBlob) Clone() NamedBlob {
return NamedBlob{
ID: b.ID,
Blob: append([]byte(nil), b.Blob...),
}
} | [
"func",
"(",
"b",
"NamedBlob",
")",
"Clone",
"(",
")",
"NamedBlob",
"{",
"return",
"NamedBlob",
"{",
"ID",
":",
"b",
".",
"ID",
",",
"Blob",
":",
"append",
"(",
"[",
"]",
"byte",
"(",
"nil",
")",
",",
"b",
".",
"Blob",
"...",
")",
",",
"}",
"... | // Clone makes a deep copy of the NamedBlob. | [
"Clone",
"makes",
"a",
"deep",
"copy",
"of",
"the",
"NamedBlob",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/secrets/secrets.go#L37-L42 |
129,372 | luci/luci-go | server/secrets/secrets.go | Blobs | func (s Secret) Blobs() []NamedBlob {
out := make([]NamedBlob, 0, 1+len(s.Previous))
out = append(out, s.Current)
out = append(out, s.Previous...)
return out
} | go | func (s Secret) Blobs() []NamedBlob {
out := make([]NamedBlob, 0, 1+len(s.Previous))
out = append(out, s.Current)
out = append(out, s.Previous...)
return out
} | [
"func",
"(",
"s",
"Secret",
")",
"Blobs",
"(",
")",
"[",
"]",
"NamedBlob",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"NamedBlob",
",",
"0",
",",
"1",
"+",
"len",
"(",
"s",
".",
"Previous",
")",
")",
"\n",
"out",
"=",
"append",
"(",
"out",
",",... | // Blobs returns current blob and all previous blobs as one array. | [
"Blobs",
"returns",
"current",
"blob",
"and",
"all",
"previous",
"blobs",
"as",
"one",
"array",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/secrets/secrets.go#L56-L61 |
129,373 | luci/luci-go | server/secrets/secrets.go | Clone | func (s Secret) Clone() Secret {
out := Secret{Current: s.Current.Clone()}
if s.Previous != nil {
out.Previous = make([]NamedBlob, len(s.Previous))
for i := range out.Previous {
out.Previous[i] = s.Previous[i].Clone()
}
}
return out
} | go | func (s Secret) Clone() Secret {
out := Secret{Current: s.Current.Clone()}
if s.Previous != nil {
out.Previous = make([]NamedBlob, len(s.Previous))
for i := range out.Previous {
out.Previous[i] = s.Previous[i].Clone()
}
}
return out
} | [
"func",
"(",
"s",
"Secret",
")",
"Clone",
"(",
")",
"Secret",
"{",
"out",
":=",
"Secret",
"{",
"Current",
":",
"s",
".",
"Current",
".",
"Clone",
"(",
")",
"}",
"\n",
"if",
"s",
".",
"Previous",
"!=",
"nil",
"{",
"out",
".",
"Previous",
"=",
"m... | // Clone makes a deep copy of the Secret. | [
"Clone",
"makes",
"a",
"deep",
"copy",
"of",
"the",
"Secret",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/secrets/secrets.go#L64-L73 |
129,374 | luci/luci-go | server/secrets/secrets.go | GetSecret | func (s StaticStore) GetSecret(k Key) (Secret, error) {
if secret, ok := s[k]; ok {
return secret.Clone(), nil
}
return Secret{}, ErrNoSuchSecret
} | go | func (s StaticStore) GetSecret(k Key) (Secret, error) {
if secret, ok := s[k]; ok {
return secret.Clone(), nil
}
return Secret{}, ErrNoSuchSecret
} | [
"func",
"(",
"s",
"StaticStore",
")",
"GetSecret",
"(",
"k",
"Key",
")",
"(",
"Secret",
",",
"error",
")",
"{",
"if",
"secret",
",",
"ok",
":=",
"s",
"[",
"k",
"]",
";",
"ok",
"{",
"return",
"secret",
".",
"Clone",
"(",
")",
",",
"nil",
"\n",
... | // GetSecret returns a copy of a secret given its key or ErrNoSuchSecret if no
// such secret. | [
"GetSecret",
"returns",
"a",
"copy",
"of",
"a",
"secret",
"given",
"its",
"key",
"or",
"ErrNoSuchSecret",
"if",
"no",
"such",
"secret",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/secrets/secrets.go#L90-L95 |
129,375 | luci/luci-go | milo/common/time.go | HumanDuration | func HumanDuration(d time.Duration) string {
t := int64(d.Seconds())
day := t / 86400
hr := (t % 86400) / 3600
if day > 0 {
if hr != 0 {
return fmt.Sprintf("%d days %d hrs", day, hr)
}
return fmt.Sprintf("%d days", day)
}
min := (t % 3600) / 60
if hr > 0 {
if min != 0 {
return fmt.Sprintf("%d hrs... | go | func HumanDuration(d time.Duration) string {
t := int64(d.Seconds())
day := t / 86400
hr := (t % 86400) / 3600
if day > 0 {
if hr != 0 {
return fmt.Sprintf("%d days %d hrs", day, hr)
}
return fmt.Sprintf("%d days", day)
}
min := (t % 3600) / 60
if hr > 0 {
if min != 0 {
return fmt.Sprintf("%d hrs... | [
"func",
"HumanDuration",
"(",
"d",
"time",
".",
"Duration",
")",
"string",
"{",
"t",
":=",
"int64",
"(",
"d",
".",
"Seconds",
"(",
")",
")",
"\n",
"day",
":=",
"t",
"/",
"86400",
"\n",
"hr",
":=",
"(",
"t",
"%",
"86400",
")",
"/",
"3600",
"\n\n... | // humanDuration translates d into a human readable string of x units y units,
// where x and y could be in days, hours, minutes, or seconds, whichever is the
// largest. | [
"humanDuration",
"translates",
"d",
"into",
"a",
"human",
"readable",
"string",
"of",
"x",
"units",
"y",
"units",
"where",
"x",
"and",
"y",
"could",
"be",
"in",
"days",
"hours",
"minutes",
"or",
"seconds",
"whichever",
"is",
"the",
"largest",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/time.go#L80-L117 |
129,376 | luci/luci-go | logdog/appengine/coordinator/config/settings.go | Load | func (s *Settings) Load(c context.Context) error {
var loadMe Settings
// Load additional global config from settings. If it's missing, that's fine,
// since its fields are all optional.
if err := settings.Get(c, globalConfigSettingsKey, &loadMe); err != nil {
// The settings are missing, so let's install the em... | go | func (s *Settings) Load(c context.Context) error {
var loadMe Settings
// Load additional global config from settings. If it's missing, that's fine,
// since its fields are all optional.
if err := settings.Get(c, globalConfigSettingsKey, &loadMe); err != nil {
// The settings are missing, so let's install the em... | [
"func",
"(",
"s",
"*",
"Settings",
")",
"Load",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"var",
"loadMe",
"Settings",
"\n\n",
"// Load additional global config from settings. If it's missing, that's fine,",
"// since its fields are all optional.",
"if",
"er... | // Load populates the settings instance from the stored settings.
//
// If no settings are stored, an empty Settings instance will be loaded and
// this will return nil.
//
// An error will be returned if an operation that is expected to succeed fails. | [
"Load",
"populates",
"the",
"settings",
"instance",
"from",
"the",
"stored",
"settings",
".",
"If",
"no",
"settings",
"are",
"stored",
"an",
"empty",
"Settings",
"instance",
"will",
"be",
"loaded",
"and",
"this",
"will",
"return",
"nil",
".",
"An",
"error",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/settings.go#L46-L65 |
129,377 | luci/luci-go | logdog/appengine/coordinator/config/settings.go | Store | func (s *Settings) Store(c context.Context, why string) error {
id := auth.CurrentIdentity(c)
log.Fields{
"identity": id,
"reason": why,
}.Infof(c, "Updating global configuration.")
return settings.Set(c, globalConfigSettingsKey, s, string(id), why)
} | go | func (s *Settings) Store(c context.Context, why string) error {
id := auth.CurrentIdentity(c)
log.Fields{
"identity": id,
"reason": why,
}.Infof(c, "Updating global configuration.")
return settings.Set(c, globalConfigSettingsKey, s, string(id), why)
} | [
"func",
"(",
"s",
"*",
"Settings",
")",
"Store",
"(",
"c",
"context",
".",
"Context",
",",
"why",
"string",
")",
"error",
"{",
"id",
":=",
"auth",
".",
"CurrentIdentity",
"(",
"c",
")",
"\n",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",
"id",
",",... | // Store stores the new global configuration. | [
"Store",
"stores",
"the",
"new",
"global",
"configuration",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/settings.go#L68-L75 |
129,378 | luci/luci-go | machine-db/appengine/model/datacenters.go | fetch | func (t *DatacentersTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, description, state
FROM datacenters
`)
if err != nil {
return errors.Annotate(err, "failed to select datacenters").Err()
}
defer rows.Close()
for rows.Next() {
dc := &Datac... | go | func (t *DatacentersTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, description, state
FROM datacenters
`)
if err != nil {
return errors.Annotate(err, "failed to select datacenters").Err()
}
defer rows.Close()
for rows.Next() {
dc := &Datac... | [
"func",
"(",
"t",
"*",
"DatacentersTable",
")",
"fetch",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"db",
":=",
"database",
".",
"Get",
"(",
"c",
")",
"\n",
"rows",
",",
"err",
":=",
"db",
".",
"QueryContext",
"(",
"c",
",",
"`\n\t\tSE... | // fetch fetches the datacenters from the database. | [
"fetch",
"fetches",
"the",
"datacenters",
"from",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/datacenters.go#L47-L65 |
129,379 | luci/luci-go | machine-db/appengine/model/datacenters.go | computeChanges | func (t *DatacentersTable) computeChanges(c context.Context, datacenters []*config.Datacenter) {
cfgs := make(map[string]*Datacenter, len(datacenters))
for _, cfg := range datacenters {
cfgs[cfg.Name] = &Datacenter{
Datacenter: config.Datacenter{
Name: cfg.Name,
Description: cfg.Description,
S... | go | func (t *DatacentersTable) computeChanges(c context.Context, datacenters []*config.Datacenter) {
cfgs := make(map[string]*Datacenter, len(datacenters))
for _, cfg := range datacenters {
cfgs[cfg.Name] = &Datacenter{
Datacenter: config.Datacenter{
Name: cfg.Name,
Description: cfg.Description,
S... | [
"func",
"(",
"t",
"*",
"DatacentersTable",
")",
"computeChanges",
"(",
"c",
"context",
".",
"Context",
",",
"datacenters",
"[",
"]",
"*",
"config",
".",
"Datacenter",
")",
"{",
"cfgs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Datacenter",
",... | // computeChanges computes the changes that need to be made to the datacenters in the database. | [
"computeChanges",
"computes",
"the",
"changes",
"that",
"need",
"to",
"be",
"made",
"to",
"the",
"datacenters",
"in",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/datacenters.go#L73-L108 |
129,380 | luci/luci-go | machine-db/appengine/model/datacenters.go | remove | func (t *DatacentersTable) remove(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.removals) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
DELETE FROM datacenters
WHERE id = ?
`)
if err != nil {
return errors.An... | go | func (t *DatacentersTable) remove(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.removals) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
DELETE FROM datacenters
WHERE id = ?
`)
if err != nil {
return errors.An... | [
"func",
"(",
"t",
"*",
"DatacentersTable",
")",
"remove",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"removals",
")",
"==",
"0",
"{",
"return",
... | // remove removes all datacenters pending removal from the database, clearing pending removals.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"remove",
"removes",
"all",
"datacenters",
"pending",
"removal",
"from",
"the",
"database",
"clearing",
"pending",
"removals",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/datacenters.go#L148-L187 |
129,381 | luci/luci-go | machine-db/appengine/model/datacenters.go | update | func (t *DatacentersTable) update(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.updates) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
UPDATE datacenters
SET description = ?, state = ?
WHERE id = ?
`)
if err ... | go | func (t *DatacentersTable) update(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.updates) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
UPDATE datacenters
SET description = ?, state = ?
WHERE id = ?
`)
if err ... | [
"func",
"(",
"t",
"*",
"DatacentersTable",
")",
"update",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"updates",
")",
"==",
"0",
"{",
"return",
"... | // update updates all datacenters pending update in the database, clearing pending updates.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"update",
"updates",
"all",
"datacenters",
"pending",
"update",
"in",
"the",
"database",
"clearing",
"pending",
"updates",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/datacenters.go#L191-L229 |
129,382 | luci/luci-go | machine-db/appengine/model/datacenters.go | ids | func (t *DatacentersTable) ids(c context.Context) map[string]int64 {
dcs := make(map[string]int64, len(t.current))
for _, dc := range t.current {
dcs[dc.Name] = dc.Id
}
return dcs
} | go | func (t *DatacentersTable) ids(c context.Context) map[string]int64 {
dcs := make(map[string]int64, len(t.current))
for _, dc := range t.current {
dcs[dc.Name] = dc.Id
}
return dcs
} | [
"func",
"(",
"t",
"*",
"DatacentersTable",
")",
"ids",
"(",
"c",
"context",
".",
"Context",
")",
"map",
"[",
"string",
"]",
"int64",
"{",
"dcs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int64",
",",
"len",
"(",
"t",
".",
"current",
")",
")"... | // ids returns a map of datacenter names to IDs. | [
"ids",
"returns",
"a",
"map",
"of",
"datacenter",
"names",
"to",
"IDs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/datacenters.go#L232-L238 |
129,383 | luci/luci-go | machine-db/appengine/model/datacenters.go | EnsureDatacenters | func EnsureDatacenters(c context.Context, cfgs []*config.Datacenter) (map[string]int64, error) {
t := &DatacentersTable{}
if err := t.fetch(c); err != nil {
return nil, errors.Annotate(err, "failed to fetch datacenters").Err()
}
t.computeChanges(c, cfgs)
if err := t.add(c); err != nil {
return nil, errors.Anno... | go | func EnsureDatacenters(c context.Context, cfgs []*config.Datacenter) (map[string]int64, error) {
t := &DatacentersTable{}
if err := t.fetch(c); err != nil {
return nil, errors.Annotate(err, "failed to fetch datacenters").Err()
}
t.computeChanges(c, cfgs)
if err := t.add(c); err != nil {
return nil, errors.Anno... | [
"func",
"EnsureDatacenters",
"(",
"c",
"context",
".",
"Context",
",",
"cfgs",
"[",
"]",
"*",
"config",
".",
"Datacenter",
")",
"(",
"map",
"[",
"string",
"]",
"int64",
",",
"error",
")",
"{",
"t",
":=",
"&",
"DatacentersTable",
"{",
"}",
"\n",
"if",... | // EnsureDatacenters ensures the database contains exactly the given datacenters.
// Returns a map of datacenter names to IDs in the database. | [
"EnsureDatacenters",
"ensures",
"the",
"database",
"contains",
"exactly",
"the",
"given",
"datacenters",
".",
"Returns",
"a",
"map",
"of",
"datacenter",
"names",
"to",
"IDs",
"in",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/datacenters.go#L242-L258 |
129,384 | luci/luci-go | grpc/cmd/prpc/show.go | show | func show(c context.Context, client *prpc.Client, name string) error {
desc, err := loadDescription(c, client)
if err != nil {
return fmt.Errorf("could not load server description: %s", err)
}
if name == "" {
for _, s := range desc.Services {
fmt.Println(s)
}
return nil
}
file, obj, path := descutil.... | go | func show(c context.Context, client *prpc.Client, name string) error {
desc, err := loadDescription(c, client)
if err != nil {
return fmt.Errorf("could not load server description: %s", err)
}
if name == "" {
for _, s := range desc.Services {
fmt.Println(s)
}
return nil
}
file, obj, path := descutil.... | [
"func",
"show",
"(",
"c",
"context",
".",
"Context",
",",
"client",
"*",
"prpc",
".",
"Client",
",",
"name",
"string",
")",
"error",
"{",
"desc",
",",
"err",
":=",
"loadDescription",
"(",
"c",
",",
"client",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{"... | // show prints a definition of an object referenced by name in proto3 style. | [
"show",
"prints",
"a",
"definition",
"of",
"an",
"object",
"referenced",
"by",
"name",
"in",
"proto3",
"style",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/show.go#L82-L154 |
129,385 | luci/luci-go | tokenserver/appengine/impl/certchecker/rpc_is_revoked_cert.go | IsRevokedCert | func (r *IsRevokedCertRPC) IsRevokedCert(c context.Context, req *admin.IsRevokedCertRequest) (*admin.IsRevokedCertResponse, error) {
sn := big.Int{}
if _, ok := sn.SetString(req.Sn, 0); !ok {
return nil, status.Errorf(codes.InvalidArgument, "can't parse 'sn'")
}
checker, err := GetCertChecker(c, req.Ca)
if err ... | go | func (r *IsRevokedCertRPC) IsRevokedCert(c context.Context, req *admin.IsRevokedCertRequest) (*admin.IsRevokedCertResponse, error) {
sn := big.Int{}
if _, ok := sn.SetString(req.Sn, 0); !ok {
return nil, status.Errorf(codes.InvalidArgument, "can't parse 'sn'")
}
checker, err := GetCertChecker(c, req.Ca)
if err ... | [
"func",
"(",
"r",
"*",
"IsRevokedCertRPC",
")",
"IsRevokedCert",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"admin",
".",
"IsRevokedCertRequest",
")",
"(",
"*",
"admin",
".",
"IsRevokedCertResponse",
",",
"error",
")",
"{",
"sn",
":=",
"big",
... | // IsRevokedCert says whether a certificate serial number is in the CRL. | [
"IsRevokedCert",
"says",
"whether",
"a",
"certificate",
"serial",
"number",
"is",
"in",
"the",
"CRL",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certchecker/rpc_is_revoked_cert.go#L32-L52 |
129,386 | luci/luci-go | luci_notify/notify/srcman.go | srcmanCheckout | func srcmanCheckout(c context.Context, build *Build) (Checkout, error) {
transport, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
return nil, errors.Annotate(err, "getting RPC Transport").Err()
}
client := coordinator.NewClient(&prpc.Client{
C: &http.Client{Transport: transport},
Host: ... | go | func srcmanCheckout(c context.Context, build *Build) (Checkout, error) {
transport, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
return nil, errors.Annotate(err, "getting RPC Transport").Err()
}
client := coordinator.NewClient(&prpc.Client{
C: &http.Client{Transport: transport},
Host: ... | [
"func",
"srcmanCheckout",
"(",
"c",
"context",
".",
"Context",
",",
"build",
"*",
"Build",
")",
"(",
"Checkout",
",",
"error",
")",
"{",
"transport",
",",
"err",
":=",
"auth",
".",
"GetRPCTransport",
"(",
"c",
",",
"auth",
".",
"AsSelf",
")",
"\n",
"... | // srcmanCheckout is a CheckoutFunc which retrieves a source checkout related
// to a build by querying LogDog for a source manifest stream associated with
// that build. It assumes that the build has exactly one source manifest. | [
"srcmanCheckout",
"is",
"a",
"CheckoutFunc",
"which",
"retrieves",
"a",
"source",
"checkout",
"related",
"to",
"a",
"build",
"by",
"querying",
"LogDog",
"for",
"a",
"source",
"manifest",
"stream",
"associated",
"with",
"that",
"build",
".",
"It",
"assumes",
"t... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/luci_notify/notify/srcman.go#L46-L113 |
129,387 | luci/luci-go | client/internal/common/concurrent.go | NewGoroutinePool | func NewGoroutinePool(ctx context.Context, maxConcurrentJobs int) *GoroutinePool {
return &GoroutinePool{
ctx: ctx,
sema: newSemaphore(maxConcurrentJobs),
}
} | go | func NewGoroutinePool(ctx context.Context, maxConcurrentJobs int) *GoroutinePool {
return &GoroutinePool{
ctx: ctx,
sema: newSemaphore(maxConcurrentJobs),
}
} | [
"func",
"NewGoroutinePool",
"(",
"ctx",
"context",
".",
"Context",
",",
"maxConcurrentJobs",
"int",
")",
"*",
"GoroutinePool",
"{",
"return",
"&",
"GoroutinePool",
"{",
"ctx",
":",
"ctx",
",",
"sema",
":",
"newSemaphore",
"(",
"maxConcurrentJobs",
")",
",",
... | // NewGoroutinePool creates a new GoroutinePool running at most
// maxConcurrentJobs concurrent operations. | [
"NewGoroutinePool",
"creates",
"a",
"new",
"GoroutinePool",
"running",
"at",
"most",
"maxConcurrentJobs",
"concurrent",
"operations",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/internal/common/concurrent.go#L86-L91 |
129,388 | luci/luci-go | client/internal/common/concurrent.go | Schedule | func (g *GoroutinePool) Schedule(job, onCanceled func()) {
g.wg.Add(1)
// Note: We could save a bit of memory by preallocating maxConcurrentJobs
// goroutines instead of one goroutine per item.
go func() {
defer g.wg.Done()
if g.sema.wait(g.ctx) == nil {
defer g.sema.signal()
job()
} else if onCanceled ... | go | func (g *GoroutinePool) Schedule(job, onCanceled func()) {
g.wg.Add(1)
// Note: We could save a bit of memory by preallocating maxConcurrentJobs
// goroutines instead of one goroutine per item.
go func() {
defer g.wg.Done()
if g.sema.wait(g.ctx) == nil {
defer g.sema.signal()
job()
} else if onCanceled ... | [
"func",
"(",
"g",
"*",
"GoroutinePool",
")",
"Schedule",
"(",
"job",
",",
"onCanceled",
"func",
"(",
")",
")",
"{",
"g",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"// Note: We could save a bit of memory by preallocating maxConcurrentJobs",
"// goroutines instead... | // Schedule adds a new job for execution as a separate goroutine.
//
// If the GoroutinePool context is canceled, onCanceled is called instead. It
// is fine to pass nil as onCanceled. | [
"Schedule",
"adds",
"a",
"new",
"job",
"for",
"execution",
"as",
"a",
"separate",
"goroutine",
".",
"If",
"the",
"GoroutinePool",
"context",
"is",
"canceled",
"onCanceled",
"is",
"called",
"instead",
".",
"It",
"is",
"fine",
"to",
"pass",
"nil",
"as",
"onC... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/internal/common/concurrent.go#L114-L127 |
129,389 | luci/luci-go | client/internal/common/concurrent.go | NewGoroutinePriorityPool | func NewGoroutinePriorityPool(ctx context.Context, maxConcurrentJobs int) *GoroutinePriorityPool {
pool := &GoroutinePriorityPool{
ctx: ctx,
sema: newSemaphore(maxConcurrentJobs),
tasks: priorityQueue{},
}
return pool
} | go | func NewGoroutinePriorityPool(ctx context.Context, maxConcurrentJobs int) *GoroutinePriorityPool {
pool := &GoroutinePriorityPool{
ctx: ctx,
sema: newSemaphore(maxConcurrentJobs),
tasks: priorityQueue{},
}
return pool
} | [
"func",
"NewGoroutinePriorityPool",
"(",
"ctx",
"context",
".",
"Context",
",",
"maxConcurrentJobs",
"int",
")",
"*",
"GoroutinePriorityPool",
"{",
"pool",
":=",
"&",
"GoroutinePriorityPool",
"{",
"ctx",
":",
"ctx",
",",
"sema",
":",
"newSemaphore",
"(",
"maxCon... | // NewGoroutinePriorityPool creates a new goroutine pool with at most
// maxConcurrentJobs.
//
// Each task is run according to the priority of each item. | [
"NewGoroutinePriorityPool",
"creates",
"a",
"new",
"goroutine",
"pool",
"with",
"at",
"most",
"maxConcurrentJobs",
".",
"Each",
"task",
"is",
"run",
"according",
"to",
"the",
"priority",
"of",
"each",
"item",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/internal/common/concurrent.go#L133-L140 |
129,390 | luci/luci-go | client/internal/common/concurrent.go | Schedule | func (g *GoroutinePriorityPool) Schedule(priority int64, job, onCanceled func()) {
g.wg.Add(1)
t := &task{priority, job, onCanceled}
g.mu.Lock()
heap.Push(&g.tasks, t)
g.mu.Unlock()
go g.executeOne()
} | go | func (g *GoroutinePriorityPool) Schedule(priority int64, job, onCanceled func()) {
g.wg.Add(1)
t := &task{priority, job, onCanceled}
g.mu.Lock()
heap.Push(&g.tasks, t)
g.mu.Unlock()
go g.executeOne()
} | [
"func",
"(",
"g",
"*",
"GoroutinePriorityPool",
")",
"Schedule",
"(",
"priority",
"int64",
",",
"job",
",",
"onCanceled",
"func",
"(",
")",
")",
"{",
"g",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"t",
":=",
"&",
"task",
"{",
"priority",
",",
"... | // Schedule adds a new job for execution as a separate goroutine.
//
// If the GoroutinePriorityPool is canceled, onCanceled is called instead. It
// is fine to pass nil as onCanceled. Smaller values of priority imply earlier
// execution.
//
// The lower the priority value, the higher the priority of the item. | [
"Schedule",
"adds",
"a",
"new",
"job",
"for",
"execution",
"as",
"a",
"separate",
"goroutine",
".",
"If",
"the",
"GoroutinePriorityPool",
"is",
"canceled",
"onCanceled",
"is",
"called",
"instead",
".",
"It",
"is",
"fine",
"to",
"pass",
"nil",
"as",
"onCancel... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/internal/common/concurrent.go#L168-L175 |
129,391 | luci/luci-go | starlark/starlarkproto/message.go | NewMessage | func NewMessage(typ *MessageType) *Message {
return &Message{
typ: typ,
fields: starlark.StringDict{},
}
} | go | func NewMessage(typ *MessageType) *Message {
return &Message{
typ: typ,
fields: starlark.StringDict{},
}
} | [
"func",
"NewMessage",
"(",
"typ",
"*",
"MessageType",
")",
"*",
"Message",
"{",
"return",
"&",
"Message",
"{",
"typ",
":",
"typ",
",",
"fields",
":",
"starlark",
".",
"StringDict",
"{",
"}",
",",
"}",
"\n",
"}"
] | // NewMessage instantiates a new empty message of the given type. | [
"NewMessage",
"instantiates",
"a",
"new",
"empty",
"message",
"of",
"the",
"given",
"type",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L41-L46 |
129,392 | luci/luci-go | starlark/starlarkproto/message.go | ToProto | func (m *Message) ToProto() (proto.Message, error) {
ptr := m.typ.NewProtoMessage() // ~ ptr := &ProtoMessage{}
msg := ptr.Elem() // ~ msg := *ptr (a reference)
for name, val := range m.fields {
fd, ok := m.typ.fields[name]
if !ok {
panic("should not happen, SetField and Attr checks the structur... | go | func (m *Message) ToProto() (proto.Message, error) {
ptr := m.typ.NewProtoMessage() // ~ ptr := &ProtoMessage{}
msg := ptr.Elem() // ~ msg := *ptr (a reference)
for name, val := range m.fields {
fd, ok := m.typ.fields[name]
if !ok {
panic("should not happen, SetField and Attr checks the structur... | [
"func",
"(",
"m",
"*",
"Message",
")",
"ToProto",
"(",
")",
"(",
"proto",
".",
"Message",
",",
"error",
")",
"{",
"ptr",
":=",
"m",
".",
"typ",
".",
"NewProtoMessage",
"(",
")",
"// ~ ptr := &ProtoMessage{}",
"\n",
"msg",
":=",
"ptr",
".",
"Elem",
"(... | // ToProto returns a new populated proto message of an appropriate type.
//
// Returns an error if the data inside the Starlark representation of
// the message has a wrong type. | [
"ToProto",
"returns",
"a",
"new",
"populated",
"proto",
"message",
"of",
"an",
"appropriate",
"type",
".",
"Returns",
"an",
"error",
"if",
"the",
"data",
"inside",
"the",
"Starlark",
"representation",
"of",
"the",
"message",
"has",
"a",
"wrong",
"type",
"."
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L57-L72 |
129,393 | luci/luci-go | starlark/starlarkproto/message.go | FromProto | func (m *Message) FromProto(p proto.Message) error {
ptr := reflect.ValueOf(p)
if ptr.Type() != m.typ.Type() {
return fmt.Errorf("bad message type: got %s, expect %s", ptr.Type(), m.typ.Type())
}
msg := ptr.Elem()
for name, fd := range m.typ.fields {
// Get the field's value from the proto message as reflect.... | go | func (m *Message) FromProto(p proto.Message) error {
ptr := reflect.ValueOf(p)
if ptr.Type() != m.typ.Type() {
return fmt.Errorf("bad message type: got %s, expect %s", ptr.Type(), m.typ.Type())
}
msg := ptr.Elem()
for name, fd := range m.typ.fields {
// Get the field's value from the proto message as reflect.... | [
"func",
"(",
"m",
"*",
"Message",
")",
"FromProto",
"(",
"p",
"proto",
".",
"Message",
")",
"error",
"{",
"ptr",
":=",
"reflect",
".",
"ValueOf",
"(",
"p",
")",
"\n",
"if",
"ptr",
".",
"Type",
"(",
")",
"!=",
"m",
".",
"typ",
".",
"Type",
"(",
... | // FromProto populates fields of this message based on values in proto.Message.
//
// Returns an error on type mismatch. | [
"FromProto",
"populates",
"fields",
"of",
"this",
"message",
"based",
"on",
"values",
"in",
"proto",
".",
"Message",
".",
"Returns",
"an",
"error",
"on",
"type",
"mismatch",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L77-L106 |
129,394 | luci/luci-go | starlark/starlarkproto/message.go | String | func (m *Message) String() string {
msg, err := m.ToProto()
if err != nil {
return fmt.Sprintf("<!Bad %s: %s!>", m.Type(), err)
}
return msg.String()
} | go | func (m *Message) String() string {
msg, err := m.ToProto()
if err != nil {
return fmt.Sprintf("<!Bad %s: %s!>", m.Type(), err)
}
return msg.String()
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"String",
"(",
")",
"string",
"{",
"msg",
",",
"err",
":=",
"m",
".",
"ToProto",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"m",
".",
"Type",
"(... | // Basic starlark.Value interface.
// String implements starlark.Value. | [
"Basic",
"starlark",
".",
"Value",
"interface",
".",
"String",
"implements",
"starlark",
".",
"Value",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L138-L144 |
129,395 | luci/luci-go | starlark/starlarkproto/message.go | Freeze | func (m *Message) Freeze() {
if !m.frozen {
m.fields.Freeze()
m.frozen = true
}
} | go | func (m *Message) Freeze() {
if !m.frozen {
m.fields.Freeze()
m.frozen = true
}
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"Freeze",
"(",
")",
"{",
"if",
"!",
"m",
".",
"frozen",
"{",
"m",
".",
"fields",
".",
"Freeze",
"(",
")",
"\n",
"m",
".",
"frozen",
"=",
"true",
"\n",
"}",
"\n",
"}"
] | // Freeze implements starlark.Value. | [
"Freeze",
"implements",
"starlark",
".",
"Value",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L157-L162 |
129,396 | luci/luci-go | starlark/starlarkproto/message.go | Attr | func (m *Message) Attr(name string) (starlark.Value, error) {
// The field was already set?
val, ok := m.fields[name]
if ok {
return val, nil
}
// The field wasn't set, but it is defined by the proto schema? Need to
// generate and return the default value then, except for oneof alternatives
// that do not ha... | go | func (m *Message) Attr(name string) (starlark.Value, error) {
// The field was already set?
val, ok := m.fields[name]
if ok {
return val, nil
}
// The field wasn't set, but it is defined by the proto schema? Need to
// generate and return the default value then, except for oneof alternatives
// that do not ha... | [
"func",
"(",
"m",
"*",
"Message",
")",
"Attr",
"(",
"name",
"string",
")",
"(",
"starlark",
".",
"Value",
",",
"error",
")",
"{",
"// The field was already set?",
"val",
",",
"ok",
":=",
"m",
".",
"fields",
"[",
"name",
"]",
"\n",
"if",
"ok",
"{",
... | // HasAttrs and HasSetField interfaces that make the message look like a struct.
// Attr implements starlark.HasAttrs. | [
"HasAttrs",
"and",
"HasSetField",
"interfaces",
"that",
"make",
"the",
"message",
"look",
"like",
"a",
"struct",
".",
"Attr",
"implements",
"starlark",
".",
"HasAttrs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L175-L213 |
129,397 | luci/luci-go | starlark/starlarkproto/message.go | SetField | func (m *Message) SetField(name string, val starlark.Value) error {
fd, ok := m.typ.fields[name]
if !ok {
return fmt.Errorf("proto message %q has no field %q", m.Type(), name)
}
// Setting a field to None removes it completely.
if val == starlark.None {
if err := m.checkMutable(); err != nil {
return err
... | go | func (m *Message) SetField(name string, val starlark.Value) error {
fd, ok := m.typ.fields[name]
if !ok {
return fmt.Errorf("proto message %q has no field %q", m.Type(), name)
}
// Setting a field to None removes it completely.
if val == starlark.None {
if err := m.checkMutable(); err != nil {
return err
... | [
"func",
"(",
"m",
"*",
"Message",
")",
"SetField",
"(",
"name",
"string",
",",
"val",
"starlark",
".",
"Value",
")",
"error",
"{",
"fd",
",",
"ok",
":=",
"m",
".",
"typ",
".",
"fields",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"f... | // SetField implements starlark.HasSetField. | [
"SetField",
"implements",
"starlark",
".",
"HasSetField",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L221-L265 |
129,398 | luci/luci-go | starlark/starlarkproto/message.go | checkMutable | func (m *Message) checkMutable() error {
if m.frozen {
return fmt.Errorf("cannot modify frozen proto message %q", m.Type())
}
return nil
} | go | func (m *Message) checkMutable() error {
if m.frozen {
return fmt.Errorf("cannot modify frozen proto message %q", m.Type())
}
return nil
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"checkMutable",
"(",
")",
"error",
"{",
"if",
"m",
".",
"frozen",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
".",
"Type",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // checkMutable returns an error if the message is frozen. | [
"checkMutable",
"returns",
"an",
"error",
"if",
"the",
"message",
"is",
"frozen",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L268-L273 |
129,399 | luci/luci-go | starlark/starlarkproto/message.go | shouldMakeMessages | func shouldMakeMessages(seq starlark.Sequence) bool {
iter := seq.Iterate()
defer iter.Done()
var v starlark.Value
for iter.Next(&v) {
if v == starlark.None {
return true
}
if _, ok := v.(*starlark.Dict); ok {
return true
}
}
return false
} | go | func shouldMakeMessages(seq starlark.Sequence) bool {
iter := seq.Iterate()
defer iter.Done()
var v starlark.Value
for iter.Next(&v) {
if v == starlark.None {
return true
}
if _, ok := v.(*starlark.Dict); ok {
return true
}
}
return false
} | [
"func",
"shouldMakeMessages",
"(",
"seq",
"starlark",
".",
"Sequence",
")",
"bool",
"{",
"iter",
":=",
"seq",
".",
"Iterate",
"(",
")",
"\n",
"defer",
"iter",
".",
"Done",
"(",
")",
"\n",
"var",
"v",
"starlark",
".",
"Value",
"\n",
"for",
"iter",
"."... | // shouldMakeMessages returns true if seq has at least one dict or None that
// should be converted to a proto message. | [
"shouldMakeMessages",
"returns",
"true",
"if",
"seq",
"has",
"at",
"least",
"one",
"dict",
"or",
"None",
"that",
"should",
"be",
"converted",
"to",
"a",
"proto",
"message",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/message.go#L337-L350 |
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.