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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
vitessio/vitess | go/trace/opentracing.go | New | func (jf openTracingService) New(parent Span, label string) Span {
var innerSpan opentracing.Span
if parent == nil {
innerSpan = jf.Tracer.StartSpan(label)
} else {
jaegerParent := parent.(openTracingSpan)
span := jaegerParent.otSpan
innerSpan = jf.Tracer.StartSpan(label, opentracing.ChildOf(span.Context()))... | go | func (jf openTracingService) New(parent Span, label string) Span {
var innerSpan opentracing.Span
if parent == nil {
innerSpan = jf.Tracer.StartSpan(label)
} else {
jaegerParent := parent.(openTracingSpan)
span := jaegerParent.otSpan
innerSpan = jf.Tracer.StartSpan(label, opentracing.ChildOf(span.Context()))... | [
"func",
"(",
"jf",
"openTracingService",
")",
"New",
"(",
"parent",
"Span",
",",
"label",
"string",
")",
"Span",
"{",
"var",
"innerSpan",
"opentracing",
".",
"Span",
"\n",
"if",
"parent",
"==",
"nil",
"{",
"innerSpan",
"=",
"jf",
".",
"Tracer",
".",
"S... | // New is part of an interface implementation | [
"New",
"is",
"part",
"of",
"an",
"interface",
"implementation"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/trace/opentracing.go#L65-L75 | train |
vitessio/vitess | go/trace/opentracing.go | FromContext | func (jf openTracingService) FromContext(ctx context.Context) (Span, bool) {
innerSpan := opentracing.SpanFromContext(ctx)
if innerSpan != nil {
return openTracingSpan{otSpan: innerSpan}, true
} else {
return nil, false
}
} | go | func (jf openTracingService) FromContext(ctx context.Context) (Span, bool) {
innerSpan := opentracing.SpanFromContext(ctx)
if innerSpan != nil {
return openTracingSpan{otSpan: innerSpan}, true
} else {
return nil, false
}
} | [
"func",
"(",
"jf",
"openTracingService",
")",
"FromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"Span",
",",
"bool",
")",
"{",
"innerSpan",
":=",
"opentracing",
".",
"SpanFromContext",
"(",
"ctx",
")",
"\n\n",
"if",
"innerSpan",
"!=",
"nil",
... | // FromContext is part of an interface implementation | [
"FromContext",
"is",
"part",
"of",
"an",
"interface",
"implementation"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/trace/opentracing.go#L78-L86 | train |
vitessio/vitess | go/trace/opentracing.go | NewContext | func (jf openTracingService) NewContext(parent context.Context, s Span) context.Context {
span, ok := s.(openTracingSpan)
if !ok {
return nil
}
return opentracing.ContextWithSpan(parent, span.otSpan)
} | go | func (jf openTracingService) NewContext(parent context.Context, s Span) context.Context {
span, ok := s.(openTracingSpan)
if !ok {
return nil
}
return opentracing.ContextWithSpan(parent, span.otSpan)
} | [
"func",
"(",
"jf",
"openTracingService",
")",
"NewContext",
"(",
"parent",
"context",
".",
"Context",
",",
"s",
"Span",
")",
"context",
".",
"Context",
"{",
"span",
",",
"ok",
":=",
"s",
".",
"(",
"openTracingSpan",
")",
"\n",
"if",
"!",
"ok",
"{",
"... | // NewContext is part of an interface implementation | [
"NewContext",
"is",
"part",
"of",
"an",
"interface",
"implementation"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/trace/opentracing.go#L89-L95 | train |
vitessio/vitess | go/vt/topo/server.go | RegisterFactory | func RegisterFactory(name string, factory Factory) {
if factories[name] != nil {
log.Fatalf("Duplicate topo.Factory registration for %v", name)
}
factories[name] = factory
} | go | func RegisterFactory(name string, factory Factory) {
if factories[name] != nil {
log.Fatalf("Duplicate topo.Factory registration for %v", name)
}
factories[name] = factory
} | [
"func",
"RegisterFactory",
"(",
"name",
"string",
",",
"factory",
"Factory",
")",
"{",
"if",
"factories",
"[",
"name",
"]",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n",
"factories",
"[",
"name",
"]",
"... | // RegisterFactory registers a Factory for an implementation for a Server.
// If an implementation with that name already exists, it log.Fatals out.
// Call this in the 'init' function in your topology implementation module. | [
"RegisterFactory",
"registers",
"a",
"Factory",
"for",
"an",
"implementation",
"for",
"a",
"Server",
".",
"If",
"an",
"implementation",
"with",
"that",
"name",
"already",
"exists",
"it",
"log",
".",
"Fatals",
"out",
".",
"Call",
"this",
"in",
"the",
"init",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/server.go#L169-L174 | train |
vitessio/vitess | go/vt/topo/server.go | NewWithFactory | func NewWithFactory(factory Factory, serverAddress, root string) (*Server, error) {
conn, err := factory.Create(GlobalCell, serverAddress, root)
if err != nil {
return nil, err
}
conn = NewStatsConn(GlobalCell, conn)
var connReadOnly Conn
if factory.HasGlobalReadOnlyCell(serverAddress, root) {
connReadOnly, ... | go | func NewWithFactory(factory Factory, serverAddress, root string) (*Server, error) {
conn, err := factory.Create(GlobalCell, serverAddress, root)
if err != nil {
return nil, err
}
conn = NewStatsConn(GlobalCell, conn)
var connReadOnly Conn
if factory.HasGlobalReadOnlyCell(serverAddress, root) {
connReadOnly, ... | [
"func",
"NewWithFactory",
"(",
"factory",
"Factory",
",",
"serverAddress",
",",
"root",
"string",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"factory",
".",
"Create",
"(",
"GlobalCell",
",",
"serverAddress",
",",
"root",
"... | // NewWithFactory creates a new Server based on the given Factory.
// It also opens the global cell connection. | [
"NewWithFactory",
"creates",
"a",
"new",
"Server",
"based",
"on",
"the",
"given",
"Factory",
".",
"It",
"also",
"opens",
"the",
"global",
"cell",
"connection",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/server.go#L178-L202 | train |
vitessio/vitess | go/vt/topo/server.go | OpenServer | func OpenServer(implementation, serverAddress, root string) (*Server, error) {
factory, ok := factories[implementation]
if !ok {
return nil, NewError(NoImplementation, implementation)
}
return NewWithFactory(factory, serverAddress, root)
} | go | func OpenServer(implementation, serverAddress, root string) (*Server, error) {
factory, ok := factories[implementation]
if !ok {
return nil, NewError(NoImplementation, implementation)
}
return NewWithFactory(factory, serverAddress, root)
} | [
"func",
"OpenServer",
"(",
"implementation",
",",
"serverAddress",
",",
"root",
"string",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"factory",
",",
"ok",
":=",
"factories",
"[",
"implementation",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
... | // OpenServer returns a Server using the provided implementation,
// address and root for the global server. | [
"OpenServer",
"returns",
"a",
"Server",
"using",
"the",
"provided",
"implementation",
"address",
"and",
"root",
"for",
"the",
"global",
"server",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/server.go#L206-L212 | train |
vitessio/vitess | go/vt/topo/server.go | Open | func Open() *Server {
if *topoGlobalServerAddress == "" {
log.Exitf("topo_global_server_address must be configured")
}
ts, err := OpenServer(*topoImplementation, *topoGlobalServerAddress, *topoGlobalRoot)
if err != nil {
log.Exitf("Failed to open topo server (%v,%v,%v): %v", *topoImplementation, *topoGlobalServ... | go | func Open() *Server {
if *topoGlobalServerAddress == "" {
log.Exitf("topo_global_server_address must be configured")
}
ts, err := OpenServer(*topoImplementation, *topoGlobalServerAddress, *topoGlobalRoot)
if err != nil {
log.Exitf("Failed to open topo server (%v,%v,%v): %v", *topoImplementation, *topoGlobalServ... | [
"func",
"Open",
"(",
")",
"*",
"Server",
"{",
"if",
"*",
"topoGlobalServerAddress",
"==",
"\"",
"\"",
"{",
"log",
".",
"Exitf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"ts",
",",
"err",
":=",
"OpenServer",
"(",
"*",
"topoImplementation",
",",
"*",
"... | // Open returns a Server using the command line parameter flags
// for implementation, address and root. It log.Exits out if an error occurs. | [
"Open",
"returns",
"a",
"Server",
"using",
"the",
"command",
"line",
"parameter",
"flags",
"for",
"implementation",
"address",
"and",
"root",
".",
"It",
"log",
".",
"Exits",
"out",
"if",
"an",
"error",
"occurs",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/server.go#L216-L225 | train |
vitessio/vitess | go/vt/topo/server.go | ConnForCell | func (ts *Server) ConnForCell(ctx context.Context, cell string) (Conn, error) {
// Global cell is the easy case.
if cell == GlobalCell {
return ts.globalCell, nil
}
// Return a cached client if present.
ts.mu.Lock()
conn, ok := ts.cells[cell]
ts.mu.Unlock()
if ok {
return conn, nil
}
// Fetch cell clust... | go | func (ts *Server) ConnForCell(ctx context.Context, cell string) (Conn, error) {
// Global cell is the easy case.
if cell == GlobalCell {
return ts.globalCell, nil
}
// Return a cached client if present.
ts.mu.Lock()
conn, ok := ts.cells[cell]
ts.mu.Unlock()
if ok {
return conn, nil
}
// Fetch cell clust... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"ConnForCell",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
"string",
")",
"(",
"Conn",
",",
"error",
")",
"{",
"// Global cell is the easy case.",
"if",
"cell",
"==",
"GlobalCell",
"{",
"return",
"ts",
".",
... | // ConnForCell returns a Conn object for the given cell.
// It caches Conn objects from previously requested cells. | [
"ConnForCell",
"returns",
"a",
"Conn",
"object",
"for",
"the",
"given",
"cell",
".",
"It",
"caches",
"Conn",
"objects",
"from",
"previously",
"requested",
"cells",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/server.go#L229-L275 | train |
vitessio/vitess | go/vt/topo/server.go | GetAliasByCell | func GetAliasByCell(ctx context.Context, ts *Server, cell string) string {
cellsAliases.mu.Lock()
defer cellsAliases.mu.Unlock()
if region, ok := cellsAliases.cellsToAliases[cell]; ok {
return region
}
if ts != nil {
// lazily get the region from cell info if `aliases` are available
cellAliases, err := ts.Ge... | go | func GetAliasByCell(ctx context.Context, ts *Server, cell string) string {
cellsAliases.mu.Lock()
defer cellsAliases.mu.Unlock()
if region, ok := cellsAliases.cellsToAliases[cell]; ok {
return region
}
if ts != nil {
// lazily get the region from cell info if `aliases` are available
cellAliases, err := ts.Ge... | [
"func",
"GetAliasByCell",
"(",
"ctx",
"context",
".",
"Context",
",",
"ts",
"*",
"Server",
",",
"cell",
"string",
")",
"string",
"{",
"cellsAliases",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cellsAliases",
".",
"mu",
".",
"Unlock",
"(",
")",
... | // GetAliasByCell returns the alias group this `cell` belongs to, if there's none, it returns the `cell` as alias. | [
"GetAliasByCell",
"returns",
"the",
"alias",
"group",
"this",
"cell",
"belongs",
"to",
"if",
"there",
"s",
"none",
"it",
"returns",
"the",
"cell",
"as",
"alias",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/server.go#L278-L303 | train |
vitessio/vitess | go/vt/topo/server.go | Close | func (ts *Server) Close() {
ts.globalCell.Close()
if ts.globalReadOnlyCell != ts.globalCell {
ts.globalReadOnlyCell.Close()
}
ts.globalCell = nil
ts.globalReadOnlyCell = nil
ts.mu.Lock()
defer ts.mu.Unlock()
for _, conn := range ts.cells {
conn.Close()
}
ts.cells = make(map[string]Conn)
} | go | func (ts *Server) Close() {
ts.globalCell.Close()
if ts.globalReadOnlyCell != ts.globalCell {
ts.globalReadOnlyCell.Close()
}
ts.globalCell = nil
ts.globalReadOnlyCell = nil
ts.mu.Lock()
defer ts.mu.Unlock()
for _, conn := range ts.cells {
conn.Close()
}
ts.cells = make(map[string]Conn)
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"Close",
"(",
")",
"{",
"ts",
".",
"globalCell",
".",
"Close",
"(",
")",
"\n",
"if",
"ts",
".",
"globalReadOnlyCell",
"!=",
"ts",
".",
"globalCell",
"{",
"ts",
".",
"globalReadOnlyCell",
".",
"Close",
"(",
")",
... | // Close will close all connections to underlying topo Server.
// It will nil all member variables, so any further access will panic. | [
"Close",
"will",
"close",
"all",
"connections",
"to",
"underlying",
"topo",
"Server",
".",
"It",
"will",
"nil",
"all",
"member",
"variables",
"so",
"any",
"further",
"access",
"will",
"panic",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/server.go#L307-L320 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/planbuilder/permission.go | BuildPermissions | func BuildPermissions(stmt sqlparser.Statement) []Permission {
var permissions []Permission
// All Statement types myst be covered here.
switch node := stmt.(type) {
case *sqlparser.Union, *sqlparser.Select:
permissions = buildSubqueryPermissions(node, tableacl.READER, permissions)
case *sqlparser.Insert:
perm... | go | func BuildPermissions(stmt sqlparser.Statement) []Permission {
var permissions []Permission
// All Statement types myst be covered here.
switch node := stmt.(type) {
case *sqlparser.Union, *sqlparser.Select:
permissions = buildSubqueryPermissions(node, tableacl.READER, permissions)
case *sqlparser.Insert:
perm... | [
"func",
"BuildPermissions",
"(",
"stmt",
"sqlparser",
".",
"Statement",
")",
"[",
"]",
"Permission",
"{",
"var",
"permissions",
"[",
"]",
"Permission",
"\n",
"// All Statement types myst be covered here.",
"switch",
"node",
":=",
"stmt",
".",
"(",
"type",
")",
"... | // BuildPermissions builds the list of required permissions for all the
// tables referenced in a query. | [
"BuildPermissions",
"builds",
"the",
"list",
"of",
"required",
"permissions",
"for",
"all",
"the",
"tables",
"referenced",
"in",
"a",
"query",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/planbuilder/permission.go#L35-L64 | train |
vitessio/vitess | go/sqltypes/plan_value.go | IsNull | func (pv PlanValue) IsNull() bool {
return pv.Key == "" && pv.Value.IsNull() && pv.ListKey == "" && pv.Values == nil
} | go | func (pv PlanValue) IsNull() bool {
return pv.Key == "" && pv.Value.IsNull() && pv.ListKey == "" && pv.Values == nil
} | [
"func",
"(",
"pv",
"PlanValue",
")",
"IsNull",
"(",
")",
"bool",
"{",
"return",
"pv",
".",
"Key",
"==",
"\"",
"\"",
"&&",
"pv",
".",
"Value",
".",
"IsNull",
"(",
")",
"&&",
"pv",
".",
"ListKey",
"==",
"\"",
"\"",
"&&",
"pv",
".",
"Values",
"=="... | // IsNull returns true if the PlanValue is NULL. | [
"IsNull",
"returns",
"true",
"if",
"the",
"PlanValue",
"is",
"NULL",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/plan_value.go#L67-L69 | train |
vitessio/vitess | go/sqltypes/plan_value.go | ResolveList | func (pv PlanValue) ResolveList(bindVars map[string]*querypb.BindVariable) ([]Value, error) {
switch {
case pv.ListKey != "":
bv, err := pv.lookupList(bindVars)
if err != nil {
return nil, err
}
values := make([]Value, 0, len(bv.Values))
for _, val := range bv.Values {
values = append(values, MakeTrus... | go | func (pv PlanValue) ResolveList(bindVars map[string]*querypb.BindVariable) ([]Value, error) {
switch {
case pv.ListKey != "":
bv, err := pv.lookupList(bindVars)
if err != nil {
return nil, err
}
values := make([]Value, 0, len(bv.Values))
for _, val := range bv.Values {
values = append(values, MakeTrus... | [
"func",
"(",
"pv",
"PlanValue",
")",
"ResolveList",
"(",
"bindVars",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"(",
"[",
"]",
"Value",
",",
"error",
")",
"{",
"switch",
"{",
"case",
"pv",
".",
"ListKey",
"!=",
"\"",
"\"",
... | // ResolveList resolves a PlanValue as a list of values based on the supplied bindvars. | [
"ResolveList",
"resolves",
"a",
"PlanValue",
"as",
"a",
"list",
"of",
"values",
"based",
"on",
"the",
"supplied",
"bindvars",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/plan_value.go#L107-L133 | train |
vitessio/vitess | go/sqltypes/plan_value.go | MarshalJSON | func (pv PlanValue) MarshalJSON() ([]byte, error) {
switch {
case pv.Key != "":
return json.Marshal(":" + pv.Key)
case !pv.Value.IsNull():
if pv.Value.IsIntegral() {
return pv.Value.ToBytes(), nil
}
return json.Marshal(pv.Value.ToString())
case pv.ListKey != "":
return json.Marshal("::" + pv.ListKey)
... | go | func (pv PlanValue) MarshalJSON() ([]byte, error) {
switch {
case pv.Key != "":
return json.Marshal(":" + pv.Key)
case !pv.Value.IsNull():
if pv.Value.IsIntegral() {
return pv.Value.ToBytes(), nil
}
return json.Marshal(pv.Value.ToString())
case pv.ListKey != "":
return json.Marshal("::" + pv.ListKey)
... | [
"func",
"(",
"pv",
"PlanValue",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"{",
"case",
"pv",
".",
"Key",
"!=",
"\"",
"\"",
":",
"return",
"json",
".",
"Marshal",
"(",
"\"",
"\"",
"+",
"pv",
".",
"Key... | // MarshalJSON should be used only for testing. | [
"MarshalJSON",
"should",
"be",
"used",
"only",
"for",
"testing",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/plan_value.go#L147-L162 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | ParseTabletURLTemplateFromFlag | func ParseTabletURLTemplateFromFlag() {
tabletURLTemplate = template.New("")
_, err := tabletURLTemplate.Parse(*tabletURLTemplateString)
if err != nil {
log.Exitf("error parsing template: %v", err)
}
} | go | func ParseTabletURLTemplateFromFlag() {
tabletURLTemplate = template.New("")
_, err := tabletURLTemplate.Parse(*tabletURLTemplateString)
if err != nil {
log.Exitf("error parsing template: %v", err)
}
} | [
"func",
"ParseTabletURLTemplateFromFlag",
"(",
")",
"{",
"tabletURLTemplate",
"=",
"template",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"_",
",",
"err",
":=",
"tabletURLTemplate",
".",
"Parse",
"(",
"*",
"tabletURLTemplateString",
")",
"\n",
"if",
"err",
"!="... | // ParseTabletURLTemplateFromFlag loads or reloads the URL template. | [
"ParseTabletURLTemplateFromFlag",
"loads",
"or",
"reloads",
"the",
"URL",
"template",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L128-L134 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | DeepEqual | func (e *TabletStats) DeepEqual(f *TabletStats) bool {
return e.Key == f.Key &&
proto.Equal(e.Tablet, f.Tablet) &&
e.Name == f.Name &&
proto.Equal(e.Target, f.Target) &&
e.Up == f.Up &&
e.Serving == f.Serving &&
e.TabletExternallyReparentedTimestamp == f.TabletExternallyReparentedTimestamp &&
proto.Equal... | go | func (e *TabletStats) DeepEqual(f *TabletStats) bool {
return e.Key == f.Key &&
proto.Equal(e.Tablet, f.Tablet) &&
e.Name == f.Name &&
proto.Equal(e.Target, f.Target) &&
e.Up == f.Up &&
e.Serving == f.Serving &&
e.TabletExternallyReparentedTimestamp == f.TabletExternallyReparentedTimestamp &&
proto.Equal... | [
"func",
"(",
"e",
"*",
"TabletStats",
")",
"DeepEqual",
"(",
"f",
"*",
"TabletStats",
")",
"bool",
"{",
"return",
"e",
".",
"Key",
"==",
"f",
".",
"Key",
"&&",
"proto",
".",
"Equal",
"(",
"e",
".",
"Tablet",
",",
"f",
".",
"Tablet",
")",
"&&",
... | // DeepEqual compares two TabletStats. Since we include protos, we
// need to use proto.Equal on these. | [
"DeepEqual",
"compares",
"two",
"TabletStats",
".",
"Since",
"we",
"include",
"protos",
"we",
"need",
"to",
"use",
"proto",
".",
"Equal",
"on",
"these",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L193-L204 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | GetTabletHostPort | func (e TabletStats) GetTabletHostPort() string {
vtPort := e.Tablet.PortMap["vt"]
return netutil.JoinHostPort(e.Tablet.Hostname, vtPort)
} | go | func (e TabletStats) GetTabletHostPort() string {
vtPort := e.Tablet.PortMap["vt"]
return netutil.JoinHostPort(e.Tablet.Hostname, vtPort)
} | [
"func",
"(",
"e",
"TabletStats",
")",
"GetTabletHostPort",
"(",
")",
"string",
"{",
"vtPort",
":=",
"e",
".",
"Tablet",
".",
"PortMap",
"[",
"\"",
"\"",
"]",
"\n",
"return",
"netutil",
".",
"JoinHostPort",
"(",
"e",
".",
"Tablet",
".",
"Hostname",
",",... | // GetTabletHostPort formats a tablet host port address. | [
"GetTabletHostPort",
"formats",
"a",
"tablet",
"host",
"port",
"address",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L213-L216 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | GetHostNameLevel | func (e TabletStats) GetHostNameLevel(level int) string {
chunkedHostname := strings.Split(e.Tablet.Hostname, ".")
if level < 0 {
return chunkedHostname[0]
} else if level >= len(chunkedHostname) {
return chunkedHostname[len(chunkedHostname)-1]
} else {
return chunkedHostname[level]
}
} | go | func (e TabletStats) GetHostNameLevel(level int) string {
chunkedHostname := strings.Split(e.Tablet.Hostname, ".")
if level < 0 {
return chunkedHostname[0]
} else if level >= len(chunkedHostname) {
return chunkedHostname[len(chunkedHostname)-1]
} else {
return chunkedHostname[level]
}
} | [
"func",
"(",
"e",
"TabletStats",
")",
"GetHostNameLevel",
"(",
"level",
"int",
")",
"string",
"{",
"chunkedHostname",
":=",
"strings",
".",
"Split",
"(",
"e",
".",
"Tablet",
".",
"Hostname",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"level",
"<",
"0",
"{",
... | // GetHostNameLevel returns the specified hostname level. If the level does not exist it will pick the closest level.
// This seems unused but can be utilized by certain url formatting templates. See getTabletDebugURL for more details. | [
"GetHostNameLevel",
"returns",
"the",
"specified",
"hostname",
"level",
".",
"If",
"the",
"level",
"does",
"not",
"exist",
"it",
"will",
"pick",
"the",
"closest",
"level",
".",
"This",
"seems",
"unused",
"but",
"can",
"be",
"utilized",
"by",
"certain",
"url"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L220-L230 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | RegisterStats | func (hc *HealthCheckImpl) RegisterStats() {
stats.NewGaugesFuncWithMultiLabels(
"HealthcheckConnections",
"the number of healthcheck connections registered",
[]string{"Keyspace", "ShardName", "TabletType"},
hc.servingConnStats)
stats.NewGaugeFunc(
"HealthcheckChecksum",
"crc32 checksum of the current he... | go | func (hc *HealthCheckImpl) RegisterStats() {
stats.NewGaugesFuncWithMultiLabels(
"HealthcheckConnections",
"the number of healthcheck connections registered",
[]string{"Keyspace", "ShardName", "TabletType"},
hc.servingConnStats)
stats.NewGaugeFunc(
"HealthcheckChecksum",
"crc32 checksum of the current he... | [
"func",
"(",
"hc",
"*",
"HealthCheckImpl",
")",
"RegisterStats",
"(",
")",
"{",
"stats",
".",
"NewGaugesFuncWithMultiLabels",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"h... | // RegisterStats registers the connection counts stats | [
"RegisterStats",
"registers",
"the",
"connection",
"counts",
"stats"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L378-L389 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | ServeHTTP | func (hc *HealthCheckImpl) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
status := hc.cacheStatusMap()
b, err := json.MarshalIndent(status, "", " ")
if err != nil {
w.Write([]byte(err.Error()))
return
}
buf := bytes.NewBuffer(nil)
json.... | go | func (hc *HealthCheckImpl) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
status := hc.cacheStatusMap()
b, err := json.MarshalIndent(status, "", " ")
if err != nil {
w.Write([]byte(err.Error()))
return
}
buf := bytes.NewBuffer(nil)
json.... | [
"func",
"(",
"hc",
"*",
"HealthCheckImpl",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"_",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"status"... | // ServeHTTP is part of the http.Handler interface. It renders the current state of the discovery gateway tablet cache into json. | [
"ServeHTTP",
"is",
"part",
"of",
"the",
"http",
".",
"Handler",
"interface",
".",
"It",
"renders",
"the",
"current",
"state",
"of",
"the",
"discovery",
"gateway",
"tablet",
"cache",
"into",
"json",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L392-L404 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | stateChecksum | func (hc *HealthCheckImpl) stateChecksum() int64 {
// CacheStatus is sorted so this should be stable across vtgates
cacheStatus := hc.CacheStatus()
var buf bytes.Buffer
for _, st := range cacheStatus {
fmt.Fprintf(&buf,
"%v%v%v%v\n",
st.Cell,
st.Target.Keyspace,
st.Target.Shard,
st.Target.TabletTyp... | go | func (hc *HealthCheckImpl) stateChecksum() int64 {
// CacheStatus is sorted so this should be stable across vtgates
cacheStatus := hc.CacheStatus()
var buf bytes.Buffer
for _, st := range cacheStatus {
fmt.Fprintf(&buf,
"%v%v%v%v\n",
st.Cell,
st.Target.Keyspace,
st.Target.Shard,
st.Target.TabletTyp... | [
"func",
"(",
"hc",
"*",
"HealthCheckImpl",
")",
"stateChecksum",
"(",
")",
"int64",
"{",
"// CacheStatus is sorted so this should be stable across vtgates",
"cacheStatus",
":=",
"hc",
".",
"CacheStatus",
"(",
")",
"\n",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
... | // stateChecksum returns a crc32 checksum of the healthcheck state | [
"stateChecksum",
"returns",
"a",
"crc32",
"checksum",
"of",
"the",
"healthcheck",
"state"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L422-L441 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | updateHealth | func (hc *HealthCheckImpl) updateHealth(ts *TabletStats, conn queryservice.QueryService) {
// Unconditionally send the received update at the end.
defer func() {
if hc.listener != nil {
hc.listener.StatsUpdate(ts)
}
}()
hc.mu.Lock()
th, ok := hc.addrToHealth[ts.Key]
if !ok {
// This can happen on delete... | go | func (hc *HealthCheckImpl) updateHealth(ts *TabletStats, conn queryservice.QueryService) {
// Unconditionally send the received update at the end.
defer func() {
if hc.listener != nil {
hc.listener.StatsUpdate(ts)
}
}()
hc.mu.Lock()
th, ok := hc.addrToHealth[ts.Key]
if !ok {
// This can happen on delete... | [
"func",
"(",
"hc",
"*",
"HealthCheckImpl",
")",
"updateHealth",
"(",
"ts",
"*",
"TabletStats",
",",
"conn",
"queryservice",
".",
"QueryService",
")",
"{",
"// Unconditionally send the received update at the end.",
"defer",
"func",
"(",
")",
"{",
"if",
"hc",
".",
... | // updateHealth updates the tabletHealth record and transmits the tablet stats
// to the listener. | [
"updateHealth",
"updates",
"the",
"tabletHealth",
"record",
"and",
"transmits",
"the",
"tablet",
"stats",
"to",
"the",
"listener",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L445-L483 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | checkConn | func (hc *HealthCheckImpl) checkConn(hcc *healthCheckConn, name string) {
defer hc.connsWG.Done()
defer hc.finalizeConn(hcc)
// Initial notification for downstream about the tablet existence.
hc.updateHealth(hcc.tabletStats.Copy(), hcc.conn)
hc.initialUpdatesWG.Done()
retryDelay := hc.retryDelay
for {
stream... | go | func (hc *HealthCheckImpl) checkConn(hcc *healthCheckConn, name string) {
defer hc.connsWG.Done()
defer hc.finalizeConn(hcc)
// Initial notification for downstream about the tablet existence.
hc.updateHealth(hcc.tabletStats.Copy(), hcc.conn)
hc.initialUpdatesWG.Done()
retryDelay := hc.retryDelay
for {
stream... | [
"func",
"(",
"hc",
"*",
"HealthCheckImpl",
")",
"checkConn",
"(",
"hcc",
"*",
"healthCheckConn",
",",
"name",
"string",
")",
"{",
"defer",
"hc",
".",
"connsWG",
".",
"Done",
"(",
")",
"\n",
"defer",
"hc",
".",
"finalizeConn",
"(",
"hcc",
")",
"\n\n",
... | // checkConn performs health checking on the given tablet. | [
"checkConn",
"performs",
"health",
"checking",
"on",
"the",
"given",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L506-L583 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | setServingState | func (hcc *healthCheckConn) setServingState(serving bool, reason string) {
if !hcc.loggedServingState || (serving != hcc.tabletStats.Serving) {
// Emit the log from a separate goroutine to avoid holding
// the hcc lock while logging is happening
go log.Infof("HealthCheckUpdate(Serving State): %v, tablet: %v serv... | go | func (hcc *healthCheckConn) setServingState(serving bool, reason string) {
if !hcc.loggedServingState || (serving != hcc.tabletStats.Serving) {
// Emit the log from a separate goroutine to avoid holding
// the hcc lock while logging is happening
go log.Infof("HealthCheckUpdate(Serving State): %v, tablet: %v serv... | [
"func",
"(",
"hcc",
"*",
"healthCheckConn",
")",
"setServingState",
"(",
"serving",
"bool",
",",
"reason",
"string",
")",
"{",
"if",
"!",
"hcc",
".",
"loggedServingState",
"||",
"(",
"serving",
"!=",
"hcc",
".",
"tabletStats",
".",
"Serving",
")",
"{",
"... | // setServingState sets the tablet state to the given value.
//
// If the state changes, it logs the change so that failures
// from the health check connection are logged the first time,
// but don't continue to log if the connection stays down.
//
// hcc.mu must be locked before calling this function | [
"setServingState",
"sets",
"the",
"tablet",
"state",
"to",
"the",
"given",
"value",
".",
"If",
"the",
"state",
"changes",
"it",
"logs",
"the",
"change",
"so",
"that",
"failures",
"from",
"the",
"health",
"check",
"connection",
"are",
"logged",
"the",
"first"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L592-L609 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | stream | func (hcc *healthCheckConn) stream(ctx context.Context, hc *HealthCheckImpl, callback func(*querypb.StreamHealthResponse) error) {
if hcc.conn == nil {
conn, err := tabletconn.GetDialer()(hcc.tabletStats.Tablet, grpcclient.FailFast(true))
if err != nil {
hcc.tabletStats.LastError = err
return
}
hcc.conn ... | go | func (hcc *healthCheckConn) stream(ctx context.Context, hc *HealthCheckImpl, callback func(*querypb.StreamHealthResponse) error) {
if hcc.conn == nil {
conn, err := tabletconn.GetDialer()(hcc.tabletStats.Tablet, grpcclient.FailFast(true))
if err != nil {
hcc.tabletStats.LastError = err
return
}
hcc.conn ... | [
"func",
"(",
"hcc",
"*",
"healthCheckConn",
")",
"stream",
"(",
"ctx",
"context",
".",
"Context",
",",
"hc",
"*",
"HealthCheckImpl",
",",
"callback",
"func",
"(",
"*",
"querypb",
".",
"StreamHealthResponse",
")",
"error",
")",
"{",
"if",
"hcc",
".",
"con... | // stream streams healthcheck responses to callback. | [
"stream",
"streams",
"healthcheck",
"responses",
"to",
"callback",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L612-L631 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | processResponse | func (hcc *healthCheckConn) processResponse(hc *HealthCheckImpl, shr *querypb.StreamHealthResponse) error {
select {
case <-hcc.ctx.Done():
return hcc.ctx.Err()
default:
}
// Check for invalid data, better than panicking.
if shr.Target == nil || shr.RealtimeStats == nil {
return fmt.Errorf("health stats is n... | go | func (hcc *healthCheckConn) processResponse(hc *HealthCheckImpl, shr *querypb.StreamHealthResponse) error {
select {
case <-hcc.ctx.Done():
return hcc.ctx.Err()
default:
}
// Check for invalid data, better than panicking.
if shr.Target == nil || shr.RealtimeStats == nil {
return fmt.Errorf("health stats is n... | [
"func",
"(",
"hcc",
"*",
"healthCheckConn",
")",
"processResponse",
"(",
"hc",
"*",
"HealthCheckImpl",
",",
"shr",
"*",
"querypb",
".",
"StreamHealthResponse",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"hcc",
".",
"ctx",
".",
"Done",
"(",
")",
":",... | // processResponse reads one health check response, and notifies HealthCheckStatsListener. | [
"processResponse",
"reads",
"one",
"health",
"check",
"response",
"and",
"notifies",
"HealthCheckStatsListener",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L634-L680 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | ReplaceTablet | func (hc *HealthCheckImpl) ReplaceTablet(old, new *topodatapb.Tablet, name string) {
go func() {
hc.deleteConn(old)
hc.AddTablet(new, name)
}()
} | go | func (hc *HealthCheckImpl) ReplaceTablet(old, new *topodatapb.Tablet, name string) {
go func() {
hc.deleteConn(old)
hc.AddTablet(new, name)
}()
} | [
"func",
"(",
"hc",
"*",
"HealthCheckImpl",
")",
"ReplaceTablet",
"(",
"old",
",",
"new",
"*",
"topodatapb",
".",
"Tablet",
",",
"name",
"string",
")",
"{",
"go",
"func",
"(",
")",
"{",
"hc",
".",
"deleteConn",
"(",
"old",
")",
"\n",
"hc",
".",
"Add... | // ReplaceTablet removes the old tablet and adds the new tablet. | [
"ReplaceTablet",
"removes",
"the",
"old",
"tablet",
"and",
"adds",
"the",
"new",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L759-L764 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | StatusAsHTML | func (tcs *TabletsCacheStatus) StatusAsHTML() template.HTML {
tLinks := make([]string, 0, 1)
if tcs.TabletsStats != nil {
sort.Sort(tcs.TabletsStats)
}
for _, ts := range tcs.TabletsStats {
color := "green"
extra := ""
if ts.LastError != nil {
color = "red"
extra = fmt.Sprintf(" (%v)", ts.LastError)
... | go | func (tcs *TabletsCacheStatus) StatusAsHTML() template.HTML {
tLinks := make([]string, 0, 1)
if tcs.TabletsStats != nil {
sort.Sort(tcs.TabletsStats)
}
for _, ts := range tcs.TabletsStats {
color := "green"
extra := ""
if ts.LastError != nil {
color = "red"
extra = fmt.Sprintf(" (%v)", ts.LastError)
... | [
"func",
"(",
"tcs",
"*",
"TabletsCacheStatus",
")",
"StatusAsHTML",
"(",
")",
"template",
".",
"HTML",
"{",
"tLinks",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"1",
")",
"\n",
"if",
"tcs",
".",
"TabletsStats",
"!=",
"nil",
"{",
"sort",
... | // StatusAsHTML returns an HTML version of the status. | [
"StatusAsHTML",
"returns",
"an",
"HTML",
"version",
"of",
"the",
"status",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L818-L847 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | CacheStatus | func (hc *HealthCheckImpl) CacheStatus() TabletsCacheStatusList {
tcsMap := hc.cacheStatusMap()
tcsl := make(TabletsCacheStatusList, 0, len(tcsMap))
for _, tcs := range tcsMap {
tcsl = append(tcsl, tcs)
}
sort.Sort(tcsl)
return tcsl
} | go | func (hc *HealthCheckImpl) CacheStatus() TabletsCacheStatusList {
tcsMap := hc.cacheStatusMap()
tcsl := make(TabletsCacheStatusList, 0, len(tcsMap))
for _, tcs := range tcsMap {
tcsl = append(tcsl, tcs)
}
sort.Sort(tcsl)
return tcsl
} | [
"func",
"(",
"hc",
"*",
"HealthCheckImpl",
")",
"CacheStatus",
"(",
")",
"TabletsCacheStatusList",
"{",
"tcsMap",
":=",
"hc",
".",
"cacheStatusMap",
"(",
")",
"\n",
"tcsl",
":=",
"make",
"(",
"TabletsCacheStatusList",
",",
"0",
",",
"len",
"(",
"tcsMap",
"... | // CacheStatus returns a displayable version of the cache. | [
"CacheStatus",
"returns",
"a",
"displayable",
"version",
"of",
"the",
"cache",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L869-L877 | train |
vitessio/vitess | go/vt/discovery/healthcheck.go | TabletToMapKey | func TabletToMapKey(tablet *topodatapb.Tablet) string {
parts := make([]string, 0, 1)
for name, port := range tablet.PortMap {
parts = append(parts, netutil.JoinHostPort(name, port))
}
sort.Strings(parts)
parts = append([]string{tablet.Hostname}, parts...)
return strings.Join(parts, ",")
} | go | func TabletToMapKey(tablet *topodatapb.Tablet) string {
parts := make([]string, 0, 1)
for name, port := range tablet.PortMap {
parts = append(parts, netutil.JoinHostPort(name, port))
}
sort.Strings(parts)
parts = append([]string{tablet.Hostname}, parts...)
return strings.Join(parts, ",")
} | [
"func",
"TabletToMapKey",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"string",
"{",
"parts",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"1",
")",
"\n",
"for",
"name",
",",
"port",
":=",
"range",
"tablet",
".",
"PortMap",
"{",
... | // TabletToMapKey creates a key to the map from tablet's host and ports.
// It should only be used in discovery and related module. | [
"TabletToMapKey",
"creates",
"a",
"key",
"to",
"the",
"map",
"from",
"tablet",
"s",
"host",
"and",
"ports",
".",
"It",
"should",
"only",
"be",
"used",
"in",
"discovery",
"and",
"related",
"module",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/healthcheck.go#L922-L930 | train |
vitessio/vitess | go/vt/vterrors/grpc.go | CodeToLegacyErrorCode | func CodeToLegacyErrorCode(code vtrpcpb.Code) vtrpcpb.LegacyErrorCode {
switch code {
case vtrpcpb.Code_OK:
return vtrpcpb.LegacyErrorCode_SUCCESS_LEGACY
case vtrpcpb.Code_CANCELED:
return vtrpcpb.LegacyErrorCode_CANCELLED_LEGACY
case vtrpcpb.Code_UNKNOWN:
return vtrpcpb.LegacyErrorCode_UNKNOWN_ERROR_LEGACY
... | go | func CodeToLegacyErrorCode(code vtrpcpb.Code) vtrpcpb.LegacyErrorCode {
switch code {
case vtrpcpb.Code_OK:
return vtrpcpb.LegacyErrorCode_SUCCESS_LEGACY
case vtrpcpb.Code_CANCELED:
return vtrpcpb.LegacyErrorCode_CANCELLED_LEGACY
case vtrpcpb.Code_UNKNOWN:
return vtrpcpb.LegacyErrorCode_UNKNOWN_ERROR_LEGACY
... | [
"func",
"CodeToLegacyErrorCode",
"(",
"code",
"vtrpcpb",
".",
"Code",
")",
"vtrpcpb",
".",
"LegacyErrorCode",
"{",
"switch",
"code",
"{",
"case",
"vtrpcpb",
".",
"Code_OK",
":",
"return",
"vtrpcpb",
".",
"LegacyErrorCode_SUCCESS_LEGACY",
"\n",
"case",
"vtrpcpb",
... | // This file contains functions to convert errors to and from gRPC codes.
// Use these methods to return an error through gRPC and still
// retain its code.
// CodeToLegacyErrorCode maps a vtrpcpb.Code to a vtrpcpb.LegacyErrorCode. | [
"This",
"file",
"contains",
"functions",
"to",
"convert",
"errors",
"to",
"and",
"from",
"gRPC",
"codes",
".",
"Use",
"these",
"methods",
"to",
"return",
"an",
"error",
"through",
"gRPC",
"and",
"still",
"retain",
"its",
"code",
".",
"CodeToLegacyErrorCode",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/grpc.go#L34-L66 | train |
vitessio/vitess | go/vt/vterrors/grpc.go | truncateError | func truncateError(err error) string {
// For more details see: https://github.com/grpc/grpc-go/issues/443
// The gRPC spec says "Clients may limit the size of Response-Headers,
// Trailers, and Trailers-Only, with a default of 8 KiB each suggested."
// Therefore, we assume 8 KiB minus some headroom.
GRPCErrorLimi... | go | func truncateError(err error) string {
// For more details see: https://github.com/grpc/grpc-go/issues/443
// The gRPC spec says "Clients may limit the size of Response-Headers,
// Trailers, and Trailers-Only, with a default of 8 KiB each suggested."
// Therefore, we assume 8 KiB minus some headroom.
GRPCErrorLimi... | [
"func",
"truncateError",
"(",
"err",
"error",
")",
"string",
"{",
"// For more details see: https://github.com/grpc/grpc-go/issues/443",
"// The gRPC spec says \"Clients may limit the size of Response-Headers,",
"// Trailers, and Trailers-Only, with a default of 8 KiB each suggested.\"",
"// T... | // truncateError shortens errors because gRPC has a size restriction on them. | [
"truncateError",
"shortens",
"errors",
"because",
"gRPC",
"has",
"a",
"size",
"restriction",
"on",
"them",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/grpc.go#L104-L116 | train |
vitessio/vitess | go/vt/vterrors/grpc.go | ToGRPC | func ToGRPC(err error) error {
if err == nil {
return nil
}
return status.Errorf(codes.Code(Code(err)), "%v", truncateError(err))
} | go | func ToGRPC(err error) error {
if err == nil {
return nil
}
return status.Errorf(codes.Code(Code(err)), "%v", truncateError(err))
} | [
"func",
"ToGRPC",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"status",
".",
"Errorf",
"(",
"codes",
".",
"Code",
"(",
"Code",
"(",
"err",
")",
")",
",",
"\"",
"\"",
",",
"t... | // ToGRPC returns an error as a gRPC error, with the appropriate error code. | [
"ToGRPC",
"returns",
"an",
"error",
"as",
"a",
"gRPC",
"error",
"with",
"the",
"appropriate",
"error",
"code",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/grpc.go#L119-L124 | train |
vitessio/vitess | go/vt/vterrors/grpc.go | FromGRPC | func FromGRPC(err error) error {
if err == nil {
return nil
}
if err == io.EOF {
// Do not wrap io.EOF because we compare against it for finished streams.
return err
}
code := codes.Unknown
if s, ok := status.FromError(err); ok {
code = s.Code()
}
return New(vtrpcpb.Code(code), err.Error())
} | go | func FromGRPC(err error) error {
if err == nil {
return nil
}
if err == io.EOF {
// Do not wrap io.EOF because we compare against it for finished streams.
return err
}
code := codes.Unknown
if s, ok := status.FromError(err); ok {
code = s.Code()
}
return New(vtrpcpb.Code(code), err.Error())
} | [
"func",
"FromGRPC",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"// Do not wrap io.EOF because we compare against it for finished streams.",
"return",
"err",
... | // FromGRPC returns a gRPC error as a vtError, translating between error codes.
// However, there are a few errors which are not translated and passed as they
// are. For example, io.EOF since our code base checks for this error to find
// out that a stream has finished. | [
"FromGRPC",
"returns",
"a",
"gRPC",
"error",
"as",
"a",
"vtError",
"translating",
"between",
"error",
"codes",
".",
"However",
"there",
"are",
"a",
"few",
"errors",
"which",
"are",
"not",
"translated",
"and",
"passed",
"as",
"they",
"are",
".",
"For",
"exa... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/grpc.go#L130-L143 | train |
vitessio/vitess | go/vt/worker/legacy_row_splitter.go | NewRowSplitter | func NewRowSplitter(shardInfos []*topo.ShardInfo, keyResolver keyspaceIDResolver) *RowSplitter {
result := &RowSplitter{
KeyResolver: keyResolver,
KeyRanges: make([]*topodatapb.KeyRange, len(shardInfos)),
}
for i, si := range shardInfos {
result.KeyRanges[i] = si.KeyRange
}
return result
} | go | func NewRowSplitter(shardInfos []*topo.ShardInfo, keyResolver keyspaceIDResolver) *RowSplitter {
result := &RowSplitter{
KeyResolver: keyResolver,
KeyRanges: make([]*topodatapb.KeyRange, len(shardInfos)),
}
for i, si := range shardInfos {
result.KeyRanges[i] = si.KeyRange
}
return result
} | [
"func",
"NewRowSplitter",
"(",
"shardInfos",
"[",
"]",
"*",
"topo",
".",
"ShardInfo",
",",
"keyResolver",
"keyspaceIDResolver",
")",
"*",
"RowSplitter",
"{",
"result",
":=",
"&",
"RowSplitter",
"{",
"KeyResolver",
":",
"keyResolver",
",",
"KeyRanges",
":",
"ma... | // NewRowSplitter returns a new row splitter for the given shard distribution. | [
"NewRowSplitter",
"returns",
"a",
"new",
"row",
"splitter",
"for",
"the",
"given",
"shard",
"distribution",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/legacy_row_splitter.go#L39-L48 | train |
vitessio/vitess | go/vt/worker/legacy_row_splitter.go | StartSplit | func (rs *RowSplitter) StartSplit() [][][]sqltypes.Value {
return make([][][]sqltypes.Value, len(rs.KeyRanges))
} | go | func (rs *RowSplitter) StartSplit() [][][]sqltypes.Value {
return make([][][]sqltypes.Value, len(rs.KeyRanges))
} | [
"func",
"(",
"rs",
"*",
"RowSplitter",
")",
"StartSplit",
"(",
")",
"[",
"]",
"[",
"]",
"[",
"]",
"sqltypes",
".",
"Value",
"{",
"return",
"make",
"(",
"[",
"]",
"[",
"]",
"[",
"]",
"sqltypes",
".",
"Value",
",",
"len",
"(",
"rs",
".",
"KeyRang... | // StartSplit starts a new split. Split can then be called multiple times. | [
"StartSplit",
"starts",
"a",
"new",
"split",
".",
"Split",
"can",
"then",
"be",
"called",
"multiple",
"times",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/legacy_row_splitter.go#L51-L53 | train |
vitessio/vitess | go/vt/worker/legacy_row_splitter.go | Split | func (rs *RowSplitter) Split(result [][][]sqltypes.Value, rows [][]sqltypes.Value) error {
for _, row := range rows {
k, err := rs.KeyResolver.keyspaceID(row)
if err != nil {
return err
}
for i, kr := range rs.KeyRanges {
if key.KeyRangeContains(kr, k) {
result[i] = append(result[i], row)
break
... | go | func (rs *RowSplitter) Split(result [][][]sqltypes.Value, rows [][]sqltypes.Value) error {
for _, row := range rows {
k, err := rs.KeyResolver.keyspaceID(row)
if err != nil {
return err
}
for i, kr := range rs.KeyRanges {
if key.KeyRangeContains(kr, k) {
result[i] = append(result[i], row)
break
... | [
"func",
"(",
"rs",
"*",
"RowSplitter",
")",
"Split",
"(",
"result",
"[",
"]",
"[",
"]",
"[",
"]",
"sqltypes",
".",
"Value",
",",
"rows",
"[",
"]",
"[",
"]",
"sqltypes",
".",
"Value",
")",
"error",
"{",
"for",
"_",
",",
"row",
":=",
"range",
"ro... | // Split will split the rows into subset for each distribution | [
"Split",
"will",
"split",
"the",
"rows",
"into",
"subset",
"for",
"each",
"distribution"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/legacy_row_splitter.go#L56-L70 | train |
vitessio/vitess | go/vt/worker/legacy_row_splitter.go | Send | func (rs *RowSplitter) Send(fields []*querypb.Field, result [][][]sqltypes.Value, baseCmds []string, insertChannels []chan string, abort <-chan struct{}) bool {
for i, c := range insertChannels {
// one of the chunks might be empty, so no need
// to send data in that case
if len(result[i]) > 0 {
cmd := baseCm... | go | func (rs *RowSplitter) Send(fields []*querypb.Field, result [][][]sqltypes.Value, baseCmds []string, insertChannels []chan string, abort <-chan struct{}) bool {
for i, c := range insertChannels {
// one of the chunks might be empty, so no need
// to send data in that case
if len(result[i]) > 0 {
cmd := baseCm... | [
"func",
"(",
"rs",
"*",
"RowSplitter",
")",
"Send",
"(",
"fields",
"[",
"]",
"*",
"querypb",
".",
"Field",
",",
"result",
"[",
"]",
"[",
"]",
"[",
"]",
"sqltypes",
".",
"Value",
",",
"baseCmds",
"[",
"]",
"string",
",",
"insertChannels",
"[",
"]",
... | // Send will send the rows to the list of channels. Returns true if aborted. | [
"Send",
"will",
"send",
"the",
"rows",
"to",
"the",
"list",
"of",
"channels",
".",
"Returns",
"true",
"if",
"aborted",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/legacy_row_splitter.go#L73-L88 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/writer.go | NewWriter | func NewWriter(checker connpool.MySQLChecker, alias topodatapb.TabletAlias, config tabletenv.TabletConfig) *Writer {
if !config.HeartbeatEnable {
return &Writer{}
}
return &Writer{
enabled: true,
tabletAlias: alias,
now: time.Now,
interval: config.HeartbeatInterval,
ticks: timer.NewT... | go | func NewWriter(checker connpool.MySQLChecker, alias topodatapb.TabletAlias, config tabletenv.TabletConfig) *Writer {
if !config.HeartbeatEnable {
return &Writer{}
}
return &Writer{
enabled: true,
tabletAlias: alias,
now: time.Now,
interval: config.HeartbeatInterval,
ticks: timer.NewT... | [
"func",
"NewWriter",
"(",
"checker",
"connpool",
".",
"MySQLChecker",
",",
"alias",
"topodatapb",
".",
"TabletAlias",
",",
"config",
"tabletenv",
".",
"TabletConfig",
")",
"*",
"Writer",
"{",
"if",
"!",
"config",
".",
"HeartbeatEnable",
"{",
"return",
"&",
"... | // NewWriter creates a new Writer. | [
"NewWriter",
"creates",
"a",
"new",
"Writer",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/writer.go#L77-L90 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/writer.go | Init | func (w *Writer) Init(target querypb.Target) error {
if !w.enabled {
return nil
}
w.mu.Lock()
defer w.mu.Unlock()
log.Info("Initializing heartbeat table.")
w.dbName = sqlescape.EscapeID(w.dbconfigs.SidecarDBName.Get())
w.keyspaceShard = fmt.Sprintf("%s:%s", target.Keyspace, target.Shard)
err := w.initializeTa... | go | func (w *Writer) Init(target querypb.Target) error {
if !w.enabled {
return nil
}
w.mu.Lock()
defer w.mu.Unlock()
log.Info("Initializing heartbeat table.")
w.dbName = sqlescape.EscapeID(w.dbconfigs.SidecarDBName.Get())
w.keyspaceShard = fmt.Sprintf("%s:%s", target.Keyspace, target.Shard)
err := w.initializeTa... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Init",
"(",
"target",
"querypb",
".",
"Target",
")",
"error",
"{",
"if",
"!",
"w",
".",
"enabled",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"... | // Init runs at tablet startup and last minute initialization of db settings, and
// creates the necessary tables for heartbeat. | [
"Init",
"runs",
"at",
"tablet",
"startup",
"and",
"last",
"minute",
"initialization",
"of",
"db",
"settings",
"and",
"creates",
"the",
"necessary",
"tables",
"for",
"heartbeat",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/writer.go#L99-L115 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/writer.go | Open | func (w *Writer) Open() {
if !w.enabled {
return
}
w.mu.Lock()
defer w.mu.Unlock()
if w.isOpen {
return
}
log.Info("Beginning heartbeat writes")
w.pool.Open(w.dbconfigs.AppWithDB(), w.dbconfigs.DbaWithDB(), w.dbconfigs.AppDebugWithDB())
w.ticks.Start(func() { w.writeHeartbeat() })
w.isOpen = true
} | go | func (w *Writer) Open() {
if !w.enabled {
return
}
w.mu.Lock()
defer w.mu.Unlock()
if w.isOpen {
return
}
log.Info("Beginning heartbeat writes")
w.pool.Open(w.dbconfigs.AppWithDB(), w.dbconfigs.DbaWithDB(), w.dbconfigs.AppDebugWithDB())
w.ticks.Start(func() { w.writeHeartbeat() })
w.isOpen = true
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Open",
"(",
")",
"{",
"if",
"!",
"w",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"w",
"... | // Open sets up the Writer's db connection and launches the ticker
// responsible for periodically writing to the heartbeat table.
// Open may be called multiple times, as long as it was closed since
// last invocation. | [
"Open",
"sets",
"up",
"the",
"Writer",
"s",
"db",
"connection",
"and",
"launches",
"the",
"ticker",
"responsible",
"for",
"periodically",
"writing",
"to",
"the",
"heartbeat",
"table",
".",
"Open",
"may",
"be",
"called",
"multiple",
"times",
"as",
"long",
"as... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/writer.go#L121-L134 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/writer.go | Close | func (w *Writer) Close() {
if !w.enabled {
return
}
w.mu.Lock()
defer w.mu.Unlock()
if !w.isOpen {
return
}
w.ticks.Stop()
w.pool.Close()
log.Info("Stopped heartbeat writes.")
w.isOpen = false
} | go | func (w *Writer) Close() {
if !w.enabled {
return
}
w.mu.Lock()
defer w.mu.Unlock()
if !w.isOpen {
return
}
w.ticks.Stop()
w.pool.Close()
log.Info("Stopped heartbeat writes.")
w.isOpen = false
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Close",
"(",
")",
"{",
"if",
"!",
"w",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"!",
... | // Close closes the Writer's db connection and stops the periodic ticker. A writer
// object can be re-opened after closing. | [
"Close",
"closes",
"the",
"Writer",
"s",
"db",
"connection",
"and",
"stops",
"the",
"periodic",
"ticker",
".",
"A",
"writer",
"object",
"can",
"be",
"re",
"-",
"opened",
"after",
"closing",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/writer.go#L138-L151 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/writer.go | writeHeartbeat | func (w *Writer) writeHeartbeat() {
defer tabletenv.LogError()
ctx, cancel := context.WithDeadline(context.Background(), w.now().Add(w.interval))
defer cancel()
update, err := w.bindHeartbeatVars(sqlUpdateHeartbeat)
if err != nil {
w.recordError(err)
return
}
err = w.exec(ctx, update)
if err != nil {
w.re... | go | func (w *Writer) writeHeartbeat() {
defer tabletenv.LogError()
ctx, cancel := context.WithDeadline(context.Background(), w.now().Add(w.interval))
defer cancel()
update, err := w.bindHeartbeatVars(sqlUpdateHeartbeat)
if err != nil {
w.recordError(err)
return
}
err = w.exec(ctx, update)
if err != nil {
w.re... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"writeHeartbeat",
"(",
")",
"{",
"defer",
"tabletenv",
".",
"LogError",
"(",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithDeadline",
"(",
"context",
".",
"Background",
"(",
")",
",",
"w",
".",
"now... | // writeHeartbeat updates the heartbeat row for this tablet with the current time in nanoseconds. | [
"writeHeartbeat",
"updates",
"the",
"heartbeat",
"row",
"for",
"this",
"tablet",
"with",
"the",
"current",
"time",
"in",
"nanoseconds",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/writer.go#L204-L219 | train |
vitessio/vitess | go/vt/workflow/topovalidator/validator.go | Run | func (w *Workflow) Run(ctx context.Context, manager *workflow.Manager, wi *topo.WorkflowInfo) error {
w.uiUpdate()
w.rootUINode.Display = workflow.NodeDisplayDeterminate
w.rootUINode.BroadcastChanges(false /* updateChildren */)
// Run all the validators. They may add fixers.
for name, v := range validators {
w.... | go | func (w *Workflow) Run(ctx context.Context, manager *workflow.Manager, wi *topo.WorkflowInfo) error {
w.uiUpdate()
w.rootUINode.Display = workflow.NodeDisplayDeterminate
w.rootUINode.BroadcastChanges(false /* updateChildren */)
// Run all the validators. They may add fixers.
for name, v := range validators {
w.... | [
"func",
"(",
"w",
"*",
"Workflow",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"manager",
"*",
"workflow",
".",
"Manager",
",",
"wi",
"*",
"topo",
".",
"WorkflowInfo",
")",
"error",
"{",
"w",
".",
"uiUpdate",
"(",
")",
"\n",
"w",
".",
... | // Run is part of the workflow.Workflow interface. | [
"Run",
"is",
"part",
"of",
"the",
"workflow",
".",
"Workflow",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/workflow/topovalidator/validator.go#L120-L175 | train |
vitessio/vitess | go/vt/workflow/topovalidator/validator.go | uiUpdate | func (w *Workflow) uiUpdate() {
c := len(validators)
w.rootUINode.Progress = 100 * w.runCount / c
w.rootUINode.ProgressMessage = fmt.Sprintf("%v/%v", w.runCount, c)
w.rootUINode.Log = w.logger.String()
} | go | func (w *Workflow) uiUpdate() {
c := len(validators)
w.rootUINode.Progress = 100 * w.runCount / c
w.rootUINode.ProgressMessage = fmt.Sprintf("%v/%v", w.runCount, c)
w.rootUINode.Log = w.logger.String()
} | [
"func",
"(",
"w",
"*",
"Workflow",
")",
"uiUpdate",
"(",
")",
"{",
"c",
":=",
"len",
"(",
"validators",
")",
"\n",
"w",
".",
"rootUINode",
".",
"Progress",
"=",
"100",
"*",
"w",
".",
"runCount",
"/",
"c",
"\n",
"w",
".",
"rootUINode",
".",
"Progr... | // uiUpdate updates the computed parts of the Node, based on the
// current state. | [
"uiUpdate",
"updates",
"the",
"computed",
"parts",
"of",
"the",
"Node",
"based",
"on",
"the",
"current",
"state",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/workflow/topovalidator/validator.go#L179-L184 | train |
vitessio/vitess | go/vt/vtgate/engine/primitive.go | AddStats | func (p *Plan) AddStats(execCount uint64, execTime time.Duration, shardQueries, rows, errors uint64) {
p.mu.Lock()
p.ExecCount += execCount
p.ExecTime += execTime
p.ShardQueries += shardQueries
p.Rows += rows
p.Errors += errors
p.mu.Unlock()
} | go | func (p *Plan) AddStats(execCount uint64, execTime time.Duration, shardQueries, rows, errors uint64) {
p.mu.Lock()
p.ExecCount += execCount
p.ExecTime += execTime
p.ShardQueries += shardQueries
p.Rows += rows
p.Errors += errors
p.mu.Unlock()
} | [
"func",
"(",
"p",
"*",
"Plan",
")",
"AddStats",
"(",
"execCount",
"uint64",
",",
"execTime",
"time",
".",
"Duration",
",",
"shardQueries",
",",
"rows",
",",
"errors",
"uint64",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"p",
".",
"ExecC... | // AddStats updates the plan execution statistics | [
"AddStats",
"updates",
"the",
"plan",
"execution",
"statistics"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/primitive.go#L94-L102 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/select.go | buildSelectPlan | func buildSelectPlan(sel *sqlparser.Select, vschema ContextVSchema) (primitive engine.Primitive, err error) {
pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(sel)))
if err := pb.processSelect(sel, nil); err != nil {
return nil, err
}
if err := pb.bldr.Wireup(pb.bldr, pb.jt); err != nil {
ret... | go | func buildSelectPlan(sel *sqlparser.Select, vschema ContextVSchema) (primitive engine.Primitive, err error) {
pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(sel)))
if err := pb.processSelect(sel, nil); err != nil {
return nil, err
}
if err := pb.bldr.Wireup(pb.bldr, pb.jt); err != nil {
ret... | [
"func",
"buildSelectPlan",
"(",
"sel",
"*",
"sqlparser",
".",
"Select",
",",
"vschema",
"ContextVSchema",
")",
"(",
"primitive",
"engine",
".",
"Primitive",
",",
"err",
"error",
")",
"{",
"pb",
":=",
"newPrimitiveBuilder",
"(",
"vschema",
",",
"newJointab",
... | // buildSelectPlan is the new function to build a Select plan. | [
"buildSelectPlan",
"is",
"the",
"new",
"function",
"to",
"build",
"a",
"Select",
"plan",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/select.go#L28-L37 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/select.go | pushFilter | func (pb *primitiveBuilder) pushFilter(boolExpr sqlparser.Expr, whereType string) error {
filters := splitAndExpression(nil, boolExpr)
reorderBySubquery(filters)
for _, filter := range filters {
pullouts, origin, expr, err := pb.findOrigin(filter)
if err != nil {
return err
}
// The returned expression ma... | go | func (pb *primitiveBuilder) pushFilter(boolExpr sqlparser.Expr, whereType string) error {
filters := splitAndExpression(nil, boolExpr)
reorderBySubquery(filters)
for _, filter := range filters {
pullouts, origin, expr, err := pb.findOrigin(filter)
if err != nil {
return err
}
// The returned expression ma... | [
"func",
"(",
"pb",
"*",
"primitiveBuilder",
")",
"pushFilter",
"(",
"boolExpr",
"sqlparser",
".",
"Expr",
",",
"whereType",
"string",
")",
"error",
"{",
"filters",
":=",
"splitAndExpression",
"(",
"nil",
",",
"boolExpr",
")",
"\n",
"reorderBySubquery",
"(",
... | // pushFilter identifies the target route for the specified bool expr,
// pushes it down, and updates the route info if the new constraint improves
// the primitive. This function can push to a WHERE or HAVING clause. | [
"pushFilter",
"identifies",
"the",
"target",
"route",
"for",
"the",
"specified",
"bool",
"expr",
"pushes",
"it",
"down",
"and",
"updates",
"the",
"route",
"info",
"if",
"the",
"new",
"constraint",
"improves",
"the",
"primitive",
".",
"This",
"function",
"can",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/select.go#L127-L144 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/select.go | reorderBySubquery | func reorderBySubquery(filters []sqlparser.Expr) {
max := len(filters)
for i := 0; i < max; i++ {
if !hasSubquery(filters[i]) {
continue
}
saved := filters[i]
for j := i; j < len(filters)-1; j++ {
filters[j] = filters[j+1]
}
filters[len(filters)-1] = saved
max--
}
} | go | func reorderBySubquery(filters []sqlparser.Expr) {
max := len(filters)
for i := 0; i < max; i++ {
if !hasSubquery(filters[i]) {
continue
}
saved := filters[i]
for j := i; j < len(filters)-1; j++ {
filters[j] = filters[j+1]
}
filters[len(filters)-1] = saved
max--
}
} | [
"func",
"reorderBySubquery",
"(",
"filters",
"[",
"]",
"sqlparser",
".",
"Expr",
")",
"{",
"max",
":=",
"len",
"(",
"filters",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"max",
";",
"i",
"++",
"{",
"if",
"!",
"hasSubquery",
"(",
"filters",
... | // reorderBySubquery reorders the filters by pushing subqueries
// to the end. This allows the non-subquery filters to be
// pushed first because they can potentially improve the routing
// plan, which can later allow a filter containing a subquery
// to successfully merge with the corresponding route. | [
"reorderBySubquery",
"reorders",
"the",
"filters",
"by",
"pushing",
"subqueries",
"to",
"the",
"end",
".",
"This",
"allows",
"the",
"non",
"-",
"subquery",
"filters",
"to",
"be",
"pushed",
"first",
"because",
"they",
"can",
"potentially",
"improve",
"the",
"ro... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/select.go#L151-L164 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/select.go | addPullouts | func (pb *primitiveBuilder) addPullouts(pullouts []*pulloutSubquery) {
for _, pullout := range pullouts {
pullout.setUnderlying(pb.bldr)
pb.bldr = pullout
}
} | go | func (pb *primitiveBuilder) addPullouts(pullouts []*pulloutSubquery) {
for _, pullout := range pullouts {
pullout.setUnderlying(pb.bldr)
pb.bldr = pullout
}
} | [
"func",
"(",
"pb",
"*",
"primitiveBuilder",
")",
"addPullouts",
"(",
"pullouts",
"[",
"]",
"*",
"pulloutSubquery",
")",
"{",
"for",
"_",
",",
"pullout",
":=",
"range",
"pullouts",
"{",
"pullout",
".",
"setUnderlying",
"(",
"pb",
".",
"bldr",
")",
"\n",
... | // addPullouts adds the pullout subqueries to the primitiveBuilder. | [
"addPullouts",
"adds",
"the",
"pullout",
"subqueries",
"to",
"the",
"primitiveBuilder",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/select.go#L167-L172 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/select.go | pushSelectExprs | func (pb *primitiveBuilder) pushSelectExprs(sel *sqlparser.Select, grouper groupByHandler) error {
resultColumns, err := pb.pushSelectRoutes(sel.SelectExprs)
if err != nil {
return err
}
pb.st.SetResultColumns(resultColumns)
return pb.pushGroupBy(sel, grouper)
} | go | func (pb *primitiveBuilder) pushSelectExprs(sel *sqlparser.Select, grouper groupByHandler) error {
resultColumns, err := pb.pushSelectRoutes(sel.SelectExprs)
if err != nil {
return err
}
pb.st.SetResultColumns(resultColumns)
return pb.pushGroupBy(sel, grouper)
} | [
"func",
"(",
"pb",
"*",
"primitiveBuilder",
")",
"pushSelectExprs",
"(",
"sel",
"*",
"sqlparser",
".",
"Select",
",",
"grouper",
"groupByHandler",
")",
"error",
"{",
"resultColumns",
",",
"err",
":=",
"pb",
".",
"pushSelectRoutes",
"(",
"sel",
".",
"SelectEx... | // pushSelectExprs identifies the target route for the
// select expressions and pushes them down. | [
"pushSelectExprs",
"identifies",
"the",
"target",
"route",
"for",
"the",
"select",
"expressions",
"and",
"pushes",
"them",
"down",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/select.go#L176-L183 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/select.go | pushSelectRoutes | func (pb *primitiveBuilder) pushSelectRoutes(selectExprs sqlparser.SelectExprs) ([]*resultColumn, error) {
resultColumns := make([]*resultColumn, 0, len(selectExprs))
for _, node := range selectExprs {
switch node := node.(type) {
case *sqlparser.AliasedExpr:
pullouts, origin, expr, err := pb.findOrigin(node.E... | go | func (pb *primitiveBuilder) pushSelectRoutes(selectExprs sqlparser.SelectExprs) ([]*resultColumn, error) {
resultColumns := make([]*resultColumn, 0, len(selectExprs))
for _, node := range selectExprs {
switch node := node.(type) {
case *sqlparser.AliasedExpr:
pullouts, origin, expr, err := pb.findOrigin(node.E... | [
"func",
"(",
"pb",
"*",
"primitiveBuilder",
")",
"pushSelectRoutes",
"(",
"selectExprs",
"sqlparser",
".",
"SelectExprs",
")",
"(",
"[",
"]",
"*",
"resultColumn",
",",
"error",
")",
"{",
"resultColumns",
":=",
"make",
"(",
"[",
"]",
"*",
"resultColumn",
",... | // pusheSelectRoutes is a convenience function that pushes all the select
// expressions and returns the list of resultColumns generated for it. | [
"pusheSelectRoutes",
"is",
"a",
"convenience",
"function",
"that",
"pushes",
"all",
"the",
"select",
"expressions",
"and",
"returns",
"the",
"list",
"of",
"resultColumns",
"generated",
"for",
"it",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/select.go#L187-L243 | train |
vitessio/vitess | go/mysql/client.go | Ping | func (c *Conn) Ping() error {
// This is a new command, need to reset the sequence.
c.sequence = 0
if err := c.writePacket([]byte{ComPing}); err != nil {
return NewSQLError(CRServerGone, SSUnknownSQLState, "%v", err)
}
data, err := c.readEphemeralPacket()
if err != nil {
return NewSQLError(CRServerLost, SSUn... | go | func (c *Conn) Ping() error {
// This is a new command, need to reset the sequence.
c.sequence = 0
if err := c.writePacket([]byte{ComPing}); err != nil {
return NewSQLError(CRServerGone, SSUnknownSQLState, "%v", err)
}
data, err := c.readEphemeralPacket()
if err != nil {
return NewSQLError(CRServerLost, SSUn... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Ping",
"(",
")",
"error",
"{",
"// This is a new command, need to reset the sequence.",
"c",
".",
"sequence",
"=",
"0",
"\n\n",
"if",
"err",
":=",
"c",
".",
"writePacket",
"(",
"[",
"]",
"byte",
"{",
"ComPing",
"}",
"... | // Ping implements mysql ping command. | [
"Ping",
"implements",
"mysql",
"ping",
"command",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/client.go#L172-L191 | train |
vitessio/vitess | go/mysql/client.go | writeSSLRequest | func (c *Conn) writeSSLRequest(capabilities uint32, characterSet uint8, params *ConnParams) error {
// Build our flags, with CapabilityClientSSL.
var flags uint32 = CapabilityClientLongPassword |
CapabilityClientLongFlag |
CapabilityClientProtocol41 |
CapabilityClientTransactions |
CapabilityClientSecureConne... | go | func (c *Conn) writeSSLRequest(capabilities uint32, characterSet uint8, params *ConnParams) error {
// Build our flags, with CapabilityClientSSL.
var flags uint32 = CapabilityClientLongPassword |
CapabilityClientLongFlag |
CapabilityClientProtocol41 |
CapabilityClientTransactions |
CapabilityClientSecureConne... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"writeSSLRequest",
"(",
"capabilities",
"uint32",
",",
"characterSet",
"uint8",
",",
"params",
"*",
"ConnParams",
")",
"error",
"{",
"// Build our flags, with CapabilityClientSSL.",
"var",
"flags",
"uint32",
"=",
"CapabilityClient... | // writeSSLRequest writes the SSLRequest packet. It's just a truncated
// HandshakeResponse41. | [
"writeSSLRequest",
"writes",
"the",
"SSLRequest",
"packet",
".",
"It",
"s",
"just",
"a",
"truncated",
"HandshakeResponse41",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/client.go#L495-L541 | train |
vitessio/vitess | go/mysql/client.go | writeHandshakeResponse41 | func (c *Conn) writeHandshakeResponse41(capabilities uint32, scrambledPassword []byte, characterSet uint8, params *ConnParams) error {
// Build our flags.
var flags uint32 = CapabilityClientLongPassword |
CapabilityClientLongFlag |
CapabilityClientProtocol41 |
CapabilityClientTransactions |
CapabilityClientSe... | go | func (c *Conn) writeHandshakeResponse41(capabilities uint32, scrambledPassword []byte, characterSet uint8, params *ConnParams) error {
// Build our flags.
var flags uint32 = CapabilityClientLongPassword |
CapabilityClientLongFlag |
CapabilityClientProtocol41 |
CapabilityClientTransactions |
CapabilityClientSe... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"writeHandshakeResponse41",
"(",
"capabilities",
"uint32",
",",
"scrambledPassword",
"[",
"]",
"byte",
",",
"characterSet",
"uint8",
",",
"params",
"*",
"ConnParams",
")",
"error",
"{",
"// Build our flags.",
"var",
"flags",
... | // writeHandshakeResponse41 writes the handshake response.
// Returns a SQLError. | [
"writeHandshakeResponse41",
"writes",
"the",
"handshake",
"response",
".",
"Returns",
"a",
"SQLError",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/client.go#L545-L633 | train |
vitessio/vitess | go/mysql/client.go | writeClearTextPassword | func (c *Conn) writeClearTextPassword(params *ConnParams) error {
length := len(params.Pass) + 1
data := c.startEphemeralPacket(length)
pos := 0
pos = writeNullString(data, pos, params.Pass)
// Sanity check.
if pos != len(data) {
return vterrors.Errorf(vtrpc.Code_INTERNAL, "error building ClearTextPassword pack... | go | func (c *Conn) writeClearTextPassword(params *ConnParams) error {
length := len(params.Pass) + 1
data := c.startEphemeralPacket(length)
pos := 0
pos = writeNullString(data, pos, params.Pass)
// Sanity check.
if pos != len(data) {
return vterrors.Errorf(vtrpc.Code_INTERNAL, "error building ClearTextPassword pack... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"writeClearTextPassword",
"(",
"params",
"*",
"ConnParams",
")",
"error",
"{",
"length",
":=",
"len",
"(",
"params",
".",
"Pass",
")",
"+",
"1",
"\n",
"data",
":=",
"c",
".",
"startEphemeralPacket",
"(",
"length",
")... | // writeClearTextPassword writes the clear text password.
// Returns a SQLError. | [
"writeClearTextPassword",
"writes",
"the",
"clear",
"text",
"password",
".",
"Returns",
"a",
"SQLError",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/client.go#L647-L657 | train |
vitessio/vitess | go/vt/callinfo/plugin_grpc.go | GRPCCallInfo | func GRPCCallInfo(ctx context.Context) context.Context {
method, ok := grpc.Method(ctx)
if !ok {
return ctx
}
callinfo := &gRPCCallInfoImpl{
method: method,
}
peer, ok := peer.FromContext(ctx)
if ok {
callinfo.remoteAddr = peer.Addr.String()
}
return NewContext(ctx, callinfo)
} | go | func GRPCCallInfo(ctx context.Context) context.Context {
method, ok := grpc.Method(ctx)
if !ok {
return ctx
}
callinfo := &gRPCCallInfoImpl{
method: method,
}
peer, ok := peer.FromContext(ctx)
if ok {
callinfo.remoteAddr = peer.Addr.String()
}
return NewContext(ctx, callinfo)
} | [
"func",
"GRPCCallInfo",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"method",
",",
"ok",
":=",
"grpc",
".",
"Method",
"(",
"ctx",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"ctx",
"\n",
"}",
"\n\n",
"callinfo",
":=",
... | // GRPCCallInfo returns an augmented context with a CallInfo structure,
// only for gRPC contexts. | [
"GRPCCallInfo",
"returns",
"an",
"augmented",
"context",
"with",
"a",
"CallInfo",
"structure",
"only",
"for",
"gRPC",
"contexts",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/callinfo/plugin_grpc.go#L32-L47 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlclient/client.go | Start | func (c *client) Start(ctx context.Context, mysqldArgs ...string) error {
return c.withRetry(ctx, func() error {
_, err := c.c.Start(ctx, &mysqlctlpb.StartRequest{
MysqldArgs: mysqldArgs,
})
return err
})
} | go | func (c *client) Start(ctx context.Context, mysqldArgs ...string) error {
return c.withRetry(ctx, func() error {
_, err := c.c.Start(ctx, &mysqlctlpb.StartRequest{
MysqldArgs: mysqldArgs,
})
return err
})
} | [
"func",
"(",
"c",
"*",
"client",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
",",
"mysqldArgs",
"...",
"string",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
... | // Start is part of the MysqlctlClient interface. | [
"Start",
"is",
"part",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlclient/client.go#L60-L67 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlclient/client.go | Shutdown | func (c *client) Shutdown(ctx context.Context, waitForMysqld bool) error {
return c.withRetry(ctx, func() error {
_, err := c.c.Shutdown(ctx, &mysqlctlpb.ShutdownRequest{
WaitForMysqld: waitForMysqld,
})
return err
})
} | go | func (c *client) Shutdown(ctx context.Context, waitForMysqld bool) error {
return c.withRetry(ctx, func() error {
_, err := c.c.Shutdown(ctx, &mysqlctlpb.ShutdownRequest{
WaitForMysqld: waitForMysqld,
})
return err
})
} | [
"func",
"(",
"c",
"*",
"client",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
",",
"waitForMysqld",
"bool",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
... | // Shutdown is part of the MysqlctlClient interface. | [
"Shutdown",
"is",
"part",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlclient/client.go#L70-L77 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlclient/client.go | RunMysqlUpgrade | func (c *client) RunMysqlUpgrade(ctx context.Context) error {
return c.withRetry(ctx, func() error {
_, err := c.c.RunMysqlUpgrade(ctx, &mysqlctlpb.RunMysqlUpgradeRequest{})
return err
})
} | go | func (c *client) RunMysqlUpgrade(ctx context.Context) error {
return c.withRetry(ctx, func() error {
_, err := c.c.RunMysqlUpgrade(ctx, &mysqlctlpb.RunMysqlUpgradeRequest{})
return err
})
} | [
"func",
"(",
"c",
"*",
"client",
")",
"RunMysqlUpgrade",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"c",
".",
"RunMy... | // RunMysqlUpgrade is part of the MysqlctlClient interface. | [
"RunMysqlUpgrade",
"is",
"part",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlclient/client.go#L80-L85 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlclient/client.go | ReinitConfig | func (c *client) ReinitConfig(ctx context.Context) error {
return c.withRetry(ctx, func() error {
_, err := c.c.ReinitConfig(ctx, &mysqlctlpb.ReinitConfigRequest{})
return err
})
} | go | func (c *client) ReinitConfig(ctx context.Context) error {
return c.withRetry(ctx, func() error {
_, err := c.c.ReinitConfig(ctx, &mysqlctlpb.ReinitConfigRequest{})
return err
})
} | [
"func",
"(",
"c",
"*",
"client",
")",
"ReinitConfig",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"c",
".",
"ReinitCo... | // ReinitConfig is part of the MysqlctlClient interface. | [
"ReinitConfig",
"is",
"part",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlclient/client.go#L88-L93 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlclient/client.go | RefreshConfig | func (c *client) RefreshConfig(ctx context.Context) error {
return c.withRetry(ctx, func() error {
_, err := c.c.RefreshConfig(ctx, &mysqlctlpb.RefreshConfigRequest{})
return err
})
} | go | func (c *client) RefreshConfig(ctx context.Context) error {
return c.withRetry(ctx, func() error {
_, err := c.c.RefreshConfig(ctx, &mysqlctlpb.RefreshConfigRequest{})
return err
})
} | [
"func",
"(",
"c",
"*",
"client",
")",
"RefreshConfig",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"c",
".",
"withRetry",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"c",
".",
"Refresh... | // RefreshConfig is part of the MysqlctlClient interface. | [
"RefreshConfig",
"is",
"part",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlclient/client.go#L96-L101 | train |
vitessio/vitess | go/vt/topo/helpers/compare.go | CompareKeyspaces | func CompareKeyspaces(ctx context.Context, fromTS, toTS *topo.Server) error {
keyspaces, err := fromTS.GetKeyspaces(ctx)
if err != nil {
return vterrors.Wrapf(err, "GetKeyspace(%v)", keyspaces)
}
for _, keyspace := range keyspaces {
fromKs, err := fromTS.GetKeyspace(ctx, keyspace)
if err != nil {
return ... | go | func CompareKeyspaces(ctx context.Context, fromTS, toTS *topo.Server) error {
keyspaces, err := fromTS.GetKeyspaces(ctx)
if err != nil {
return vterrors.Wrapf(err, "GetKeyspace(%v)", keyspaces)
}
for _, keyspace := range keyspaces {
fromKs, err := fromTS.GetKeyspace(ctx, keyspace)
if err != nil {
return ... | [
"func",
"CompareKeyspaces",
"(",
"ctx",
"context",
".",
"Context",
",",
"fromTS",
",",
"toTS",
"*",
"topo",
".",
"Server",
")",
"error",
"{",
"keyspaces",
",",
"err",
":=",
"fromTS",
".",
"GetKeyspaces",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // CompareKeyspaces will compare the keyspaces in the destination topo. | [
"CompareKeyspaces",
"will",
"compare",
"the",
"keyspaces",
"in",
"the",
"destination",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/compare.go#L32-L79 | train |
vitessio/vitess | go/vt/topo/helpers/compare.go | CompareShards | func CompareShards(ctx context.Context, fromTS, toTS *topo.Server) error {
keyspaces, err := fromTS.GetKeyspaces(ctx)
if err != nil {
return vterrors.Wrapf(err, "fromTS.GetKeyspaces")
}
for _, keyspace := range keyspaces {
shards, err := fromTS.GetShardNames(ctx, keyspace)
if err != nil {
return vterrors.... | go | func CompareShards(ctx context.Context, fromTS, toTS *topo.Server) error {
keyspaces, err := fromTS.GetKeyspaces(ctx)
if err != nil {
return vterrors.Wrapf(err, "fromTS.GetKeyspaces")
}
for _, keyspace := range keyspaces {
shards, err := fromTS.GetShardNames(ctx, keyspace)
if err != nil {
return vterrors.... | [
"func",
"CompareShards",
"(",
"ctx",
"context",
".",
"Context",
",",
"fromTS",
",",
"toTS",
"*",
"topo",
".",
"Server",
")",
"error",
"{",
"keyspaces",
",",
"err",
":=",
"fromTS",
".",
"GetKeyspaces",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // CompareShards will compare the shards in the destination topo. | [
"CompareShards",
"will",
"compare",
"the",
"shards",
"in",
"the",
"destination",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/compare.go#L82-L110 | train |
vitessio/vitess | go/vt/topo/helpers/compare.go | CompareTablets | func CompareTablets(ctx context.Context, fromTS, toTS *topo.Server) error {
cells, err := fromTS.GetKnownCells(ctx)
if err != nil {
return vterrors.Wrapf(err, "fromTS.GetKnownCells")
}
for _, cell := range cells {
tabletAliases, err := fromTS.GetTabletsByCell(ctx, cell)
if err != nil {
return vterrors.Wra... | go | func CompareTablets(ctx context.Context, fromTS, toTS *topo.Server) error {
cells, err := fromTS.GetKnownCells(ctx)
if err != nil {
return vterrors.Wrapf(err, "fromTS.GetKnownCells")
}
for _, cell := range cells {
tabletAliases, err := fromTS.GetTabletsByCell(ctx, cell)
if err != nil {
return vterrors.Wra... | [
"func",
"CompareTablets",
"(",
"ctx",
"context",
".",
"Context",
",",
"fromTS",
",",
"toTS",
"*",
"topo",
".",
"Server",
")",
"error",
"{",
"cells",
",",
"err",
":=",
"fromTS",
".",
"GetKnownCells",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // CompareTablets will compare the tablets in the destination topo. | [
"CompareTablets",
"will",
"compare",
"the",
"tablets",
"in",
"the",
"destination",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/compare.go#L113-L141 | train |
vitessio/vitess | go/vt/topo/helpers/compare.go | CompareShardReplications | func CompareShardReplications(ctx context.Context, fromTS, toTS *topo.Server) error {
keyspaces, err := fromTS.GetKeyspaces(ctx)
if err != nil {
return vterrors.Wrapf(err, "fromTS.GetKeyspaces")
}
cells, err := fromTS.GetCellInfoNames(ctx)
if err != nil {
return vterrors.Wrap(err, "GetCellInfoNames()")
}
fo... | go | func CompareShardReplications(ctx context.Context, fromTS, toTS *topo.Server) error {
keyspaces, err := fromTS.GetKeyspaces(ctx)
if err != nil {
return vterrors.Wrapf(err, "fromTS.GetKeyspaces")
}
cells, err := fromTS.GetCellInfoNames(ctx)
if err != nil {
return vterrors.Wrap(err, "GetCellInfoNames()")
}
fo... | [
"func",
"CompareShardReplications",
"(",
"ctx",
"context",
".",
"Context",
",",
"fromTS",
",",
"toTS",
"*",
"topo",
".",
"Server",
")",
"error",
"{",
"keyspaces",
",",
"err",
":=",
"fromTS",
".",
"GetKeyspaces",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
... | // CompareShardReplications will compare the ShardReplication objects in
// the destination topo. | [
"CompareShardReplications",
"will",
"compare",
"the",
"ShardReplication",
"objects",
"in",
"the",
"destination",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/compare.go#L145-L182 | train |
vitessio/vitess | go/vt/topo/helpers/compare.go | CompareRoutingRules | func CompareRoutingRules(ctx context.Context, fromTS, toTS *topo.Server) error {
rrFrom, err := fromTS.GetRoutingRules(ctx)
if err != nil {
return vterrors.Wrapf(err, "GetKeyspace(from)")
}
rrTo, err := toTS.GetRoutingRules(ctx)
if err != nil {
return vterrors.Wrapf(err, "GetKeyspace(to)")
}
if !proto.Equal(... | go | func CompareRoutingRules(ctx context.Context, fromTS, toTS *topo.Server) error {
rrFrom, err := fromTS.GetRoutingRules(ctx)
if err != nil {
return vterrors.Wrapf(err, "GetKeyspace(from)")
}
rrTo, err := toTS.GetRoutingRules(ctx)
if err != nil {
return vterrors.Wrapf(err, "GetKeyspace(to)")
}
if !proto.Equal(... | [
"func",
"CompareRoutingRules",
"(",
"ctx",
"context",
".",
"Context",
",",
"fromTS",
",",
"toTS",
"*",
"topo",
".",
"Server",
")",
"error",
"{",
"rrFrom",
",",
"err",
":=",
"fromTS",
".",
"GetRoutingRules",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"ni... | // CompareRoutingRules will compare the routing rules in the destination topo. | [
"CompareRoutingRules",
"will",
"compare",
"the",
"routing",
"rules",
"in",
"the",
"destination",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/compare.go#L185-L198 | train |
vitessio/vitess | go/vt/vtctl/grpcvtctlserver/server.go | ExecuteVtctlCommand | func (s *VtctlServer) ExecuteVtctlCommand(args *vtctldatapb.ExecuteVtctlCommandRequest, stream vtctlservicepb.Vtctl_ExecuteVtctlCommandServer) (err error) {
defer servenv.HandlePanic("vtctl", &err)
// Create a logger, send the result back to the caller.
// We may execute this in parallel (inside multiple go routine... | go | func (s *VtctlServer) ExecuteVtctlCommand(args *vtctldatapb.ExecuteVtctlCommandRequest, stream vtctlservicepb.Vtctl_ExecuteVtctlCommandServer) (err error) {
defer servenv.HandlePanic("vtctl", &err)
// Create a logger, send the result back to the caller.
// We may execute this in parallel (inside multiple go routine... | [
"func",
"(",
"s",
"*",
"VtctlServer",
")",
"ExecuteVtctlCommand",
"(",
"args",
"*",
"vtctldatapb",
".",
"ExecuteVtctlCommandRequest",
",",
"stream",
"vtctlservicepb",
".",
"Vtctl_ExecuteVtctlCommandServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"servenv",
"... | // ExecuteVtctlCommand is part of the vtctldatapb.VtctlServer interface | [
"ExecuteVtctlCommand",
"is",
"part",
"of",
"the",
"vtctldatapb",
".",
"VtctlServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctl/grpcvtctlserver/server.go#L51-L78 | train |
vitessio/vitess | go/vt/vtctl/grpcvtctlserver/server.go | StartServer | func StartServer(s *grpc.Server, ts *topo.Server) {
vtctlservicepb.RegisterVtctlServer(s, NewVtctlServer(ts))
} | go | func StartServer(s *grpc.Server, ts *topo.Server) {
vtctlservicepb.RegisterVtctlServer(s, NewVtctlServer(ts))
} | [
"func",
"StartServer",
"(",
"s",
"*",
"grpc",
".",
"Server",
",",
"ts",
"*",
"topo",
".",
"Server",
")",
"{",
"vtctlservicepb",
".",
"RegisterVtctlServer",
"(",
"s",
",",
"NewVtctlServer",
"(",
"ts",
")",
")",
"\n",
"}"
] | // StartServer registers the VtctlServer for RPCs | [
"StartServer",
"registers",
"the",
"VtctlServer",
"for",
"RPCs"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctl/grpcvtctlserver/server.go#L81-L83 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/querylogz.go | querylogzHandler | func querylogzHandler(ch chan interface{}, w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {
acl.SendError(w, err)
return
}
timeout, limit := parseTimeoutLimitParams(r)
logz.StartHTMLTable(w)
defer logz.EndHTMLTable(w)
w.Write(querylogzHeader)
tmr := tim... | go | func querylogzHandler(ch chan interface{}, w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {
acl.SendError(w, err)
return
}
timeout, limit := parseTimeoutLimitParams(r)
logz.StartHTMLTable(w)
defer logz.EndHTMLTable(w)
w.Write(querylogzHeader)
tmr := tim... | [
"func",
"querylogzHandler",
"(",
"ch",
"chan",
"interface",
"{",
"}",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"err",
":=",
"acl",
".",
"CheckAccessHTTP",
"(",
"r",
",",
"acl",
".",
"DEBUGGING",
... | // querylogzHandler serves a human readable snapshot of the
// current query log. | [
"querylogzHandler",
"serves",
"a",
"human",
"readable",
"snapshot",
"of",
"the",
"current",
"query",
"log",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/querylogz.go#L98-L146 | train |
vitessio/vitess | go/vt/mysqlctl/backupengine.go | GetBackupEngine | func GetBackupEngine() (BackupEngine, error) {
be, ok := BackupEngineMap[*backupEngineImplementation]
if !ok {
return nil, vterrors.New(vtrpc.Code_NOT_FOUND, "no registered implementation of BackupEngine")
}
return be, nil
} | go | func GetBackupEngine() (BackupEngine, error) {
be, ok := BackupEngineMap[*backupEngineImplementation]
if !ok {
return nil, vterrors.New(vtrpc.Code_NOT_FOUND, "no registered implementation of BackupEngine")
}
return be, nil
} | [
"func",
"GetBackupEngine",
"(",
")",
"(",
"BackupEngine",
",",
"error",
")",
"{",
"be",
",",
"ok",
":=",
"BackupEngineMap",
"[",
"*",
"backupEngineImplementation",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"vterrors",
".",
"New",
"(",
"vtrpc... | // GetBackupEngine returns the current BackupEngine implementation.
// Should be called after flags have been initialized. | [
"GetBackupEngine",
"returns",
"the",
"current",
"BackupEngine",
"implementation",
".",
"Should",
"be",
"called",
"after",
"flags",
"have",
"been",
"initialized",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/backupengine.go#L46-L52 | train |
vitessio/vitess | go/mysql/slave_status.go | SlaveStatusToProto | func SlaveStatusToProto(s SlaveStatus) *replicationdatapb.Status {
return &replicationdatapb.Status{
Position: EncodePosition(s.Position),
SlaveIoRunning: s.SlaveIORunning,
SlaveSqlRunning: s.SlaveSQLRunning,
SecondsBehindMaster: uint32(s.SecondsBehindMaster),
MasterHost: s.Maste... | go | func SlaveStatusToProto(s SlaveStatus) *replicationdatapb.Status {
return &replicationdatapb.Status{
Position: EncodePosition(s.Position),
SlaveIoRunning: s.SlaveIORunning,
SlaveSqlRunning: s.SlaveSQLRunning,
SecondsBehindMaster: uint32(s.SecondsBehindMaster),
MasterHost: s.Maste... | [
"func",
"SlaveStatusToProto",
"(",
"s",
"SlaveStatus",
")",
"*",
"replicationdatapb",
".",
"Status",
"{",
"return",
"&",
"replicationdatapb",
".",
"Status",
"{",
"Position",
":",
"EncodePosition",
"(",
"s",
".",
"Position",
")",
",",
"SlaveIoRunning",
":",
"s"... | // SlaveStatusToProto translates a Status to proto3. | [
"SlaveStatusToProto",
"translates",
"a",
"Status",
"to",
"proto3",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/slave_status.go#L42-L52 | train |
vitessio/vitess | go/mysql/slave_status.go | ProtoToSlaveStatus | func ProtoToSlaveStatus(s *replicationdatapb.Status) SlaveStatus {
pos, err := DecodePosition(s.Position)
if err != nil {
panic(vterrors.Wrapf(err, "cannot decode Position"))
}
return SlaveStatus{
Position: pos,
SlaveIORunning: s.SlaveIoRunning,
SlaveSQLRunning: s.SlaveSqlRunning,
Seco... | go | func ProtoToSlaveStatus(s *replicationdatapb.Status) SlaveStatus {
pos, err := DecodePosition(s.Position)
if err != nil {
panic(vterrors.Wrapf(err, "cannot decode Position"))
}
return SlaveStatus{
Position: pos,
SlaveIORunning: s.SlaveIoRunning,
SlaveSQLRunning: s.SlaveSqlRunning,
Seco... | [
"func",
"ProtoToSlaveStatus",
"(",
"s",
"*",
"replicationdatapb",
".",
"Status",
")",
"SlaveStatus",
"{",
"pos",
",",
"err",
":=",
"DecodePosition",
"(",
"s",
".",
"Position",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"vterrors",
".",
"Wrap... | // ProtoToSlaveStatus translates a proto Status, or panics. | [
"ProtoToSlaveStatus",
"translates",
"a",
"proto",
"Status",
"or",
"panics",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/slave_status.go#L55-L69 | train |
vitessio/vitess | go/vt/topotools/split.go | ContainsShard | func (os *OverlappingShards) ContainsShard(shardName string) bool {
for _, l := range os.Left {
if l.ShardName() == shardName {
return true
}
}
for _, r := range os.Right {
if r.ShardName() == shardName {
return true
}
}
return false
} | go | func (os *OverlappingShards) ContainsShard(shardName string) bool {
for _, l := range os.Left {
if l.ShardName() == shardName {
return true
}
}
for _, r := range os.Right {
if r.ShardName() == shardName {
return true
}
}
return false
} | [
"func",
"(",
"os",
"*",
"OverlappingShards",
")",
"ContainsShard",
"(",
"shardName",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"l",
":=",
"range",
"os",
".",
"Left",
"{",
"if",
"l",
".",
"ShardName",
"(",
")",
"==",
"shardName",
"{",
"return",
"tr... | // ContainsShard returns true if either Left or Right lists contain
// the provided Shard. | [
"ContainsShard",
"returns",
"true",
"if",
"either",
"Left",
"or",
"Right",
"lists",
"contain",
"the",
"provided",
"Shard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/split.go#L37-L49 | train |
vitessio/vitess | go/vt/topotools/split.go | OverlappingShardsForShard | func OverlappingShardsForShard(os []*OverlappingShards, shardName string) *OverlappingShards {
for _, o := range os {
if o.ContainsShard(shardName) {
return o
}
}
return nil
} | go | func OverlappingShardsForShard(os []*OverlappingShards, shardName string) *OverlappingShards {
for _, o := range os {
if o.ContainsShard(shardName) {
return o
}
}
return nil
} | [
"func",
"OverlappingShardsForShard",
"(",
"os",
"[",
"]",
"*",
"OverlappingShards",
",",
"shardName",
"string",
")",
"*",
"OverlappingShards",
"{",
"for",
"_",
",",
"o",
":=",
"range",
"os",
"{",
"if",
"o",
".",
"ContainsShard",
"(",
"shardName",
")",
"{",... | // OverlappingShardsForShard returns the OverlappingShards object
// from the list that has he provided shard, or nil | [
"OverlappingShardsForShard",
"returns",
"the",
"OverlappingShards",
"object",
"from",
"the",
"list",
"that",
"has",
"he",
"provided",
"shard",
"or",
"nil"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/split.go#L53-L60 | train |
vitessio/vitess | go/vt/topotools/split.go | findOverlappingShards | func findOverlappingShards(shardMap map[string]*topo.ShardInfo) ([]*OverlappingShards, error) {
var result []*OverlappingShards
for len(shardMap) > 0 {
var left []*topo.ShardInfo
var right []*topo.ShardInfo
// get the first value from the map, seed our left array with it
var name string
var si *topo.Shar... | go | func findOverlappingShards(shardMap map[string]*topo.ShardInfo) ([]*OverlappingShards, error) {
var result []*OverlappingShards
for len(shardMap) > 0 {
var left []*topo.ShardInfo
var right []*topo.ShardInfo
// get the first value from the map, seed our left array with it
var name string
var si *topo.Shar... | [
"func",
"findOverlappingShards",
"(",
"shardMap",
"map",
"[",
"string",
"]",
"*",
"topo",
".",
"ShardInfo",
")",
"(",
"[",
"]",
"*",
"OverlappingShards",
",",
"error",
")",
"{",
"var",
"result",
"[",
"]",
"*",
"OverlappingShards",
"\n\n",
"for",
"len",
"... | // findOverlappingShards does the work for FindOverlappingShards but
// can be called on test data too. | [
"findOverlappingShards",
"does",
"the",
"work",
"for",
"FindOverlappingShards",
"but",
"can",
"be",
"called",
"on",
"test",
"data",
"too",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/split.go#L79-L164 | train |
vitessio/vitess | go/vt/topotools/split.go | findIntersectingShard | func findIntersectingShard(shardMap map[string]*topo.ShardInfo, sourceArray []*topo.ShardInfo) *topo.ShardInfo {
for name, si := range shardMap {
for _, sourceShardInfo := range sourceArray {
if si.KeyRange == nil || sourceShardInfo.KeyRange == nil || key.KeyRangesIntersect(si.KeyRange, sourceShardInfo.KeyRange) ... | go | func findIntersectingShard(shardMap map[string]*topo.ShardInfo, sourceArray []*topo.ShardInfo) *topo.ShardInfo {
for name, si := range shardMap {
for _, sourceShardInfo := range sourceArray {
if si.KeyRange == nil || sourceShardInfo.KeyRange == nil || key.KeyRangesIntersect(si.KeyRange, sourceShardInfo.KeyRange) ... | [
"func",
"findIntersectingShard",
"(",
"shardMap",
"map",
"[",
"string",
"]",
"*",
"topo",
".",
"ShardInfo",
",",
"sourceArray",
"[",
"]",
"*",
"topo",
".",
"ShardInfo",
")",
"*",
"topo",
".",
"ShardInfo",
"{",
"for",
"name",
",",
"si",
":=",
"range",
"... | // findIntersectingShard will go through the map and take the first
// entry in there that intersect with the source array, remove it from
// the map, and return it | [
"findIntersectingShard",
"will",
"go",
"through",
"the",
"map",
"and",
"take",
"the",
"first",
"entry",
"in",
"there",
"that",
"intersect",
"with",
"the",
"source",
"array",
"remove",
"it",
"from",
"the",
"map",
"and",
"return",
"it"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/split.go#L169-L179 | train |
vitessio/vitess | go/vt/topotools/split.go | intersect | func intersect(si *topo.ShardInfo, allShards []*topo.ShardInfo) bool {
for _, shard := range allShards {
if key.KeyRangesIntersect(si.KeyRange, shard.KeyRange) {
return true
}
}
return false
} | go | func intersect(si *topo.ShardInfo, allShards []*topo.ShardInfo) bool {
for _, shard := range allShards {
if key.KeyRangesIntersect(si.KeyRange, shard.KeyRange) {
return true
}
}
return false
} | [
"func",
"intersect",
"(",
"si",
"*",
"topo",
".",
"ShardInfo",
",",
"allShards",
"[",
"]",
"*",
"topo",
".",
"ShardInfo",
")",
"bool",
"{",
"for",
"_",
",",
"shard",
":=",
"range",
"allShards",
"{",
"if",
"key",
".",
"KeyRangesIntersect",
"(",
"si",
... | // intersect returns true if the provided shard intersect with any shard
// in the destination array | [
"intersect",
"returns",
"true",
"if",
"the",
"provided",
"shard",
"intersect",
"with",
"any",
"shard",
"in",
"the",
"destination",
"array"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/split.go#L183-L190 | train |
vitessio/vitess | go/vt/automation/scheduler.go | NewScheduler | func NewScheduler() (*Scheduler, error) {
defaultClusterOperations := map[string]bool{
"HorizontalReshardingTask": true,
"VerticalSplitTask": true,
}
s := &Scheduler{
registeredClusterOperations: defaultClusterOperations,
idGenerator: IDGenerator{},
toBeScheduledClusterOperati... | go | func NewScheduler() (*Scheduler, error) {
defaultClusterOperations := map[string]bool{
"HorizontalReshardingTask": true,
"VerticalSplitTask": true,
}
s := &Scheduler{
registeredClusterOperations: defaultClusterOperations,
idGenerator: IDGenerator{},
toBeScheduledClusterOperati... | [
"func",
"NewScheduler",
"(",
")",
"(",
"*",
"Scheduler",
",",
"error",
")",
"{",
"defaultClusterOperations",
":=",
"map",
"[",
"string",
"]",
"bool",
"{",
"\"",
"\"",
":",
"true",
",",
"\"",
"\"",
":",
"true",
",",
"}",
"\n\n",
"s",
":=",
"&",
"Sch... | // NewScheduler creates a new instance. | [
"NewScheduler",
"creates",
"a",
"new",
"instance",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/scheduler.go#L76-L94 | train |
vitessio/vitess | go/vt/automation/scheduler.go | Run | func (s *Scheduler) Run() {
s.mu.Lock()
s.state = stateRunning
s.mu.Unlock()
s.startProcessRequestsLoop()
} | go | func (s *Scheduler) Run() {
s.mu.Lock()
s.state = stateRunning
s.mu.Unlock()
s.startProcessRequestsLoop()
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Run",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"state",
"=",
"stateRunning",
"\n",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"startProcessRequestsLoop",
"(",
... | // Run processes queued cluster operations. | [
"Run",
"processes",
"queued",
"cluster",
"operations",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/scheduler.go#L104-L110 | train |
vitessio/vitess | go/vt/automation/scheduler.go | EnqueueClusterOperation | func (s *Scheduler) EnqueueClusterOperation(ctx context.Context, req *automationpb.EnqueueClusterOperationRequest) (*automationpb.EnqueueClusterOperationResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
if s.state != stateRunning {
return nil, fmt.Errorf("scheduler is not running. State: %v", s.state)
}
if !s... | go | func (s *Scheduler) EnqueueClusterOperation(ctx context.Context, req *automationpb.EnqueueClusterOperationRequest) (*automationpb.EnqueueClusterOperationResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
if s.state != stateRunning {
return nil, fmt.Errorf("scheduler is not running. State: %v", s.state)
}
if !s... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"EnqueueClusterOperation",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"automationpb",
".",
"EnqueueClusterOperationRequest",
")",
"(",
"*",
"automationpb",
".",
"EnqueueClusterOperationResponse",
",",
"error",
... | // EnqueueClusterOperation can be used to start a new cluster operation. | [
"EnqueueClusterOperation",
"can",
"be",
"used",
"to",
"start",
"a",
"new",
"cluster",
"operation",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/scheduler.go#L307-L337 | train |
vitessio/vitess | go/vt/automation/scheduler.go | findClusterOp | func (s *Scheduler) findClusterOp(id string) (ClusterOperationInstance, error) {
var ok bool
var clusterOp ClusterOperationInstance
s.muOpList.Lock()
defer s.muOpList.Unlock()
clusterOp, ok = s.activeClusterOperations[id]
if !ok {
clusterOp, ok = s.finishedClusterOperations[id]
}
if !ok {
return clusterOp,... | go | func (s *Scheduler) findClusterOp(id string) (ClusterOperationInstance, error) {
var ok bool
var clusterOp ClusterOperationInstance
s.muOpList.Lock()
defer s.muOpList.Unlock()
clusterOp, ok = s.activeClusterOperations[id]
if !ok {
clusterOp, ok = s.finishedClusterOperations[id]
}
if !ok {
return clusterOp,... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"findClusterOp",
"(",
"id",
"string",
")",
"(",
"ClusterOperationInstance",
",",
"error",
")",
"{",
"var",
"ok",
"bool",
"\n",
"var",
"clusterOp",
"ClusterOperationInstance",
"\n\n",
"s",
".",
"muOpList",
".",
"Lock",... | // findClusterOp checks for a given ClusterOperation ID if it's in the list of active or finished operations. | [
"findClusterOp",
"checks",
"for",
"a",
"given",
"ClusterOperation",
"ID",
"if",
"it",
"s",
"in",
"the",
"list",
"of",
"active",
"or",
"finished",
"operations",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/scheduler.go#L340-L354 | train |
vitessio/vitess | go/vt/automation/scheduler.go | Checkpoint | func (s *Scheduler) Checkpoint(clusterOp ClusterOperationInstance) {
// TODO(mberlin): Add here support for persistent checkpoints.
s.muOpList.Lock()
defer s.muOpList.Unlock()
s.activeClusterOperations[clusterOp.Id] = clusterOp.Clone()
} | go | func (s *Scheduler) Checkpoint(clusterOp ClusterOperationInstance) {
// TODO(mberlin): Add here support for persistent checkpoints.
s.muOpList.Lock()
defer s.muOpList.Unlock()
s.activeClusterOperations[clusterOp.Id] = clusterOp.Clone()
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Checkpoint",
"(",
"clusterOp",
"ClusterOperationInstance",
")",
"{",
"// TODO(mberlin): Add here support for persistent checkpoints.",
"s",
".",
"muOpList",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"muOpList",
".",
... | // Checkpoint should be called every time the state of the cluster op changes.
// It is used to update the copy of the state in activeClusterOperations. | [
"Checkpoint",
"should",
"be",
"called",
"every",
"time",
"the",
"state",
"of",
"the",
"cluster",
"op",
"changes",
".",
"It",
"is",
"used",
"to",
"update",
"the",
"copy",
"of",
"the",
"state",
"in",
"activeClusterOperations",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/scheduler.go#L358-L363 | train |
vitessio/vitess | go/vt/automation/scheduler.go | GetClusterOperationDetails | func (s *Scheduler) GetClusterOperationDetails(ctx context.Context, req *automationpb.GetClusterOperationDetailsRequest) (*automationpb.GetClusterOperationDetailsResponse, error) {
clusterOp, err := s.findClusterOp(req.Id)
if err != nil {
return nil, err
}
return &automationpb.GetClusterOperationDetailsResponse{
... | go | func (s *Scheduler) GetClusterOperationDetails(ctx context.Context, req *automationpb.GetClusterOperationDetailsRequest) (*automationpb.GetClusterOperationDetailsResponse, error) {
clusterOp, err := s.findClusterOp(req.Id)
if err != nil {
return nil, err
}
return &automationpb.GetClusterOperationDetailsResponse{
... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"GetClusterOperationDetails",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"automationpb",
".",
"GetClusterOperationDetailsRequest",
")",
"(",
"*",
"automationpb",
".",
"GetClusterOperationDetailsResponse",
",",
"e... | // GetClusterOperationDetails can be used to query the full details of active or finished operations. | [
"GetClusterOperationDetails",
"can",
"be",
"used",
"to",
"query",
"the",
"full",
"details",
"of",
"active",
"or",
"finished",
"operations",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/scheduler.go#L366-L374 | train |
vitessio/vitess | go/vt/automation/scheduler.go | ShutdownAndWait | func (s *Scheduler) ShutdownAndWait() {
s.mu.Lock()
if s.state != stateShuttingDown {
s.state = stateShuttingDown
close(s.toBeScheduledClusterOperations)
}
s.mu.Unlock()
log.Infof("Scheduler was shut down. Waiting for pending ClusterOperations to finish.")
s.pendingOpsWg.Wait()
s.mu.Lock()
s.state = state... | go | func (s *Scheduler) ShutdownAndWait() {
s.mu.Lock()
if s.state != stateShuttingDown {
s.state = stateShuttingDown
close(s.toBeScheduledClusterOperations)
}
s.mu.Unlock()
log.Infof("Scheduler was shut down. Waiting for pending ClusterOperations to finish.")
s.pendingOpsWg.Wait()
s.mu.Lock()
s.state = state... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"ShutdownAndWait",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"s",
".",
"state",
"!=",
"stateShuttingDown",
"{",
"s",
".",
"state",
"=",
"stateShuttingDown",
"\n",
"close",
"(",
"s",
"... | // ShutdownAndWait shuts down the scheduler and waits infinitely until all pending cluster operations have finished. | [
"ShutdownAndWait",
"shuts",
"down",
"the",
"scheduler",
"and",
"waits",
"infinitely",
"until",
"all",
"pending",
"cluster",
"operations",
"have",
"finished",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/scheduler.go#L377-L392 | train |
vitessio/vitess | go/vt/topo/memorytopo/memorytopo.go | SetError | func (f *Factory) SetError(err error) {
f.mu.Lock()
defer f.mu.Unlock()
f.err = err
if err != nil {
for _, node := range f.cells {
node.PropagateWatchError(err)
}
}
} | go | func (f *Factory) SetError(err error) {
f.mu.Lock()
defer f.mu.Unlock()
f.err = err
if err != nil {
for _, node := range f.cells {
node.PropagateWatchError(err)
}
}
} | [
"func",
"(",
"f",
"*",
"Factory",
")",
"SetError",
"(",
"err",
"error",
")",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"f",
".",
"err",
"=",
"err",
"\n",
"if",
"err",
"!=",
"... | // SetError forces the given error to be returned from all calls and propagates
// the error to all active watches. | [
"SetError",
"forces",
"the",
"given",
"error",
"to",
"be",
"returned",
"from",
"all",
"calls",
"and",
"propagates",
"the",
"error",
"to",
"all",
"active",
"watches",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/memorytopo.go#L89-L99 | train |
vitessio/vitess | go/vt/topo/memorytopo/memorytopo.go | PropagateWatchError | func (n *node) PropagateWatchError(err error) {
for _, ch := range n.watches {
ch <- &topo.WatchData{
Err: err,
}
}
for _, c := range n.children {
c.PropagateWatchError(err)
}
} | go | func (n *node) PropagateWatchError(err error) {
for _, ch := range n.watches {
ch <- &topo.WatchData{
Err: err,
}
}
for _, c := range n.children {
c.PropagateWatchError(err)
}
} | [
"func",
"(",
"n",
"*",
"node",
")",
"PropagateWatchError",
"(",
"err",
"error",
")",
"{",
"for",
"_",
",",
"ch",
":=",
"range",
"n",
".",
"watches",
"{",
"ch",
"<-",
"&",
"topo",
".",
"WatchData",
"{",
"Err",
":",
"err",
",",
"}",
"\n",
"}",
"\... | // PropagateWatchError propagates the given error to all watches on this node
// and recursively applies to all children | [
"PropagateWatchError",
"propagates",
"the",
"given",
"error",
"to",
"all",
"watches",
"on",
"this",
"node",
"and",
"recursively",
"applies",
"to",
"all",
"children"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/memorytopo.go#L157-L167 | train |
vitessio/vitess | go/vt/topo/memorytopo/memorytopo.go | NewServerAndFactory | func NewServerAndFactory(cells ...string) (*topo.Server, *Factory) {
f := &Factory{
cells: make(map[string]*node),
generation: uint64(rand.Int63n(2 ^ 60)),
}
f.cells[topo.GlobalCell] = f.newDirectory(topo.GlobalCell, nil)
ctx := context.Background()
ts, err := topo.NewWithFactory(f, "" /*serverAddress*/,... | go | func NewServerAndFactory(cells ...string) (*topo.Server, *Factory) {
f := &Factory{
cells: make(map[string]*node),
generation: uint64(rand.Int63n(2 ^ 60)),
}
f.cells[topo.GlobalCell] = f.newDirectory(topo.GlobalCell, nil)
ctx := context.Background()
ts, err := topo.NewWithFactory(f, "" /*serverAddress*/,... | [
"func",
"NewServerAndFactory",
"(",
"cells",
"...",
"string",
")",
"(",
"*",
"topo",
".",
"Server",
",",
"*",
"Factory",
")",
"{",
"f",
":=",
"&",
"Factory",
"{",
"cells",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"node",
")",
",",
"generat... | // NewServerAndFactory returns a new MemoryTopo and the backing factory for all
// the cells. It will create one cell for each parameter passed in. It will log.Exit out
// in case of a problem. | [
"NewServerAndFactory",
"returns",
"a",
"new",
"MemoryTopo",
"and",
"the",
"backing",
"factory",
"for",
"all",
"the",
"cells",
".",
"It",
"will",
"create",
"one",
"cell",
"for",
"each",
"parameter",
"passed",
"in",
".",
"It",
"will",
"log",
".",
"Exit",
"ou... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/memorytopo.go#L172-L191 | train |
vitessio/vitess | go/vt/topo/memorytopo/memorytopo.go | NewServer | func NewServer(cells ...string) *topo.Server {
server, _ := NewServerAndFactory(cells...)
return server
} | go | func NewServer(cells ...string) *topo.Server {
server, _ := NewServerAndFactory(cells...)
return server
} | [
"func",
"NewServer",
"(",
"cells",
"...",
"string",
")",
"*",
"topo",
".",
"Server",
"{",
"server",
",",
"_",
":=",
"NewServerAndFactory",
"(",
"cells",
"...",
")",
"\n",
"return",
"server",
"\n",
"}"
] | // NewServer returns the new server | [
"NewServer",
"returns",
"the",
"new",
"server"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/memorytopo.go#L194-L197 | train |
vitessio/vitess | go/vt/topo/memorytopo/memorytopo.go | recursiveDelete | func (f *Factory) recursiveDelete(n *node) {
parent := n.parent
if parent == nil {
return
}
delete(parent.children, n.name)
if len(parent.children) == 0 {
f.recursiveDelete(parent)
}
} | go | func (f *Factory) recursiveDelete(n *node) {
parent := n.parent
if parent == nil {
return
}
delete(parent.children, n.name)
if len(parent.children) == 0 {
f.recursiveDelete(parent)
}
} | [
"func",
"(",
"f",
"*",
"Factory",
")",
"recursiveDelete",
"(",
"n",
"*",
"node",
")",
"{",
"parent",
":=",
"n",
".",
"parent",
"\n",
"if",
"parent",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"delete",
"(",
"parent",
".",
"children",
",",
"n",
... | // recursiveDelete deletes a node and its parent directory if empty. | [
"recursiveDelete",
"deletes",
"a",
"node",
"and",
"its",
"parent",
"directory",
"if",
"empty",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/memorytopo.go#L277-L286 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlserver/server.go | Start | func (s *server) Start(ctx context.Context, request *mysqlctlpb.StartRequest) (*mysqlctlpb.StartResponse, error) {
return &mysqlctlpb.StartResponse{}, s.mysqld.Start(ctx, s.cnf, request.MysqldArgs...)
} | go | func (s *server) Start(ctx context.Context, request *mysqlctlpb.StartRequest) (*mysqlctlpb.StartResponse, error) {
return &mysqlctlpb.StartResponse{}, s.mysqld.Start(ctx, s.cnf, request.MysqldArgs...)
} | [
"func",
"(",
"s",
"*",
"server",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"mysqlctlpb",
".",
"StartRequest",
")",
"(",
"*",
"mysqlctlpb",
".",
"StartResponse",
",",
"error",
")",
"{",
"return",
"&",
"mysqlctlpb",
".",
"... | // Start implements the server side of the MysqlctlClient interface. | [
"Start",
"implements",
"the",
"server",
"side",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlserver/server.go#L39-L41 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlserver/server.go | Shutdown | func (s *server) Shutdown(ctx context.Context, request *mysqlctlpb.ShutdownRequest) (*mysqlctlpb.ShutdownResponse, error) {
return &mysqlctlpb.ShutdownResponse{}, s.mysqld.Shutdown(ctx, s.cnf, request.WaitForMysqld)
} | go | func (s *server) Shutdown(ctx context.Context, request *mysqlctlpb.ShutdownRequest) (*mysqlctlpb.ShutdownResponse, error) {
return &mysqlctlpb.ShutdownResponse{}, s.mysqld.Shutdown(ctx, s.cnf, request.WaitForMysqld)
} | [
"func",
"(",
"s",
"*",
"server",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"mysqlctlpb",
".",
"ShutdownRequest",
")",
"(",
"*",
"mysqlctlpb",
".",
"ShutdownResponse",
",",
"error",
")",
"{",
"return",
"&",
"mysqlctlpb",
... | // Shutdown implements the server side of the MysqlctlClient interface. | [
"Shutdown",
"implements",
"the",
"server",
"side",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlserver/server.go#L44-L46 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlserver/server.go | RunMysqlUpgrade | func (s *server) RunMysqlUpgrade(ctx context.Context, request *mysqlctlpb.RunMysqlUpgradeRequest) (*mysqlctlpb.RunMysqlUpgradeResponse, error) {
return &mysqlctlpb.RunMysqlUpgradeResponse{}, s.mysqld.RunMysqlUpgrade()
} | go | func (s *server) RunMysqlUpgrade(ctx context.Context, request *mysqlctlpb.RunMysqlUpgradeRequest) (*mysqlctlpb.RunMysqlUpgradeResponse, error) {
return &mysqlctlpb.RunMysqlUpgradeResponse{}, s.mysqld.RunMysqlUpgrade()
} | [
"func",
"(",
"s",
"*",
"server",
")",
"RunMysqlUpgrade",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"mysqlctlpb",
".",
"RunMysqlUpgradeRequest",
")",
"(",
"*",
"mysqlctlpb",
".",
"RunMysqlUpgradeResponse",
",",
"error",
")",
"{",
"return",
"... | // RunMysqlUpgrade implements the server side of the MysqlctlClient interface. | [
"RunMysqlUpgrade",
"implements",
"the",
"server",
"side",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlserver/server.go#L49-L51 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlserver/server.go | ReinitConfig | func (s *server) ReinitConfig(ctx context.Context, request *mysqlctlpb.ReinitConfigRequest) (*mysqlctlpb.ReinitConfigResponse, error) {
return &mysqlctlpb.ReinitConfigResponse{}, s.mysqld.ReinitConfig(ctx, s.cnf)
} | go | func (s *server) ReinitConfig(ctx context.Context, request *mysqlctlpb.ReinitConfigRequest) (*mysqlctlpb.ReinitConfigResponse, error) {
return &mysqlctlpb.ReinitConfigResponse{}, s.mysqld.ReinitConfig(ctx, s.cnf)
} | [
"func",
"(",
"s",
"*",
"server",
")",
"ReinitConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"mysqlctlpb",
".",
"ReinitConfigRequest",
")",
"(",
"*",
"mysqlctlpb",
".",
"ReinitConfigResponse",
",",
"error",
")",
"{",
"return",
"&",
"my... | // ReinitConfig implements the server side of the MysqlctlClient interface. | [
"ReinitConfig",
"implements",
"the",
"server",
"side",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlserver/server.go#L54-L56 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlserver/server.go | RefreshConfig | func (s *server) RefreshConfig(ctx context.Context, request *mysqlctlpb.RefreshConfigRequest) (*mysqlctlpb.RefreshConfigResponse, error) {
return &mysqlctlpb.RefreshConfigResponse{}, s.mysqld.RefreshConfig(ctx, s.cnf)
} | go | func (s *server) RefreshConfig(ctx context.Context, request *mysqlctlpb.RefreshConfigRequest) (*mysqlctlpb.RefreshConfigResponse, error) {
return &mysqlctlpb.RefreshConfigResponse{}, s.mysqld.RefreshConfig(ctx, s.cnf)
} | [
"func",
"(",
"s",
"*",
"server",
")",
"RefreshConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"mysqlctlpb",
".",
"RefreshConfigRequest",
")",
"(",
"*",
"mysqlctlpb",
".",
"RefreshConfigResponse",
",",
"error",
")",
"{",
"return",
"&",
... | // RefreshConfig implements the server side of the MysqlctlClient interface. | [
"RefreshConfig",
"implements",
"the",
"server",
"side",
"of",
"the",
"MysqlctlClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlserver/server.go#L59-L61 | train |
vitessio/vitess | go/vt/mysqlctl/grpcmysqlctlserver/server.go | StartServer | func StartServer(s *grpc.Server, cnf *mysqlctl.Mycnf, mysqld *mysqlctl.Mysqld) {
mysqlctlpb.RegisterMysqlCtlServer(s, &server{cnf: cnf, mysqld: mysqld})
} | go | func StartServer(s *grpc.Server, cnf *mysqlctl.Mycnf, mysqld *mysqlctl.Mysqld) {
mysqlctlpb.RegisterMysqlCtlServer(s, &server{cnf: cnf, mysqld: mysqld})
} | [
"func",
"StartServer",
"(",
"s",
"*",
"grpc",
".",
"Server",
",",
"cnf",
"*",
"mysqlctl",
".",
"Mycnf",
",",
"mysqld",
"*",
"mysqlctl",
".",
"Mysqld",
")",
"{",
"mysqlctlpb",
".",
"RegisterMysqlCtlServer",
"(",
"s",
",",
"&",
"server",
"{",
"cnf",
":",... | // StartServer registers the Server for RPCs. | [
"StartServer",
"registers",
"the",
"Server",
"for",
"RPCs",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/grpcmysqlctlserver/server.go#L64-L66 | train |
vitessio/vitess | go/vt/vtgate/vindexes/numeric.go | NewNumeric | func NewNumeric(name string, _ map[string]string) (Vindex, error) {
return &Numeric{name: name}, nil
} | go | func NewNumeric(name string, _ map[string]string) (Vindex, error) {
return &Numeric{name: name}, nil
} | [
"func",
"NewNumeric",
"(",
"name",
"string",
",",
"_",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"return",
"&",
"Numeric",
"{",
"name",
":",
"name",
"}",
",",
"nil",
"\n",
"}"
] | // NewNumeric creates a Numeric vindex. | [
"NewNumeric",
"creates",
"a",
"Numeric",
"vindex",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/numeric.go#L41-L43 | train |
vitessio/vitess | go/vt/throttler/max_rate_module.go | SetMaxRate | func (m *MaxRateModule) SetMaxRate(rate int64) {
m.maxRate.Set(rate)
m.rateUpdateChan <- struct{}{}
} | go | func (m *MaxRateModule) SetMaxRate(rate int64) {
m.maxRate.Set(rate)
m.rateUpdateChan <- struct{}{}
} | [
"func",
"(",
"m",
"*",
"MaxRateModule",
")",
"SetMaxRate",
"(",
"rate",
"int64",
")",
"{",
"m",
".",
"maxRate",
".",
"Set",
"(",
"rate",
")",
"\n",
"m",
".",
"rateUpdateChan",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}"
] | // SetMaxRate sets the current max rate and notifies the throttler about the
// rate update. | [
"SetMaxRate",
"sets",
"the",
"current",
"max",
"rate",
"and",
"notifies",
"the",
"throttler",
"about",
"the",
"rate",
"update",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/max_rate_module.go#L53-L56 | train |
vitessio/vitess | go/vt/vtgate/vindexes/null.go | NewNull | func NewNull(name string, m map[string]string) (Vindex, error) {
return &Null{name: name}, nil
} | go | func NewNull(name string, m map[string]string) (Vindex, error) {
return &Null{name: name}, nil
} | [
"func",
"NewNull",
"(",
"name",
"string",
",",
"m",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"return",
"&",
"Null",
"{",
"name",
":",
"name",
"}",
",",
"nil",
"\n",
"}"
] | // NewNull creates a new Null. | [
"NewNull",
"creates",
"a",
"new",
"Null",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/null.go#L42-L44 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/mock_dbclient.go | NewMockDBClient | func NewMockDBClient(t *testing.T) *MockDBClient {
return &MockDBClient{
t: t,
done: make(chan struct{}),
}
} | go | func NewMockDBClient(t *testing.T) *MockDBClient {
return &MockDBClient{
t: t,
done: make(chan struct{}),
}
} | [
"func",
"NewMockDBClient",
"(",
"t",
"*",
"testing",
".",
"T",
")",
"*",
"MockDBClient",
"{",
"return",
"&",
"MockDBClient",
"{",
"t",
":",
"t",
",",
"done",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"
] | // NewMockDBClient returns a new DBClientMock. | [
"NewMockDBClient",
"returns",
"a",
"new",
"DBClientMock",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/mock_dbclient.go#L44-L49 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.