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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
146,000 | favclip/ucon | plugin.go | HandlersScanner | func (p *pluginContainer) HandlersScanner() HandlersScannerPlugin {
if v, ok := p.base.(HandlersScannerPlugin); ok {
return v
}
return nil
} | go | func (p *pluginContainer) HandlersScanner() HandlersScannerPlugin {
if v, ok := p.base.(HandlersScannerPlugin); ok {
return v
}
return nil
} | [
"func",
"(",
"p",
"*",
"pluginContainer",
")",
"HandlersScanner",
"(",
")",
"HandlersScannerPlugin",
"{",
"if",
"v",
",",
"ok",
":=",
"p",
".",
"base",
".",
"(",
"HandlersScannerPlugin",
")",
";",
"ok",
"{",
"return",
"v",
"\n",
"}",
"\n\n",
"return",
... | // HandlersScanner returns itself if it implements HandlersScannerPlugin. | [
"HandlersScanner",
"returns",
"itself",
"if",
"it",
"implements",
"HandlersScannerPlugin",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/plugin.go#L23-L29 |
146,001 | favclip/ucon | middleware_builtin.go | HTTPRWDI | func HTTPRWDI() MiddlewareFunc {
return func(b *Bubble) error {
for idx, argT := range b.ArgumentTypes {
if httpReqType.AssignableTo(argT) {
b.Arguments[idx] = reflect.ValueOf(b.R)
continue
}
if httpRespType.AssignableTo(argT) {
b.Arguments[idx] = reflect.ValueOf(b.W)
continue
}
}
re... | go | func HTTPRWDI() MiddlewareFunc {
return func(b *Bubble) error {
for idx, argT := range b.ArgumentTypes {
if httpReqType.AssignableTo(argT) {
b.Arguments[idx] = reflect.ValueOf(b.R)
continue
}
if httpRespType.AssignableTo(argT) {
b.Arguments[idx] = reflect.ValueOf(b.W)
continue
}
}
re... | [
"func",
"HTTPRWDI",
"(",
")",
"MiddlewareFunc",
"{",
"return",
"func",
"(",
"b",
"*",
"Bubble",
")",
"error",
"{",
"for",
"idx",
",",
"argT",
":=",
"range",
"b",
".",
"ArgumentTypes",
"{",
"if",
"httpReqType",
".",
"AssignableTo",
"(",
"argT",
")",
"{"... | // HTTPRWDI injects Bubble.R and Bubble.W into the bubble.Arguments. | [
"HTTPRWDI",
"injects",
"Bubble",
".",
"R",
"and",
"Bubble",
".",
"W",
"into",
"the",
"bubble",
".",
"Arguments",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/middleware_builtin.go#L82-L97 |
146,002 | favclip/ucon | middleware_builtin.go | ContextDI | func ContextDI() MiddlewareFunc {
return func(b *Bubble) error {
for idx, argT := range b.ArgumentTypes {
if contextType.AssignableTo(argT) {
b.Arguments[idx] = reflect.ValueOf(b.Context)
continue
}
}
return b.Next()
}
} | go | func ContextDI() MiddlewareFunc {
return func(b *Bubble) error {
for idx, argT := range b.ArgumentTypes {
if contextType.AssignableTo(argT) {
b.Arguments[idx] = reflect.ValueOf(b.Context)
continue
}
}
return b.Next()
}
} | [
"func",
"ContextDI",
"(",
")",
"MiddlewareFunc",
"{",
"return",
"func",
"(",
"b",
"*",
"Bubble",
")",
"error",
"{",
"for",
"idx",
",",
"argT",
":=",
"range",
"b",
".",
"ArgumentTypes",
"{",
"if",
"contextType",
".",
"AssignableTo",
"(",
"argT",
")",
"{... | // ContextDI injects Bubble.Context into the bubble.Arguments. | [
"ContextDI",
"injects",
"Bubble",
".",
"Context",
"into",
"the",
"bubble",
".",
"Arguments",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/middleware_builtin.go#L106-L117 |
146,003 | favclip/ucon | middleware_builtin.go | RequestObjectMapper | func RequestObjectMapper() MiddlewareFunc {
return func(b *Bubble) error {
argIdx := -1
var argT reflect.Type
for idx, arg := range b.Arguments {
if arg.IsValid() {
// already injected
continue
}
if b.ArgumentTypes[idx].Kind() != reflect.Ptr || b.ArgumentTypes[idx].Elem().Kind() != reflect.Struc... | go | func RequestObjectMapper() MiddlewareFunc {
return func(b *Bubble) error {
argIdx := -1
var argT reflect.Type
for idx, arg := range b.Arguments {
if arg.IsValid() {
// already injected
continue
}
if b.ArgumentTypes[idx].Kind() != reflect.Ptr || b.ArgumentTypes[idx].Elem().Kind() != reflect.Struc... | [
"func",
"RequestObjectMapper",
"(",
")",
"MiddlewareFunc",
"{",
"return",
"func",
"(",
"b",
"*",
"Bubble",
")",
"error",
"{",
"argIdx",
":=",
"-",
"1",
"\n",
"var",
"argT",
"reflect",
".",
"Type",
"\n",
"for",
"idx",
",",
"arg",
":=",
"range",
"b",
"... | // RequestObjectMapper converts a request to object and injects it into the bubble.Arguments. | [
"RequestObjectMapper",
"converts",
"a",
"request",
"to",
"object",
"and",
"injects",
"it",
"into",
"the",
"bubble",
".",
"Arguments",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/middleware_builtin.go#L120-L214 |
146,004 | favclip/ucon | middleware_builtin.go | ResponseMapper | func ResponseMapper() MiddlewareFunc {
return func(b *Bubble) error {
err := b.Next()
// first, error handling
if err != nil {
return b.writeErrorObject(err)
}
// second, error from handlers
for idx := len(b.Returns) - 1; 0 <= idx; idx-- {
rv := b.Returns[idx]
if rv.Type().AssignableTo(errorType... | go | func ResponseMapper() MiddlewareFunc {
return func(b *Bubble) error {
err := b.Next()
// first, error handling
if err != nil {
return b.writeErrorObject(err)
}
// second, error from handlers
for idx := len(b.Returns) - 1; 0 <= idx; idx-- {
rv := b.Returns[idx]
if rv.Type().AssignableTo(errorType... | [
"func",
"ResponseMapper",
"(",
")",
"MiddlewareFunc",
"{",
"return",
"func",
"(",
"b",
"*",
"Bubble",
")",
"error",
"{",
"err",
":=",
"b",
".",
"Next",
"(",
")",
"\n\n",
"// first, error handling",
"if",
"err",
"!=",
"nil",
"{",
"return",
"b",
".",
"wr... | // ResponseMapper converts a response object to JSON and writes it as response body. | [
"ResponseMapper",
"converts",
"a",
"response",
"object",
"to",
"JSON",
"and",
"writes",
"it",
"as",
"response",
"body",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/middleware_builtin.go#L217-L274 |
146,005 | favclip/ucon | middleware_builtin.go | RequestValidator | func RequestValidator(validator Validator) MiddlewareFunc {
if validator == nil {
v := golidator.NewValidator()
v.SetTag("ucon")
validator = v
}
return func(b *Bubble) error {
for idx, argT := range b.ArgumentTypes {
if httpReqType.AssignableTo(argT) {
continue
} else if httpRespType.AssignableTo(... | go | func RequestValidator(validator Validator) MiddlewareFunc {
if validator == nil {
v := golidator.NewValidator()
v.SetTag("ucon")
validator = v
}
return func(b *Bubble) error {
for idx, argT := range b.ArgumentTypes {
if httpReqType.AssignableTo(argT) {
continue
} else if httpRespType.AssignableTo(... | [
"func",
"RequestValidator",
"(",
"validator",
"Validator",
")",
"MiddlewareFunc",
"{",
"if",
"validator",
"==",
"nil",
"{",
"v",
":=",
"golidator",
".",
"NewValidator",
"(",
")",
"\n",
"v",
".",
"SetTag",
"(",
"\"",
"\"",
")",
"\n",
"validator",
"=",
"v"... | // RequestValidator checks request object validity. | [
"RequestValidator",
"checks",
"request",
"object",
"validity",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/middleware_builtin.go#L339-L373 |
146,006 | favclip/ucon | sample/appengine/model_query.go | NewTodoQueryBuilderWithKind | func NewTodoQueryBuilderWithKind(kind string) *TodoQueryBuilder {
q := datastore.NewQuery(kind)
bldr := &TodoQueryBuilder{q: q}
bldr.ID = &TodoQueryProperty{
bldr: bldr,
name: "__key__",
}
bldr.Text = &TodoQueryProperty{
bldr: bldr,
name: "Text",
}
bldr.Done = &TodoQueryProperty{
bldr: bldr,
name: "D... | go | func NewTodoQueryBuilderWithKind(kind string) *TodoQueryBuilder {
q := datastore.NewQuery(kind)
bldr := &TodoQueryBuilder{q: q}
bldr.ID = &TodoQueryProperty{
bldr: bldr,
name: "__key__",
}
bldr.Text = &TodoQueryProperty{
bldr: bldr,
name: "Text",
}
bldr.Done = &TodoQueryProperty{
bldr: bldr,
name: "D... | [
"func",
"NewTodoQueryBuilderWithKind",
"(",
"kind",
"string",
")",
"*",
"TodoQueryBuilder",
"{",
"q",
":=",
"datastore",
".",
"NewQuery",
"(",
"kind",
")",
"\n",
"bldr",
":=",
"&",
"TodoQueryBuilder",
"{",
"q",
":",
"q",
"}",
"\n",
"bldr",
".",
"ID",
"="... | // NewTodoQueryBuilderWithKind create new TodoQueryBuilder with specific kind. | [
"NewTodoQueryBuilderWithKind",
"create",
"new",
"TodoQueryBuilder",
"with",
"specific",
"kind",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/sample/appengine/model_query.go#L33-L63 |
146,007 | favclip/ucon | swagger/swagger_model.go | Private | func (swaggerTag TagSwagger) Private() bool {
text := reflect.StructTag(swaggerTag).Get("swagger")
name := strings.Split(text, ",")[0]
return name == "-"
} | go | func (swaggerTag TagSwagger) Private() bool {
text := reflect.StructTag(swaggerTag).Get("swagger")
name := strings.Split(text, ",")[0]
return name == "-"
} | [
"func",
"(",
"swaggerTag",
"TagSwagger",
")",
"Private",
"(",
")",
"bool",
"{",
"text",
":=",
"reflect",
".",
"StructTag",
"(",
"swaggerTag",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"name",
":=",
"strings",
".",
"Split",
"(",
"text",
",",
"\"",
... | // Private returns whether the field is hidden from swagger. | [
"Private",
"returns",
"whether",
"the",
"field",
"is",
"hidden",
"from",
"swagger",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/swagger_model.go#L21-L26 |
146,008 | favclip/ucon | swagger/swagger_model.go | Name | func (swaggerTag TagSwagger) Name() string {
{
text := reflect.StructTag(swaggerTag).Get("swagger")
name := strings.Split(text, ",")[0]
if name != "" {
return name
}
}
{
text := reflect.StructTag(swaggerTag).Get("json")
name := strings.Split(text, ",")[0]
if name != "" {
return name
}
}
re... | go | func (swaggerTag TagSwagger) Name() string {
{
text := reflect.StructTag(swaggerTag).Get("swagger")
name := strings.Split(text, ",")[0]
if name != "" {
return name
}
}
{
text := reflect.StructTag(swaggerTag).Get("json")
name := strings.Split(text, ",")[0]
if name != "" {
return name
}
}
re... | [
"func",
"(",
"swaggerTag",
"TagSwagger",
")",
"Name",
"(",
")",
"string",
"{",
"{",
"text",
":=",
"reflect",
".",
"StructTag",
"(",
"swaggerTag",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"name",
":=",
"strings",
".",
"Split",
"(",
"text",
",",
... | // Name returns the name for swagger.
// If the name is not given by `swagger` tag, `json` tag will be used instead. | [
"Name",
"returns",
"the",
"name",
"for",
"swagger",
".",
"If",
"the",
"name",
"is",
"not",
"given",
"by",
"swagger",
"tag",
"json",
"tag",
"will",
"be",
"used",
"instead",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/swagger_model.go#L30-L49 |
146,009 | favclip/ucon | swagger/swagger_model.go | Empty | func (swaggerTag TagSwagger) Empty() bool {
text := reflect.StructTag(swaggerTag).Get("swagger")
if len(text) == 0 {
return true
}
return false
} | go | func (swaggerTag TagSwagger) Empty() bool {
text := reflect.StructTag(swaggerTag).Get("swagger")
if len(text) == 0 {
return true
}
return false
} | [
"func",
"(",
"swaggerTag",
"TagSwagger",
")",
"Empty",
"(",
")",
"bool",
"{",
"text",
":=",
"reflect",
".",
"StructTag",
"(",
"swaggerTag",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"text",
")",
"==",
"0",
"{",
"return",
"true"... | // Empty returns whether the text of the tag is empty. | [
"Empty",
"returns",
"whether",
"the",
"text",
"of",
"the",
"tag",
"is",
"empty",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/swagger_model.go#L52-L58 |
146,010 | favclip/ucon | swagger/swagger_model.go | In | func (swaggerTag TagSwagger) In() string {
text := reflect.StructTag(swaggerTag).Get("swagger")
texts := strings.Split(text, ",")[1:]
for _, text := range texts {
if strings.HasPrefix(text, "in=") {
return text[3:]
}
}
return ""
} | go | func (swaggerTag TagSwagger) In() string {
text := reflect.StructTag(swaggerTag).Get("swagger")
texts := strings.Split(text, ",")[1:]
for _, text := range texts {
if strings.HasPrefix(text, "in=") {
return text[3:]
}
}
return ""
} | [
"func",
"(",
"swaggerTag",
"TagSwagger",
")",
"In",
"(",
")",
"string",
"{",
"text",
":=",
"reflect",
".",
"StructTag",
"(",
"swaggerTag",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"texts",
":=",
"strings",
".",
"Split",
"(",
"text",
",",
"\"",
... | // In returns the place where the field will be put as parameter. | [
"In",
"returns",
"the",
"place",
"where",
"the",
"field",
"will",
"be",
"put",
"as",
"parameter",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/swagger_model.go#L75-L86 |
146,011 | favclip/ucon | swagger/swagger_model.go | Required | func (swaggerTag TagSwagger) Required() bool {
text := reflect.StructTag(swaggerTag).Get("swagger")
texts := strings.Split(text, ",")[1:]
for _, text := range texts {
if text == "req" {
return true
}
}
return false
} | go | func (swaggerTag TagSwagger) Required() bool {
text := reflect.StructTag(swaggerTag).Get("swagger")
texts := strings.Split(text, ",")[1:]
for _, text := range texts {
if text == "req" {
return true
}
}
return false
} | [
"func",
"(",
"swaggerTag",
"TagSwagger",
")",
"Required",
"(",
")",
"bool",
"{",
"text",
":=",
"reflect",
".",
"StructTag",
"(",
"swaggerTag",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"texts",
":=",
"strings",
".",
"Split",
"(",
"text",
",",
"\""... | // Required returns whether the field is required. | [
"Required",
"returns",
"whether",
"the",
"field",
"is",
"required",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/swagger_model.go#L89-L100 |
146,012 | favclip/ucon | core.go | Middleware | func (m *ServeMux) Middleware(f MiddlewareFunc) {
m.middlewares = append(m.middlewares, f)
} | go | func (m *ServeMux) Middleware(f MiddlewareFunc) {
m.middlewares = append(m.middlewares, f)
} | [
"func",
"(",
"m",
"*",
"ServeMux",
")",
"Middleware",
"(",
"f",
"MiddlewareFunc",
")",
"{",
"m",
".",
"middlewares",
"=",
"append",
"(",
"m",
".",
"middlewares",
",",
"f",
")",
"\n",
"}"
] | // Middleware can append Middleware to ServeMux. | [
"Middleware",
"can",
"append",
"Middleware",
"to",
"ServeMux",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/core.go#L35-L37 |
146,013 | favclip/ucon | core.go | Plugin | func (m *ServeMux) Plugin(plugin interface{}) {
p, ok := plugin.(*pluginContainer)
if !ok {
p = &pluginContainer{base: plugin}
}
p.check()
m.plugins = append(m.plugins, p)
} | go | func (m *ServeMux) Plugin(plugin interface{}) {
p, ok := plugin.(*pluginContainer)
if !ok {
p = &pluginContainer{base: plugin}
}
p.check()
m.plugins = append(m.plugins, p)
} | [
"func",
"(",
"m",
"*",
"ServeMux",
")",
"Plugin",
"(",
"plugin",
"interface",
"{",
"}",
")",
"{",
"p",
",",
"ok",
":=",
"plugin",
".",
"(",
"*",
"pluginContainer",
")",
"\n",
"if",
"!",
"ok",
"{",
"p",
"=",
"&",
"pluginContainer",
"{",
"base",
":... | // Plugin can append Plugin to ServeMux. | [
"Plugin",
"can",
"append",
"Plugin",
"to",
"ServeMux",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/core.go#L40-L47 |
146,014 | favclip/ucon | core.go | Prepare | func (m *ServeMux) Prepare() {
for _, plugin := range m.plugins {
used := false
if sc := plugin.HandlersScanner(); sc != nil {
err := sc.HandlersScannerProcess(m, m.router.handlers)
if err != nil {
panic(err)
}
used = true
}
if !used {
panic(fmt.Sprintf("unused plugin: %#v", plugin))
}
}
... | go | func (m *ServeMux) Prepare() {
for _, plugin := range m.plugins {
used := false
if sc := plugin.HandlersScanner(); sc != nil {
err := sc.HandlersScannerProcess(m, m.router.handlers)
if err != nil {
panic(err)
}
used = true
}
if !used {
panic(fmt.Sprintf("unused plugin: %#v", plugin))
}
}
... | [
"func",
"(",
"m",
"*",
"ServeMux",
")",
"Prepare",
"(",
")",
"{",
"for",
"_",
",",
"plugin",
":=",
"range",
"m",
".",
"plugins",
"{",
"used",
":=",
"false",
"\n",
"if",
"sc",
":=",
"plugin",
".",
"HandlersScanner",
"(",
")",
";",
"sc",
"!=",
"nil... | // Prepare the ServeMux.
// Plugin is not show affect to anything.
// This method is enabled plugins. | [
"Prepare",
"the",
"ServeMux",
".",
"Plugin",
"is",
"not",
"show",
"affect",
"to",
"anything",
".",
"This",
"method",
"is",
"enabled",
"plugins",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/core.go#L52-L66 |
146,015 | favclip/ucon | core.go | ServeHTTP | func (m *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// NOTE ucon内部のルーティングは一元的にこの関数から行う
// Handlerを細分化しhttp.ServeMuxに登録すると、OPTIONSのhandleがうまくできなくなる
// このため、Handlerはucon全体で1つとし、OPTIONSも通常のMethodと同じようにHandlerを設定し利用する
// OPTIONSを適切にhandleするため、全てのHandlerに特殊なHookを入れるよりマシである
m.router.ServeHTTP(w, r)
} | go | func (m *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// NOTE ucon内部のルーティングは一元的にこの関数から行う
// Handlerを細分化しhttp.ServeMuxに登録すると、OPTIONSのhandleがうまくできなくなる
// このため、Handlerはucon全体で1つとし、OPTIONSも通常のMethodと同じようにHandlerを設定し利用する
// OPTIONSを適切にhandleするため、全てのHandlerに特殊なHookを入れるよりマシである
m.router.ServeHTTP(w, r)
} | [
"func",
"(",
"m",
"*",
"ServeMux",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// NOTE ucon内部のルーティングは一元的にこの関数から行う",
"// Handlerを細分化しhttp.ServeMuxに登録すると、OPTIONSのhandleがうまくできなくなる",
"// このため、Handlerはucon全体で1つとし... | // ServeHTTP dispatches request to the handler. | [
"ServeHTTP",
"dispatches",
"request",
"to",
"the",
"handler",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/core.go#L69-L76 |
146,016 | favclip/ucon | core.go | ListenAndServe | func (m *ServeMux) ListenAndServe(addr string) error {
m.Prepare()
server := &http.Server{Addr: addr, Handler: m}
return server.ListenAndServe()
} | go | func (m *ServeMux) ListenAndServe(addr string) error {
m.Prepare()
server := &http.Server{Addr: addr, Handler: m}
return server.ListenAndServe()
} | [
"func",
"(",
"m",
"*",
"ServeMux",
")",
"ListenAndServe",
"(",
"addr",
"string",
")",
"error",
"{",
"m",
".",
"Prepare",
"(",
")",
"\n\n",
"server",
":=",
"&",
"http",
".",
"Server",
"{",
"Addr",
":",
"addr",
",",
"Handler",
":",
"m",
"}",
"\n",
... | // ListenAndServe start accepts the client request. | [
"ListenAndServe",
"start",
"accepts",
"the",
"client",
"request",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/core.go#L79-L84 |
146,017 | favclip/ucon | core.go | Orthodox | func Orthodox() {
DefaultMux.Middleware(ResponseMapper())
DefaultMux.Middleware(HTTPRWDI())
DefaultMux.Middleware(ContextDI())
DefaultMux.Middleware(RequestObjectMapper())
} | go | func Orthodox() {
DefaultMux.Middleware(ResponseMapper())
DefaultMux.Middleware(HTTPRWDI())
DefaultMux.Middleware(ContextDI())
DefaultMux.Middleware(RequestObjectMapper())
} | [
"func",
"Orthodox",
"(",
")",
"{",
"DefaultMux",
".",
"Middleware",
"(",
"ResponseMapper",
"(",
")",
")",
"\n",
"DefaultMux",
".",
"Middleware",
"(",
"HTTPRWDI",
"(",
")",
")",
"\n",
"DefaultMux",
".",
"Middleware",
"(",
"ContextDI",
"(",
")",
")",
"\n",... | // Orthodox middlewares enable to DefaultServeMux. | [
"Orthodox",
"middlewares",
"enable",
"to",
"DefaultServeMux",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/core.go#L142-L147 |
146,018 | favclip/ucon | request.go | Next | func (b *Bubble) Next() error {
if b.queueIndex < len(b.mux.middlewares) {
qi := b.queueIndex
b.queueIndex++
m := b.mux.middlewares[qi]
err := m(b)
return err
}
return b.do()
} | go | func (b *Bubble) Next() error {
if b.queueIndex < len(b.mux.middlewares) {
qi := b.queueIndex
b.queueIndex++
m := b.mux.middlewares[qi]
err := m(b)
return err
}
return b.do()
} | [
"func",
"(",
"b",
"*",
"Bubble",
")",
"Next",
"(",
")",
"error",
"{",
"if",
"b",
".",
"queueIndex",
"<",
"len",
"(",
"b",
".",
"mux",
".",
"middlewares",
")",
"{",
"qi",
":=",
"b",
".",
"queueIndex",
"\n",
"b",
".",
"queueIndex",
"++",
"\n",
"m... | // Next passes the bubble to next middleware.
// If the bubble reaches at last, RequestHandler will be called. | [
"Next",
"passes",
"the",
"bubble",
"to",
"next",
"middleware",
".",
"If",
"the",
"bubble",
"reaches",
"at",
"last",
"RequestHandler",
"will",
"be",
"called",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/request.go#L86-L96 |
146,019 | favclip/ucon | sample/appengine/model_json.go | Properties | func (b *TodoJSONBuilder) Properties() []*TodoPropertyInfo {
return []*TodoPropertyInfo{
b.ID,
b.Text,
b.Done,
b.UpdatedAt,
b.CreatedAt,
}
} | go | func (b *TodoJSONBuilder) Properties() []*TodoPropertyInfo {
return []*TodoPropertyInfo{
b.ID,
b.Text,
b.Done,
b.UpdatedAt,
b.CreatedAt,
}
} | [
"func",
"(",
"b",
"*",
"TodoJSONBuilder",
")",
"Properties",
"(",
")",
"[",
"]",
"*",
"TodoPropertyInfo",
"{",
"return",
"[",
"]",
"*",
"TodoPropertyInfo",
"{",
"b",
".",
"ID",
",",
"b",
".",
"Text",
",",
"b",
".",
"Done",
",",
"b",
".",
"UpdatedAt... | // Properties returns all properties on TodoJSONBuilder. | [
"Properties",
"returns",
"all",
"properties",
"on",
"TodoJSONBuilder",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/sample/appengine/model_json.go#L169-L177 |
146,020 | favclip/ucon | sample/appengine/model_json.go | AddAll | func (b *TodoJSONBuilder) AddAll() *TodoJSONBuilder {
b._properties["ID"] = b.ID
b._properties["Text"] = b.Text
b._properties["Done"] = b.Done
b._properties["UpdatedAt"] = b.UpdatedAt
b._properties["CreatedAt"] = b.CreatedAt
return b
} | go | func (b *TodoJSONBuilder) AddAll() *TodoJSONBuilder {
b._properties["ID"] = b.ID
b._properties["Text"] = b.Text
b._properties["Done"] = b.Done
b._properties["UpdatedAt"] = b.UpdatedAt
b._properties["CreatedAt"] = b.CreatedAt
return b
} | [
"func",
"(",
"b",
"*",
"TodoJSONBuilder",
")",
"AddAll",
"(",
")",
"*",
"TodoJSONBuilder",
"{",
"b",
".",
"_properties",
"[",
"\"",
"\"",
"]",
"=",
"b",
".",
"ID",
"\n",
"b",
".",
"_properties",
"[",
"\"",
"\"",
"]",
"=",
"b",
".",
"Text",
"\n",
... | // AddAll adds all property to TodoJSONBuilder. | [
"AddAll",
"adds",
"all",
"property",
"to",
"TodoJSONBuilder",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/sample/appengine/model_json.go#L180-L187 |
146,021 | favclip/ucon | sample/appengine/model_json.go | Add | func (b *TodoJSONBuilder) Add(infos ...*TodoPropertyInfo) *TodoJSONBuilder {
for _, info := range infos {
b._properties[info.fieldName] = info
}
return b
} | go | func (b *TodoJSONBuilder) Add(infos ...*TodoPropertyInfo) *TodoJSONBuilder {
for _, info := range infos {
b._properties[info.fieldName] = info
}
return b
} | [
"func",
"(",
"b",
"*",
"TodoJSONBuilder",
")",
"Add",
"(",
"infos",
"...",
"*",
"TodoPropertyInfo",
")",
"*",
"TodoJSONBuilder",
"{",
"for",
"_",
",",
"info",
":=",
"range",
"infos",
"{",
"b",
".",
"_properties",
"[",
"info",
".",
"fieldName",
"]",
"="... | // Add specified property to TodoJSONBuilder. | [
"Add",
"specified",
"property",
"to",
"TodoJSONBuilder",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/sample/appengine/model_json.go#L190-L195 |
146,022 | favclip/ucon | sample/appengine/model_json.go | Remove | func (b *TodoJSONBuilder) Remove(infos ...*TodoPropertyInfo) *TodoJSONBuilder {
for _, info := range infos {
delete(b._properties, info.fieldName)
}
return b
} | go | func (b *TodoJSONBuilder) Remove(infos ...*TodoPropertyInfo) *TodoJSONBuilder {
for _, info := range infos {
delete(b._properties, info.fieldName)
}
return b
} | [
"func",
"(",
"b",
"*",
"TodoJSONBuilder",
")",
"Remove",
"(",
"infos",
"...",
"*",
"TodoPropertyInfo",
")",
"*",
"TodoJSONBuilder",
"{",
"for",
"_",
",",
"info",
":=",
"range",
"infos",
"{",
"delete",
"(",
"b",
".",
"_properties",
",",
"info",
".",
"fi... | // Remove specified property to TodoJSONBuilder. | [
"Remove",
"specified",
"property",
"to",
"TodoJSONBuilder",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/sample/appengine/model_json.go#L222-L227 |
146,023 | favclip/ucon | utils.go | HasString | func (jsonTag TagJSON) HasString() bool {
for _, tag := range strings.Split(string(jsonTag), ",")[1:] {
if tag == "string" {
return true
}
}
return false
} | go | func (jsonTag TagJSON) HasString() bool {
for _, tag := range strings.Split(string(jsonTag), ",")[1:] {
if tag == "string" {
return true
}
}
return false
} | [
"func",
"(",
"jsonTag",
"TagJSON",
")",
"HasString",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"tag",
":=",
"range",
"strings",
".",
"Split",
"(",
"string",
"(",
"jsonTag",
")",
",",
"\"",
"\"",
")",
"[",
"1",
":",
"]",
"{",
"if",
"tag",
"==",
"\... | // HasString returns whether a field is emitted as string. | [
"HasString",
"returns",
"whether",
"a",
"field",
"is",
"emitted",
"as",
"string",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/utils.go#L24-L31 |
146,024 | favclip/ucon | utils.go | IsEmpty | func IsEmpty(fV reflect.Value) bool {
switch fV.Kind() {
case reflect.Ptr, reflect.Interface:
return fV.IsNil()
case reflect.String:
return fV.String() == ""
case reflect.Array, reflect.Slice:
return fV.Len() == 0
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return fV.Int() ... | go | func IsEmpty(fV reflect.Value) bool {
switch fV.Kind() {
case reflect.Ptr, reflect.Interface:
return fV.IsNil()
case reflect.String:
return fV.String() == ""
case reflect.Array, reflect.Slice:
return fV.Len() == 0
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return fV.Int() ... | [
"func",
"IsEmpty",
"(",
"fV",
"reflect",
".",
"Value",
")",
"bool",
"{",
"switch",
"fV",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Ptr",
",",
"reflect",
".",
"Interface",
":",
"return",
"fV",
".",
"IsNil",
"(",
")",
"\n",
"case",
"reflec... | // IsEmpty returns whether the value is empty. | [
"IsEmpty",
"returns",
"whether",
"the",
"value",
"is",
"empty",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/utils.go#L179-L196 |
146,025 | favclip/ucon | utils.go | SetValueFromString | func SetValueFromString(f reflect.Value, value string) error {
ft := f.Type()
if ft.Kind() == reflect.Ptr {
ft = ft.Elem()
f = f.Elem()
}
switch ft.Kind() {
case reflect.String:
f.SetString(value)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
{
v, err := strconv.ParseInt... | go | func SetValueFromString(f reflect.Value, value string) error {
ft := f.Type()
if ft.Kind() == reflect.Ptr {
ft = ft.Elem()
f = f.Elem()
}
switch ft.Kind() {
case reflect.String:
f.SetString(value)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
{
v, err := strconv.ParseInt... | [
"func",
"SetValueFromString",
"(",
"f",
"reflect",
".",
"Value",
",",
"value",
"string",
")",
"error",
"{",
"ft",
":=",
"f",
".",
"Type",
"(",
")",
"\n",
"if",
"ft",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"{",
"ft",
"=",
"ft",
".",
... | // SetValueFromString parses string and sets value. | [
"SetValueFromString",
"parses",
"string",
"and",
"sets",
"value",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/utils.go#L199-L255 |
146,026 | favclip/ucon | routing_common.go | ServeHTTP | func (ro *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
rd := ro.pickupBestRouteDefinition(r)
if rd == nil {
http.NotFound(w, r)
return
}
ctx := getDefaultContext(r)
match, params := rd.PathTemplate.Match(encodedPathFromRequest(r))
if !match {
http.Error(w, "[ucon] invalid handler picked", ... | go | func (ro *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
rd := ro.pickupBestRouteDefinition(r)
if rd == nil {
http.NotFound(w, r)
return
}
ctx := getDefaultContext(r)
match, params := rd.PathTemplate.Match(encodedPathFromRequest(r))
if !match {
http.Error(w, "[ucon] invalid handler picked", ... | [
"func",
"(",
"ro",
"*",
"Router",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"rd",
":=",
"ro",
".",
"pickupBestRouteDefinition",
"(",
"r",
")",
"\n\n",
"if",
"rd",
"==",
"nil",
"{",
"... | // ServeHTTP routes a request to the handler and creates new bubble. | [
"ServeHTTP",
"routes",
"a",
"request",
"to",
"the",
"handler",
"and",
"creates",
"new",
"bubble",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/routing_common.go#L48-L75 |
146,027 | favclip/ucon | routing_common.go | Match | func (pt *PathTemplate) Match(requestPath string) (bool, map[string]string) {
if pt.PathTemplate == pt.httpHandlePath {
// TODO ざっくりした実装なので後でリファクタリングすること
if strings.HasPrefix(requestPath, pt.httpHandlePath) {
return true, nil
}
}
requestPathSplitted := strings.Split(requestPath, "/")
if requiredLen, reque... | go | func (pt *PathTemplate) Match(requestPath string) (bool, map[string]string) {
if pt.PathTemplate == pt.httpHandlePath {
// TODO ざっくりした実装なので後でリファクタリングすること
if strings.HasPrefix(requestPath, pt.httpHandlePath) {
return true, nil
}
}
requestPathSplitted := strings.Split(requestPath, "/")
if requiredLen, reque... | [
"func",
"(",
"pt",
"*",
"PathTemplate",
")",
"Match",
"(",
"requestPath",
"string",
")",
"(",
"bool",
",",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"if",
"pt",
".",
"PathTemplate",
"==",
"pt",
".",
"httpHandlePath",
"{",
"// TODO ざっくりした実装なので後でリファクタリン... | // Match checks whether PathTemplate matches the request path.
// If the path contains parameter templates, those key-value map is also returned. | [
"Match",
"checks",
"whether",
"PathTemplate",
"matches",
"the",
"request",
"path",
".",
"If",
"the",
"path",
"contains",
"parameter",
"templates",
"those",
"key",
"-",
"value",
"map",
"is",
"also",
"returned",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/routing_common.go#L199-L235 |
146,028 | favclip/ucon | routing_common.go | ParsePathTemplate | func ParsePathTemplate(pathTmpl string) *PathTemplate {
tmpl := &PathTemplate{}
tmpl.PathTemplate = pathTmpl
vIndex := strings.Index(pathTmpl, "{")
if vIndex == -1 {
tmpl.httpHandlePath = pathTmpl
} else {
tmpl.httpHandlePath = pathTmpl[:vIndex]
}
tmpl.splittedPathTemplate = strings.Split(pathTmpl, "/")
tm... | go | func ParsePathTemplate(pathTmpl string) *PathTemplate {
tmpl := &PathTemplate{}
tmpl.PathTemplate = pathTmpl
vIndex := strings.Index(pathTmpl, "{")
if vIndex == -1 {
tmpl.httpHandlePath = pathTmpl
} else {
tmpl.httpHandlePath = pathTmpl[:vIndex]
}
tmpl.splittedPathTemplate = strings.Split(pathTmpl, "/")
tm... | [
"func",
"ParsePathTemplate",
"(",
"pathTmpl",
"string",
")",
"*",
"PathTemplate",
"{",
"tmpl",
":=",
"&",
"PathTemplate",
"{",
"}",
"\n",
"tmpl",
".",
"PathTemplate",
"=",
"pathTmpl",
"\n",
"vIndex",
":=",
"strings",
".",
"Index",
"(",
"pathTmpl",
",",
"\"... | // ParsePathTemplate parses path string to PathTemplate. | [
"ParsePathTemplate",
"parses",
"path",
"string",
"to",
"PathTemplate",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/routing_common.go#L238-L262 |
146,029 | favclip/ucon | swagger/middleware.go | CheckSecurityRequirements | func CheckSecurityRequirements(obj *Object, getScopes func(b *ucon.Bubble) ([]string, error)) ucon.MiddlewareFunc {
return func(b *ucon.Bubble) error {
op, ok := b.RequestHandler.Value(swaggerOperationKey{}).(*Operation)
if !ok {
return b.Next()
}
var secReqs []SecurityRequirement
if op.Security != nil ... | go | func CheckSecurityRequirements(obj *Object, getScopes func(b *ucon.Bubble) ([]string, error)) ucon.MiddlewareFunc {
return func(b *ucon.Bubble) error {
op, ok := b.RequestHandler.Value(swaggerOperationKey{}).(*Operation)
if !ok {
return b.Next()
}
var secReqs []SecurityRequirement
if op.Security != nil ... | [
"func",
"CheckSecurityRequirements",
"(",
"obj",
"*",
"Object",
",",
"getScopes",
"func",
"(",
"b",
"*",
"ucon",
".",
"Bubble",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
")",
"ucon",
".",
"MiddlewareFunc",
"{",
"return",
"func",
"(",
"b",
"*",
... | // CheckSecurityRequirements about request. | [
"CheckSecurityRequirements",
"about",
"request",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/middleware.go#L52-L124 |
146,030 | dcos/dcos-go | zkstore/location.go | Validate | func (l Location) Validate() error {
if err := ValidateNamed(l.Name, true); err != nil {
return errors.Wrap(err, "invalid name")
}
if err := ValidateCategory(l.Category); err != nil {
return errors.Wrap(err, "invalid category")
}
return nil
} | go | func (l Location) Validate() error {
if err := ValidateNamed(l.Name, true); err != nil {
return errors.Wrap(err, "invalid name")
}
if err := ValidateCategory(l.Category); err != nil {
return errors.Wrap(err, "invalid category")
}
return nil
} | [
"func",
"(",
"l",
"Location",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"ValidateNamed",
"(",
"l",
".",
"Name",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
... | // Validate performs validation on the Location | [
"Validate",
"performs",
"validation",
"on",
"the",
"Location"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/location.go#L25-L33 |
146,031 | dcos/dcos-go | dcos/http/transport/roundtripper.go | NewRoundTripper | func NewRoundTripper(rt http.RoundTripper, opts ...OptionRoundtripperFunc) (http.RoundTripper, error) {
if rt == nil {
rt = http.DefaultTransport
}
t := &dcosRoundtripper{
transport: rt,
}
for _, opt := range opts {
if opt == nil {
continue
}
if err := opt(t); err != nil {
return nil, err
}
}... | go | func NewRoundTripper(rt http.RoundTripper, opts ...OptionRoundtripperFunc) (http.RoundTripper, error) {
if rt == nil {
rt = http.DefaultTransport
}
t := &dcosRoundtripper{
transport: rt,
}
for _, opt := range opts {
if opt == nil {
continue
}
if err := opt(t); err != nil {
return nil, err
}
}... | [
"func",
"NewRoundTripper",
"(",
"rt",
"http",
".",
"RoundTripper",
",",
"opts",
"...",
"OptionRoundtripperFunc",
")",
"(",
"http",
".",
"RoundTripper",
",",
"error",
")",
"{",
"if",
"rt",
"==",
"nil",
"{",
"rt",
"=",
"http",
".",
"DefaultTransport",
"\n",
... | // NewRoundTripper returns RoundTripper implementation with JWT handling. | [
"NewRoundTripper",
"returns",
"RoundTripper",
"implementation",
"with",
"JWT",
"handling",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/roundtripper.go#L65-L94 |
146,032 | dcos/dcos-go | dcos/http/transport/roundtripper.go | GenerateToken | func (t *dcosRoundtripper) GenerateToken() error {
t.Lock()
defer t.Unlock()
sig, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.RS256, Key: t.secret}, (&jose.SignerOptions{}).WithType("JWT"))
if err != nil {
return err
}
cl := struct {
UID string `json:"uid"`
Exp int64 `json:"exp"`
}{
t.uid,
... | go | func (t *dcosRoundtripper) GenerateToken() error {
t.Lock()
defer t.Unlock()
sig, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.RS256, Key: t.secret}, (&jose.SignerOptions{}).WithType("JWT"))
if err != nil {
return err
}
cl := struct {
UID string `json:"uid"`
Exp int64 `json:"exp"`
}{
t.uid,
... | [
"func",
"(",
"t",
"*",
"dcosRoundtripper",
")",
"GenerateToken",
"(",
")",
"error",
"{",
"t",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"Unlock",
"(",
")",
"\n\n",
"sig",
",",
"err",
":=",
"jose",
".",
"NewSigner",
"(",
"jose",
".",
"SigningK... | // generateToken is a function that generates JWT and makes a POST request to bouncer to sign it. | [
"generateToken",
"is",
"a",
"function",
"that",
"generates",
"JWT",
"and",
"makes",
"a",
"POST",
"request",
"to",
"bouncer",
"to",
"sign",
"it",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/roundtripper.go#L97-L166 |
146,033 | dcos/dcos-go | dcos/http/transport/roundtripper.go | RoundTrip | func (t *dcosRoundtripper) RoundTrip(req *http.Request) (*http.Response, error) {
// Set `User-Agent` header, defaulting to `dcos-go`
userAgent := "dcos-go"
if t.userAgent != "" {
userAgent = t.userAgent
}
req.Header.Set("User-Agent", userAgent)
// helper function to update `Authorization` header.
addAuthToke... | go | func (t *dcosRoundtripper) RoundTrip(req *http.Request) (*http.Response, error) {
// Set `User-Agent` header, defaulting to `dcos-go`
userAgent := "dcos-go"
if t.userAgent != "" {
userAgent = t.userAgent
}
req.Header.Set("User-Agent", userAgent)
// helper function to update `Authorization` header.
addAuthToke... | [
"func",
"(",
"t",
"*",
"dcosRoundtripper",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"// Set `User-Agent` header, defaulting to `dcos-go`",
"userAgent",
":=",
"\"",
"\"",
"\n",
... | // RoundTrip is implementation of RoundTripper interface. | [
"RoundTrip",
"is",
"implementation",
"of",
"RoundTripper",
"interface",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/roundtripper.go#L175-L216 |
146,034 | dcos/dcos-go | dcos/http/transport/roundtripper.go | DebugTransport | func DebugTransport(rt http.RoundTripper) (Debug, error) {
d, ok := rt.(Debug)
if !ok {
return nil, ErrWrongRoundTripperImpl
}
return d, nil
} | go | func DebugTransport(rt http.RoundTripper) (Debug, error) {
d, ok := rt.(Debug)
if !ok {
return nil, ErrWrongRoundTripperImpl
}
return d, nil
} | [
"func",
"DebugTransport",
"(",
"rt",
"http",
".",
"RoundTripper",
")",
"(",
"Debug",
",",
"error",
")",
"{",
"d",
",",
"ok",
":=",
"rt",
".",
"(",
"Debug",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ErrWrongRoundTripperImpl",
"\n",
"}",
... | // DebugTransport is a function user can use to get a token from decorated http.RoundTripper if it implements
// implWithJWT. | [
"DebugTransport",
"is",
"a",
"function",
"user",
"can",
"use",
"to",
"get",
"a",
"token",
"from",
"decorated",
"http",
".",
"RoundTripper",
"if",
"it",
"implements",
"implWithJWT",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/roundtripper.go#L220-L226 |
146,035 | dcos/dcos-go | elector/elector.go | Start | func Start(ident string, basePath string, acl []zk.ACL, connector Connector) (*Elector, error) {
if strings.TrimSpace(ident) == "" {
return nil, errors.New("ident must not be blank")
}
if acl == nil {
acl = zk.WorldACL(zk.PermAll)
}
conn, zkEvents, err := connector.Connect()
if err != nil {
return nil, err
... | go | func Start(ident string, basePath string, acl []zk.ACL, connector Connector) (*Elector, error) {
if strings.TrimSpace(ident) == "" {
return nil, errors.New("ident must not be blank")
}
if acl == nil {
acl = zk.WorldACL(zk.PermAll)
}
conn, zkEvents, err := connector.Connect()
if err != nil {
return nil, err
... | [
"func",
"Start",
"(",
"ident",
"string",
",",
"basePath",
"string",
",",
"acl",
"[",
"]",
"zk",
".",
"ACL",
",",
"connector",
"Connector",
")",
"(",
"*",
"Elector",
",",
"error",
")",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"ident",
")",
"==",
... | // Start builds a new elector and runs it in the background.
//
// The 'ident' parameter is the content that the elector will store inside of
// it's znode data. This will typically be the IP address of the client of
// the elector.
//
// The 'basePath' parameter is the znode under which the leader election will
// ha... | [
"Start",
"builds",
"a",
"new",
"elector",
"and",
"runs",
"it",
"in",
"the",
"background",
".",
"The",
"ident",
"parameter",
"is",
"the",
"content",
"that",
"the",
"elector",
"will",
"store",
"inside",
"of",
"it",
"s",
"znode",
"data",
".",
"This",
"will"... | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L68-L95 |
146,036 | dcos/dcos-go | elector/elector.go | LeaderIdent | func (e *Elector) LeaderIdent() string {
e.mut.Lock()
defer e.mut.Unlock()
return e.leaderIdent
} | go | func (e *Elector) LeaderIdent() string {
e.mut.Lock()
defer e.mut.Unlock()
return e.leaderIdent
} | [
"func",
"(",
"e",
"*",
"Elector",
")",
"LeaderIdent",
"(",
")",
"string",
"{",
"e",
".",
"mut",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"mut",
".",
"Unlock",
"(",
")",
"\n",
"return",
"e",
".",
"leaderIdent",
"\n",
"}"
] | // LeaderIdent returns the current leader, or "" if no current leader is
// known yet. | [
"LeaderIdent",
"returns",
"the",
"current",
"leader",
"or",
"if",
"no",
"current",
"leader",
"is",
"known",
"yet",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L99-L103 |
146,037 | dcos/dcos-go | elector/elector.go | initialize | func (e *Elector) initialize() error {
exists, _, err := e.conn.Exists(e.basePath)
if err != nil {
return errors.Wrapf(err, "could not check if base path %s exists", e.basePath)
}
if exists {
return nil
}
segments := strings.Split(e.basePath, "/")
create := "/"
for _, segment := range segments {
create = ... | go | func (e *Elector) initialize() error {
exists, _, err := e.conn.Exists(e.basePath)
if err != nil {
return errors.Wrapf(err, "could not check if base path %s exists", e.basePath)
}
if exists {
return nil
}
segments := strings.Split(e.basePath, "/")
create := "/"
for _, segment := range segments {
create = ... | [
"func",
"(",
"e",
"*",
"Elector",
")",
"initialize",
"(",
")",
"error",
"{",
"exists",
",",
"_",
",",
"err",
":=",
"e",
".",
"conn",
".",
"Exists",
"(",
"e",
".",
"basePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"W... | // initialize sets up the basePath if necessary | [
"initialize",
"sets",
"up",
"the",
"basePath",
"if",
"necessary"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L118-L143 |
146,038 | dcos/dcos-go | elector/elector.go | updateLeaderData | func (e *Elector) updateLeaderData(leaderIdent string, leader bool, forceSend bool) {
e.mut.Lock()
prevLeader := e.isLeader // used later to determine if update necessary
e.leaderIdent = leaderIdent
e.isLeader = leader
e.mut.Unlock()
if prevLeader == leader && !forceSend {
return
}
e.sendEvent(Event{Leader: l... | go | func (e *Elector) updateLeaderData(leaderIdent string, leader bool, forceSend bool) {
e.mut.Lock()
prevLeader := e.isLeader // used later to determine if update necessary
e.leaderIdent = leaderIdent
e.isLeader = leader
e.mut.Unlock()
if prevLeader == leader && !forceSend {
return
}
e.sendEvent(Event{Leader: l... | [
"func",
"(",
"e",
"*",
"Elector",
")",
"updateLeaderData",
"(",
"leaderIdent",
"string",
",",
"leader",
"bool",
",",
"forceSend",
"bool",
")",
"{",
"e",
".",
"mut",
".",
"Lock",
"(",
")",
"\n",
"prevLeader",
":=",
"e",
".",
"isLeader",
"// used later to ... | // updateLeaderData updates the leadership information on the elector, and also
// sends a Leader event if the elector leadership transitioned. | [
"updateLeaderData",
"updates",
"the",
"leadership",
"information",
"on",
"the",
"elector",
"and",
"also",
"sends",
"a",
"Leader",
"event",
"if",
"the",
"elector",
"leadership",
"transitioned",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L257-L267 |
146,039 | dcos/dcos-go | elector/elector.go | getIdentFromNode | func (e *Elector) getIdentFromNode(node string) (ident string, err error) {
nodePath := path.Join(e.basePath, node)
b, _, err := e.conn.Get(nodePath)
return string(b), err
} | go | func (e *Elector) getIdentFromNode(node string) (ident string, err error) {
nodePath := path.Join(e.basePath, node)
b, _, err := e.conn.Get(nodePath)
return string(b), err
} | [
"func",
"(",
"e",
"*",
"Elector",
")",
"getIdentFromNode",
"(",
"node",
"string",
")",
"(",
"ident",
"string",
",",
"err",
"error",
")",
"{",
"nodePath",
":=",
"path",
".",
"Join",
"(",
"e",
".",
"basePath",
",",
"node",
")",
"\n",
"b",
",",
"_",
... | // getIdentFromNode fetches the znode data from the specified node and returns
// it as a string | [
"getIdentFromNode",
"fetches",
"the",
"znode",
"data",
"from",
"the",
"specified",
"node",
"and",
"returns",
"it",
"as",
"a",
"string"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L271-L275 |
146,040 | dcos/dcos-go | elector/elector.go | sendErr | func (e *Elector) sendErr(err error) {
e.sendEvent(Event{Err: err})
} | go | func (e *Elector) sendErr(err error) {
e.sendEvent(Event{Err: err})
} | [
"func",
"(",
"e",
"*",
"Elector",
")",
"sendErr",
"(",
"err",
"error",
")",
"{",
"e",
".",
"sendEvent",
"(",
"Event",
"{",
"Err",
":",
"err",
"}",
")",
"\n",
"}"
] | // sendErr sends an error event on the events chan. | [
"sendErr",
"sends",
"an",
"error",
"event",
"on",
"the",
"events",
"chan",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L278-L280 |
146,041 | dcos/dcos-go | elector/elector.go | sendEvent | func (e *Elector) sendEvent(event Event) {
select {
case e.events <- event:
case <-e.closing:
select {
case e.events <- event:
default:
// drop outgoing events if close was called and there is no
// longer a listener awaiting events.
}
}
} | go | func (e *Elector) sendEvent(event Event) {
select {
case e.events <- event:
case <-e.closing:
select {
case e.events <- event:
default:
// drop outgoing events if close was called and there is no
// longer a listener awaiting events.
}
}
} | [
"func",
"(",
"e",
"*",
"Elector",
")",
"sendEvent",
"(",
"event",
"Event",
")",
"{",
"select",
"{",
"case",
"e",
".",
"events",
"<-",
"event",
":",
"case",
"<-",
"e",
".",
"closing",
":",
"select",
"{",
"case",
"e",
".",
"events",
"<-",
"event",
... | // sendEvent sends the specified event on the events channel | [
"sendEvent",
"sends",
"the",
"specified",
"event",
"on",
"the",
"events",
"channel"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L283-L294 |
146,042 | dcos/dcos-go | elector/elector.go | sortedChildrenSequences | func sortedChildrenSequences(children []string) (sorted []int, lookup map[int]string, err error) {
sorted = make([]int, len(children))
lookup = make(map[int]string)
for i, child := range children {
seq, err := sequencePart(child)
if err != nil {
return nil, nil, err
}
sorted[i] = seq
lookup[seq] = child... | go | func sortedChildrenSequences(children []string) (sorted []int, lookup map[int]string, err error) {
sorted = make([]int, len(children))
lookup = make(map[int]string)
for i, child := range children {
seq, err := sequencePart(child)
if err != nil {
return nil, nil, err
}
sorted[i] = seq
lookup[seq] = child... | [
"func",
"sortedChildrenSequences",
"(",
"children",
"[",
"]",
"string",
")",
"(",
"sorted",
"[",
"]",
"int",
",",
"lookup",
"map",
"[",
"int",
"]",
"string",
",",
"err",
"error",
")",
"{",
"sorted",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(... | // sorted children sequences converts the children to sequence parts, and
// then returns the sorted sequences, along with a lookup map of sequence
// to nodes | [
"sorted",
"children",
"sequences",
"converts",
"the",
"children",
"to",
"sequence",
"parts",
"and",
"then",
"returns",
"the",
"sorted",
"sequences",
"along",
"with",
"a",
"lookup",
"map",
"of",
"sequence",
"to",
"nodes"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L299-L314 |
146,043 | dcos/dcos-go | elector/elector.go | determineLeader | func determineLeader(node string, children []string) (isLeader bool, leaderNode string, err error) {
err = func() error {
if len(children) == 0 {
return errors.New("no child nodes")
}
sequences, lookup, err := sortedChildrenSequences(children)
if err != nil {
return err
}
mySeq, err := sequencePart(n... | go | func determineLeader(node string, children []string) (isLeader bool, leaderNode string, err error) {
err = func() error {
if len(children) == 0 {
return errors.New("no child nodes")
}
sequences, lookup, err := sortedChildrenSequences(children)
if err != nil {
return err
}
mySeq, err := sequencePart(n... | [
"func",
"determineLeader",
"(",
"node",
"string",
",",
"children",
"[",
"]",
"string",
")",
"(",
"isLeader",
"bool",
",",
"leaderNode",
"string",
",",
"err",
"error",
")",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"children",
... | // determineLeader takes the current node, and all of the children of the
// leader node, and then determines if the node is the leader, and also,
// which node is the leader. | [
"determineLeader",
"takes",
"the",
"current",
"node",
"and",
"all",
"of",
"the",
"children",
"of",
"the",
"leader",
"node",
"and",
"then",
"determines",
"if",
"the",
"node",
"is",
"the",
"leader",
"and",
"also",
"which",
"node",
"is",
"the",
"leader",
"."
... | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L319-L338 |
146,044 | dcos/dcos-go | elector/elector.go | sequencePart | func sequencePart(node string) (int, error) {
if node == "" {
return 0, errors.New("node cannot be blank")
}
matches := sequenceRe.FindStringSubmatch(node)
if len(matches) != 2 {
return 0, fmt.Errorf("invalid node: %s", node)
}
res, err := strconv.Atoi(matches[1])
if err != nil {
return 0, fmt.Errorf("inva... | go | func sequencePart(node string) (int, error) {
if node == "" {
return 0, errors.New("node cannot be blank")
}
matches := sequenceRe.FindStringSubmatch(node)
if len(matches) != 2 {
return 0, fmt.Errorf("invalid node: %s", node)
}
res, err := strconv.Atoi(matches[1])
if err != nil {
return 0, fmt.Errorf("inva... | [
"func",
"sequencePart",
"(",
"node",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"node",
"==",
"\"",
"\"",
"{",
"return",
"0",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"matches",
":=",
"sequenceRe",
".",
"Fin... | // sequencePart extracts the trailing integer part of a zk sequential node
// into an int. | [
"sequencePart",
"extracts",
"the",
"trailing",
"integer",
"part",
"of",
"a",
"zk",
"sequential",
"node",
"into",
"an",
"int",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/elector.go#L342-L355 |
146,045 | dcos/dcos-go | elector/connector_existing.go | ExistingConnection | func ExistingConnection(conn Conn, events <-chan zk.Event) Connector {
return &existingConnection{
conn: conn,
events: events,
}
} | go | func ExistingConnection(conn Conn, events <-chan zk.Event) Connector {
return &existingConnection{
conn: conn,
events: events,
}
} | [
"func",
"ExistingConnection",
"(",
"conn",
"Conn",
",",
"events",
"<-",
"chan",
"zk",
".",
"Event",
")",
"Connector",
"{",
"return",
"&",
"existingConnection",
"{",
"conn",
":",
"conn",
",",
"events",
":",
"events",
",",
"}",
"\n",
"}"
] | // ExistingConnection returns an existing connection. Since it consumes
// from the zk.Event channel, it might be necessary for the client to fan out
// incoming events on the original channel to a new one so that events are not
// lost.
//
// The existing connection should have already established a session before
//... | [
"ExistingConnection",
"returns",
"an",
"existing",
"connection",
".",
"Since",
"it",
"consumes",
"from",
"the",
"zk",
".",
"Event",
"channel",
"it",
"might",
"be",
"necessary",
"for",
"the",
"client",
"to",
"fan",
"out",
"incoming",
"events",
"on",
"the",
"o... | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/connector_existing.go#L12-L17 |
146,046 | dcos/dcos-go | zkstore/hash.go | hashBytesToBucket | func hashBytesToBucket(bucketCount int, res uint64) int {
mod := res % uint64(bucketCount)
return int(mod)
} | go | func hashBytesToBucket(bucketCount int, res uint64) int {
mod := res % uint64(bucketCount)
return int(mod)
} | [
"func",
"hashBytesToBucket",
"(",
"bucketCount",
"int",
",",
"res",
"uint64",
")",
"int",
"{",
"mod",
":=",
"res",
"%",
"uint64",
"(",
"bucketCount",
")",
"\n",
"return",
"int",
"(",
"mod",
")",
"\n",
"}"
] | // hashBytesToBucket produces a positive int from a hashed byte slice | [
"hashBytesToBucket",
"produces",
"a",
"positive",
"int",
"from",
"a",
"hashed",
"byte",
"slice"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/hash.go#L17-L20 |
146,047 | dcos/dcos-go | zkstore/hash.go | HashProvider | func HashProvider(f func() hash.Hash) HashProviderFunc {
if f == nil {
return nil
}
return func(s string) (uint64, error) {
hasher := f()
_, err := hasher.Write([]byte(s))
if err != nil {
return 0, err
}
hash := hasher.Sum(nil)
if x := len(hash); x > 8 {
hash = hash[:8]
}
y, z := binary.Uvari... | go | func HashProvider(f func() hash.Hash) HashProviderFunc {
if f == nil {
return nil
}
return func(s string) (uint64, error) {
hasher := f()
_, err := hasher.Write([]byte(s))
if err != nil {
return 0, err
}
hash := hasher.Sum(nil)
if x := len(hash); x > 8 {
hash = hash[:8]
}
y, z := binary.Uvari... | [
"func",
"HashProvider",
"(",
"f",
"func",
"(",
")",
"hash",
".",
"Hash",
")",
"HashProviderFunc",
"{",
"if",
"f",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"func",
"(",
"s",
"string",
")",
"(",
"uint64",
",",
"error",
")",
"{",
... | // HashProvider adapts a golang stdlib hasher into a hash provider func for use by this package. | [
"HashProvider",
"adapts",
"a",
"golang",
"stdlib",
"hasher",
"into",
"a",
"hash",
"provider",
"func",
"for",
"use",
"by",
"this",
"package",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/hash.go#L23-L44 |
146,048 | dcos/dcos-go | zkstore/validate.go | ValidateNamed | func ValidateNamed(name string, required bool) error {
if strings.TrimSpace(name) != name {
return errors.New("leader or trailing spaces not allowed")
}
if name == "" {
if required {
return errors.New("cannot be blank")
}
return nil
}
if !validNameRE.MatchString(name) {
return fmt.Errorf("must match %... | go | func ValidateNamed(name string, required bool) error {
if strings.TrimSpace(name) != name {
return errors.New("leader or trailing spaces not allowed")
}
if name == "" {
if required {
return errors.New("cannot be blank")
}
return nil
}
if !validNameRE.MatchString(name) {
return fmt.Errorf("must match %... | [
"func",
"ValidateNamed",
"(",
"name",
"string",
",",
"required",
"bool",
")",
"error",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"name",
")",
"!=",
"name",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"name",
... | // ValidateNamed validates items that have a "name". Like an actual Name
// or perhaps a Version. Since some names can be blank, we use the
// 'required' parameter to signify whether or not a name can be blank, and
// then after that we check against the regexp. | [
"ValidateNamed",
"validates",
"items",
"that",
"have",
"a",
"name",
".",
"Like",
"an",
"actual",
"Name",
"or",
"perhaps",
"a",
"Version",
".",
"Since",
"some",
"names",
"can",
"be",
"blank",
"we",
"use",
"the",
"required",
"parameter",
"to",
"signify",
"wh... | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/validate.go#L21-L35 |
146,049 | dcos/dcos-go | zkstore/validate.go | ValidateCategory | func ValidateCategory(name string) error {
if strings.TrimSpace(name) == "" {
return errBadCategory
}
if !validCategoryRE.MatchString(name) {
return fmt.Errorf("must match %s", validCategoryRE)
}
cleaned := path.Clean(name)
if cleaned != name {
return errBadCategory
}
return nil
} | go | func ValidateCategory(name string) error {
if strings.TrimSpace(name) == "" {
return errBadCategory
}
if !validCategoryRE.MatchString(name) {
return fmt.Errorf("must match %s", validCategoryRE)
}
cleaned := path.Clean(name)
if cleaned != name {
return errBadCategory
}
return nil
} | [
"func",
"ValidateCategory",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"name",
")",
"==",
"\"",
"\"",
"{",
"return",
"errBadCategory",
"\n",
"}",
"\n",
"if",
"!",
"validCategoryRE",
".",
"MatchString",
"(",
"name",
... | // ValidateCategory checks that a category is required, and can look like a path or not. | [
"ValidateCategory",
"checks",
"that",
"a",
"category",
"is",
"required",
"and",
"can",
"look",
"like",
"a",
"path",
"or",
"not",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/validate.go#L38-L50 |
146,050 | dcos/dcos-go | zkstore/store.go | NewStore | func NewStore(connector Connector, opts ...StoreOpt) (*Store, error) {
conn, err := connector.Connect()
if err != nil {
return nil, err
}
store := &Store{
conn: conn,
closeFunc: connector.Close,
bucketsZnodeName: DefaultBucketsZnodeName,
acls: DefaultZKACL,
bucketFunc: ... | go | func NewStore(connector Connector, opts ...StoreOpt) (*Store, error) {
conn, err := connector.Connect()
if err != nil {
return nil, err
}
store := &Store{
conn: conn,
closeFunc: connector.Close,
bucketsZnodeName: DefaultBucketsZnodeName,
acls: DefaultZKACL,
bucketFunc: ... | [
"func",
"NewStore",
"(",
"connector",
"Connector",
",",
"opts",
"...",
"StoreOpt",
")",
"(",
"*",
"Store",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"connector",
".",
"Connect",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // NewStore creates a new Store that is ready for use. | [
"NewStore",
"creates",
"a",
"new",
"Store",
"that",
"is",
"ready",
"for",
"use",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L48-L69 |
146,051 | dcos/dcos-go | zkstore/store.go | setFully | func (s *Store) setFully(item Item) (stat *zk.Stat, err error) {
err = func() error {
identPath, err := s.identPath(item.Ident)
if err != nil {
return err
}
current := "/"
segments := strings.Split(identPath, "/")
for i, segment := range segments {
isLast := i == len(segments)-1
current = path.Joi... | go | func (s *Store) setFully(item Item) (stat *zk.Stat, err error) {
err = func() error {
identPath, err := s.identPath(item.Ident)
if err != nil {
return err
}
current := "/"
segments := strings.Split(identPath, "/")
for i, segment := range segments {
isLast := i == len(segments)-1
current = path.Joi... | [
"func",
"(",
"s",
"*",
"Store",
")",
"setFully",
"(",
"item",
"Item",
")",
"(",
"stat",
"*",
"zk",
".",
"Stat",
",",
"err",
"error",
")",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"identPath",
",",
"err",
":=",
"s",
".",
"identPath",
"("... | // setFully sets data for a path, creating any parents nodes as necessary.
// The stat returned will be the stat of the final created node. | [
"setFully",
"sets",
"data",
"for",
"a",
"path",
"creating",
"any",
"parents",
"nodes",
"as",
"necessary",
".",
"The",
"stat",
"returned",
"will",
"be",
"the",
"stat",
"of",
"the",
"final",
"created",
"node",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L150-L191 |
146,052 | dcos/dcos-go | zkstore/store.go | Get | func (s *Store) Get(ident Ident) (item Item, err error) {
err = func() error {
if err := ident.Validate(); err != nil {
return err
}
identPath, err := s.identPath(ident)
if err != nil {
return err
}
data, stat, err := s.conn.Get(identPath)
switch {
case err == zk.ErrNoNode:
return ErrNotFound
... | go | func (s *Store) Get(ident Ident) (item Item, err error) {
err = func() error {
if err := ident.Validate(); err != nil {
return err
}
identPath, err := s.identPath(ident)
if err != nil {
return err
}
data, stat, err := s.conn.Get(identPath)
switch {
case err == zk.ErrNoNode:
return ErrNotFound
... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Get",
"(",
"ident",
"Ident",
")",
"(",
"item",
"Item",
",",
"err",
"error",
")",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"ident",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"... | // Get fetches the data for a particuar item. If a particluar version is
// desired, it must be set on the ident.
// Returns ErrNotFound if no such item exists. | [
"Get",
"fetches",
"the",
"data",
"for",
"a",
"particuar",
"item",
".",
"If",
"a",
"particluar",
"version",
"is",
"desired",
"it",
"must",
"be",
"set",
"on",
"the",
"ident",
".",
"Returns",
"ErrNotFound",
"if",
"no",
"such",
"item",
"exists",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L196-L218 |
146,053 | dcos/dcos-go | zkstore/store.go | Variants | func (s *Store) Variants(location Location) (variants []string, err error) {
err = func() error {
if err := location.Validate(); err != nil {
return err
}
// create an ident in order to get the full path for the item node
ident := Ident{Location: location}
identPath, err := s.identPath(ident)
if err != ... | go | func (s *Store) Variants(location Location) (variants []string, err error) {
err = func() error {
if err := location.Validate(); err != nil {
return err
}
// create an ident in order to get the full path for the item node
ident := Ident{Location: location}
identPath, err := s.identPath(ident)
if err != ... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Variants",
"(",
"location",
"Location",
")",
"(",
"variants",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"location",
".",
"Validate",
"(",
... | // Variants fetches all of the variants for a particular item.
// Returns ErrNotFound if no item exists at the given location. | [
"Variants",
"fetches",
"all",
"of",
"the",
"variants",
"for",
"a",
"particular",
"item",
".",
"Returns",
"ErrNotFound",
"if",
"no",
"item",
"exists",
"at",
"the",
"given",
"location",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L222-L243 |
146,054 | dcos/dcos-go | zkstore/store.go | Delete | func (s *Store) Delete(ident Ident) (err error) {
if err = ident.Validate(); err != nil {
return
}
if ident.Variant != "" {
return s.deleteVariant(ident)
}
return s.deleteItem(ident)
} | go | func (s *Store) Delete(ident Ident) (err error) {
if err = ident.Validate(); err != nil {
return
}
if ident.Variant != "" {
return s.deleteVariant(ident)
}
return s.deleteItem(ident)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Delete",
"(",
"ident",
"Ident",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"ident",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"ident",
".",
"Varian... | // Delete deletes the identified item.
// An error is NOT returned in the case where the item does not already exist in the store. | [
"Delete",
"deletes",
"the",
"identified",
"item",
".",
"An",
"error",
"is",
"NOT",
"returned",
"in",
"the",
"case",
"where",
"the",
"item",
"does",
"not",
"already",
"exist",
"in",
"the",
"store",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L247-L255 |
146,055 | dcos/dcos-go | zkstore/store.go | deleteItem | func (s *Store) deleteItem(ident Ident) (err error) {
var variants []string
variants, err = s.Variants(ident.Location)
switch {
case err == ErrNotFound:
return nil
case err != nil:
return
}
// delete each variant of the specified item
for _, v := range variants {
variant := ident
variant.Variant = v
v... | go | func (s *Store) deleteItem(ident Ident) (err error) {
var variants []string
variants, err = s.Variants(ident.Location)
switch {
case err == ErrNotFound:
return nil
case err != nil:
return
}
// delete each variant of the specified item
for _, v := range variants {
variant := ident
variant.Variant = v
v... | [
"func",
"(",
"s",
"*",
"Store",
")",
"deleteItem",
"(",
"ident",
"Ident",
")",
"(",
"err",
"error",
")",
"{",
"var",
"variants",
"[",
"]",
"string",
"\n",
"variants",
",",
"err",
"=",
"s",
".",
"Variants",
"(",
"ident",
".",
"Location",
")",
"\n",
... | // deleteItem deletes the item and all versions within it | [
"deleteItem",
"deletes",
"the",
"item",
"and",
"all",
"versions",
"within",
"it"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L258-L289 |
146,056 | dcos/dcos-go | zkstore/store.go | deleteVariant | func (s *Store) deleteVariant(ident Ident) (err error) {
identPath, err := s.identPath(ident)
if err != nil {
return err
}
err = s.conn.Delete(identPath, ident.actualVersion())
switch err {
case zk.ErrNoNode:
// perhaps someone already deleted it?
return nil
case zk.ErrBadVersion:
return ErrVersionConfli... | go | func (s *Store) deleteVariant(ident Ident) (err error) {
identPath, err := s.identPath(ident)
if err != nil {
return err
}
err = s.conn.Delete(identPath, ident.actualVersion())
switch err {
case zk.ErrNoNode:
// perhaps someone already deleted it?
return nil
case zk.ErrBadVersion:
return ErrVersionConfli... | [
"func",
"(",
"s",
"*",
"Store",
")",
"deleteVariant",
"(",
"ident",
"Ident",
")",
"(",
"err",
"error",
")",
"{",
"identPath",
",",
"err",
":=",
"s",
".",
"identPath",
"(",
"ident",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // deleteVariant deletes only an item variant | [
"deleteVariant",
"deletes",
"only",
"an",
"item",
"variant"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L292-L306 |
146,057 | dcos/dcos-go | zkstore/store.go | List | func (s *Store) List(category string) (locations []Location, err error) {
err = func() error {
if err := ValidateCategory(category); err != nil {
return errors.Wrap(err, "invalid category")
}
bucketsPath, err := s.bucketsPath(category)
if err != nil {
return err
}
buckets, _, err := s.conn.Children(b... | go | func (s *Store) List(category string) (locations []Location, err error) {
err = func() error {
if err := ValidateCategory(category); err != nil {
return errors.Wrap(err, "invalid category")
}
bucketsPath, err := s.bucketsPath(category)
if err != nil {
return err
}
buckets, _, err := s.conn.Children(b... | [
"func",
"(",
"s",
"*",
"Store",
")",
"List",
"(",
"category",
"string",
")",
"(",
"locations",
"[",
"]",
"Location",
",",
"err",
"error",
")",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"ValidateCategory",
"(",
"category",
... | // List lists all of the known, latest version Locations that exist under
// the specified category.
// Returns ErrNotFound if the category cannot be found within the store. | [
"List",
"lists",
"all",
"of",
"the",
"known",
"latest",
"version",
"Locations",
"that",
"exist",
"under",
"the",
"specified",
"category",
".",
"Returns",
"ErrNotFound",
"if",
"the",
"category",
"cannot",
"be",
"found",
"within",
"the",
"store",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L311-L351 |
146,058 | dcos/dcos-go | zkstore/store.go | LocationsByName | func LocationsByName(locations []Location) (interface{}, func(_, _ int) bool) {
return locations, func(i, j int) bool {
return locations[i].Name < locations[j].Name
}
} | go | func LocationsByName(locations []Location) (interface{}, func(_, _ int) bool) {
return locations, func(i, j int) bool {
return locations[i].Name < locations[j].Name
}
} | [
"func",
"LocationsByName",
"(",
"locations",
"[",
"]",
"Location",
")",
"(",
"interface",
"{",
"}",
",",
"func",
"(",
"_",
",",
"_",
"int",
")",
"bool",
")",
"{",
"return",
"locations",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"r... | // LocationsByName returns a sort function helper that may be passed to sort.Slice in order to sort
// a slice of Location structs. | [
"LocationsByName",
"returns",
"a",
"sort",
"function",
"helper",
"that",
"may",
"be",
"passed",
"to",
"sort",
".",
"Slice",
"in",
"order",
"to",
"sort",
"a",
"slice",
"of",
"Location",
"structs",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L355-L359 |
146,059 | dcos/dcos-go | zkstore/store.go | mustExist | func (s *Store) mustExist(path string) (stat *zk.Stat, err error) {
err = func() error {
var exists bool
exists, stat, err = s.conn.Exists(path)
switch {
case err != nil:
return err
case !exists:
return errors.Errorf("%v did not exist ", path)
case stat == nil:
return errors.Errorf("got nil stat f... | go | func (s *Store) mustExist(path string) (stat *zk.Stat, err error) {
err = func() error {
var exists bool
exists, stat, err = s.conn.Exists(path)
switch {
case err != nil:
return err
case !exists:
return errors.Errorf("%v did not exist ", path)
case stat == nil:
return errors.Errorf("got nil stat f... | [
"func",
"(",
"s",
"*",
"Store",
")",
"mustExist",
"(",
"path",
"string",
")",
"(",
"stat",
"*",
"zk",
".",
"Stat",
",",
"err",
"error",
")",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"var",
"exists",
"bool",
"\n",
"exists",
",",
"stat",
... | // mustExist checks whether or not the path exists, and returns an error
// if it could not be verified to exist. | [
"mustExist",
"checks",
"whether",
"or",
"not",
"the",
"path",
"exists",
"and",
"returns",
"an",
"error",
"if",
"it",
"could",
"not",
"be",
"verified",
"to",
"exist",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L368-L383 |
146,060 | dcos/dcos-go | zkstore/store.go | identPath | func (s *Store) identPath(ident Ident) (string, error) {
bucket, err := s.bucketFunc(ident.Location.Name)
if err != nil {
return "", err
}
bucketsPath, err := s.bucketsPath(ident.Location.Category)
if err != nil {
return "", err
}
return path.Join(
bucketsPath,
strconv.Itoa(bucket),
ident.Location.Name... | go | func (s *Store) identPath(ident Ident) (string, error) {
bucket, err := s.bucketFunc(ident.Location.Name)
if err != nil {
return "", err
}
bucketsPath, err := s.bucketsPath(ident.Location.Category)
if err != nil {
return "", err
}
return path.Join(
bucketsPath,
strconv.Itoa(bucket),
ident.Location.Name... | [
"func",
"(",
"s",
"*",
"Store",
")",
"identPath",
"(",
"ident",
"Ident",
")",
"(",
"string",
",",
"error",
")",
"{",
"bucket",
",",
"err",
":=",
"s",
".",
"bucketFunc",
"(",
"ident",
".",
"Location",
".",
"Name",
")",
"\n",
"if",
"err",
"!=",
"ni... | // identPath returns the full path of the item pointed to by the Ident | [
"identPath",
"returns",
"the",
"full",
"path",
"of",
"the",
"item",
"pointed",
"to",
"by",
"the",
"Ident"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L386-L401 |
146,061 | dcos/dcos-go | zkstore/store.go | bucketsPath | func (s *Store) bucketsPath(category string) (string, error) {
leaf := path.Base(path.Clean(category))
if leaf == s.bucketsZnodeName {
return "", errBadCategory
}
return path.Join(
"/",
s.basePath,
category,
s.bucketsZnodeName,
), nil
} | go | func (s *Store) bucketsPath(category string) (string, error) {
leaf := path.Base(path.Clean(category))
if leaf == s.bucketsZnodeName {
return "", errBadCategory
}
return path.Join(
"/",
s.basePath,
category,
s.bucketsZnodeName,
), nil
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"bucketsPath",
"(",
"category",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"leaf",
":=",
"path",
".",
"Base",
"(",
"path",
".",
"Clean",
"(",
"category",
")",
")",
"\n",
"if",
"leaf",
"==",
"s",
"."... | // bucketsPath returns the full path of the buckets znode for a given category.
// an error will be returned if the category ends with the name of the buckets
// znode name. | [
"bucketsPath",
"returns",
"the",
"full",
"path",
"of",
"the",
"buckets",
"znode",
"for",
"a",
"given",
"category",
".",
"an",
"error",
"will",
"be",
"returned",
"if",
"the",
"category",
"ends",
"with",
"the",
"name",
"of",
"the",
"buckets",
"znode",
"name"... | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/store.go#L406-L417 |
146,062 | dcos/dcos-go | dcos/http/transport/transport.go | configureTLS | func configureTLS(caCertificatePath string) (*http.Transport, error) {
tr := &http.Transport{}
// if user provided CA cert we must use it, otherwise use InsecureSkipVerify: true for all HTTPS requests.
if caCertificatePath != "" {
caPool, err := loadCAPool(caCertificatePath)
if err != nil {
return tr, err
}... | go | func configureTLS(caCertificatePath string) (*http.Transport, error) {
tr := &http.Transport{}
// if user provided CA cert we must use it, otherwise use InsecureSkipVerify: true for all HTTPS requests.
if caCertificatePath != "" {
caPool, err := loadCAPool(caCertificatePath)
if err != nil {
return tr, err
}... | [
"func",
"configureTLS",
"(",
"caCertificatePath",
"string",
")",
"(",
"*",
"http",
".",
"Transport",
",",
"error",
")",
"{",
"tr",
":=",
"&",
"http",
".",
"Transport",
"{",
"}",
"\n",
"// if user provided CA cert we must use it, otherwise use InsecureSkipVerify: true ... | // newTransport will return transport for http.Client | [
"newTransport",
"will",
"return",
"transport",
"for",
"http",
".",
"Client"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/transport.go#L53-L71 |
146,063 | dcos/dcos-go | dcos/nodeutil/util.go | NewNodeInfo | func NewNodeInfo(client *http.Client, role string, options ...Option) (NodeInfo, error) {
if client == nil {
return nil, ErrNodeInfo{"Client paramter cannot be empty"}
}
validRole := func() bool {
for _, validRole := range []string{dcos.RoleMaster, dcos.RoleAgent, dcos.RoleAgentPublic} {
if role == validRole... | go | func NewNodeInfo(client *http.Client, role string, options ...Option) (NodeInfo, error) {
if client == nil {
return nil, ErrNodeInfo{"Client paramter cannot be empty"}
}
validRole := func() bool {
for _, validRole := range []string{dcos.RoleMaster, dcos.RoleAgent, dcos.RoleAgentPublic} {
if role == validRole... | [
"func",
"NewNodeInfo",
"(",
"client",
"*",
"http",
".",
"Client",
",",
"role",
"string",
",",
"options",
"...",
"Option",
")",
"(",
"NodeInfo",
",",
"error",
")",
"{",
"if",
"client",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrNodeInfo",
"{",
"\"",
... | // NewNodeInfo returns a new instance of NodeInfo implementation. | [
"NewNodeInfo",
"returns",
"a",
"new",
"instance",
"of",
"NodeInfo",
"implementation",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L104-L146 |
146,064 | dcos/dcos-go | dcos/nodeutil/util.go | DetectIP | func (d *dcosInfo) DetectIP() (net.IP, error) {
// get ip address from cache.
d.Lock()
defer d.Unlock()
// retrieve from cache
if d.cache && d.cachedIP != nil {
return *d.cachedIP, nil
}
if _, err := os.Stat(d.detectIPLocation); err != nil {
return nil, err
}
ctx, cancel := context.WithTimeout(context.B... | go | func (d *dcosInfo) DetectIP() (net.IP, error) {
// get ip address from cache.
d.Lock()
defer d.Unlock()
// retrieve from cache
if d.cache && d.cachedIP != nil {
return *d.cachedIP, nil
}
if _, err := os.Stat(d.detectIPLocation); err != nil {
return nil, err
}
ctx, cancel := context.WithTimeout(context.B... | [
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"DetectIP",
"(",
")",
"(",
"net",
".",
"IP",
",",
"error",
")",
"{",
"// get ip address from cache.",
"d",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"Unlock",
"(",
")",
"\n\n",
"// retrieve from cache",
"if... | // DetectIP returns an output from `FileDetectIP` script.
// This is a nice way of shelling out to `detect_ip` script which handles timeout. | [
"DetectIP",
"returns",
"an",
"output",
"from",
"FileDetectIP",
"script",
".",
"This",
"is",
"a",
"nice",
"way",
"of",
"shelling",
"out",
"to",
"detect_ip",
"script",
"which",
"handles",
"timeout",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L150-L198 |
146,065 | dcos/dcos-go | dcos/nodeutil/util.go | IsLeader | func (d *dcosInfo) IsLeader() (bool, error) {
// find role and IP before locking the structure.
localIP, err := d.DetectIP()
if err != nil {
return false, err
}
d.Lock()
defer d.Unlock()
if d.cache && d.cachedIsLeader != nil {
return *d.cachedIsLeader, nil
}
// agent cannot be leader
if d.role != dcos.... | go | func (d *dcosInfo) IsLeader() (bool, error) {
// find role and IP before locking the structure.
localIP, err := d.DetectIP()
if err != nil {
return false, err
}
d.Lock()
defer d.Unlock()
if d.cache && d.cachedIsLeader != nil {
return *d.cachedIsLeader, nil
}
// agent cannot be leader
if d.role != dcos.... | [
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"IsLeader",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// find role and IP before locking the structure.",
"localIP",
",",
"err",
":=",
"d",
".",
"DetectIP",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // IsLeader checks if the node is leader. | [
"IsLeader",
"checks",
"if",
"the",
"node",
"is",
"leader",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L201-L238 |
146,066 | dcos/dcos-go | dcos/nodeutil/util.go | MesosID | func (d *dcosInfo) MesosID(ctx context.Context) (string, error) {
if d.client == nil {
panic("Unable to get mesos ID. Uninitialized http client")
}
if d.mesosStateURL == "" {
panic("Unable to get mesos ID. Uninitialized url")
}
// retrieve from cache
d.Lock()
if d.cache && d.cachedMesosID != "" {
var res... | go | func (d *dcosInfo) MesosID(ctx context.Context) (string, error) {
if d.client == nil {
panic("Unable to get mesos ID. Uninitialized http client")
}
if d.mesosStateURL == "" {
panic("Unable to get mesos ID. Uninitialized url")
}
// retrieve from cache
d.Lock()
if d.cache && d.cachedMesosID != "" {
var res... | [
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"MesosID",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"d",
".",
"client",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"d",
".",
... | // MesosID returns a mesosID for leading master and agents.
// This function will panic if dcosInfo is missing http.Client or mesosStateURL is empty. | [
"MesosID",
"returns",
"a",
"mesosID",
"for",
"leading",
"master",
"and",
"agents",
".",
"This",
"function",
"will",
"panic",
"if",
"dcosInfo",
"is",
"missing",
"http",
".",
"Client",
"or",
"mesosStateURL",
"is",
"empty",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L242-L304 |
146,067 | dcos/dcos-go | dcos/nodeutil/util.go | ClusterID | func (d *dcosInfo) ClusterID() (string, error) {
d.Lock()
defer d.Unlock()
if d.cache && d.cachedClusterID != "" {
return d.cachedClusterID, nil
}
body, err := ioutil.ReadFile(d.clusterIDLocation)
if err != nil {
return "", err
}
clusterID := string(bytes.TrimSpace(body))
if clusterID == "" {
return "... | go | func (d *dcosInfo) ClusterID() (string, error) {
d.Lock()
defer d.Unlock()
if d.cache && d.cachedClusterID != "" {
return d.cachedClusterID, nil
}
body, err := ioutil.ReadFile(d.clusterIDLocation)
if err != nil {
return "", err
}
clusterID := string(bytes.TrimSpace(body))
if clusterID == "" {
return "... | [
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"ClusterID",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"d",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"d",
".",
"cache",
"&&",
"d",
".",
"cachedClusterID",
"... | // ClusterID returns a UUID of a specific cluster. The file containing the UUID
// is available on every node at d.clusterIDLocation. | [
"ClusterID",
"returns",
"a",
"UUID",
"of",
"a",
"specific",
"cluster",
".",
"The",
"file",
"containing",
"the",
"UUID",
"is",
"available",
"on",
"every",
"node",
"at",
"d",
".",
"clusterIDLocation",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L329-L356 |
146,068 | dcos/dcos-go | dcos/nodeutil/util.go | TaskCanonicalID | func (d *dcosInfo) TaskCanonicalID(ctx context.Context, task string, completed bool) (*CanonicalTaskID, error) {
state, err := d.state(ctx)
if err != nil {
return nil, err
}
frameworksTasks := findTask(task, completed, state.Frameworks)
var completedFrameworksTasks []Task
if completed {
completedFrameworksT... | go | func (d *dcosInfo) TaskCanonicalID(ctx context.Context, task string, completed bool) (*CanonicalTaskID, error) {
state, err := d.state(ctx)
if err != nil {
return nil, err
}
frameworksTasks := findTask(task, completed, state.Frameworks)
var completedFrameworksTasks []Task
if completed {
completedFrameworksT... | [
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"TaskCanonicalID",
"(",
"ctx",
"context",
".",
"Context",
",",
"task",
"string",
",",
"completed",
"bool",
")",
"(",
"*",
"CanonicalTaskID",
",",
"error",
")",
"{",
"state",
",",
"err",
":=",
"d",
".",
"state",
... | // TaskCanonicalID return a CanonicalTaskID for a given task. | [
"TaskCanonicalID",
"return",
"a",
"CanonicalTaskID",
"for",
"a",
"given",
"task",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L403-L441 |
146,069 | dcos/dcos-go | dcos/nodeutil/util.go | HeaderFromContext | func HeaderFromContext(ctx context.Context) (http.Header, bool) {
if ctx == nil {
panic("Context cannot be nil")
}
requestValue := ctx.Value(requestHeaderKey)
if requestValue == nil {
return nil, false
}
header, ok := requestValue.(http.Header)
return header, ok
} | go | func HeaderFromContext(ctx context.Context) (http.Header, bool) {
if ctx == nil {
panic("Context cannot be nil")
}
requestValue := ctx.Value(requestHeaderKey)
if requestValue == nil {
return nil, false
}
header, ok := requestValue.(http.Header)
return header, ok
} | [
"func",
"HeaderFromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"http",
".",
"Header",
",",
"bool",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"requestValue",
":=",
"ctx",
".",
"Value",
... | // HeaderFromContext returns http.Header from a context if it's found. | [
"HeaderFromContext",
"returns",
"http",
".",
"Header",
"from",
"a",
"context",
"if",
"it",
"s",
"found",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L444-L456 |
146,070 | dcos/dcos-go | dcos/nodeutil/util.go | NewContextWithHeaders | func NewContextWithHeaders(ctx context.Context, header http.Header) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, requestHeaderKey, header)
} | go | func NewContextWithHeaders(ctx context.Context, header http.Header) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, requestHeaderKey, header)
} | [
"func",
"NewContextWithHeaders",
"(",
"ctx",
"context",
".",
"Context",
",",
"header",
"http",
".",
"Header",
")",
"context",
".",
"Context",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"ctx",
"=",
"context",
".",
"Background",
"(",
")",
"\n",
"}",
"\n",
"retu... | // NewContextWithHeaders adds http.Header to the instance of context. | [
"NewContextWithHeaders",
"adds",
"http",
".",
"Header",
"to",
"the",
"instance",
"of",
"context",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/util.go#L459-L464 |
146,071 | dcos/dcos-go | dcos/http/transport/option.go | OptionCaCertificatePath | func OptionCaCertificatePath(caCertificatePath string) OptionTransportFunc {
return func(o *dcosTransport) error {
err := errorOnEmpty(caCertificatePath)
if err == nil {
o.CaCertificatePath = caCertificatePath
}
return err
}
} | go | func OptionCaCertificatePath(caCertificatePath string) OptionTransportFunc {
return func(o *dcosTransport) error {
err := errorOnEmpty(caCertificatePath)
if err == nil {
o.CaCertificatePath = caCertificatePath
}
return err
}
} | [
"func",
"OptionCaCertificatePath",
"(",
"caCertificatePath",
"string",
")",
"OptionTransportFunc",
"{",
"return",
"func",
"(",
"o",
"*",
"dcosTransport",
")",
"error",
"{",
"err",
":=",
"errorOnEmpty",
"(",
"caCertificatePath",
")",
"\n",
"if",
"err",
"==",
"nil... | // OptionCaCertificatePath sets the CA certificate path option. | [
"OptionCaCertificatePath",
"sets",
"the",
"CA",
"certificate",
"path",
"option",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/option.go#L56-L64 |
146,072 | dcos/dcos-go | dcos/http/transport/option.go | OptionIAMConfigPath | func OptionIAMConfigPath(iamConfigPath string) OptionTransportFunc {
return func(o *dcosTransport) error {
err := errorOnEmpty(iamConfigPath)
if err == nil {
o.IAMConfigPath = iamConfigPath
}
return err
}
} | go | func OptionIAMConfigPath(iamConfigPath string) OptionTransportFunc {
return func(o *dcosTransport) error {
err := errorOnEmpty(iamConfigPath)
if err == nil {
o.IAMConfigPath = iamConfigPath
}
return err
}
} | [
"func",
"OptionIAMConfigPath",
"(",
"iamConfigPath",
"string",
")",
"OptionTransportFunc",
"{",
"return",
"func",
"(",
"o",
"*",
"dcosTransport",
")",
"error",
"{",
"err",
":=",
"errorOnEmpty",
"(",
"iamConfigPath",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
... | // OptionIAMConfigPath sets the IAM configuration path option. | [
"OptionIAMConfigPath",
"sets",
"the",
"IAM",
"configuration",
"path",
"option",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/option.go#L67-L75 |
146,073 | dcos/dcos-go | dcos/http/transport/option.go | OptionTokenExpire | func OptionTokenExpire(t time.Duration) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
if t < 1 {
return ErrInvalidExpireDuration
}
j.expire = t
return nil
}
} | go | func OptionTokenExpire(t time.Duration) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
if t < 1 {
return ErrInvalidExpireDuration
}
j.expire = t
return nil
}
} | [
"func",
"OptionTokenExpire",
"(",
"t",
"time",
".",
"Duration",
")",
"OptionRoundtripperFunc",
"{",
"return",
"func",
"(",
"j",
"*",
"dcosRoundtripper",
")",
"error",
"{",
"if",
"t",
"<",
"1",
"{",
"return",
"ErrInvalidExpireDuration",
"\n",
"}",
"\n",
"j",
... | // OptionTokenExpire is an option to set JWT expiration date. If not set 24h is ussed by default. | [
"OptionTokenExpire",
"is",
"an",
"option",
"to",
"set",
"JWT",
"expiration",
"date",
".",
"If",
"not",
"set",
"24h",
"is",
"ussed",
"by",
"default",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/option.go#L78-L86 |
146,074 | dcos/dcos-go | dcos/http/transport/option.go | OptionCredentials | func OptionCredentials(uid, secret, loginEndpoint string) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
if uid == "" || secret == "" || loginEndpoint == "" {
return ErrInvalidCredentials
}
j.uid = uid
j.loginEndpoint = loginEndpoint
block, _ := pem.Decode([]byte(secret))
if block ==... | go | func OptionCredentials(uid, secret, loginEndpoint string) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
if uid == "" || secret == "" || loginEndpoint == "" {
return ErrInvalidCredentials
}
j.uid = uid
j.loginEndpoint = loginEndpoint
block, _ := pem.Decode([]byte(secret))
if block ==... | [
"func",
"OptionCredentials",
"(",
"uid",
",",
"secret",
",",
"loginEndpoint",
"string",
")",
"OptionRoundtripperFunc",
"{",
"return",
"func",
"(",
"j",
"*",
"dcosRoundtripper",
")",
"error",
"{",
"if",
"uid",
"==",
"\"",
"\"",
"||",
"secret",
"==",
"\"",
"... | // OptionCredentials is an option to set uid, secret and loginEndpoint. | [
"OptionCredentials",
"is",
"an",
"option",
"to",
"set",
"uid",
"secret",
"and",
"loginEndpoint",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/option.go#L89-L112 |
146,075 | dcos/dcos-go | dcos/http/transport/option.go | OptionUserAgent | func OptionUserAgent(userAgent string) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
if userAgent == "" {
return ErrInvalidUserAgent
}
j.userAgent = userAgent
return nil
}
} | go | func OptionUserAgent(userAgent string) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
if userAgent == "" {
return ErrInvalidUserAgent
}
j.userAgent = userAgent
return nil
}
} | [
"func",
"OptionUserAgent",
"(",
"userAgent",
"string",
")",
"OptionRoundtripperFunc",
"{",
"return",
"func",
"(",
"j",
"*",
"dcosRoundtripper",
")",
"error",
"{",
"if",
"userAgent",
"==",
"\"",
"\"",
"{",
"return",
"ErrInvalidUserAgent",
"\n",
"}",
"\n",
"j",
... | // OptionUserAgent is an option to set userAgent | [
"OptionUserAgent",
"is",
"an",
"option",
"to",
"set",
"userAgent"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/option.go#L115-L123 |
146,076 | dcos/dcos-go | dcos/http/transport/option.go | OptionReadIAMConfig | func OptionReadIAMConfig(path string) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()
fileContent, err := ioutil.ReadAll(f)
if err != nil {
return err
}
var cfg = struct {
UID string `json:"uid"`... | go | func OptionReadIAMConfig(path string) OptionRoundtripperFunc {
return func(j *dcosRoundtripper) error {
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()
fileContent, err := ioutil.ReadAll(f)
if err != nil {
return err
}
var cfg = struct {
UID string `json:"uid"`... | [
"func",
"OptionReadIAMConfig",
"(",
"path",
"string",
")",
"OptionRoundtripperFunc",
"{",
"return",
"func",
"(",
"j",
"*",
"dcosRoundtripper",
")",
"error",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // OptionReadIAMConfig is an option to read the IAMConfig from file system and populate uid, secret and loginEndpoint. | [
"OptionReadIAMConfig",
"is",
"an",
"option",
"to",
"read",
"the",
"IAMConfig",
"from",
"file",
"system",
"and",
"populate",
"uid",
"secret",
"and",
"loginEndpoint",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/http/transport/option.go#L126-L151 |
146,077 | dcos/dcos-go | elector/connector.go | Get | func (c ConnAdapter) Get(path string) ([]byte, *zk.Stat, error) {
return c.GetF(path)
} | go | func (c ConnAdapter) Get(path string) ([]byte, *zk.Stat, error) {
return c.GetF(path)
} | [
"func",
"(",
"c",
"ConnAdapter",
")",
"Get",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"*",
"zk",
".",
"Stat",
",",
"error",
")",
"{",
"return",
"c",
".",
"GetF",
"(",
"path",
")",
"\n",
"}"
] | // Get implements Conn. | [
"Get",
"implements",
"Conn",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/connector.go#L35-L37 |
146,078 | dcos/dcos-go | elector/connector.go | Exists | func (c ConnAdapter) Exists(path string) (bool, *zk.Stat, error) {
return c.ExistsF(path)
} | go | func (c ConnAdapter) Exists(path string) (bool, *zk.Stat, error) {
return c.ExistsF(path)
} | [
"func",
"(",
"c",
"ConnAdapter",
")",
"Exists",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"*",
"zk",
".",
"Stat",
",",
"error",
")",
"{",
"return",
"c",
".",
"ExistsF",
"(",
"path",
")",
"\n",
"}"
] | // Exists implements Conn. | [
"Exists",
"implements",
"Conn",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/connector.go#L40-L42 |
146,079 | dcos/dcos-go | elector/connector.go | Create | func (c ConnAdapter) Create(path string, data []byte, flags int32, acl []zk.ACL) (string, error) {
return c.CreateF(path, data, flags, acl)
} | go | func (c ConnAdapter) Create(path string, data []byte, flags int32, acl []zk.ACL) (string, error) {
return c.CreateF(path, data, flags, acl)
} | [
"func",
"(",
"c",
"ConnAdapter",
")",
"Create",
"(",
"path",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"flags",
"int32",
",",
"acl",
"[",
"]",
"zk",
".",
"ACL",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"CreateF",
"(",
... | // Create implements Conn. | [
"Create",
"implements",
"Conn",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/connector.go#L45-L47 |
146,080 | dcos/dcos-go | elector/connector.go | CreateProtectedEphemeralSequential | func (c ConnAdapter) CreateProtectedEphemeralSequential(path string, data []byte, acl []zk.ACL) (string, error) {
return c.CreateProtectedEphemeralSequentialF(path, data, acl)
} | go | func (c ConnAdapter) CreateProtectedEphemeralSequential(path string, data []byte, acl []zk.ACL) (string, error) {
return c.CreateProtectedEphemeralSequentialF(path, data, acl)
} | [
"func",
"(",
"c",
"ConnAdapter",
")",
"CreateProtectedEphemeralSequential",
"(",
"path",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"acl",
"[",
"]",
"zk",
".",
"ACL",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"CreateProtectedEphe... | // CreateProtectedEphemeralSequential implements Conn. | [
"CreateProtectedEphemeralSequential",
"implements",
"Conn",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/connector.go#L50-L52 |
146,081 | dcos/dcos-go | elector/connector.go | ChildrenW | func (c ConnAdapter) ChildrenW(path string) ([]string, *zk.Stat, <-chan zk.Event, error) {
return c.ChildrenWF(path)
} | go | func (c ConnAdapter) ChildrenW(path string) ([]string, *zk.Stat, <-chan zk.Event, error) {
return c.ChildrenWF(path)
} | [
"func",
"(",
"c",
"ConnAdapter",
")",
"ChildrenW",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"*",
"zk",
".",
"Stat",
",",
"<-",
"chan",
"zk",
".",
"Event",
",",
"error",
")",
"{",
"return",
"c",
".",
"ChildrenWF",
"(",
"path",
")"... | // ChildrenW implements Conn. | [
"ChildrenW",
"implements",
"Conn",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/elector/connector.go#L55-L57 |
146,082 | dcos/dcos-go | zkstore/item.go | Validate | func (i Item) Validate() error {
if err := i.Ident.Validate(); err != nil {
return err
}
if len(i.Data) > MaxDataSize {
return errors.New("data is greater than 1MB")
}
return nil
} | go | func (i Item) Validate() error {
if err := i.Ident.Validate(); err != nil {
return err
}
if len(i.Data) > MaxDataSize {
return errors.New("data is greater than 1MB")
}
return nil
} | [
"func",
"(",
"i",
"Item",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"i",
".",
"Ident",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"i",
".",
"Data",
")",
">",
... | // Validate performs validation on the Item | [
"Validate",
"performs",
"validation",
"on",
"the",
"Item"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/item.go#L22-L30 |
146,083 | dcos/dcos-go | dcos/nodeutil/options.go | OptionDetectIP | func OptionDetectIP(path string) Option {
return func(d *dcosInfo) error {
if _, err := os.Stat(path); err != nil {
return err
}
d.detectIPLocation = path
return nil
}
} | go | func OptionDetectIP(path string) Option {
return func(d *dcosInfo) error {
if _, err := os.Stat(path); err != nil {
return err
}
d.detectIPLocation = path
return nil
}
} | [
"func",
"OptionDetectIP",
"(",
"path",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // OptionDetectIP sets the location of detectIP script. | [
"OptionDetectIP",
"sets",
"the",
"location",
"of",
"detectIP",
"script",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/options.go#L16-L25 |
146,084 | dcos/dcos-go | dcos/nodeutil/options.go | OptionDetectIPTimeout | func OptionDetectIPTimeout(timeout time.Duration) Option {
return func(d *dcosInfo) error {
if timeout <= 0 {
return ErrEmptyParam
}
d.detectIPTimeout = timeout
return nil
}
} | go | func OptionDetectIPTimeout(timeout time.Duration) Option {
return func(d *dcosInfo) error {
if timeout <= 0 {
return ErrEmptyParam
}
d.detectIPTimeout = timeout
return nil
}
} | [
"func",
"OptionDetectIPTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"error",
"{",
"if",
"timeout",
"<=",
"0",
"{",
"return",
"ErrEmptyParam",
"\n",
"}",
"\n\n",
"d",
".",
"detect... | // OptionDetectIPTimeout update timeout for detect_ip command. | [
"OptionDetectIPTimeout",
"update",
"timeout",
"for",
"detect_ip",
"command",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/options.go#L28-L37 |
146,085 | dcos/dcos-go | dcos/nodeutil/options.go | OptionLeaderDNSRecord | func OptionLeaderDNSRecord(r string) Option {
return func(d *dcosInfo) error {
if r == "" {
return ErrEmptyParam
}
d.dnsRecordLeader = r
return nil
}
} | go | func OptionLeaderDNSRecord(r string) Option {
return func(d *dcosInfo) error {
if r == "" {
return ErrEmptyParam
}
d.dnsRecordLeader = r
return nil
}
} | [
"func",
"OptionLeaderDNSRecord",
"(",
"r",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"error",
"{",
"if",
"r",
"==",
"\"",
"\"",
"{",
"return",
"ErrEmptyParam",
"\n",
"}",
"\n",
"d",
".",
"dnsRecordLeader",
"=",
"r"... | // OptionLeaderDNSRecord sets a mesos leader dns entry. | [
"OptionLeaderDNSRecord",
"sets",
"a",
"mesos",
"leader",
"dns",
"entry",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/options.go#L59-L67 |
146,086 | dcos/dcos-go | dcos/nodeutil/options.go | OptionClusterIDFile | func OptionClusterIDFile(f string) Option {
return func(d *dcosInfo) error {
if f == "" {
return ErrEmptyParam
}
d.clusterIDLocation = f
return nil
}
} | go | func OptionClusterIDFile(f string) Option {
return func(d *dcosInfo) error {
if f == "" {
return ErrEmptyParam
}
d.clusterIDLocation = f
return nil
}
} | [
"func",
"OptionClusterIDFile",
"(",
"f",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"d",
"*",
"dcosInfo",
")",
"error",
"{",
"if",
"f",
"==",
"\"",
"\"",
"{",
"return",
"ErrEmptyParam",
"\n",
"}",
"\n",
"d",
".",
"clusterIDLocation",
"=",
"f"... | // OptionClusterIDFile sets a path to cluster-id file. | [
"OptionClusterIDFile",
"sets",
"a",
"path",
"to",
"cluster",
"-",
"id",
"file",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/options.go#L70-L78 |
146,087 | dcos/dcos-go | zkstore/ident.go | Validate | func (i Ident) Validate() error {
if err := i.Location.Validate(); err != nil {
return errors.Wrap(err, "invalid location")
}
if err := ValidateNamed(i.Variant, false); err != nil {
return errors.Wrap(err, "invalid variant")
}
return nil
} | go | func (i Ident) Validate() error {
if err := i.Location.Validate(); err != nil {
return errors.Wrap(err, "invalid location")
}
if err := ValidateNamed(i.Variant, false); err != nil {
return errors.Wrap(err, "invalid variant")
}
return nil
} | [
"func",
"(",
"i",
"Ident",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"i",
".",
"Location",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
... | // Validate performs validation on the Ident | [
"Validate",
"performs",
"validation",
"on",
"the",
"Ident"
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/ident.go#L43-L51 |
146,088 | dcos/dcos-go | zkstore/options.go | OptNumHashBuckets | func OptNumHashBuckets(numBuckets int) StoreOpt {
if numBuckets == 0 {
return nil
}
if numBuckets < 0 {
return optError
}
return func(store *Store) error {
store.hashBuckets = numBuckets
return optBucketFunc(bucketFunc(numBuckets, store.hashProviderFunc)).Apply(store)
}
} | go | func OptNumHashBuckets(numBuckets int) StoreOpt {
if numBuckets == 0 {
return nil
}
if numBuckets < 0 {
return optError
}
return func(store *Store) error {
store.hashBuckets = numBuckets
return optBucketFunc(bucketFunc(numBuckets, store.hashProviderFunc)).Apply(store)
}
} | [
"func",
"OptNumHashBuckets",
"(",
"numBuckets",
"int",
")",
"StoreOpt",
"{",
"if",
"numBuckets",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"numBuckets",
"<",
"0",
"{",
"return",
"optError",
"\n",
"}",
"\n",
"return",
"func",
"(",
"store",
... | // OptNumHashBuckets specifies the number of hash buckets that will be created under
// a store path for each content type when data is being written or read.
//
// If this value is changed after data is written, previously written data may
// not be able to be found later.
// If the bucket count is zero then the store... | [
"OptNumHashBuckets",
"specifies",
"the",
"number",
"of",
"hash",
"buckets",
"that",
"will",
"be",
"created",
"under",
"a",
"store",
"path",
"for",
"each",
"content",
"type",
"when",
"data",
"is",
"being",
"written",
"or",
"read",
".",
"If",
"this",
"value",
... | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/options.go#L50-L62 |
146,089 | dcos/dcos-go | zkstore/options.go | OptACL | func OptACL(acl []zk.ACL) StoreOpt {
if len(acl) == 0 {
return nil // use default instead
}
return func(store *Store) error {
store.acls = acl
return nil
}
} | go | func OptACL(acl []zk.ACL) StoreOpt {
if len(acl) == 0 {
return nil // use default instead
}
return func(store *Store) error {
store.acls = acl
return nil
}
} | [
"func",
"OptACL",
"(",
"acl",
"[",
"]",
"zk",
".",
"ACL",
")",
"StoreOpt",
"{",
"if",
"len",
"(",
"acl",
")",
"==",
"0",
"{",
"return",
"nil",
"// use default instead",
"\n",
"}",
"\n",
"return",
"func",
"(",
"store",
"*",
"Store",
")",
"error",
"{... | // OptACL configures the store to use a particular ACL when creating nodes.
// A nil or empty ACL list does not alter the store configuration. | [
"OptACL",
"configures",
"the",
"store",
"to",
"use",
"a",
"particular",
"ACL",
"when",
"creating",
"nodes",
".",
"A",
"nil",
"or",
"empty",
"ACL",
"list",
"does",
"not",
"alter",
"the",
"store",
"configuration",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/options.go#L66-L74 |
146,090 | dcos/dcos-go | zkstore/options.go | OptHashProviderFunc | func OptHashProviderFunc(hashProviderFunc HashProviderFunc) StoreOpt {
if hashProviderFunc == nil {
return nil // use default instead
}
return func(store *Store) error {
store.hashProviderFunc = hashProviderFunc
return optBucketFunc(bucketFunc(store.hashBuckets, hashProviderFunc)).Apply(store)
}
} | go | func OptHashProviderFunc(hashProviderFunc HashProviderFunc) StoreOpt {
if hashProviderFunc == nil {
return nil // use default instead
}
return func(store *Store) error {
store.hashProviderFunc = hashProviderFunc
return optBucketFunc(bucketFunc(store.hashBuckets, hashProviderFunc)).Apply(store)
}
} | [
"func",
"OptHashProviderFunc",
"(",
"hashProviderFunc",
"HashProviderFunc",
")",
"StoreOpt",
"{",
"if",
"hashProviderFunc",
"==",
"nil",
"{",
"return",
"nil",
"// use default instead",
"\n",
"}",
"\n",
"return",
"func",
"(",
"store",
"*",
"Store",
")",
"error",
... | // OptHashProviderFunc allows the client to configure which hasher to use to map
// item names to buckets.
// A nil hash func does not alter the store configuration. | [
"OptHashProviderFunc",
"allows",
"the",
"client",
"to",
"configure",
"which",
"hasher",
"to",
"use",
"to",
"map",
"item",
"names",
"to",
"buckets",
".",
"A",
"nil",
"hash",
"func",
"does",
"not",
"alter",
"the",
"store",
"configuration",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/options.go#L79-L87 |
146,091 | dcos/dcos-go | zkstore/options.go | OptBucketsZnodeName | func OptBucketsZnodeName(name string) StoreOpt {
if err := ValidateNamed(name, true); err != nil {
return optError
}
return func(store *Store) error {
store.bucketsZnodeName = name
return nil
}
} | go | func OptBucketsZnodeName(name string) StoreOpt {
if err := ValidateNamed(name, true); err != nil {
return optError
}
return func(store *Store) error {
store.bucketsZnodeName = name
return nil
}
} | [
"func",
"OptBucketsZnodeName",
"(",
"name",
"string",
")",
"StoreOpt",
"{",
"if",
"err",
":=",
"ValidateNamed",
"(",
"name",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"optError",
"\n",
"}",
"\n",
"return",
"func",
"(",
"store",
"*",
"St... | // OptBucketsZnodeName allows the client to configure the znode name that will
// contain the numerically-named bucket nodes.
// Returns ErrIllegalOption when the specifeid znode name is invalid. | [
"OptBucketsZnodeName",
"allows",
"the",
"client",
"to",
"configure",
"the",
"znode",
"name",
"that",
"will",
"contain",
"the",
"numerically",
"-",
"named",
"bucket",
"nodes",
".",
"Returns",
"ErrIllegalOption",
"when",
"the",
"specifeid",
"znode",
"name",
"is",
... | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/options.go#L92-L100 |
146,092 | dcos/dcos-go | store/store.go | Delete | func (s *storeImpl) Delete(key string) {
s.mutex.Lock()
defer s.mutex.Unlock()
delete(s.objects, key)
} | go | func (s *storeImpl) Delete(key string) {
s.mutex.Lock()
defer s.mutex.Unlock()
delete(s.objects, key)
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Delete",
"(",
"key",
"string",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"s",
".",
"objects",
",",
"key",
")",
... | // Delete removes a single object from the store. | [
"Delete",
"removes",
"a",
"single",
"object",
"from",
"the",
"store",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L58-L62 |
146,093 | dcos/dcos-go | store/store.go | Get | func (s *storeImpl) Get(key string) (interface{}, bool) {
s.mutex.RLock()
defer s.mutex.RUnlock()
object, ok := s.objects[key]
if !ok {
return nil, false
}
return object.contents, true
} | go | func (s *storeImpl) Get(key string) (interface{}, bool) {
s.mutex.RLock()
defer s.mutex.RUnlock()
object, ok := s.objects[key]
if !ok {
return nil, false
}
return object.contents, true
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"object... | // Get returns a single key-value pair from the store based on its name. | [
"Get",
"returns",
"a",
"single",
"key",
"-",
"value",
"pair",
"from",
"the",
"store",
"based",
"on",
"its",
"name",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L65-L75 |
146,094 | dcos/dcos-go | store/store.go | GetByRegex | func (s *storeImpl) GetByRegex(expr string) (map[string]interface{}, error) {
s.mutex.RLock()
defer s.mutex.RUnlock()
m := make(map[string]interface{})
for k, v := range s.objects {
matched, err := regexp.MatchString(expr, k)
if err != nil {
return m, err
}
if matched {
m[k] = v.contents
}
}
retu... | go | func (s *storeImpl) GetByRegex(expr string) (map[string]interface{}, error) {
s.mutex.RLock()
defer s.mutex.RUnlock()
m := make(map[string]interface{})
for k, v := range s.objects {
matched, err := regexp.MatchString(expr, k)
if err != nil {
return m, err
}
if matched {
m[k] = v.contents
}
}
retu... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"GetByRegex",
"(",
"expr",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
... | // GetByRegex returns a map of key-value pairs from the store based on a regexp search. | [
"GetByRegex",
"returns",
"a",
"map",
"of",
"key",
"-",
"value",
"pairs",
"from",
"the",
"store",
"based",
"on",
"a",
"regexp",
"search",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L78-L93 |
146,095 | dcos/dcos-go | store/store.go | Objects | func (s *storeImpl) Objects() (m map[string]interface{}) {
s.mutex.RLock()
defer s.mutex.RUnlock()
sz := len(s.objects)
if sz == 0 {
return
}
m = make(map[string]interface{}, sz)
for k, v := range s.objects {
m[k] = v.contents
}
return
} | go | func (s *storeImpl) Objects() (m map[string]interface{}) {
s.mutex.RLock()
defer s.mutex.RUnlock()
sz := len(s.objects)
if sz == 0 {
return
}
m = make(map[string]interface{}, sz)
for k, v := range s.objects {
m[k] = v.contents
}
return
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Objects",
"(",
")",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
... | // Objects returns all objects in the store. | [
"Objects",
"returns",
"all",
"objects",
"in",
"the",
"store",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L96-L110 |
146,096 | dcos/dcos-go | store/store.go | Purge | func (s *storeImpl) Purge() {
s.mutex.Lock()
defer s.mutex.Unlock()
s.objects = map[string]object{}
} | go | func (s *storeImpl) Purge() {
s.mutex.Lock()
defer s.mutex.Unlock()
s.objects = map[string]object{}
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Purge",
"(",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"objects",
"=",
"map",
"[",
"string",
"]",
"object",
"{",
"}... | // Purge removes ALL objects from the store. | [
"Purge",
"removes",
"ALL",
"objects",
"from",
"the",
"store",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L113-L117 |
146,097 | dcos/dcos-go | store/store.go | Set | func (s *storeImpl) Set(key string, val interface{}) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.objects[key] = object{contents: val}
} | go | func (s *storeImpl) Set(key string, val interface{}) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.objects[key] = object{contents: val}
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Set",
"(",
"key",
"string",
",",
"val",
"interface",
"{",
"}",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"objects",
... | // Set creates an object in the store. If the object already exists, it is overwritten. | [
"Set",
"creates",
"an",
"object",
"in",
"the",
"store",
".",
"If",
"the",
"object",
"already",
"exists",
"it",
"is",
"overwritten",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L120-L124 |
146,098 | dcos/dcos-go | store/store.go | Size | func (s *storeImpl) Size() int {
s.mutex.RLock()
defer s.mutex.RUnlock()
return len(s.objects)
} | go | func (s *storeImpl) Size() int {
s.mutex.RLock()
defer s.mutex.RUnlock()
return len(s.objects)
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Size",
"(",
")",
"int",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"s",
".",
"objects",
")",
"\n",
"}"
] | // Size returns the number of objects in the store as an integer. | [
"Size",
"returns",
"the",
"number",
"of",
"objects",
"in",
"the",
"store",
"as",
"an",
"integer",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L127-L131 |
146,099 | dcos/dcos-go | store/store.go | Supplant | func (s *storeImpl) Supplant(m map[string]interface{}) {
s.mutex.Lock()
defer s.mutex.Unlock()
n := make(map[string]object, len(m))
for k, v := range m {
n[k] = object{contents: v}
}
s.objects = n
} | go | func (s *storeImpl) Supplant(m map[string]interface{}) {
s.mutex.Lock()
defer s.mutex.Unlock()
n := make(map[string]object, len(m))
for k, v := range m {
n[k] = object{contents: v}
}
s.objects = n
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Supplant",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"n",
":=",
... | // Supplant replaces all objects in the store based on a given map. | [
"Supplant",
"replaces",
"all",
"objects",
"in",
"the",
"store",
"based",
"on",
"a",
"given",
"map",
"."
] | 3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0 | https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/store/store.go#L134-L144 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.