id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
158,000 | vitessio/vitess | go/vt/worker/grpcvtworkerclient/client.go | ExecuteVtworkerCommand | func (client *gRPCVtworkerClient) ExecuteVtworkerCommand(ctx context.Context, args []string) (logutil.EventStream, error) {
query := &vtworkerdatapb.ExecuteVtworkerCommandRequest{
Args: args,
}
stream, err := client.c.ExecuteVtworkerCommand(ctx, query)
if err != nil {
return nil, vterrors.FromGRPC(err)
}
return &eventStreamAdapter{stream}, nil
} | go | func (client *gRPCVtworkerClient) ExecuteVtworkerCommand(ctx context.Context, args []string) (logutil.EventStream, error) {
query := &vtworkerdatapb.ExecuteVtworkerCommandRequest{
Args: args,
}
stream, err := client.c.ExecuteVtworkerCommand(ctx, query)
if err != nil {
return nil, vterrors.FromGRPC(err)
}
return &eventStreamAdapter{stream}, nil
} | [
"func",
"(",
"client",
"*",
"gRPCVtworkerClient",
")",
"ExecuteVtworkerCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"[",
"]",
"string",
")",
"(",
"logutil",
".",
"EventStream",
",",
"error",
")",
"{",
"query",
":=",
"&",
"vtworkerdatapb",
... | // ExecuteVtworkerCommand is part of the VtworkerClient interface. | [
"ExecuteVtworkerCommand",
"is",
"part",
"of",
"the",
"VtworkerClient",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/grpcvtworkerclient/client.go#L80-L90 |
158,001 | vitessio/vitess | go/vt/automation/cluster_operation_instance.go | NewClusterOperationInstance | func NewClusterOperationInstance(clusterOpID string, initialTask *automationpb.TaskContainer, taskIDGenerator *IDGenerator) ClusterOperationInstance {
c := ClusterOperationInstance{
automationpb.ClusterOperation{
Id: clusterOpID,
SerialTasks: []*automationpb.TaskContainer{},
State: automationpb.ClusterOperationState_CLUSTER_OPERATION_NOT_STARTED,
},
taskIDGenerator,
}
c.InsertTaskContainers([]*automationpb.TaskContainer{initialTask}, 0)
return c
} | go | func NewClusterOperationInstance(clusterOpID string, initialTask *automationpb.TaskContainer, taskIDGenerator *IDGenerator) ClusterOperationInstance {
c := ClusterOperationInstance{
automationpb.ClusterOperation{
Id: clusterOpID,
SerialTasks: []*automationpb.TaskContainer{},
State: automationpb.ClusterOperationState_CLUSTER_OPERATION_NOT_STARTED,
},
taskIDGenerator,
}
c.InsertTaskContainers([]*automationpb.TaskContainer{initialTask}, 0)
return c
} | [
"func",
"NewClusterOperationInstance",
"(",
"clusterOpID",
"string",
",",
"initialTask",
"*",
"automationpb",
".",
"TaskContainer",
",",
"taskIDGenerator",
"*",
"IDGenerator",
")",
"ClusterOperationInstance",
"{",
"c",
":=",
"ClusterOperationInstance",
"{",
"automationpb"... | // NewClusterOperationInstance creates a new cluster operation instance with one initial task. | [
"NewClusterOperationInstance",
"creates",
"a",
"new",
"cluster",
"operation",
"instance",
"with",
"one",
"initial",
"task",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/cluster_operation_instance.go#L33-L44 |
158,002 | vitessio/vitess | go/vt/automation/cluster_operation_instance.go | InsertTaskContainers | func (c *ClusterOperationInstance) InsertTaskContainers(newTaskContainers []*automationpb.TaskContainer, pos int) {
AddMissingTaskID(newTaskContainers, c.taskIDGenerator)
newSerialTasks := make([]*automationpb.TaskContainer, len(c.SerialTasks)+len(newTaskContainers))
copy(newSerialTasks, c.SerialTasks[:pos])
copy(newSerialTasks[pos:], newTaskContainers)
copy(newSerialTasks[pos+len(newTaskContainers):], c.SerialTasks[pos:])
c.SerialTasks = newSerialTasks
} | go | func (c *ClusterOperationInstance) InsertTaskContainers(newTaskContainers []*automationpb.TaskContainer, pos int) {
AddMissingTaskID(newTaskContainers, c.taskIDGenerator)
newSerialTasks := make([]*automationpb.TaskContainer, len(c.SerialTasks)+len(newTaskContainers))
copy(newSerialTasks, c.SerialTasks[:pos])
copy(newSerialTasks[pos:], newTaskContainers)
copy(newSerialTasks[pos+len(newTaskContainers):], c.SerialTasks[pos:])
c.SerialTasks = newSerialTasks
} | [
"func",
"(",
"c",
"*",
"ClusterOperationInstance",
")",
"InsertTaskContainers",
"(",
"newTaskContainers",
"[",
"]",
"*",
"automationpb",
".",
"TaskContainer",
",",
"pos",
"int",
")",
"{",
"AddMissingTaskID",
"(",
"newTaskContainers",
",",
"c",
".",
"taskIDGenerato... | // InsertTaskContainers inserts "newTaskContainers" at pos in the current list of task containers. Existing task containers will be moved after the new task containers. | [
"InsertTaskContainers",
"inserts",
"newTaskContainers",
"at",
"pos",
"in",
"the",
"current",
"list",
"of",
"task",
"containers",
".",
"Existing",
"task",
"containers",
"will",
"be",
"moved",
"after",
"the",
"new",
"task",
"containers",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/cluster_operation_instance.go#L47-L55 |
158,003 | vitessio/vitess | go/vt/vttablet/filelogger/filelogger.go | Init | func Init(path string) (FileLogger, error) {
log.Info("Logging queries to file %s", path)
logChan, err := tabletenv.StatsLogger.LogToFile(path, streamlog.GetFormatter(tabletenv.StatsLogger))
if err != nil {
return nil, err
}
return &fileLogger{
logChan: logChan,
}, nil
} | go | func Init(path string) (FileLogger, error) {
log.Info("Logging queries to file %s", path)
logChan, err := tabletenv.StatsLogger.LogToFile(path, streamlog.GetFormatter(tabletenv.StatsLogger))
if err != nil {
return nil, err
}
return &fileLogger{
logChan: logChan,
}, nil
} | [
"func",
"Init",
"(",
"path",
"string",
")",
"(",
"FileLogger",
",",
"error",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"logChan",
",",
"err",
":=",
"tabletenv",
".",
"StatsLogger",
".",
"LogToFile",
"(",
"path",
",",
"s... | // Init starts logging to the given file path. | [
"Init",
"starts",
"logging",
"to",
"the",
"given",
"file",
"path",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/filelogger/filelogger.go#L55-L64 |
158,004 | vitessio/vitess | go/vt/vterrors/aggregate.go | Aggregate | func Aggregate(errors []error) error {
if len(errors) == 0 {
return nil
}
return New(aggregateCodes(errors), aggregateErrors(errors))
} | go | func Aggregate(errors []error) error {
if len(errors) == 0 {
return nil
}
return New(aggregateCodes(errors), aggregateErrors(errors))
} | [
"func",
"Aggregate",
"(",
"errors",
"[",
"]",
"error",
")",
"error",
"{",
"if",
"len",
"(",
"errors",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"New",
"(",
"aggregateCodes",
"(",
"errors",
")",
",",
"aggregateErrors",
"(",
"err... | // Aggregate aggregates several errors into a single one.
// The resulting error code will be the one with the highest
// priority as defined by the priority constants in this package. | [
"Aggregate",
"aggregates",
"several",
"errors",
"into",
"a",
"single",
"one",
".",
"The",
"resulting",
"error",
"code",
"will",
"be",
"the",
"one",
"with",
"the",
"highest",
"priority",
"as",
"defined",
"by",
"the",
"priority",
"constants",
"in",
"this",
"pa... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/aggregate.go#L79-L84 |
158,005 | vitessio/vitess | go/vt/vterrors/aggregate.go | aggregateErrors | func aggregateErrors(errs []error) string {
errStrs := make([]string, 0, len(errs))
for _, e := range errs {
errStrs = append(errStrs, e.Error())
}
// sort the error strings so we always have deterministic ordering
sort.Strings(errStrs)
return strings.Join(errStrs, "\n")
} | go | func aggregateErrors(errs []error) string {
errStrs := make([]string, 0, len(errs))
for _, e := range errs {
errStrs = append(errStrs, e.Error())
}
// sort the error strings so we always have deterministic ordering
sort.Strings(errStrs)
return strings.Join(errStrs, "\n")
} | [
"func",
"aggregateErrors",
"(",
"errs",
"[",
"]",
"error",
")",
"string",
"{",
"errStrs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"errs",
")",
")",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"errs",
"{",
"errStrs",
"=",
... | // ConcatenateErrors aggregates an array of errors into a single error by string concatenation. | [
"ConcatenateErrors",
"aggregates",
"an",
"array",
"of",
"errors",
"into",
"a",
"single",
"error",
"by",
"string",
"concatenation",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vterrors/aggregate.go#L98-L106 |
158,006 | vitessio/vitess | go/vt/sqlparser/tracked_buffer.go | NewTrackedBuffer | func NewTrackedBuffer(nodeFormatter NodeFormatter) *TrackedBuffer {
return &TrackedBuffer{
Builder: new(strings.Builder),
nodeFormatter: nodeFormatter,
}
} | go | func NewTrackedBuffer(nodeFormatter NodeFormatter) *TrackedBuffer {
return &TrackedBuffer{
Builder: new(strings.Builder),
nodeFormatter: nodeFormatter,
}
} | [
"func",
"NewTrackedBuffer",
"(",
"nodeFormatter",
"NodeFormatter",
")",
"*",
"TrackedBuffer",
"{",
"return",
"&",
"TrackedBuffer",
"{",
"Builder",
":",
"new",
"(",
"strings",
".",
"Builder",
")",
",",
"nodeFormatter",
":",
"nodeFormatter",
",",
"}",
"\n",
"}"
... | // NewTrackedBuffer creates a new TrackedBuffer. | [
"NewTrackedBuffer",
"creates",
"a",
"new",
"TrackedBuffer",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/tracked_buffer.go#L42-L47 |
158,007 | vitessio/vitess | go/vt/sqlparser/tracked_buffer.go | WriteNode | func (buf *TrackedBuffer) WriteNode(node SQLNode) *TrackedBuffer {
buf.Myprintf("%v", node)
return buf
} | go | func (buf *TrackedBuffer) WriteNode(node SQLNode) *TrackedBuffer {
buf.Myprintf("%v", node)
return buf
} | [
"func",
"(",
"buf",
"*",
"TrackedBuffer",
")",
"WriteNode",
"(",
"node",
"SQLNode",
")",
"*",
"TrackedBuffer",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"node",
")",
"\n",
"return",
"buf",
"\n",
"}"
] | // WriteNode function, initiates the writing of a single SQLNode tree by passing
// through to Myprintf with a default format string | [
"WriteNode",
"function",
"initiates",
"the",
"writing",
"of",
"a",
"single",
"SQLNode",
"tree",
"by",
"passing",
"through",
"to",
"Myprintf",
"with",
"a",
"default",
"format",
"string"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/tracked_buffer.go#L51-L54 |
158,008 | vitessio/vitess | go/vt/sqlparser/tracked_buffer.go | ParsedQuery | func (buf *TrackedBuffer) ParsedQuery() *ParsedQuery {
return &ParsedQuery{Query: buf.String(), bindLocations: buf.bindLocations}
} | go | func (buf *TrackedBuffer) ParsedQuery() *ParsedQuery {
return &ParsedQuery{Query: buf.String(), bindLocations: buf.bindLocations}
} | [
"func",
"(",
"buf",
"*",
"TrackedBuffer",
")",
"ParsedQuery",
"(",
")",
"*",
"ParsedQuery",
"{",
"return",
"&",
"ParsedQuery",
"{",
"Query",
":",
"buf",
".",
"String",
"(",
")",
",",
"bindLocations",
":",
"buf",
".",
"bindLocations",
"}",
"\n",
"}"
] | // ParsedQuery returns a ParsedQuery that contains bind
// locations for easy substitution. | [
"ParsedQuery",
"returns",
"a",
"ParsedQuery",
"that",
"contains",
"bind",
"locations",
"for",
"easy",
"substitution",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/tracked_buffer.go#L126-L128 |
158,009 | vitessio/vitess | go/vt/sqlparser/tracked_buffer.go | BuildParsedQuery | func BuildParsedQuery(in string, vars ...interface{}) *ParsedQuery {
buf := NewTrackedBuffer(nil)
buf.Myprintf(in, vars...)
return buf.ParsedQuery()
} | go | func BuildParsedQuery(in string, vars ...interface{}) *ParsedQuery {
buf := NewTrackedBuffer(nil)
buf.Myprintf(in, vars...)
return buf.ParsedQuery()
} | [
"func",
"BuildParsedQuery",
"(",
"in",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"*",
"ParsedQuery",
"{",
"buf",
":=",
"NewTrackedBuffer",
"(",
"nil",
")",
"\n",
"buf",
".",
"Myprintf",
"(",
"in",
",",
"vars",
"...",
")",
"\n",
"return"... | // BuildParsedQuery builds a ParsedQuery from the input. | [
"BuildParsedQuery",
"builds",
"a",
"ParsedQuery",
"from",
"the",
"input",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/tracked_buffer.go#L136-L140 |
158,010 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | Execute | func (q *query) Execute(ctx context.Context, request *querypb.ExecuteRequest) (response *querypb.ExecuteResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
result, err := q.server.Execute(ctx, request.Target, request.Query.Sql, request.Query.BindVariables, request.TransactionId, request.Options)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ExecuteResponse{
Result: sqltypes.ResultToProto3(result),
}, nil
} | go | func (q *query) Execute(ctx context.Context, request *querypb.ExecuteRequest) (response *querypb.ExecuteResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
result, err := q.server.Execute(ctx, request.Target, request.Query.Sql, request.Query.BindVariables, request.TransactionId, request.Options)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ExecuteResponse{
Result: sqltypes.ResultToProto3(result),
}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"Execute",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"ExecuteRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"ExecuteResponse",
",",
"err",
"error",
")",
"{",
"defer",
"q",
"."... | // Execute is part of the queryservice.QueryServer interface | [
"Execute",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L41-L54 |
158,011 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | ExecuteBatch | func (q *query) ExecuteBatch(ctx context.Context, request *querypb.ExecuteBatchRequest) (response *querypb.ExecuteBatchResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
results, err := q.server.ExecuteBatch(ctx, request.Target, request.Queries, request.AsTransaction, request.TransactionId, request.Options)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ExecuteBatchResponse{
Results: sqltypes.ResultsToProto3(results),
}, nil
} | go | func (q *query) ExecuteBatch(ctx context.Context, request *querypb.ExecuteBatchRequest) (response *querypb.ExecuteBatchResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
results, err := q.server.ExecuteBatch(ctx, request.Target, request.Queries, request.AsTransaction, request.TransactionId, request.Options)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ExecuteBatchResponse{
Results: sqltypes.ResultsToProto3(results),
}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"ExecuteBatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"ExecuteBatchRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"ExecuteBatchResponse",
",",
"err",
"error",
")",
"{",
"defer... | // ExecuteBatch is part of the queryservice.QueryServer interface | [
"ExecuteBatch",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L57-L70 |
158,012 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | StreamExecute | func (q *query) StreamExecute(request *querypb.StreamExecuteRequest, stream queryservicepb.Query_StreamExecuteServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.StreamExecute(ctx, request.Target, request.Query.Sql, request.Query.BindVariables, request.TransactionId, request.Options, func(reply *sqltypes.Result) error {
return stream.Send(&querypb.StreamExecuteResponse{
Result: sqltypes.ResultToProto3(reply),
})
})
return vterrors.ToGRPC(err)
} | go | func (q *query) StreamExecute(request *querypb.StreamExecuteRequest, stream queryservicepb.Query_StreamExecuteServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.StreamExecute(ctx, request.Target, request.Query.Sql, request.Query.BindVariables, request.TransactionId, request.Options, func(reply *sqltypes.Result) error {
return stream.Send(&querypb.StreamExecuteResponse{
Result: sqltypes.ResultToProto3(reply),
})
})
return vterrors.ToGRPC(err)
} | [
"func",
"(",
"q",
"*",
"query",
")",
"StreamExecute",
"(",
"request",
"*",
"querypb",
".",
"StreamExecuteRequest",
",",
"stream",
"queryservicepb",
".",
"Query_StreamExecuteServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"q",
".",
"server",
".",
"Handl... | // StreamExecute is part of the queryservice.QueryServer interface | [
"StreamExecute",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L73-L85 |
158,013 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | Begin | func (q *query) Begin(ctx context.Context, request *querypb.BeginRequest) (response *querypb.BeginResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
transactionID, err := q.server.Begin(ctx, request.Target, request.Options)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.BeginResponse{
TransactionId: transactionID,
}, nil
} | go | func (q *query) Begin(ctx context.Context, request *querypb.BeginRequest) (response *querypb.BeginResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
transactionID, err := q.server.Begin(ctx, request.Target, request.Options)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.BeginResponse{
TransactionId: transactionID,
}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"Begin",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"BeginRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"BeginResponse",
",",
"err",
"error",
")",
"{",
"defer",
"q",
".",
"s... | // Begin is part of the queryservice.QueryServer interface | [
"Begin",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L88-L102 |
158,014 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | Commit | func (q *query) Commit(ctx context.Context, request *querypb.CommitRequest) (response *querypb.CommitResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.Commit(ctx, request.Target, request.TransactionId); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.CommitResponse{}, nil
} | go | func (q *query) Commit(ctx context.Context, request *querypb.CommitRequest) (response *querypb.CommitResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.Commit(ctx, request.Target, request.TransactionId); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.CommitResponse{}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"Commit",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"CommitRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"CommitResponse",
",",
"err",
"error",
")",
"{",
"defer",
"q",
".",
... | // Commit is part of the queryservice.QueryServer interface | [
"Commit",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L105-L115 |
158,015 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | Rollback | func (q *query) Rollback(ctx context.Context, request *querypb.RollbackRequest) (response *querypb.RollbackResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.Rollback(ctx, request.Target, request.TransactionId); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.RollbackResponse{}, nil
} | go | func (q *query) Rollback(ctx context.Context, request *querypb.RollbackRequest) (response *querypb.RollbackResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.Rollback(ctx, request.Target, request.TransactionId); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.RollbackResponse{}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"Rollback",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"RollbackRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"RollbackResponse",
",",
"err",
"error",
")",
"{",
"defer",
"q",
... | // Rollback is part of the queryservice.QueryServer interface | [
"Rollback",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L118-L129 |
158,016 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | CommitPrepared | func (q *query) CommitPrepared(ctx context.Context, request *querypb.CommitPreparedRequest) (response *querypb.CommitPreparedResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.CommitPrepared(ctx, request.Target, request.Dtid); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.CommitPreparedResponse{}, nil
} | go | func (q *query) CommitPrepared(ctx context.Context, request *querypb.CommitPreparedRequest) (response *querypb.CommitPreparedResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.CommitPrepared(ctx, request.Target, request.Dtid); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.CommitPreparedResponse{}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"CommitPrepared",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"CommitPreparedRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"CommitPreparedResponse",
",",
"err",
"error",
")",
"{",
... | // CommitPrepared is part of the queryservice.QueryServer interface | [
"CommitPrepared",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L146-L157 |
158,017 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | CreateTransaction | func (q *query) CreateTransaction(ctx context.Context, request *querypb.CreateTransactionRequest) (response *querypb.CreateTransactionResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.CreateTransaction(ctx, request.Target, request.Dtid, request.Participants); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.CreateTransactionResponse{}, nil
} | go | func (q *query) CreateTransaction(ctx context.Context, request *querypb.CreateTransactionRequest) (response *querypb.CreateTransactionResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.CreateTransaction(ctx, request.Target, request.Dtid, request.Participants); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.CreateTransactionResponse{}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"CreateTransaction",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"CreateTransactionRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"CreateTransactionResponse",
",",
"err",
"error",
")",
... | // CreateTransaction is part of the queryservice.QueryServer interface | [
"CreateTransaction",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L174-L185 |
158,018 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | StartCommit | func (q *query) StartCommit(ctx context.Context, request *querypb.StartCommitRequest) (response *querypb.StartCommitResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.StartCommit(ctx, request.Target, request.TransactionId, request.Dtid); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.StartCommitResponse{}, nil
} | go | func (q *query) StartCommit(ctx context.Context, request *querypb.StartCommitRequest) (response *querypb.StartCommitResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.StartCommit(ctx, request.Target, request.TransactionId, request.Dtid); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.StartCommitResponse{}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"StartCommit",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"StartCommitRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"StartCommitResponse",
",",
"err",
"error",
")",
"{",
"defer",
... | // StartCommit is part of the queryservice.QueryServer interface | [
"StartCommit",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L188-L199 |
158,019 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | ConcludeTransaction | func (q *query) ConcludeTransaction(ctx context.Context, request *querypb.ConcludeTransactionRequest) (response *querypb.ConcludeTransactionResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.ConcludeTransaction(ctx, request.Target, request.Dtid); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ConcludeTransactionResponse{}, nil
} | go | func (q *query) ConcludeTransaction(ctx context.Context, request *querypb.ConcludeTransactionRequest) (response *querypb.ConcludeTransactionResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
if err := q.server.ConcludeTransaction(ctx, request.Target, request.Dtid); err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ConcludeTransactionResponse{}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"ConcludeTransaction",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"ConcludeTransactionRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"ConcludeTransactionResponse",
",",
"err",
"error",
... | // ConcludeTransaction is part of the queryservice.QueryServer interface | [
"ConcludeTransaction",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L216-L227 |
158,020 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | ReadTransaction | func (q *query) ReadTransaction(ctx context.Context, request *querypb.ReadTransactionRequest) (response *querypb.ReadTransactionResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
result, err := q.server.ReadTransaction(ctx, request.Target, request.Dtid)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ReadTransactionResponse{Metadata: result}, nil
} | go | func (q *query) ReadTransaction(ctx context.Context, request *querypb.ReadTransactionRequest) (response *querypb.ReadTransactionResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
result, err := q.server.ReadTransaction(ctx, request.Target, request.Dtid)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.ReadTransactionResponse{Metadata: result}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"ReadTransaction",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"ReadTransactionRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"ReadTransactionResponse",
",",
"err",
"error",
")",
"{",... | // ReadTransaction is part of the queryservice.QueryServer interface | [
"ReadTransaction",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L230-L242 |
158,021 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | BeginExecute | func (q *query) BeginExecute(ctx context.Context, request *querypb.BeginExecuteRequest) (response *querypb.BeginExecuteResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
result, transactionID, err := q.server.BeginExecute(ctx, request.Target, request.Query.Sql, request.Query.BindVariables, request.Options)
if err != nil {
// if we have a valid transactionID, return the error in-band
if transactionID != 0 {
return &querypb.BeginExecuteResponse{
Error: vterrors.ToVTRPC(err),
TransactionId: transactionID,
}, nil
}
return nil, vterrors.ToGRPC(err)
}
return &querypb.BeginExecuteResponse{
Result: sqltypes.ResultToProto3(result),
TransactionId: transactionID,
}, nil
} | go | func (q *query) BeginExecute(ctx context.Context, request *querypb.BeginExecuteRequest) (response *querypb.BeginExecuteResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
result, transactionID, err := q.server.BeginExecute(ctx, request.Target, request.Query.Sql, request.Query.BindVariables, request.Options)
if err != nil {
// if we have a valid transactionID, return the error in-band
if transactionID != 0 {
return &querypb.BeginExecuteResponse{
Error: vterrors.ToVTRPC(err),
TransactionId: transactionID,
}, nil
}
return nil, vterrors.ToGRPC(err)
}
return &querypb.BeginExecuteResponse{
Result: sqltypes.ResultToProto3(result),
TransactionId: transactionID,
}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"BeginExecute",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"BeginExecuteRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"BeginExecuteResponse",
",",
"err",
"error",
")",
"{",
"defer... | // BeginExecute is part of the queryservice.QueryServer interface | [
"BeginExecute",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L245-L267 |
158,022 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | BeginExecuteBatch | func (q *query) BeginExecuteBatch(ctx context.Context, request *querypb.BeginExecuteBatchRequest) (response *querypb.BeginExecuteBatchResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
results, transactionID, err := q.server.BeginExecuteBatch(ctx, request.Target, request.Queries, request.AsTransaction, request.Options)
if err != nil {
// if we have a valid transactionID, return the error in-band
if transactionID != 0 {
return &querypb.BeginExecuteBatchResponse{
Error: vterrors.ToVTRPC(err),
TransactionId: transactionID,
}, nil
}
return nil, vterrors.ToGRPC(err)
}
return &querypb.BeginExecuteBatchResponse{
Results: sqltypes.ResultsToProto3(results),
TransactionId: transactionID,
}, nil
} | go | func (q *query) BeginExecuteBatch(ctx context.Context, request *querypb.BeginExecuteBatchRequest) (response *querypb.BeginExecuteBatchResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
results, transactionID, err := q.server.BeginExecuteBatch(ctx, request.Target, request.Queries, request.AsTransaction, request.Options)
if err != nil {
// if we have a valid transactionID, return the error in-band
if transactionID != 0 {
return &querypb.BeginExecuteBatchResponse{
Error: vterrors.ToVTRPC(err),
TransactionId: transactionID,
}, nil
}
return nil, vterrors.ToGRPC(err)
}
return &querypb.BeginExecuteBatchResponse{
Results: sqltypes.ResultsToProto3(results),
TransactionId: transactionID,
}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"BeginExecuteBatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"BeginExecuteBatchRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"BeginExecuteBatchResponse",
",",
"err",
"error",
")",
... | // BeginExecuteBatch is part of the queryservice.QueryServer interface | [
"BeginExecuteBatch",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L270-L292 |
158,023 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | MessageStream | func (q *query) MessageStream(request *querypb.MessageStreamRequest, stream queryservicepb.Query_MessageStreamServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.MessageStream(ctx, request.Target, request.Name, func(qr *sqltypes.Result) error {
return stream.Send(&querypb.MessageStreamResponse{
Result: sqltypes.ResultToProto3(qr),
})
})
return vterrors.ToGRPC(err)
} | go | func (q *query) MessageStream(request *querypb.MessageStreamRequest, stream queryservicepb.Query_MessageStreamServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.MessageStream(ctx, request.Target, request.Name, func(qr *sqltypes.Result) error {
return stream.Send(&querypb.MessageStreamResponse{
Result: sqltypes.ResultToProto3(qr),
})
})
return vterrors.ToGRPC(err)
} | [
"func",
"(",
"q",
"*",
"query",
")",
"MessageStream",
"(",
"request",
"*",
"querypb",
".",
"MessageStreamRequest",
",",
"stream",
"queryservicepb",
".",
"Query_MessageStreamServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"q",
".",
"server",
".",
"Handl... | // MessageStream is part of the queryservice.QueryServer interface | [
"MessageStream",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L295-L307 |
158,024 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | MessageAck | func (q *query) MessageAck(ctx context.Context, request *querypb.MessageAckRequest) (response *querypb.MessageAckResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
count, err := q.server.MessageAck(ctx, request.Target, request.Name, request.Ids)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.MessageAckResponse{
Result: &querypb.QueryResult{
RowsAffected: uint64(count),
},
}, nil
} | go | func (q *query) MessageAck(ctx context.Context, request *querypb.MessageAckRequest) (response *querypb.MessageAckResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
count, err := q.server.MessageAck(ctx, request.Target, request.Name, request.Ids)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.MessageAckResponse{
Result: &querypb.QueryResult{
RowsAffected: uint64(count),
},
}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"MessageAck",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"MessageAckRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"MessageAckResponse",
",",
"err",
"error",
")",
"{",
"defer",
"... | // MessageAck is part of the queryservice.QueryServer interface | [
"MessageAck",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L310-L325 |
158,025 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | SplitQuery | func (q *query) SplitQuery(ctx context.Context, request *querypb.SplitQueryRequest) (response *querypb.SplitQueryResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
splits, err := q.server.SplitQuery(
ctx,
request.Target,
request.Query,
request.SplitColumn,
request.SplitCount,
request.NumRowsPerQueryPart,
request.Algorithm)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.SplitQueryResponse{Queries: splits}, nil
} | go | func (q *query) SplitQuery(ctx context.Context, request *querypb.SplitQueryRequest) (response *querypb.SplitQueryResponse, err error) {
defer q.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
splits, err := q.server.SplitQuery(
ctx,
request.Target,
request.Query,
request.SplitColumn,
request.SplitCount,
request.NumRowsPerQueryPart,
request.Algorithm)
if err != nil {
return nil, vterrors.ToGRPC(err)
}
return &querypb.SplitQueryResponse{Queries: splits}, nil
} | [
"func",
"(",
"q",
"*",
"query",
")",
"SplitQuery",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"querypb",
".",
"SplitQueryRequest",
")",
"(",
"response",
"*",
"querypb",
".",
"SplitQueryResponse",
",",
"err",
"error",
")",
"{",
"defer",
"... | // SplitQuery is part of the queryservice.QueryServer interface | [
"SplitQuery",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L328-L346 |
158,026 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | StreamHealth | func (q *query) StreamHealth(request *querypb.StreamHealthRequest, stream queryservicepb.Query_StreamHealthServer) (err error) {
defer q.server.HandlePanic(&err)
err = q.server.StreamHealth(stream.Context(), stream.Send)
return vterrors.ToGRPC(err)
} | go | func (q *query) StreamHealth(request *querypb.StreamHealthRequest, stream queryservicepb.Query_StreamHealthServer) (err error) {
defer q.server.HandlePanic(&err)
err = q.server.StreamHealth(stream.Context(), stream.Send)
return vterrors.ToGRPC(err)
} | [
"func",
"(",
"q",
"*",
"query",
")",
"StreamHealth",
"(",
"request",
"*",
"querypb",
".",
"StreamHealthRequest",
",",
"stream",
"queryservicepb",
".",
"Query_StreamHealthServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"q",
".",
"server",
".",
"HandlePa... | // StreamHealth is part of the queryservice.QueryServer interface | [
"StreamHealth",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L349-L353 |
158,027 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | UpdateStream | func (q *query) UpdateStream(request *querypb.UpdateStreamRequest, stream queryservicepb.Query_UpdateStreamServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.UpdateStream(ctx, request.Target, request.Position, request.Timestamp, func(reply *querypb.StreamEvent) error {
return stream.Send(&querypb.UpdateStreamResponse{
Event: reply,
})
})
return vterrors.ToGRPC(err)
} | go | func (q *query) UpdateStream(request *querypb.UpdateStreamRequest, stream queryservicepb.Query_UpdateStreamServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.UpdateStream(ctx, request.Target, request.Position, request.Timestamp, func(reply *querypb.StreamEvent) error {
return stream.Send(&querypb.UpdateStreamResponse{
Event: reply,
})
})
return vterrors.ToGRPC(err)
} | [
"func",
"(",
"q",
"*",
"query",
")",
"UpdateStream",
"(",
"request",
"*",
"querypb",
".",
"UpdateStreamRequest",
",",
"stream",
"queryservicepb",
".",
"Query_UpdateStreamServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"q",
".",
"server",
".",
"HandlePa... | // UpdateStream is part of the queryservice.QueryServer interface | [
"UpdateStream",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L356-L368 |
158,028 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | VStream | func (q *query) VStream(request *binlogdatapb.VStreamRequest, stream queryservicepb.Query_VStreamServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.VStream(ctx, request.Target, request.Position, request.Filter, func(events []*binlogdatapb.VEvent) error {
return stream.Send(&binlogdatapb.VStreamResponse{
Events: events,
})
})
return vterrors.ToGRPC(err)
} | go | func (q *query) VStream(request *binlogdatapb.VStreamRequest, stream queryservicepb.Query_VStreamServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.VStream(ctx, request.Target, request.Position, request.Filter, func(events []*binlogdatapb.VEvent) error {
return stream.Send(&binlogdatapb.VStreamResponse{
Events: events,
})
})
return vterrors.ToGRPC(err)
} | [
"func",
"(",
"q",
"*",
"query",
")",
"VStream",
"(",
"request",
"*",
"binlogdatapb",
".",
"VStreamRequest",
",",
"stream",
"queryservicepb",
".",
"Query_VStreamServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"q",
".",
"server",
".",
"HandlePanic",
"(... | // VStream is part of the queryservice.QueryServer interface | [
"VStream",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L371-L383 |
158,029 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | VStreamRows | func (q *query) VStreamRows(request *binlogdatapb.VStreamRowsRequest, stream queryservicepb.Query_VStreamRowsServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.VStreamRows(ctx, request.Target, request.Query, request.Lastpk, stream.Send)
return vterrors.ToGRPC(err)
} | go | func (q *query) VStreamRows(request *binlogdatapb.VStreamRowsRequest, stream queryservicepb.Query_VStreamRowsServer) (err error) {
defer q.server.HandlePanic(&err)
ctx := callerid.NewContext(callinfo.GRPCCallInfo(stream.Context()),
request.EffectiveCallerId,
request.ImmediateCallerId,
)
err = q.server.VStreamRows(ctx, request.Target, request.Query, request.Lastpk, stream.Send)
return vterrors.ToGRPC(err)
} | [
"func",
"(",
"q",
"*",
"query",
")",
"VStreamRows",
"(",
"request",
"*",
"binlogdatapb",
".",
"VStreamRowsRequest",
",",
"stream",
"queryservicepb",
".",
"Query_VStreamRowsServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"q",
".",
"server",
".",
"Handle... | // VStreamRows is part of the queryservice.QueryServer interface | [
"VStreamRows",
"is",
"part",
"of",
"the",
"queryservice",
".",
"QueryServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L386-L394 |
158,030 | vitessio/vitess | go/vt/vttablet/grpcqueryservice/server.go | Register | func Register(s *grpc.Server, server queryservice.QueryService) {
queryservicepb.RegisterQueryServer(s, &query{server})
} | go | func Register(s *grpc.Server, server queryservice.QueryService) {
queryservicepb.RegisterQueryServer(s, &query{server})
} | [
"func",
"Register",
"(",
"s",
"*",
"grpc",
".",
"Server",
",",
"server",
"queryservice",
".",
"QueryService",
")",
"{",
"queryservicepb",
".",
"RegisterQueryServer",
"(",
"s",
",",
"&",
"query",
"{",
"server",
"}",
")",
"\n",
"}"
] | // Register registers the implementation on the provide gRPC Server. | [
"Register",
"registers",
"the",
"implementation",
"on",
"the",
"provide",
"gRPC",
"Server",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpcqueryservice/server.go#L397-L399 |
158,031 | vitessio/vitess | go/stats/counter.go | NewCounter | func NewCounter(name string, help string) *Counter {
v := &Counter{help: help}
if name != "" {
publish(name, v)
}
return v
} | go | func NewCounter(name string, help string) *Counter {
v := &Counter{help: help}
if name != "" {
publish(name, v)
}
return v
} | [
"func",
"NewCounter",
"(",
"name",
"string",
",",
"help",
"string",
")",
"*",
"Counter",
"{",
"v",
":=",
"&",
"Counter",
"{",
"help",
":",
"help",
"}",
"\n",
"if",
"name",
"!=",
"\"",
"\"",
"{",
"publish",
"(",
"name",
",",
"v",
")",
"\n",
"}",
... | // NewCounter returns a new Counter. | [
"NewCounter",
"returns",
"a",
"new",
"Counter",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/counter.go#L39-L45 |
158,032 | vitessio/vitess | go/stats/counter.go | Add | func (v *Counter) Add(delta int64) {
if delta < 0 {
logCounterNegative.Warningf("Adding a negative value to a counter, %v should be a gauge instead", v)
}
v.i.Add(delta)
} | go | func (v *Counter) Add(delta int64) {
if delta < 0 {
logCounterNegative.Warningf("Adding a negative value to a counter, %v should be a gauge instead", v)
}
v.i.Add(delta)
} | [
"func",
"(",
"v",
"*",
"Counter",
")",
"Add",
"(",
"delta",
"int64",
")",
"{",
"if",
"delta",
"<",
"0",
"{",
"logCounterNegative",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"v",
".",
"i",
".",
"Add",
"(",
"delta",
")",
... | // Add adds the provided value to the Counter. | [
"Add",
"adds",
"the",
"provided",
"value",
"to",
"the",
"Counter",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/counter.go#L48-L53 |
158,033 | vitessio/vitess | go/stats/counter.go | NewCounterFunc | func NewCounterFunc(name string, help string, f func() int64) *CounterFunc {
c := &CounterFunc{
F: f,
help: help,
}
if name != "" {
publish(name, c)
}
return c
} | go | func NewCounterFunc(name string, help string, f func() int64) *CounterFunc {
c := &CounterFunc{
F: f,
help: help,
}
if name != "" {
publish(name, c)
}
return c
} | [
"func",
"NewCounterFunc",
"(",
"name",
"string",
",",
"help",
"string",
",",
"f",
"func",
"(",
")",
"int64",
")",
"*",
"CounterFunc",
"{",
"c",
":=",
"&",
"CounterFunc",
"{",
"F",
":",
"f",
",",
"help",
":",
"help",
",",
"}",
"\n\n",
"if",
"name",
... | // NewCounterFunc creates a new CounterFunc instance and publishes it if name is
// set. | [
"NewCounterFunc",
"creates",
"a",
"new",
"CounterFunc",
"instance",
"and",
"publishes",
"it",
"if",
"name",
"is",
"set",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/counter.go#L85-L95 |
158,034 | vitessio/vitess | go/stats/counter.go | NewGauge | func NewGauge(name string, help string) *Gauge {
v := &Gauge{Counter: Counter{help: help}}
if name != "" {
publish(name, v)
}
return v
} | go | func NewGauge(name string, help string) *Gauge {
v := &Gauge{Counter: Counter{help: help}}
if name != "" {
publish(name, v)
}
return v
} | [
"func",
"NewGauge",
"(",
"name",
"string",
",",
"help",
"string",
")",
"*",
"Gauge",
"{",
"v",
":=",
"&",
"Gauge",
"{",
"Counter",
":",
"Counter",
"{",
"help",
":",
"help",
"}",
"}",
"\n\n",
"if",
"name",
"!=",
"\"",
"\"",
"{",
"publish",
"(",
"n... | // NewGauge creates a new Gauge and publishes it if name is set. | [
"NewGauge",
"creates",
"a",
"new",
"Gauge",
"and",
"publishes",
"it",
"if",
"name",
"is",
"set",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/counter.go#L116-L123 |
158,035 | vitessio/vitess | go/stats/counter.go | Set | func (v *Gauge) Set(value int64) {
v.Counter.i.Set(value)
} | go | func (v *Gauge) Set(value int64) {
v.Counter.i.Set(value)
} | [
"func",
"(",
"v",
"*",
"Gauge",
")",
"Set",
"(",
"value",
"int64",
")",
"{",
"v",
".",
"Counter",
".",
"i",
".",
"Set",
"(",
"value",
")",
"\n",
"}"
] | // Set overwrites the current value. | [
"Set",
"overwrites",
"the",
"current",
"value",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/counter.go#L126-L128 |
158,036 | vitessio/vitess | go/stats/counter.go | Add | func (v *Gauge) Add(delta int64) {
v.Counter.i.Add(delta)
} | go | func (v *Gauge) Add(delta int64) {
v.Counter.i.Add(delta)
} | [
"func",
"(",
"v",
"*",
"Gauge",
")",
"Add",
"(",
"delta",
"int64",
")",
"{",
"v",
".",
"Counter",
".",
"i",
".",
"Add",
"(",
"delta",
")",
"\n",
"}"
] | // Add adds the provided value to the Gauge. | [
"Add",
"adds",
"the",
"provided",
"value",
"to",
"the",
"Gauge",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/counter.go#L131-L133 |
158,037 | vitessio/vitess | go/stats/counter.go | NewGaugeFunc | func NewGaugeFunc(name string, help string, f func() int64) *GaugeFunc {
i := &GaugeFunc{
CounterFunc: CounterFunc{
F: f,
help: help,
}}
if name != "" {
publish(name, i)
}
return i
} | go | func NewGaugeFunc(name string, help string, f func() int64) *GaugeFunc {
i := &GaugeFunc{
CounterFunc: CounterFunc{
F: f,
help: help,
}}
if name != "" {
publish(name, i)
}
return i
} | [
"func",
"NewGaugeFunc",
"(",
"name",
"string",
",",
"help",
"string",
",",
"f",
"func",
"(",
")",
"int64",
")",
"*",
"GaugeFunc",
"{",
"i",
":=",
"&",
"GaugeFunc",
"{",
"CounterFunc",
":",
"CounterFunc",
"{",
"F",
":",
"f",
",",
"help",
":",
"help",
... | // NewGaugeFunc creates a new GaugeFunc instance and publishes it if name is
// set. | [
"NewGaugeFunc",
"creates",
"a",
"new",
"GaugeFunc",
"instance",
"and",
"publishes",
"it",
"if",
"name",
"is",
"set",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/counter.go#L145-L156 |
158,038 | vitessio/vitess | go/vt/vtctld/debug_health.go | RegisterDebugHealthHandler | func RegisterDebugHealthHandler(ts *topo.Server) {
http.HandleFunc("/debug/health", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.MONITORING); err != nil {
acl.SendError(w, err)
return
}
w.Header().Set("Content-Type", "text/plain")
if err := isHealthy(ts); err != nil {
w.Write([]byte("not ok"))
return
}
w.Write([]byte("ok"))
})
} | go | func RegisterDebugHealthHandler(ts *topo.Server) {
http.HandleFunc("/debug/health", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.MONITORING); err != nil {
acl.SendError(w, err)
return
}
w.Header().Set("Content-Type", "text/plain")
if err := isHealthy(ts); err != nil {
w.Write([]byte("not ok"))
return
}
w.Write([]byte("ok"))
})
} | [
"func",
"RegisterDebugHealthHandler",
"(",
"ts",
"*",
"topo",
".",
"Server",
")",
"{",
"http",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"err",
":=... | // RegisterDebugHealthHandler register a debug health http endpoint for a vtcld server | [
"RegisterDebugHealthHandler",
"register",
"a",
"debug",
"health",
"http",
"endpoint",
"for",
"a",
"vtcld",
"server"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/debug_health.go#L31-L44 |
158,039 | vitessio/vitess | go/vt/vttablet/tabletserver/schema/load_table.go | LoadTable | func LoadTable(conn *connpool.DBConn, tableName string, tableType string, comment string) (*Table, error) {
ta := NewTable(tableName)
sqlTableName := sqlparser.String(ta.Name)
if err := fetchColumns(ta, conn, sqlTableName); err != nil {
return nil, err
}
if err := fetchIndexes(ta, conn, sqlTableName); err != nil {
return nil, err
}
switch {
case strings.Contains(comment, "vitess_sequence"):
ta.Type = Sequence
ta.SequenceInfo = &SequenceInfo{}
case strings.Contains(comment, "vitess_message"):
if err := loadMessageInfo(ta, comment); err != nil {
return nil, err
}
ta.Type = Message
}
return ta, nil
} | go | func LoadTable(conn *connpool.DBConn, tableName string, tableType string, comment string) (*Table, error) {
ta := NewTable(tableName)
sqlTableName := sqlparser.String(ta.Name)
if err := fetchColumns(ta, conn, sqlTableName); err != nil {
return nil, err
}
if err := fetchIndexes(ta, conn, sqlTableName); err != nil {
return nil, err
}
switch {
case strings.Contains(comment, "vitess_sequence"):
ta.Type = Sequence
ta.SequenceInfo = &SequenceInfo{}
case strings.Contains(comment, "vitess_message"):
if err := loadMessageInfo(ta, comment); err != nil {
return nil, err
}
ta.Type = Message
}
return ta, nil
} | [
"func",
"LoadTable",
"(",
"conn",
"*",
"connpool",
".",
"DBConn",
",",
"tableName",
"string",
",",
"tableType",
"string",
",",
"comment",
"string",
")",
"(",
"*",
"Table",
",",
"error",
")",
"{",
"ta",
":=",
"NewTable",
"(",
"tableName",
")",
"\n",
"sq... | // LoadTable creates a Table from the schema info in the database. | [
"LoadTable",
"creates",
"a",
"Table",
"from",
"the",
"schema",
"info",
"in",
"the",
"database",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/load_table.go#L35-L55 |
158,040 | vitessio/vitess | go/vt/vttablet/tabletserver/rules/map.go | RegisterSource | func (qri *Map) RegisterSource(ruleSource string) {
qri.mu.Lock()
defer qri.mu.Unlock()
if _, existed := qri.queryRulesMap[ruleSource]; existed {
log.Errorf("Query rule source " + ruleSource + " has been registered")
panic("Query rule source " + ruleSource + " has been registered")
}
qri.queryRulesMap[ruleSource] = New()
} | go | func (qri *Map) RegisterSource(ruleSource string) {
qri.mu.Lock()
defer qri.mu.Unlock()
if _, existed := qri.queryRulesMap[ruleSource]; existed {
log.Errorf("Query rule source " + ruleSource + " has been registered")
panic("Query rule source " + ruleSource + " has been registered")
}
qri.queryRulesMap[ruleSource] = New()
} | [
"func",
"(",
"qri",
"*",
"Map",
")",
"RegisterSource",
"(",
"ruleSource",
"string",
")",
"{",
"qri",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"qri",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"_",
",",
"existed",
":=",
"qri",
".",
... | // RegisterSource registers a query rule source name with Map. | [
"RegisterSource",
"registers",
"a",
"query",
"rule",
"source",
"name",
"with",
"Map",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/rules/map.go#L45-L53 |
158,041 | vitessio/vitess | go/vt/vttablet/tabletserver/rules/map.go | UnRegisterSource | func (qri *Map) UnRegisterSource(ruleSource string) {
qri.mu.Lock()
defer qri.mu.Unlock()
delete(qri.queryRulesMap, ruleSource)
} | go | func (qri *Map) UnRegisterSource(ruleSource string) {
qri.mu.Lock()
defer qri.mu.Unlock()
delete(qri.queryRulesMap, ruleSource)
} | [
"func",
"(",
"qri",
"*",
"Map",
")",
"UnRegisterSource",
"(",
"ruleSource",
"string",
")",
"{",
"qri",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"qri",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"qri",
".",
"queryRulesMap",
","... | // UnRegisterSource removes a registered query rule source name. | [
"UnRegisterSource",
"removes",
"a",
"registered",
"query",
"rule",
"source",
"name",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/rules/map.go#L56-L60 |
158,042 | vitessio/vitess | go/vt/vttablet/tabletserver/rules/map.go | SetRules | func (qri *Map) SetRules(ruleSource string, newRules *Rules) error {
if newRules == nil {
newRules = New()
}
qri.mu.Lock()
defer qri.mu.Unlock()
if _, ok := qri.queryRulesMap[ruleSource]; ok {
qri.queryRulesMap[ruleSource] = newRules.Copy()
return nil
}
return errors.New("Rule source identifier " + ruleSource + " is not valid")
} | go | func (qri *Map) SetRules(ruleSource string, newRules *Rules) error {
if newRules == nil {
newRules = New()
}
qri.mu.Lock()
defer qri.mu.Unlock()
if _, ok := qri.queryRulesMap[ruleSource]; ok {
qri.queryRulesMap[ruleSource] = newRules.Copy()
return nil
}
return errors.New("Rule source identifier " + ruleSource + " is not valid")
} | [
"func",
"(",
"qri",
"*",
"Map",
")",
"SetRules",
"(",
"ruleSource",
"string",
",",
"newRules",
"*",
"Rules",
")",
"error",
"{",
"if",
"newRules",
"==",
"nil",
"{",
"newRules",
"=",
"New",
"(",
")",
"\n",
"}",
"\n",
"qri",
".",
"mu",
".",
"Lock",
... | // SetRules takes an external Rules structure and overwrite one of the
// internal Rules as designated by ruleSource parameter. | [
"SetRules",
"takes",
"an",
"external",
"Rules",
"structure",
"and",
"overwrite",
"one",
"of",
"the",
"internal",
"Rules",
"as",
"designated",
"by",
"ruleSource",
"parameter",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/rules/map.go#L64-L75 |
158,043 | vitessio/vitess | go/vt/vttablet/tabletserver/rules/map.go | Get | func (qri *Map) Get(ruleSource string) (*Rules, error) {
qri.mu.Lock()
defer qri.mu.Unlock()
if ruleset, ok := qri.queryRulesMap[ruleSource]; ok {
return ruleset.Copy(), nil
}
return New(), errors.New("Rule source identifier " + ruleSource + " is not valid")
} | go | func (qri *Map) Get(ruleSource string) (*Rules, error) {
qri.mu.Lock()
defer qri.mu.Unlock()
if ruleset, ok := qri.queryRulesMap[ruleSource]; ok {
return ruleset.Copy(), nil
}
return New(), errors.New("Rule source identifier " + ruleSource + " is not valid")
} | [
"func",
"(",
"qri",
"*",
"Map",
")",
"Get",
"(",
"ruleSource",
"string",
")",
"(",
"*",
"Rules",
",",
"error",
")",
"{",
"qri",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"qri",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"ruleset",
... | // Get returns the corresponding Rules as designated by ruleSource parameter. | [
"Get",
"returns",
"the",
"corresponding",
"Rules",
"as",
"designated",
"by",
"ruleSource",
"parameter",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/rules/map.go#L78-L85 |
158,044 | vitessio/vitess | go/vt/vttablet/tabletserver/rules/map.go | FilterByPlan | func (qri *Map) FilterByPlan(query string, planid planbuilder.PlanType, tableName string) (newqrs *Rules) {
qri.mu.Lock()
defer qri.mu.Unlock()
newqrs = New()
for _, rules := range qri.queryRulesMap {
newqrs.Append(rules.FilterByPlan(query, planid, tableName))
}
return newqrs
} | go | func (qri *Map) FilterByPlan(query string, planid planbuilder.PlanType, tableName string) (newqrs *Rules) {
qri.mu.Lock()
defer qri.mu.Unlock()
newqrs = New()
for _, rules := range qri.queryRulesMap {
newqrs.Append(rules.FilterByPlan(query, planid, tableName))
}
return newqrs
} | [
"func",
"(",
"qri",
"*",
"Map",
")",
"FilterByPlan",
"(",
"query",
"string",
",",
"planid",
"planbuilder",
".",
"PlanType",
",",
"tableName",
"string",
")",
"(",
"newqrs",
"*",
"Rules",
")",
"{",
"qri",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer"... | // FilterByPlan creates a new Rules by prefiltering on all query rules that are contained in internal
// Rules structures, in other words, query rules from all predefined sources will be applied. | [
"FilterByPlan",
"creates",
"a",
"new",
"Rules",
"by",
"prefiltering",
"on",
"all",
"query",
"rules",
"that",
"are",
"contained",
"in",
"internal",
"Rules",
"structures",
"in",
"other",
"words",
"query",
"rules",
"from",
"all",
"predefined",
"sources",
"will",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/rules/map.go#L89-L97 |
158,045 | vitessio/vitess | go/vt/topotools/tablet.go | ConfigureTabletHook | func ConfigureTabletHook(hk *hook.Hook, tabletAlias *topodatapb.TabletAlias) {
if hk.ExtraEnv == nil {
hk.ExtraEnv = make(map[string]string, 1)
}
hk.ExtraEnv["TABLET_ALIAS"] = topoproto.TabletAliasString(tabletAlias)
} | go | func ConfigureTabletHook(hk *hook.Hook, tabletAlias *topodatapb.TabletAlias) {
if hk.ExtraEnv == nil {
hk.ExtraEnv = make(map[string]string, 1)
}
hk.ExtraEnv["TABLET_ALIAS"] = topoproto.TabletAliasString(tabletAlias)
} | [
"func",
"ConfigureTabletHook",
"(",
"hk",
"*",
"hook",
".",
"Hook",
",",
"tabletAlias",
"*",
"topodatapb",
".",
"TabletAlias",
")",
"{",
"if",
"hk",
".",
"ExtraEnv",
"==",
"nil",
"{",
"hk",
".",
"ExtraEnv",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
... | // ConfigureTabletHook configures the right parameters for a hook
// running locally on a tablet. | [
"ConfigureTabletHook",
"configures",
"the",
"right",
"parameters",
"for",
"a",
"hook",
"running",
"locally",
"on",
"a",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/tablet.go#L53-L58 |
158,046 | vitessio/vitess | go/vt/topotools/tablet.go | ChangeType | func ChangeType(ctx context.Context, ts *topo.Server, tabletAlias *topodatapb.TabletAlias, newType topodatapb.TabletType) (*topodatapb.Tablet, error) {
return ts.UpdateTabletFields(ctx, tabletAlias, func(tablet *topodatapb.Tablet) error {
tablet.Type = newType
return nil
})
} | go | func ChangeType(ctx context.Context, ts *topo.Server, tabletAlias *topodatapb.TabletAlias, newType topodatapb.TabletType) (*topodatapb.Tablet, error) {
return ts.UpdateTabletFields(ctx, tabletAlias, func(tablet *topodatapb.Tablet) error {
tablet.Type = newType
return nil
})
} | [
"func",
"ChangeType",
"(",
"ctx",
"context",
".",
"Context",
",",
"ts",
"*",
"topo",
".",
"Server",
",",
"tabletAlias",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"newType",
"topodatapb",
".",
"TabletType",
")",
"(",
"*",
"topodatapb",
".",
"Tablet",
",",... | // ChangeType changes the type of the tablet. Make this external, since these
// transitions need to be forced from time to time.
//
// If successful, the updated tablet record is returned. | [
"ChangeType",
"changes",
"the",
"type",
"of",
"the",
"tablet",
".",
"Make",
"this",
"external",
"since",
"these",
"transitions",
"need",
"to",
"be",
"forced",
"from",
"time",
"to",
"time",
".",
"If",
"successful",
"the",
"updated",
"tablet",
"record",
"is",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/tablet.go#L64-L69 |
158,047 | vitessio/vitess | go/vt/topotools/tablet.go | CheckOwnership | func CheckOwnership(oldTablet, newTablet *topodatapb.Tablet) error {
if oldTablet == nil || newTablet == nil {
return errors.New("unable to verify ownership of tablet record")
}
if oldTablet.Hostname != newTablet.Hostname || oldTablet.PortMap["vt"] != newTablet.PortMap["vt"] {
return fmt.Errorf(
"tablet record was taken over by another process: "+
"my address is %v:%v, but record is owned by %v:%v",
oldTablet.Hostname, oldTablet.PortMap["vt"], newTablet.Hostname, newTablet.PortMap["vt"])
}
return nil
} | go | func CheckOwnership(oldTablet, newTablet *topodatapb.Tablet) error {
if oldTablet == nil || newTablet == nil {
return errors.New("unable to verify ownership of tablet record")
}
if oldTablet.Hostname != newTablet.Hostname || oldTablet.PortMap["vt"] != newTablet.PortMap["vt"] {
return fmt.Errorf(
"tablet record was taken over by another process: "+
"my address is %v:%v, but record is owned by %v:%v",
oldTablet.Hostname, oldTablet.PortMap["vt"], newTablet.Hostname, newTablet.PortMap["vt"])
}
return nil
} | [
"func",
"CheckOwnership",
"(",
"oldTablet",
",",
"newTablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"error",
"{",
"if",
"oldTablet",
"==",
"nil",
"||",
"newTablet",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n... | // CheckOwnership returns nil iff the Hostname and port match on oldTablet and
// newTablet, which implies that no other tablet process has taken over the
// record. | [
"CheckOwnership",
"returns",
"nil",
"iff",
"the",
"Hostname",
"and",
"port",
"match",
"on",
"oldTablet",
"and",
"newTablet",
"which",
"implies",
"that",
"no",
"other",
"tablet",
"process",
"has",
"taken",
"over",
"the",
"record",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/tablet.go#L74-L85 |
158,048 | vitessio/vitess | go/vt/topotools/tablet.go | TabletIdent | func TabletIdent(tablet *topodatapb.Tablet) string {
tagStr := ""
if tablet.Tags != nil {
for key, val := range tablet.Tags {
tagStr = tagStr + fmt.Sprintf(" %s=%s", key, val)
}
}
return fmt.Sprintf("%s-%d (%s%s)", tablet.Alias.Cell, tablet.Alias.Uid, tablet.Hostname, tagStr)
} | go | func TabletIdent(tablet *topodatapb.Tablet) string {
tagStr := ""
if tablet.Tags != nil {
for key, val := range tablet.Tags {
tagStr = tagStr + fmt.Sprintf(" %s=%s", key, val)
}
}
return fmt.Sprintf("%s-%d (%s%s)", tablet.Alias.Cell, tablet.Alias.Uid, tablet.Hostname, tagStr)
} | [
"func",
"TabletIdent",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"string",
"{",
"tagStr",
":=",
"\"",
"\"",
"\n",
"if",
"tablet",
".",
"Tags",
"!=",
"nil",
"{",
"for",
"key",
",",
"val",
":=",
"range",
"tablet",
".",
"Tags",
"{",
"tagStr"... | // TabletIdent returns a concise string representation of this tablet. | [
"TabletIdent",
"returns",
"a",
"concise",
"string",
"representation",
"of",
"this",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/tablet.go#L107-L116 |
158,049 | vitessio/vitess | go/vt/topotools/tablet.go | TargetIdent | func TargetIdent(target *querypb.Target) string {
return fmt.Sprintf("%s/%s (%s)", target.Keyspace, target.Shard, target.TabletType)
} | go | func TargetIdent(target *querypb.Target) string {
return fmt.Sprintf("%s/%s (%s)", target.Keyspace, target.Shard, target.TabletType)
} | [
"func",
"TargetIdent",
"(",
"target",
"*",
"querypb",
".",
"Target",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"target",
".",
"Keyspace",
",",
"target",
".",
"Shard",
",",
"target",
".",
"TabletType",
")",
"\n",
"}"
] | // TargetIdent returns a concise string representation of a query target | [
"TargetIdent",
"returns",
"a",
"concise",
"string",
"representation",
"of",
"a",
"query",
"target"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/tablet.go#L119-L121 |
158,050 | vitessio/vitess | go/vt/topo/zk2topo/utils.go | CreateRecursive | func CreateRecursive(ctx context.Context, conn *ZkConn, zkPath string, value []byte, flags int32, aclv []zk.ACL, maxCreationDepth int) (string, error) {
pathCreated, err := conn.Create(ctx, zkPath, value, flags, aclv)
if err == zk.ErrNoNode {
if maxCreationDepth == 0 {
return "", zk.ErrNoNode
}
// Make sure that nodes are either "file" or
// "directory" to mirror file system semantics.
dirAclv := make([]zk.ACL, len(aclv))
for i, acl := range aclv {
dirAclv[i] = acl
dirAclv[i].Perms = PermDirectory
}
parentPath := path.Dir(zkPath)
_, err = CreateRecursive(ctx, conn, parentPath, nil, 0, dirAclv, maxCreationDepth-1)
if err != nil && err != zk.ErrNodeExists {
return "", err
}
pathCreated, err = conn.Create(ctx, zkPath, value, flags, aclv)
}
return pathCreated, err
} | go | func CreateRecursive(ctx context.Context, conn *ZkConn, zkPath string, value []byte, flags int32, aclv []zk.ACL, maxCreationDepth int) (string, error) {
pathCreated, err := conn.Create(ctx, zkPath, value, flags, aclv)
if err == zk.ErrNoNode {
if maxCreationDepth == 0 {
return "", zk.ErrNoNode
}
// Make sure that nodes are either "file" or
// "directory" to mirror file system semantics.
dirAclv := make([]zk.ACL, len(aclv))
for i, acl := range aclv {
dirAclv[i] = acl
dirAclv[i].Perms = PermDirectory
}
parentPath := path.Dir(zkPath)
_, err = CreateRecursive(ctx, conn, parentPath, nil, 0, dirAclv, maxCreationDepth-1)
if err != nil && err != zk.ErrNodeExists {
return "", err
}
pathCreated, err = conn.Create(ctx, zkPath, value, flags, aclv)
}
return pathCreated, err
} | [
"func",
"CreateRecursive",
"(",
"ctx",
"context",
".",
"Context",
",",
"conn",
"*",
"ZkConn",
",",
"zkPath",
"string",
",",
"value",
"[",
"]",
"byte",
",",
"flags",
"int32",
",",
"aclv",
"[",
"]",
"zk",
".",
"ACL",
",",
"maxCreationDepth",
"int",
")",
... | // CreateRecursive is a helper function on top of Create. It will
// create a path and any pieces required, think mkdir -p.
// Intermediate znodes are always created empty.
// Pass maxCreationDepth=-1 to create all nodes to the top. | [
"CreateRecursive",
"is",
"a",
"helper",
"function",
"on",
"top",
"of",
"Create",
".",
"It",
"will",
"create",
"a",
"path",
"and",
"any",
"pieces",
"required",
"think",
"mkdir",
"-",
"p",
".",
"Intermediate",
"znodes",
"are",
"always",
"created",
"empty",
"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/utils.go#L38-L60 |
158,051 | vitessio/vitess | go/vt/topo/zk2topo/utils.go | ChildrenRecursive | func ChildrenRecursive(ctx context.Context, zconn *ZkConn, zkPath string) ([]string, error) {
var err error
mutex := sync.Mutex{}
wg := sync.WaitGroup{}
pathList := make([]string, 0, 32)
children, _, err := zconn.Children(ctx, zkPath)
if err != nil {
return nil, err
}
for _, child := range children {
wg.Add(1)
go func(child string) {
childPath := path.Join(zkPath, child)
rChildren, zkErr := ChildrenRecursive(ctx, zconn, childPath)
if zkErr != nil {
// If other processes are deleting nodes, we need to ignore
// the missing nodes.
if zkErr != zk.ErrNoNode {
mutex.Lock()
err = zkErr
mutex.Unlock()
}
} else {
mutex.Lock()
pathList = append(pathList, child)
for _, rChild := range rChildren {
pathList = append(pathList, path.Join(child, rChild))
}
mutex.Unlock()
}
wg.Done()
}(child)
}
wg.Wait()
mutex.Lock()
defer mutex.Unlock()
if err != nil {
return nil, err
}
return pathList, nil
} | go | func ChildrenRecursive(ctx context.Context, zconn *ZkConn, zkPath string) ([]string, error) {
var err error
mutex := sync.Mutex{}
wg := sync.WaitGroup{}
pathList := make([]string, 0, 32)
children, _, err := zconn.Children(ctx, zkPath)
if err != nil {
return nil, err
}
for _, child := range children {
wg.Add(1)
go func(child string) {
childPath := path.Join(zkPath, child)
rChildren, zkErr := ChildrenRecursive(ctx, zconn, childPath)
if zkErr != nil {
// If other processes are deleting nodes, we need to ignore
// the missing nodes.
if zkErr != zk.ErrNoNode {
mutex.Lock()
err = zkErr
mutex.Unlock()
}
} else {
mutex.Lock()
pathList = append(pathList, child)
for _, rChild := range rChildren {
pathList = append(pathList, path.Join(child, rChild))
}
mutex.Unlock()
}
wg.Done()
}(child)
}
wg.Wait()
mutex.Lock()
defer mutex.Unlock()
if err != nil {
return nil, err
}
return pathList, nil
} | [
"func",
"ChildrenRecursive",
"(",
"ctx",
"context",
".",
"Context",
",",
"zconn",
"*",
"ZkConn",
",",
"zkPath",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"mutex",
":=",
"sync",
".",
"Mutex",
"{",
"}"... | // ChildrenRecursive returns the relative path of all the children of
// the provided node. | [
"ChildrenRecursive",
"returns",
"the",
"relative",
"path",
"of",
"all",
"the",
"children",
"of",
"the",
"provided",
"node",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/utils.go#L64-L107 |
158,052 | vitessio/vitess | go/vt/topo/zk2topo/utils.go | DeleteRecursive | func DeleteRecursive(ctx context.Context, zconn *ZkConn, zkPath string, version int32) error {
// version: -1 delete any version of the node at path - only applies to the top node
err := zconn.Delete(ctx, zkPath, version)
if err == nil {
return nil
}
if err != zk.ErrNotEmpty {
return err
}
// Remove the ability for other nodes to get created while we are trying to delete.
// Otherwise, you can enter a race condition, or get starved out from deleting.
err = zconn.SetACL(ctx, zkPath, zk.WorldACL(zk.PermAdmin|zk.PermDelete|zk.PermRead), version)
if err != nil {
return err
}
children, _, err := zconn.Children(ctx, zkPath)
if err != nil {
return err
}
for _, child := range children {
err := DeleteRecursive(ctx, zconn, path.Join(zkPath, child), -1)
if err != nil && err != zk.ErrNoNode {
return vterrors.Wrapf(err, "DeleteRecursive: recursive delete failed")
}
}
err = zconn.Delete(ctx, zkPath, version)
if err != nil && err != zk.ErrNotEmpty {
err = fmt.Errorf("DeleteRecursive: nodes getting recreated underneath delete (app race condition): %v", zkPath)
}
return err
} | go | func DeleteRecursive(ctx context.Context, zconn *ZkConn, zkPath string, version int32) error {
// version: -1 delete any version of the node at path - only applies to the top node
err := zconn.Delete(ctx, zkPath, version)
if err == nil {
return nil
}
if err != zk.ErrNotEmpty {
return err
}
// Remove the ability for other nodes to get created while we are trying to delete.
// Otherwise, you can enter a race condition, or get starved out from deleting.
err = zconn.SetACL(ctx, zkPath, zk.WorldACL(zk.PermAdmin|zk.PermDelete|zk.PermRead), version)
if err != nil {
return err
}
children, _, err := zconn.Children(ctx, zkPath)
if err != nil {
return err
}
for _, child := range children {
err := DeleteRecursive(ctx, zconn, path.Join(zkPath, child), -1)
if err != nil && err != zk.ErrNoNode {
return vterrors.Wrapf(err, "DeleteRecursive: recursive delete failed")
}
}
err = zconn.Delete(ctx, zkPath, version)
if err != nil && err != zk.ErrNotEmpty {
err = fmt.Errorf("DeleteRecursive: nodes getting recreated underneath delete (app race condition): %v", zkPath)
}
return err
} | [
"func",
"DeleteRecursive",
"(",
"ctx",
"context",
".",
"Context",
",",
"zconn",
"*",
"ZkConn",
",",
"zkPath",
"string",
",",
"version",
"int32",
")",
"error",
"{",
"// version: -1 delete any version of the node at path - only applies to the top node",
"err",
":=",
"zcon... | // DeleteRecursive will delete all children of the given path. | [
"DeleteRecursive",
"will",
"delete",
"all",
"children",
"of",
"the",
"given",
"path",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/utils.go#L255-L286 |
158,053 | vitessio/vitess | go/vt/topo/zk2topo/utils.go | obtainQueueLock | func obtainQueueLock(ctx context.Context, conn *ZkConn, zkPath string) error {
queueNode := path.Dir(zkPath)
lockNode := path.Base(zkPath)
for {
// Get our siblings.
children, _, err := conn.Children(ctx, queueNode)
if err != nil {
return vterrors.Wrap(err, "obtainQueueLock: trylock failed %v")
}
sort.Strings(children)
if len(children) == 0 {
return fmt.Errorf("obtainQueueLock: empty queue node: %v", queueNode)
}
// If we are the first node, we got the lock.
if children[0] == lockNode {
return nil
}
// If not, find the previous node.
prevLock := ""
for i := 1; i < len(children); i++ {
if children[i] == lockNode {
prevLock = children[i-1]
break
}
}
if prevLock == "" {
return fmt.Errorf("obtainQueueLock: no previous queue node found: %v", zkPath)
}
// Set a watch on the previous node.
zkPrevLock := path.Join(queueNode, prevLock)
exists, _, watch, err := conn.ExistsW(ctx, zkPrevLock)
if err != nil {
return vterrors.Wrapf(err, "obtainQueueLock: unable to watch queued node %v", zkPrevLock)
}
if !exists {
// The lock disappeared, try to read again.
continue
}
select {
case <-ctx.Done():
return ctx.Err()
case <-watch:
// Something happened to the previous lock.
// It doesn't matter what, read again.
}
}
} | go | func obtainQueueLock(ctx context.Context, conn *ZkConn, zkPath string) error {
queueNode := path.Dir(zkPath)
lockNode := path.Base(zkPath)
for {
// Get our siblings.
children, _, err := conn.Children(ctx, queueNode)
if err != nil {
return vterrors.Wrap(err, "obtainQueueLock: trylock failed %v")
}
sort.Strings(children)
if len(children) == 0 {
return fmt.Errorf("obtainQueueLock: empty queue node: %v", queueNode)
}
// If we are the first node, we got the lock.
if children[0] == lockNode {
return nil
}
// If not, find the previous node.
prevLock := ""
for i := 1; i < len(children); i++ {
if children[i] == lockNode {
prevLock = children[i-1]
break
}
}
if prevLock == "" {
return fmt.Errorf("obtainQueueLock: no previous queue node found: %v", zkPath)
}
// Set a watch on the previous node.
zkPrevLock := path.Join(queueNode, prevLock)
exists, _, watch, err := conn.ExistsW(ctx, zkPrevLock)
if err != nil {
return vterrors.Wrapf(err, "obtainQueueLock: unable to watch queued node %v", zkPrevLock)
}
if !exists {
// The lock disappeared, try to read again.
continue
}
select {
case <-ctx.Done():
return ctx.Err()
case <-watch:
// Something happened to the previous lock.
// It doesn't matter what, read again.
}
}
} | [
"func",
"obtainQueueLock",
"(",
"ctx",
"context",
".",
"Context",
",",
"conn",
"*",
"ZkConn",
",",
"zkPath",
"string",
")",
"error",
"{",
"queueNode",
":=",
"path",
".",
"Dir",
"(",
"zkPath",
")",
"\n",
"lockNode",
":=",
"path",
".",
"Base",
"(",
"zkPa... | // obtainQueueLock waits until we hold the lock in the provided path.
// The lexically lowest node is the lock holder - verify that this
// path holds the lock. Call this queue-lock because the semantics are
// a hybrid. Normal Zookeeper locks make assumptions about sequential
// numbering that don't hold when the data in a lock is modified. | [
"obtainQueueLock",
"waits",
"until",
"we",
"hold",
"the",
"lock",
"in",
"the",
"provided",
"path",
".",
"The",
"lexically",
"lowest",
"node",
"is",
"the",
"lock",
"holder",
"-",
"verify",
"that",
"this",
"path",
"holds",
"the",
"lock",
".",
"Call",
"this",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/zk2topo/utils.go#L293-L343 |
158,054 | vitessio/vitess | go/vt/worker/result_merger.go | NewResultMerger | func NewResultMerger(inputs []ResultReader, pkFieldCount int) (*ResultMerger, error) {
if len(inputs) < 2 {
panic("ResultMerger requires at least two ResultReaders as input")
}
fields := inputs[0].Fields()
if err := checkFieldsEqual(fields, inputs); err != nil {
return nil, err
}
err := CheckValidTypesForResultMerger(fields, pkFieldCount)
if err != nil {
return nil, vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "invalid PK types for ResultMerger. Use the vtworker LegacySplitClone command instead. %v", err.Error())
}
// Initialize the priority queue with all input ResultReader which have at
// least one row.
var activeInputs []ResultReader
nextRowHeap := newNextRowHeap(fields, pkFieldCount)
for i, input := range inputs {
nextRow := newNextRow(input)
if err := nextRow.next(); err != nil {
if err == io.EOF {
continue
}
return nil, vterrors.Wrapf(err, "failed to read from input at index: %v ResultReader: %v err", i, input)
}
activeInputs = append(activeInputs, input)
heap.Push(nextRowHeap, nextRow)
}
rm := &ResultMerger{
inputs: activeInputs,
allInputs: inputs,
fields: fields,
nextRowHeap: nextRowHeap,
}
rm.reset()
return rm, nil
} | go | func NewResultMerger(inputs []ResultReader, pkFieldCount int) (*ResultMerger, error) {
if len(inputs) < 2 {
panic("ResultMerger requires at least two ResultReaders as input")
}
fields := inputs[0].Fields()
if err := checkFieldsEqual(fields, inputs); err != nil {
return nil, err
}
err := CheckValidTypesForResultMerger(fields, pkFieldCount)
if err != nil {
return nil, vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "invalid PK types for ResultMerger. Use the vtworker LegacySplitClone command instead. %v", err.Error())
}
// Initialize the priority queue with all input ResultReader which have at
// least one row.
var activeInputs []ResultReader
nextRowHeap := newNextRowHeap(fields, pkFieldCount)
for i, input := range inputs {
nextRow := newNextRow(input)
if err := nextRow.next(); err != nil {
if err == io.EOF {
continue
}
return nil, vterrors.Wrapf(err, "failed to read from input at index: %v ResultReader: %v err", i, input)
}
activeInputs = append(activeInputs, input)
heap.Push(nextRowHeap, nextRow)
}
rm := &ResultMerger{
inputs: activeInputs,
allInputs: inputs,
fields: fields,
nextRowHeap: nextRowHeap,
}
rm.reset()
return rm, nil
} | [
"func",
"NewResultMerger",
"(",
"inputs",
"[",
"]",
"ResultReader",
",",
"pkFieldCount",
"int",
")",
"(",
"*",
"ResultMerger",
",",
"error",
")",
"{",
"if",
"len",
"(",
"inputs",
")",
"<",
"2",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
... | // NewResultMerger returns a new ResultMerger. | [
"NewResultMerger",
"returns",
"a",
"new",
"ResultMerger",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/result_merger.go#L63-L103 |
158,055 | vitessio/vitess | go/vt/worker/result_merger.go | CheckValidTypesForResultMerger | func CheckValidTypesForResultMerger(fields []*querypb.Field, pkFieldCount int) error {
for i := 0; i < pkFieldCount; i++ {
typ := fields[i].Type
if !sqltypes.IsIntegral(typ) && !sqltypes.IsFloat(typ) && !sqltypes.IsBinary(typ) {
return vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "unsupported type: %v cannot compare fields with this type", typ)
}
}
return nil
} | go | func CheckValidTypesForResultMerger(fields []*querypb.Field, pkFieldCount int) error {
for i := 0; i < pkFieldCount; i++ {
typ := fields[i].Type
if !sqltypes.IsIntegral(typ) && !sqltypes.IsFloat(typ) && !sqltypes.IsBinary(typ) {
return vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "unsupported type: %v cannot compare fields with this type", typ)
}
}
return nil
} | [
"func",
"CheckValidTypesForResultMerger",
"(",
"fields",
"[",
"]",
"*",
"querypb",
".",
"Field",
",",
"pkFieldCount",
"int",
")",
"error",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"pkFieldCount",
";",
"i",
"++",
"{",
"typ",
":=",
"fields",
"[",
"i",
... | // CheckValidTypesForResultMerger returns an error if the provided fields are not compatible with how ResultMerger works | [
"CheckValidTypesForResultMerger",
"returns",
"an",
"error",
"if",
"the",
"provided",
"fields",
"are",
"not",
"compatible",
"with",
"how",
"ResultMerger",
"works"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/result_merger.go#L106-L114 |
158,056 | vitessio/vitess | go/vt/worker/result_merger.go | Next | func (rm *ResultMerger) Next() (*sqltypes.Result, error) {
// All input readers were consumed during a merge. Return end of stream.
if len(rm.inputs) == 0 {
return nil, io.EOF
}
// Endgame mode if there is exactly one input left.
if len(rm.inputs) == 1 && rm.lastRowReaderDrained {
return rm.inputs[0].Next()
}
// Current output buffer is not full and there is more than one input left.
// Keep merging rows from the inputs using the priority queue.
for len(rm.output) < ResultSizeRows && len(rm.inputs) != 0 {
// Get the next smallest row.
next := heap.Pop(rm.nextRowHeap).(*nextRow)
// Add it to the output.
rm.output = append(rm.output, next.row)
// Check if the input we just popped has more rows.
if err := next.next(); err != nil {
if err == io.EOF {
// No more rows. Delete this input ResultReader from "inputs".
rm.deleteInput(next.input)
if len(rm.inputs) == 1 {
// We just deleted the second last ResultReader from "inputs" i.e.
// only one input is left. Tell the last input's RowReader to stop
// processing new Results after the current Result. Once we read the
// remaining rows, we can switch to the endgame mode where we read the
// Result directly from the input.
lastNextRow := heap.Pop(rm.nextRowHeap).(*nextRow)
lastNextRow.rowReader.StopAfterCurrentResult()
heap.Push(rm.nextRowHeap, lastNextRow)
}
// Do not add back the deleted input to the priority queue.
continue
} else if err == ErrStoppedRowReader {
// Endgame mode: We just consumed all rows from the last input.
// Switch to a faster mode where we read Results from the input instead
// of reading rows from the RowReader.
rm.lastRowReaderDrained = true
break
} else {
return nil, vterrors.Wrapf(err, "failed to read from input ResultReader: %v err", next.input)
}
}
// Input has more rows. Add it back to the priority queue.
heap.Push(rm.nextRowHeap, next)
}
result := &sqltypes.Result{
Fields: rm.fields,
RowsAffected: uint64(len(rm.output)),
Rows: rm.output,
}
rm.reset()
return result, nil
} | go | func (rm *ResultMerger) Next() (*sqltypes.Result, error) {
// All input readers were consumed during a merge. Return end of stream.
if len(rm.inputs) == 0 {
return nil, io.EOF
}
// Endgame mode if there is exactly one input left.
if len(rm.inputs) == 1 && rm.lastRowReaderDrained {
return rm.inputs[0].Next()
}
// Current output buffer is not full and there is more than one input left.
// Keep merging rows from the inputs using the priority queue.
for len(rm.output) < ResultSizeRows && len(rm.inputs) != 0 {
// Get the next smallest row.
next := heap.Pop(rm.nextRowHeap).(*nextRow)
// Add it to the output.
rm.output = append(rm.output, next.row)
// Check if the input we just popped has more rows.
if err := next.next(); err != nil {
if err == io.EOF {
// No more rows. Delete this input ResultReader from "inputs".
rm.deleteInput(next.input)
if len(rm.inputs) == 1 {
// We just deleted the second last ResultReader from "inputs" i.e.
// only one input is left. Tell the last input's RowReader to stop
// processing new Results after the current Result. Once we read the
// remaining rows, we can switch to the endgame mode where we read the
// Result directly from the input.
lastNextRow := heap.Pop(rm.nextRowHeap).(*nextRow)
lastNextRow.rowReader.StopAfterCurrentResult()
heap.Push(rm.nextRowHeap, lastNextRow)
}
// Do not add back the deleted input to the priority queue.
continue
} else if err == ErrStoppedRowReader {
// Endgame mode: We just consumed all rows from the last input.
// Switch to a faster mode where we read Results from the input instead
// of reading rows from the RowReader.
rm.lastRowReaderDrained = true
break
} else {
return nil, vterrors.Wrapf(err, "failed to read from input ResultReader: %v err", next.input)
}
}
// Input has more rows. Add it back to the priority queue.
heap.Push(rm.nextRowHeap, next)
}
result := &sqltypes.Result{
Fields: rm.fields,
RowsAffected: uint64(len(rm.output)),
Rows: rm.output,
}
rm.reset()
return result, nil
} | [
"func",
"(",
"rm",
"*",
"ResultMerger",
")",
"Next",
"(",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"// All input readers were consumed during a merge. Return end of stream.",
"if",
"len",
"(",
"rm",
".",
"inputs",
")",
"==",
"0",
"{",
... | // Next returns the next Result in the sorted, merged stream.
// It is part of the ResultReader interface. | [
"Next",
"returns",
"the",
"next",
"Result",
"in",
"the",
"sorted",
"merged",
"stream",
".",
"It",
"is",
"part",
"of",
"the",
"ResultReader",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/result_merger.go#L124-L182 |
158,057 | vitessio/vitess | go/vt/worker/result_merger.go | Close | func (rm *ResultMerger) Close(ctx context.Context) {
for _, i := range rm.allInputs {
i.Close(ctx)
}
} | go | func (rm *ResultMerger) Close(ctx context.Context) {
for _, i := range rm.allInputs {
i.Close(ctx)
}
} | [
"func",
"(",
"rm",
"*",
"ResultMerger",
")",
"Close",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"rm",
".",
"allInputs",
"{",
"i",
".",
"Close",
"(",
"ctx",
")",
"\n",
"}",
"\n",
"}"
] | // Close closes all inputs | [
"Close",
"closes",
"all",
"inputs"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/result_merger.go#L185-L189 |
158,058 | vitessio/vitess | go/vt/worker/result_merger.go | next | func (n *nextRow) next() error {
var err error
n.row, err = n.rowReader.Next()
if err != nil {
return err
}
if n.row == nil {
return io.EOF
}
return nil
} | go | func (n *nextRow) next() error {
var err error
n.row, err = n.rowReader.Next()
if err != nil {
return err
}
if n.row == nil {
return io.EOF
}
return nil
} | [
"func",
"(",
"n",
"*",
"nextRow",
")",
"next",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"n",
".",
"row",
",",
"err",
"=",
"n",
".",
"rowReader",
".",
"Next",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}... | // next reads the next row from the input. It returns io.EOF if the input stream
// has ended. | [
"next",
"reads",
"the",
"next",
"row",
"from",
"the",
"input",
".",
"It",
"returns",
"io",
".",
"EOF",
"if",
"the",
"input",
"stream",
"has",
"ended",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/result_merger.go#L247-L257 |
158,059 | vitessio/vitess | go/vt/wrangler/validator.go | waitForResults | func (wr *Wrangler) waitForResults(wg *sync.WaitGroup, results chan error) error {
go func() {
wg.Wait()
close(results)
}()
var finalErr error
for err := range results {
finalErr = errors.New("some validation errors - see log")
wr.Logger().Error(err)
}
return finalErr
} | go | func (wr *Wrangler) waitForResults(wg *sync.WaitGroup, results chan error) error {
go func() {
wg.Wait()
close(results)
}()
var finalErr error
for err := range results {
finalErr = errors.New("some validation errors - see log")
wr.Logger().Error(err)
}
return finalErr
} | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"waitForResults",
"(",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"results",
"chan",
"error",
")",
"error",
"{",
"go",
"func",
"(",
")",
"{",
"wg",
".",
"Wait",
"(",
")",
"\n",
"close",
"(",
"results",
")",
... | // As with all distributed systems, things can skew. These functions
// explore data in topology server and attempt to square that with reality.
//
// Given the node counts are usually large, this work should be done
// with as much parallelism as is viable.
//
// This may eventually move into a separate package.
// waitForResults will wait for all the errors to come back.
// There is no timeout, as individual calls will use the context and timeout
// and fail at the end anyway. | [
"As",
"with",
"all",
"distributed",
"systems",
"things",
"can",
"skew",
".",
"These",
"functions",
"explore",
"data",
"in",
"topology",
"server",
"and",
"attempt",
"to",
"square",
"that",
"with",
"reality",
".",
"Given",
"the",
"node",
"counts",
"are",
"usua... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/validator.go#L43-L55 |
158,060 | vitessio/vitess | go/vt/wrangler/validator.go | validateAllTablets | func (wr *Wrangler) validateAllTablets(ctx context.Context, wg *sync.WaitGroup, results chan<- error) {
cellSet := make(map[string]bool, 16)
keyspaces, err := wr.ts.GetKeyspaces(ctx)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetKeyspaces failed: %v", err)
return
}
for _, keyspace := range keyspaces {
shards, err := wr.ts.GetShardNames(ctx, keyspace)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetShardNames(%v) failed: %v", keyspace, err)
return
}
for _, shard := range shards {
aliases, err := wr.ts.FindAllTabletAliasesInShard(ctx, keyspace, shard)
if err != nil {
results <- fmt.Errorf("TopologyServer.FindAllTabletAliasesInShard(%v, %v) failed: %v", keyspace, shard, err)
return
}
for _, alias := range aliases {
cellSet[alias.Cell] = true
}
}
}
for cell := range cellSet {
aliases, err := wr.ts.GetTabletsByCell(ctx, cell)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetTabletsByCell(%v) failed: %v", cell, err)
continue
}
for _, alias := range aliases {
wg.Add(1)
go func(alias *topodatapb.TabletAlias) {
defer wg.Done()
if err := topo.Validate(ctx, wr.ts, alias); err != nil {
results <- fmt.Errorf("topo.Validate(%v) failed: %v", topoproto.TabletAliasString(alias), err)
} else {
wr.Logger().Infof("tablet %v is valid", topoproto.TabletAliasString(alias))
}
}(alias)
}
}
} | go | func (wr *Wrangler) validateAllTablets(ctx context.Context, wg *sync.WaitGroup, results chan<- error) {
cellSet := make(map[string]bool, 16)
keyspaces, err := wr.ts.GetKeyspaces(ctx)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetKeyspaces failed: %v", err)
return
}
for _, keyspace := range keyspaces {
shards, err := wr.ts.GetShardNames(ctx, keyspace)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetShardNames(%v) failed: %v", keyspace, err)
return
}
for _, shard := range shards {
aliases, err := wr.ts.FindAllTabletAliasesInShard(ctx, keyspace, shard)
if err != nil {
results <- fmt.Errorf("TopologyServer.FindAllTabletAliasesInShard(%v, %v) failed: %v", keyspace, shard, err)
return
}
for _, alias := range aliases {
cellSet[alias.Cell] = true
}
}
}
for cell := range cellSet {
aliases, err := wr.ts.GetTabletsByCell(ctx, cell)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetTabletsByCell(%v) failed: %v", cell, err)
continue
}
for _, alias := range aliases {
wg.Add(1)
go func(alias *topodatapb.TabletAlias) {
defer wg.Done()
if err := topo.Validate(ctx, wr.ts, alias); err != nil {
results <- fmt.Errorf("topo.Validate(%v) failed: %v", topoproto.TabletAliasString(alias), err)
} else {
wr.Logger().Infof("tablet %v is valid", topoproto.TabletAliasString(alias))
}
}(alias)
}
}
} | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"validateAllTablets",
"(",
"ctx",
"context",
".",
"Context",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"results",
"chan",
"<-",
"error",
")",
"{",
"cellSet",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
... | // Validate all tablets in all discoverable cells, even if they are
// not in the replication graph. | [
"Validate",
"all",
"tablets",
"in",
"all",
"discoverable",
"cells",
"even",
"if",
"they",
"are",
"not",
"in",
"the",
"replication",
"graph",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/validator.go#L59-L105 |
158,061 | vitessio/vitess | go/vt/wrangler/validator.go | Validate | func (wr *Wrangler) Validate(ctx context.Context, pingTablets bool) error {
// Results from various actions feed here.
results := make(chan error, 16)
wg := &sync.WaitGroup{}
// Validate all tablets in all cells, even if they are not discoverable
// by the replication graph.
wg.Add(1)
go func() {
defer wg.Done()
wr.validateAllTablets(ctx, wg, results)
}()
// Validate replication graph by traversing each keyspace and then each shard.
keyspaces, err := wr.ts.GetKeyspaces(ctx)
if err != nil {
results <- fmt.Errorf("GetKeyspaces failed: %v", err)
} else {
for _, keyspace := range keyspaces {
wg.Add(1)
go func(keyspace string) {
defer wg.Done()
wr.validateKeyspace(ctx, keyspace, pingTablets, wg, results)
}(keyspace)
}
}
return wr.waitForResults(wg, results)
} | go | func (wr *Wrangler) Validate(ctx context.Context, pingTablets bool) error {
// Results from various actions feed here.
results := make(chan error, 16)
wg := &sync.WaitGroup{}
// Validate all tablets in all cells, even if they are not discoverable
// by the replication graph.
wg.Add(1)
go func() {
defer wg.Done()
wr.validateAllTablets(ctx, wg, results)
}()
// Validate replication graph by traversing each keyspace and then each shard.
keyspaces, err := wr.ts.GetKeyspaces(ctx)
if err != nil {
results <- fmt.Errorf("GetKeyspaces failed: %v", err)
} else {
for _, keyspace := range keyspaces {
wg.Add(1)
go func(keyspace string) {
defer wg.Done()
wr.validateKeyspace(ctx, keyspace, pingTablets, wg, results)
}(keyspace)
}
}
return wr.waitForResults(wg, results)
} | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"Validate",
"(",
"ctx",
"context",
".",
"Context",
",",
"pingTablets",
"bool",
")",
"error",
"{",
"// Results from various actions feed here.",
"results",
":=",
"make",
"(",
"chan",
"error",
",",
"16",
")",
"\n",
"wg"... | // Validate a whole TopologyServer tree | [
"Validate",
"a",
"whole",
"TopologyServer",
"tree"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/validator.go#L262-L289 |
158,062 | vitessio/vitess | go/vt/wrangler/validator.go | ValidateKeyspace | func (wr *Wrangler) ValidateKeyspace(ctx context.Context, keyspace string, pingTablets bool) error {
wg := &sync.WaitGroup{}
results := make(chan error, 16)
wg.Add(1)
go func() {
defer wg.Done()
wr.validateKeyspace(ctx, keyspace, pingTablets, wg, results)
}()
return wr.waitForResults(wg, results)
} | go | func (wr *Wrangler) ValidateKeyspace(ctx context.Context, keyspace string, pingTablets bool) error {
wg := &sync.WaitGroup{}
results := make(chan error, 16)
wg.Add(1)
go func() {
defer wg.Done()
wr.validateKeyspace(ctx, keyspace, pingTablets, wg, results)
}()
return wr.waitForResults(wg, results)
} | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"ValidateKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"pingTablets",
"bool",
")",
"error",
"{",
"wg",
":=",
"&",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"results",
":=",
"m... | // ValidateKeyspace will validate a bunch of information in a keyspace
// is correct. | [
"ValidateKeyspace",
"will",
"validate",
"a",
"bunch",
"of",
"information",
"in",
"a",
"keyspace",
"is",
"correct",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/validator.go#L293-L302 |
158,063 | vitessio/vitess | go/vt/wrangler/validator.go | ValidateShard | func (wr *Wrangler) ValidateShard(ctx context.Context, keyspace, shard string, pingTablets bool) error {
wg := &sync.WaitGroup{}
results := make(chan error, 16)
wg.Add(1)
go func() {
defer wg.Done()
wr.validateShard(ctx, keyspace, shard, pingTablets, wg, results)
}()
return wr.waitForResults(wg, results)
} | go | func (wr *Wrangler) ValidateShard(ctx context.Context, keyspace, shard string, pingTablets bool) error {
wg := &sync.WaitGroup{}
results := make(chan error, 16)
wg.Add(1)
go func() {
defer wg.Done()
wr.validateShard(ctx, keyspace, shard, pingTablets, wg, results)
}()
return wr.waitForResults(wg, results)
} | [
"func",
"(",
"wr",
"*",
"Wrangler",
")",
"ValidateShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
",",
"pingTablets",
"bool",
")",
"error",
"{",
"wg",
":=",
"&",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"results... | // ValidateShard will validate a bunch of information in a shard is correct. | [
"ValidateShard",
"will",
"validate",
"a",
"bunch",
"of",
"information",
"in",
"a",
"shard",
"is",
"correct",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/validator.go#L305-L314 |
158,064 | vitessio/vitess | go/vt/vitessdriver/time.go | DatetimeToNative | func DatetimeToNative(v sqltypes.Value, loc *time.Location) (time.Time, error) {
// Valid format string offsets for a DATETIME
// |DATETIME |19+
// |------------------|------|
// "2006-01-02 15:04:05.999999"
return parseISOTime(v.ToString(), loc, 19, isoTimeLength)
} | go | func DatetimeToNative(v sqltypes.Value, loc *time.Location) (time.Time, error) {
// Valid format string offsets for a DATETIME
// |DATETIME |19+
// |------------------|------|
// "2006-01-02 15:04:05.999999"
return parseISOTime(v.ToString(), loc, 19, isoTimeLength)
} | [
"func",
"DatetimeToNative",
"(",
"v",
"sqltypes",
".",
"Value",
",",
"loc",
"*",
"time",
".",
"Location",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"// Valid format string offsets for a DATETIME",
"// |DATETIME |19+",
"// |------------------|--... | // DatetimeToNative converts a Datetime Value into a time.Time | [
"DatetimeToNative",
"converts",
"a",
"Datetime",
"Value",
"into",
"a",
"time",
".",
"Time"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vitessdriver/time.go#L78-L84 |
158,065 | vitessio/vitess | go/vt/vitessdriver/time.go | NewDatetime | func NewDatetime(t time.Time, defaultLoc *time.Location) sqltypes.Value {
if t.Location() != defaultLoc {
t = t.In(defaultLoc)
}
return sqltypes.MakeTrusted(sqltypes.Datetime, []byte(t.Format(isoTimeFormat)))
} | go | func NewDatetime(t time.Time, defaultLoc *time.Location) sqltypes.Value {
if t.Location() != defaultLoc {
t = t.In(defaultLoc)
}
return sqltypes.MakeTrusted(sqltypes.Datetime, []byte(t.Format(isoTimeFormat)))
} | [
"func",
"NewDatetime",
"(",
"t",
"time",
".",
"Time",
",",
"defaultLoc",
"*",
"time",
".",
"Location",
")",
"sqltypes",
".",
"Value",
"{",
"if",
"t",
".",
"Location",
"(",
")",
"!=",
"defaultLoc",
"{",
"t",
"=",
"t",
".",
"In",
"(",
"defaultLoc",
"... | // NewDatetime builds a Datetime Value | [
"NewDatetime",
"builds",
"a",
"Datetime",
"Value"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vitessdriver/time.go#L99-L104 |
158,066 | vitessio/vitess | go/vt/callinfo/plugin_mysql.go | MysqlCallInfo | func MysqlCallInfo(ctx context.Context, c *mysql.Conn) context.Context {
return NewContext(ctx, &mysqlCallInfoImpl{
remoteAddr: c.RemoteAddr().String(),
user: c.User,
})
} | go | func MysqlCallInfo(ctx context.Context, c *mysql.Conn) context.Context {
return NewContext(ctx, &mysqlCallInfoImpl{
remoteAddr: c.RemoteAddr().String(),
user: c.User,
})
} | [
"func",
"MysqlCallInfo",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"mysql",
".",
"Conn",
")",
"context",
".",
"Context",
"{",
"return",
"NewContext",
"(",
"ctx",
",",
"&",
"mysqlCallInfoImpl",
"{",
"remoteAddr",
":",
"c",
".",
"RemoteAddr",
"... | // MysqlCallInfo returns an augmented context with a CallInfo structure,
// only for Mysql contexts. | [
"MysqlCallInfo",
"returns",
"an",
"augmented",
"context",
"with",
"a",
"CallInfo",
"structure",
"only",
"for",
"Mysql",
"contexts",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/callinfo/plugin_mysql.go#L31-L36 |
158,067 | vitessio/vitess | go/vt/worker/block.go | NewBlockWorker | func NewBlockWorker(wr *wrangler.Wrangler) (Worker, error) {
return &BlockWorker{
StatusWorker: NewStatusWorker(),
wr: wr,
}, nil
} | go | func NewBlockWorker(wr *wrangler.Wrangler) (Worker, error) {
return &BlockWorker{
StatusWorker: NewStatusWorker(),
wr: wr,
}, nil
} | [
"func",
"NewBlockWorker",
"(",
"wr",
"*",
"wrangler",
".",
"Wrangler",
")",
"(",
"Worker",
",",
"error",
")",
"{",
"return",
"&",
"BlockWorker",
"{",
"StatusWorker",
":",
"NewStatusWorker",
"(",
")",
",",
"wr",
":",
"wr",
",",
"}",
",",
"nil",
"\n",
... | // NewBlockWorker returns a new BlockWorker object. | [
"NewBlockWorker",
"returns",
"a",
"new",
"BlockWorker",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/block.go#L38-L43 |
158,068 | vitessio/vitess | go/vt/worker/block.go | StatusAsHTML | func (bw *BlockWorker) StatusAsHTML() template.HTML {
state := bw.State()
result := "<b>Block Command</b> (blocking infinitely until context is canceled)</br>\n"
result += "<b>State:</b> " + state.String() + "</br>\n"
switch state {
case WorkerStateDebugRunning:
result += "<b>Running (blocking)</b></br>\n"
case WorkerStateDone:
result += "<b>Success (unblocked)</b></br>\n"
}
return template.HTML(result)
} | go | func (bw *BlockWorker) StatusAsHTML() template.HTML {
state := bw.State()
result := "<b>Block Command</b> (blocking infinitely until context is canceled)</br>\n"
result += "<b>State:</b> " + state.String() + "</br>\n"
switch state {
case WorkerStateDebugRunning:
result += "<b>Running (blocking)</b></br>\n"
case WorkerStateDone:
result += "<b>Success (unblocked)</b></br>\n"
}
return template.HTML(result)
} | [
"func",
"(",
"bw",
"*",
"BlockWorker",
")",
"StatusAsHTML",
"(",
")",
"template",
".",
"HTML",
"{",
"state",
":=",
"bw",
".",
"State",
"(",
")",
"\n\n",
"result",
":=",
"\"",
"\\n",
"\"",
"\n",
"result",
"+=",
"\"",
"\"",
"+",
"state",
".",
"String... | // StatusAsHTML implements the Worker interface. | [
"StatusAsHTML",
"implements",
"the",
"Worker",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/block.go#L46-L59 |
158,069 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | NewDBConn | func NewDBConn(
cp *Pool,
appParams *mysql.ConnParams) (*DBConn, error) {
c, err := dbconnpool.NewDBConnection(appParams, tabletenv.MySQLStats)
if err != nil {
cp.checker.CheckMySQL()
return nil, err
}
return &DBConn{
conn: c,
info: appParams,
pool: cp,
dbaPool: cp.dbaPool,
}, nil
} | go | func NewDBConn(
cp *Pool,
appParams *mysql.ConnParams) (*DBConn, error) {
c, err := dbconnpool.NewDBConnection(appParams, tabletenv.MySQLStats)
if err != nil {
cp.checker.CheckMySQL()
return nil, err
}
return &DBConn{
conn: c,
info: appParams,
pool: cp,
dbaPool: cp.dbaPool,
}, nil
} | [
"func",
"NewDBConn",
"(",
"cp",
"*",
"Pool",
",",
"appParams",
"*",
"mysql",
".",
"ConnParams",
")",
"(",
"*",
"DBConn",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"dbconnpool",
".",
"NewDBConnection",
"(",
"appParams",
",",
"tabletenv",
".",
"MySQ... | // NewDBConn creates a new DBConn. It triggers a CheckMySQL if creation fails. | [
"NewDBConn",
"creates",
"a",
"new",
"DBConn",
".",
"It",
"triggers",
"a",
"CheckMySQL",
"if",
"creation",
"fails",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L64-L78 |
158,070 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | NewDBConnNoPool | func NewDBConnNoPool(params *mysql.ConnParams, dbaPool *dbconnpool.ConnectionPool) (*DBConn, error) {
c, err := dbconnpool.NewDBConnection(params, tabletenv.MySQLStats)
if err != nil {
return nil, err
}
return &DBConn{
conn: c,
info: params,
dbaPool: dbaPool,
pool: nil,
}, nil
} | go | func NewDBConnNoPool(params *mysql.ConnParams, dbaPool *dbconnpool.ConnectionPool) (*DBConn, error) {
c, err := dbconnpool.NewDBConnection(params, tabletenv.MySQLStats)
if err != nil {
return nil, err
}
return &DBConn{
conn: c,
info: params,
dbaPool: dbaPool,
pool: nil,
}, nil
} | [
"func",
"NewDBConnNoPool",
"(",
"params",
"*",
"mysql",
".",
"ConnParams",
",",
"dbaPool",
"*",
"dbconnpool",
".",
"ConnectionPool",
")",
"(",
"*",
"DBConn",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"dbconnpool",
".",
"NewDBConnection",
"(",
"params"... | // NewDBConnNoPool creates a new DBConn without a pool. | [
"NewDBConnNoPool",
"creates",
"a",
"new",
"DBConn",
"without",
"a",
"pool",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L81-L92 |
158,071 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | Exec | func (dbc *DBConn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error) {
span, ctx := trace.NewSpan(ctx, "DBConn.Exec")
defer span.Finish()
for attempt := 1; attempt <= 2; attempt++ {
r, err := dbc.execOnce(ctx, query, maxrows, wantfields)
switch {
case err == nil:
// Success.
return r, nil
case !mysql.IsConnErr(err):
// Not a connection error. Don't retry.
return nil, err
case attempt == 2:
// Reached the retry limit.
return nil, err
}
// Connection error. Retry if context has not expired.
select {
case <-ctx.Done():
return nil, err
default:
}
if reconnectErr := dbc.reconnect(); reconnectErr != nil {
dbc.pool.checker.CheckMySQL()
// Return the error of the reconnect and not the original connection error.
return nil, reconnectErr
}
// Reconnect succeeded. Retry query at second attempt.
}
panic("unreachable")
} | go | func (dbc *DBConn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error) {
span, ctx := trace.NewSpan(ctx, "DBConn.Exec")
defer span.Finish()
for attempt := 1; attempt <= 2; attempt++ {
r, err := dbc.execOnce(ctx, query, maxrows, wantfields)
switch {
case err == nil:
// Success.
return r, nil
case !mysql.IsConnErr(err):
// Not a connection error. Don't retry.
return nil, err
case attempt == 2:
// Reached the retry limit.
return nil, err
}
// Connection error. Retry if context has not expired.
select {
case <-ctx.Done():
return nil, err
default:
}
if reconnectErr := dbc.reconnect(); reconnectErr != nil {
dbc.pool.checker.CheckMySQL()
// Return the error of the reconnect and not the original connection error.
return nil, reconnectErr
}
// Reconnect succeeded. Retry query at second attempt.
}
panic("unreachable")
} | [
"func",
"(",
"dbc",
"*",
"DBConn",
")",
"Exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"maxrows",
"int",
",",
"wantfields",
"bool",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"span",
",",
"ctx",
"... | // Exec executes the specified query. If there is a connection error, it will reconnect
// and retry. A failed reconnect will trigger a CheckMySQL. | [
"Exec",
"executes",
"the",
"specified",
"query",
".",
"If",
"there",
"is",
"a",
"connection",
"error",
"it",
"will",
"reconnect",
"and",
"retry",
".",
"A",
"failed",
"reconnect",
"will",
"trigger",
"a",
"CheckMySQL",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L96-L130 |
158,072 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | ExecOnce | func (dbc *DBConn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error) {
return dbc.execOnce(ctx, query, maxrows, wantfields)
} | go | func (dbc *DBConn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error) {
return dbc.execOnce(ctx, query, maxrows, wantfields)
} | [
"func",
"(",
"dbc",
"*",
"DBConn",
")",
"ExecOnce",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"maxrows",
"int",
",",
"wantfields",
"bool",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"return",
"dbc",
".... | // ExecOnce executes the specified query, but does not retry on connection errors. | [
"ExecOnce",
"executes",
"the",
"specified",
"query",
"but",
"does",
"not",
"retry",
"on",
"connection",
"errors",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L157-L159 |
158,073 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | Stream | func (dbc *DBConn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, streamBufferSize int, includedFields querypb.ExecuteOptions_IncludedFields) error {
span, ctx := trace.NewSpan(ctx, "DBConn.Stream")
trace.AnnotateSQL(span, query)
defer span.Finish()
resultSent := false
for attempt := 1; attempt <= 2; attempt++ {
err := dbc.streamOnce(
ctx,
query,
func(r *sqltypes.Result) error {
if !resultSent {
resultSent = true
r = r.StripMetadata(includedFields)
}
return callback(r)
},
streamBufferSize,
)
switch {
case err == nil:
// Success.
return nil
case !mysql.IsConnErr(err):
// Not a connection error. Don't retry.
return err
case attempt == 2:
// Reached the retry limit.
return err
case resultSent:
// Don't retry if streaming has started.
return err
}
// Connection error. Retry if context has not expired.
select {
case <-ctx.Done():
return err
default:
}
if reconnectErr := dbc.reconnect(); reconnectErr != nil {
dbc.pool.checker.CheckMySQL()
// Return the error of the reconnect and not the original connection error.
return reconnectErr
}
}
panic("unreachable")
} | go | func (dbc *DBConn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, streamBufferSize int, includedFields querypb.ExecuteOptions_IncludedFields) error {
span, ctx := trace.NewSpan(ctx, "DBConn.Stream")
trace.AnnotateSQL(span, query)
defer span.Finish()
resultSent := false
for attempt := 1; attempt <= 2; attempt++ {
err := dbc.streamOnce(
ctx,
query,
func(r *sqltypes.Result) error {
if !resultSent {
resultSent = true
r = r.StripMetadata(includedFields)
}
return callback(r)
},
streamBufferSize,
)
switch {
case err == nil:
// Success.
return nil
case !mysql.IsConnErr(err):
// Not a connection error. Don't retry.
return err
case attempt == 2:
// Reached the retry limit.
return err
case resultSent:
// Don't retry if streaming has started.
return err
}
// Connection error. Retry if context has not expired.
select {
case <-ctx.Done():
return err
default:
}
if reconnectErr := dbc.reconnect(); reconnectErr != nil {
dbc.pool.checker.CheckMySQL()
// Return the error of the reconnect and not the original connection error.
return reconnectErr
}
}
panic("unreachable")
} | [
"func",
"(",
"dbc",
"*",
"DBConn",
")",
"Stream",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"callback",
"func",
"(",
"*",
"sqltypes",
".",
"Result",
")",
"error",
",",
"streamBufferSize",
"int",
",",
"includedFields",
"querypb",
... | // Stream executes the query and streams the results. | [
"Stream",
"executes",
"the",
"query",
"and",
"streams",
"the",
"results",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L162-L209 |
158,074 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | Recycle | func (dbc *DBConn) Recycle() {
switch {
case dbc.pool == nil:
dbc.Close()
case dbc.conn.IsClosed():
dbc.pool.Put(nil)
default:
dbc.pool.Put(dbc)
}
} | go | func (dbc *DBConn) Recycle() {
switch {
case dbc.pool == nil:
dbc.Close()
case dbc.conn.IsClosed():
dbc.pool.Put(nil)
default:
dbc.pool.Put(dbc)
}
} | [
"func",
"(",
"dbc",
"*",
"DBConn",
")",
"Recycle",
"(",
")",
"{",
"switch",
"{",
"case",
"dbc",
".",
"pool",
"==",
"nil",
":",
"dbc",
".",
"Close",
"(",
")",
"\n",
"case",
"dbc",
".",
"conn",
".",
"IsClosed",
"(",
")",
":",
"dbc",
".",
"pool",
... | // Recycle returns the DBConn to the pool. | [
"Recycle",
"returns",
"the",
"DBConn",
"to",
"the",
"pool",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L301-L310 |
158,075 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | Kill | func (dbc *DBConn) Kill(reason string, elapsed time.Duration) error {
tabletenv.KillStats.Add("Queries", 1)
log.Infof("Due to %s, elapsed time: %v, killing query ID %v %s", reason, elapsed, dbc.conn.ID(), dbc.Current())
killConn, err := dbc.dbaPool.Get(context.TODO())
if err != nil {
log.Warningf("Failed to get conn from dba pool: %v", err)
return err
}
defer killConn.Recycle()
sql := fmt.Sprintf("kill %d", dbc.conn.ID())
_, err = killConn.ExecuteFetch(sql, 10000, false)
if err != nil {
log.Errorf("Could not kill query ID %v %s: %v", dbc.conn.ID(), dbc.Current(), err)
return err
}
return nil
} | go | func (dbc *DBConn) Kill(reason string, elapsed time.Duration) error {
tabletenv.KillStats.Add("Queries", 1)
log.Infof("Due to %s, elapsed time: %v, killing query ID %v %s", reason, elapsed, dbc.conn.ID(), dbc.Current())
killConn, err := dbc.dbaPool.Get(context.TODO())
if err != nil {
log.Warningf("Failed to get conn from dba pool: %v", err)
return err
}
defer killConn.Recycle()
sql := fmt.Sprintf("kill %d", dbc.conn.ID())
_, err = killConn.ExecuteFetch(sql, 10000, false)
if err != nil {
log.Errorf("Could not kill query ID %v %s: %v", dbc.conn.ID(), dbc.Current(), err)
return err
}
return nil
} | [
"func",
"(",
"dbc",
"*",
"DBConn",
")",
"Kill",
"(",
"reason",
"string",
",",
"elapsed",
"time",
".",
"Duration",
")",
"error",
"{",
"tabletenv",
".",
"KillStats",
".",
"Add",
"(",
"\"",
"\"",
",",
"1",
")",
"\n",
"log",
".",
"Infof",
"(",
"\"",
... | // Kill kills the currently executing query both on MySQL side
// and on the connection side. If no query is executing, it's a no-op.
// Kill will also not kill a query more than once. | [
"Kill",
"kills",
"the",
"currently",
"executing",
"query",
"both",
"on",
"MySQL",
"side",
"and",
"on",
"the",
"connection",
"side",
".",
"If",
"no",
"query",
"is",
"executing",
"it",
"s",
"a",
"no",
"-",
"op",
".",
"Kill",
"will",
"also",
"not",
"kill"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L315-L331 |
158,076 | vitessio/vitess | go/vt/vttablet/tabletserver/connpool/dbconn.go | setDeadline | func (dbc *DBConn) setDeadline(ctx context.Context) (chan bool, *sync.WaitGroup) {
if ctx.Done() == nil {
return nil, nil
}
done := make(chan bool)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
startTime := time.Now()
select {
case <-ctx.Done():
dbc.Kill(ctx.Err().Error(), time.Since(startTime))
case <-done:
return
}
elapsed := time.Since(startTime)
// Give 2x the elapsed time and some buffer as grace period
// for the query to get killed.
tmr2 := time.NewTimer(2*elapsed + 5*time.Second)
defer tmr2.Stop()
select {
case <-tmr2.C:
tabletenv.InternalErrors.Add("HungQuery", 1)
log.Warningf("Query may be hung: %s", dbc.Current())
case <-done:
return
}
<-done
log.Warningf("Hung query returned")
}()
return done, &wg
} | go | func (dbc *DBConn) setDeadline(ctx context.Context) (chan bool, *sync.WaitGroup) {
if ctx.Done() == nil {
return nil, nil
}
done := make(chan bool)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
startTime := time.Now()
select {
case <-ctx.Done():
dbc.Kill(ctx.Err().Error(), time.Since(startTime))
case <-done:
return
}
elapsed := time.Since(startTime)
// Give 2x the elapsed time and some buffer as grace period
// for the query to get killed.
tmr2 := time.NewTimer(2*elapsed + 5*time.Second)
defer tmr2.Stop()
select {
case <-tmr2.C:
tabletenv.InternalErrors.Add("HungQuery", 1)
log.Warningf("Query may be hung: %s", dbc.Current())
case <-done:
return
}
<-done
log.Warningf("Hung query returned")
}()
return done, &wg
} | [
"func",
"(",
"dbc",
"*",
"DBConn",
")",
"setDeadline",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"chan",
"bool",
",",
"*",
"sync",
".",
"WaitGroup",
")",
"{",
"if",
"ctx",
".",
"Done",
"(",
")",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil... | // setDeadline starts a goroutine that will kill the currently executing query
// if the deadline is exceeded. It returns a channel and a waitgroup. After the
// query is done executing, the caller is required to close the done channel
// and wait for the waitgroup to make sure that the necessary cleanup is done. | [
"setDeadline",
"starts",
"a",
"goroutine",
"that",
"will",
"kill",
"the",
"currently",
"executing",
"query",
"if",
"the",
"deadline",
"is",
"exceeded",
".",
"It",
"returns",
"a",
"channel",
"and",
"a",
"waitgroup",
".",
"After",
"the",
"query",
"is",
"done",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/dbconn.go#L357-L390 |
158,077 | vitessio/vitess | go/vt/topo/vschema.go | SaveVSchema | func (ts *Server) SaveVSchema(ctx context.Context, keyspace string, vschema *vschemapb.Keyspace) error {
err := vindexes.ValidateKeyspace(vschema)
if err != nil {
return err
}
nodePath := path.Join(KeyspacesPath, keyspace, VSchemaFile)
data, err := proto.Marshal(vschema)
if err != nil {
return err
}
if len(data) == 0 {
// No vschema, remove it. So we can remove the keyspace.
return ts.globalCell.Delete(ctx, nodePath, nil)
}
_, err = ts.globalCell.Update(ctx, nodePath, data, nil)
return err
} | go | func (ts *Server) SaveVSchema(ctx context.Context, keyspace string, vschema *vschemapb.Keyspace) error {
err := vindexes.ValidateKeyspace(vschema)
if err != nil {
return err
}
nodePath := path.Join(KeyspacesPath, keyspace, VSchemaFile)
data, err := proto.Marshal(vschema)
if err != nil {
return err
}
if len(data) == 0 {
// No vschema, remove it. So we can remove the keyspace.
return ts.globalCell.Delete(ctx, nodePath, nil)
}
_, err = ts.globalCell.Update(ctx, nodePath, data, nil)
return err
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"SaveVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"vschema",
"*",
"vschemapb",
".",
"Keyspace",
")",
"error",
"{",
"err",
":=",
"vindexes",
".",
"ValidateKeyspace",
"(",
"vschema",
... | // SaveVSchema first validates the VSchema, then saves it.
// If the VSchema is empty, just remove it. | [
"SaveVSchema",
"first",
"validates",
"the",
"VSchema",
"then",
"saves",
"it",
".",
"If",
"the",
"VSchema",
"is",
"empty",
"just",
"remove",
"it",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/vschema.go#L32-L51 |
158,078 | vitessio/vitess | go/vt/topo/vschema.go | GetVSchema | func (ts *Server) GetVSchema(ctx context.Context, keyspace string) (*vschemapb.Keyspace, error) {
nodePath := path.Join(KeyspacesPath, keyspace, VSchemaFile)
data, _, err := ts.globalCell.Get(ctx, nodePath)
if err != nil {
return nil, err
}
var vs vschemapb.Keyspace
err = proto.Unmarshal(data, &vs)
if err != nil {
return nil, vterrors.Wrapf(err, "bad vschema data: %q", data)
}
return &vs, nil
} | go | func (ts *Server) GetVSchema(ctx context.Context, keyspace string) (*vschemapb.Keyspace, error) {
nodePath := path.Join(KeyspacesPath, keyspace, VSchemaFile)
data, _, err := ts.globalCell.Get(ctx, nodePath)
if err != nil {
return nil, err
}
var vs vschemapb.Keyspace
err = proto.Unmarshal(data, &vs)
if err != nil {
return nil, vterrors.Wrapf(err, "bad vschema data: %q", data)
}
return &vs, nil
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"(",
"*",
"vschemapb",
".",
"Keyspace",
",",
"error",
")",
"{",
"nodePath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
","... | // GetVSchema fetches the vschema from the topo. | [
"GetVSchema",
"fetches",
"the",
"vschema",
"from",
"the",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/vschema.go#L54-L66 |
158,079 | vitessio/vitess | go/vt/topo/vschema.go | SaveRoutingRules | func (ts *Server) SaveRoutingRules(ctx context.Context, routingRules *vschemapb.RoutingRules) error {
data, err := proto.Marshal(routingRules)
if err != nil {
return err
}
if len(data) == 0 {
// No vschema, remove it. So we can remove the keyspace.
return ts.globalCell.Delete(ctx, RoutingRulesFile, nil)
}
_, err = ts.globalCell.Update(ctx, RoutingRulesFile, data, nil)
return err
} | go | func (ts *Server) SaveRoutingRules(ctx context.Context, routingRules *vschemapb.RoutingRules) error {
data, err := proto.Marshal(routingRules)
if err != nil {
return err
}
if len(data) == 0 {
// No vschema, remove it. So we can remove the keyspace.
return ts.globalCell.Delete(ctx, RoutingRulesFile, nil)
}
_, err = ts.globalCell.Update(ctx, RoutingRulesFile, data, nil)
return err
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"SaveRoutingRules",
"(",
"ctx",
"context",
".",
"Context",
",",
"routingRules",
"*",
"vschemapb",
".",
"RoutingRules",
")",
"error",
"{",
"data",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"routingRules",
")",
... | // SaveRoutingRules saves the routing rules into the topo. | [
"SaveRoutingRules",
"saves",
"the",
"routing",
"rules",
"into",
"the",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/vschema.go#L69-L82 |
158,080 | vitessio/vitess | go/vt/topo/vschema.go | GetRoutingRules | func (ts *Server) GetRoutingRules(ctx context.Context) (*vschemapb.RoutingRules, error) {
rr := &vschemapb.RoutingRules{}
data, _, err := ts.globalCell.Get(ctx, RoutingRulesFile)
if err != nil {
if IsErrType(err, NoNode) {
return rr, nil
}
return nil, err
}
err = proto.Unmarshal(data, rr)
if err != nil {
return nil, vterrors.Wrapf(err, "bad routing rules data: %q", data)
}
return rr, nil
} | go | func (ts *Server) GetRoutingRules(ctx context.Context) (*vschemapb.RoutingRules, error) {
rr := &vschemapb.RoutingRules{}
data, _, err := ts.globalCell.Get(ctx, RoutingRulesFile)
if err != nil {
if IsErrType(err, NoNode) {
return rr, nil
}
return nil, err
}
err = proto.Unmarshal(data, rr)
if err != nil {
return nil, vterrors.Wrapf(err, "bad routing rules data: %q", data)
}
return rr, nil
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetRoutingRules",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"vschemapb",
".",
"RoutingRules",
",",
"error",
")",
"{",
"rr",
":=",
"&",
"vschemapb",
".",
"RoutingRules",
"{",
"}",
"\n",
"data",
",",
... | // GetRoutingRules fetches the routing rules from the topo. | [
"GetRoutingRules",
"fetches",
"the",
"routing",
"rules",
"from",
"the",
"topo",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/vschema.go#L85-L99 |
158,081 | vitessio/vitess | go/vt/automation/tasks.go | MarkTaskSucceeded | func MarkTaskSucceeded(t *automationpb.Task, output string) {
t.State = automationpb.TaskState_DONE
t.Output = output
} | go | func MarkTaskSucceeded(t *automationpb.Task, output string) {
t.State = automationpb.TaskState_DONE
t.Output = output
} | [
"func",
"MarkTaskSucceeded",
"(",
"t",
"*",
"automationpb",
".",
"Task",
",",
"output",
"string",
")",
"{",
"t",
".",
"State",
"=",
"automationpb",
".",
"TaskState_DONE",
"\n",
"t",
".",
"Output",
"=",
"output",
"\n",
"}"
] | // Helper functions for "Task" protobuf message.
// MarkTaskSucceeded marks the task as done. | [
"Helper",
"functions",
"for",
"Task",
"protobuf",
"message",
".",
"MarkTaskSucceeded",
"marks",
"the",
"task",
"as",
"done",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/tasks.go#L26-L29 |
158,082 | vitessio/vitess | go/vt/automation/tasks.go | MarkTaskFailed | func MarkTaskFailed(t *automationpb.Task, output string, err error) {
t.State = automationpb.TaskState_DONE
t.Output = output
t.Error = err.Error()
} | go | func MarkTaskFailed(t *automationpb.Task, output string, err error) {
t.State = automationpb.TaskState_DONE
t.Output = output
t.Error = err.Error()
} | [
"func",
"MarkTaskFailed",
"(",
"t",
"*",
"automationpb",
".",
"Task",
",",
"output",
"string",
",",
"err",
"error",
")",
"{",
"t",
".",
"State",
"=",
"automationpb",
".",
"TaskState_DONE",
"\n",
"t",
".",
"Output",
"=",
"output",
"\n",
"t",
".",
"Error... | // MarkTaskFailed marks the task as failed. | [
"MarkTaskFailed",
"marks",
"the",
"task",
"as",
"failed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/tasks.go#L32-L36 |
158,083 | vitessio/vitess | go/vt/automation/tasks.go | NewTask | func NewTask(taskName string, parameters map[string]string) *automationpb.Task {
return &automationpb.Task{
State: automationpb.TaskState_NOT_STARTED,
Name: taskName,
Parameters: parameters,
}
} | go | func NewTask(taskName string, parameters map[string]string) *automationpb.Task {
return &automationpb.Task{
State: automationpb.TaskState_NOT_STARTED,
Name: taskName,
Parameters: parameters,
}
} | [
"func",
"NewTask",
"(",
"taskName",
"string",
",",
"parameters",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"automationpb",
".",
"Task",
"{",
"return",
"&",
"automationpb",
".",
"Task",
"{",
"State",
":",
"automationpb",
".",
"TaskState_NOT_STARTED",
","... | // NewTask creates a new task protobuf message for "taskName" with "parameters". | [
"NewTask",
"creates",
"a",
"new",
"task",
"protobuf",
"message",
"for",
"taskName",
"with",
"parameters",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/tasks.go#L39-L45 |
158,084 | vitessio/vitess | go/vt/mysqlctl/mycnf.go | ReadMycnf | func ReadMycnf(mycnf *Mycnf) (*Mycnf, error) {
f, err := os.Open(mycnf.path)
if err != nil {
return nil, err
}
defer f.Close()
buf := bufio.NewReader(f)
if err != nil {
return nil, err
}
mycnf.mycnfMap = make(map[string]string)
var lval, rval string
var parts [][]byte
for {
line, _, err := buf.ReadLine()
if err == io.EOF {
break
}
line = bytes.TrimSpace(line)
parts = bytes.Split(line, []byte("="))
if len(parts) < 2 {
continue
}
lval = normKey(parts[0])
rval = string(bytes.TrimSpace(parts[1]))
mycnf.mycnfMap[lval] = rval
}
serverID, err := mycnf.lookupInt("server-id")
if err != nil {
return nil, err
}
mycnf.ServerID = uint32(serverID)
port, err := mycnf.lookupInt("port")
if err != nil {
return nil, err
}
mycnf.MysqlPort = int32(port)
mapping := map[string]*string{
"datadir": &mycnf.DataDir,
"innodb_data_home_dir": &mycnf.InnodbDataHomeDir,
"innodb_log_group_home_dir": &mycnf.InnodbLogGroupHomeDir,
"socket": &mycnf.SocketFile,
"general_log_file": &mycnf.GeneralLogPath,
"log-error": &mycnf.ErrorLogPath,
"slow-query-log-file": &mycnf.SlowLogPath,
"relay-log": &mycnf.RelayLogPath,
"relay-log-index": &mycnf.RelayLogIndexPath,
"relay-log-info-file": &mycnf.RelayLogInfoPath,
"log-bin": &mycnf.BinLogPath,
"master-info-file": &mycnf.MasterInfoFile,
"pid-file": &mycnf.PidFile,
"tmpdir": &mycnf.TmpDir,
"slave_load_tmpdir": &mycnf.SlaveLoadTmpDir,
}
for key, member := range mapping {
val, err := mycnf.lookupWithDefault(key, *member)
if err != nil {
return nil, err
}
*member = val
}
return mycnf, nil
} | go | func ReadMycnf(mycnf *Mycnf) (*Mycnf, error) {
f, err := os.Open(mycnf.path)
if err != nil {
return nil, err
}
defer f.Close()
buf := bufio.NewReader(f)
if err != nil {
return nil, err
}
mycnf.mycnfMap = make(map[string]string)
var lval, rval string
var parts [][]byte
for {
line, _, err := buf.ReadLine()
if err == io.EOF {
break
}
line = bytes.TrimSpace(line)
parts = bytes.Split(line, []byte("="))
if len(parts) < 2 {
continue
}
lval = normKey(parts[0])
rval = string(bytes.TrimSpace(parts[1]))
mycnf.mycnfMap[lval] = rval
}
serverID, err := mycnf.lookupInt("server-id")
if err != nil {
return nil, err
}
mycnf.ServerID = uint32(serverID)
port, err := mycnf.lookupInt("port")
if err != nil {
return nil, err
}
mycnf.MysqlPort = int32(port)
mapping := map[string]*string{
"datadir": &mycnf.DataDir,
"innodb_data_home_dir": &mycnf.InnodbDataHomeDir,
"innodb_log_group_home_dir": &mycnf.InnodbLogGroupHomeDir,
"socket": &mycnf.SocketFile,
"general_log_file": &mycnf.GeneralLogPath,
"log-error": &mycnf.ErrorLogPath,
"slow-query-log-file": &mycnf.SlowLogPath,
"relay-log": &mycnf.RelayLogPath,
"relay-log-index": &mycnf.RelayLogIndexPath,
"relay-log-info-file": &mycnf.RelayLogInfoPath,
"log-bin": &mycnf.BinLogPath,
"master-info-file": &mycnf.MasterInfoFile,
"pid-file": &mycnf.PidFile,
"tmpdir": &mycnf.TmpDir,
"slave_load_tmpdir": &mycnf.SlaveLoadTmpDir,
}
for key, member := range mapping {
val, err := mycnf.lookupWithDefault(key, *member)
if err != nil {
return nil, err
}
*member = val
}
return mycnf, nil
} | [
"func",
"ReadMycnf",
"(",
"mycnf",
"*",
"Mycnf",
")",
"(",
"*",
"Mycnf",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"mycnf",
".",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // ReadMycnf will read an existing my.cnf from disk, and update the passed in Mycnf object
// with values from the my.cnf on disk. | [
"ReadMycnf",
"will",
"read",
"an",
"existing",
"my",
".",
"cnf",
"from",
"disk",
"and",
"update",
"the",
"passed",
"in",
"Mycnf",
"object",
"with",
"values",
"from",
"the",
"my",
".",
"cnf",
"on",
"disk",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/mycnf.go#L152-L221 |
158,085 | vitessio/vitess | go/vt/vtgate/engine/subquery.go | buildResult | func (sq *Subquery) buildResult(inner *sqltypes.Result) *sqltypes.Result {
result := &sqltypes.Result{Fields: sq.buildFields(inner)}
result.Rows = make([][]sqltypes.Value, 0, len(inner.Rows))
for _, innerRow := range inner.Rows {
row := make([]sqltypes.Value, 0, len(sq.Cols))
for _, col := range sq.Cols {
row = append(row, innerRow[col])
}
result.Rows = append(result.Rows, row)
}
result.RowsAffected = inner.RowsAffected
return result
} | go | func (sq *Subquery) buildResult(inner *sqltypes.Result) *sqltypes.Result {
result := &sqltypes.Result{Fields: sq.buildFields(inner)}
result.Rows = make([][]sqltypes.Value, 0, len(inner.Rows))
for _, innerRow := range inner.Rows {
row := make([]sqltypes.Value, 0, len(sq.Cols))
for _, col := range sq.Cols {
row = append(row, innerRow[col])
}
result.Rows = append(result.Rows, row)
}
result.RowsAffected = inner.RowsAffected
return result
} | [
"func",
"(",
"sq",
"*",
"Subquery",
")",
"buildResult",
"(",
"inner",
"*",
"sqltypes",
".",
"Result",
")",
"*",
"sqltypes",
".",
"Result",
"{",
"result",
":=",
"&",
"sqltypes",
".",
"Result",
"{",
"Fields",
":",
"sq",
".",
"buildFields",
"(",
"inner",
... | // buildResult builds a new result by pulling the necessary columns from
// the subquery in the requested order. | [
"buildResult",
"builds",
"a",
"new",
"result",
"by",
"pulling",
"the",
"necessary",
"columns",
"from",
"the",
"subquery",
"in",
"the",
"requested",
"order",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/subquery.go#L66-L78 |
158,086 | vitessio/vitess | go/vt/wrangler/cleaner.go | Record | func (cleaner *Cleaner) Record(name, target string, action CleanerFunction) {
cleaner.mu.Lock()
cleaner.actions = append(cleaner.actions, cleanerActionReference{
name: name,
target: target,
action: action,
})
cleaner.mu.Unlock()
} | go | func (cleaner *Cleaner) Record(name, target string, action CleanerFunction) {
cleaner.mu.Lock()
cleaner.actions = append(cleaner.actions, cleanerActionReference{
name: name,
target: target,
action: action,
})
cleaner.mu.Unlock()
} | [
"func",
"(",
"cleaner",
"*",
"Cleaner",
")",
"Record",
"(",
"name",
",",
"target",
"string",
",",
"action",
"CleanerFunction",
")",
"{",
"cleaner",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"cleaner",
".",
"actions",
"=",
"append",
"(",
"cleaner",
".",
... | // Record will add a cleaning action to the list | [
"Record",
"will",
"add",
"a",
"cleaning",
"action",
"to",
"the",
"list"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/cleaner.go#L76-L84 |
158,087 | vitessio/vitess | go/vt/wrangler/cleaner.go | RecordChangeSlaveTypeAction | func RecordChangeSlaveTypeAction(cleaner *Cleaner, tabletAlias *topodatapb.TabletAlias, from topodatapb.TabletType, to topodatapb.TabletType) {
cleaner.Record(ChangeSlaveTypeActionName, topoproto.TabletAliasString(tabletAlias), func(ctx context.Context, wr *Wrangler) error {
ti, err := wr.ts.GetTablet(ctx, tabletAlias)
if err != nil {
return err
}
if ti.Type != from {
return fmt.Errorf("tablet %v is not of the right type (got %v expected %v), not changing it to %v", topoproto.TabletAliasString(tabletAlias), ti.Type, from, to)
}
if !topo.IsTrivialTypeChange(ti.Type, to) {
return fmt.Errorf("tablet %v type change %v -> %v is not an allowed transition for ChangeSlaveType", topoproto.TabletAliasString(tabletAlias), ti.Type, to)
}
// ask the tablet to make the change
return wr.tmc.ChangeType(ctx, ti.Tablet, to)
})
} | go | func RecordChangeSlaveTypeAction(cleaner *Cleaner, tabletAlias *topodatapb.TabletAlias, from topodatapb.TabletType, to topodatapb.TabletType) {
cleaner.Record(ChangeSlaveTypeActionName, topoproto.TabletAliasString(tabletAlias), func(ctx context.Context, wr *Wrangler) error {
ti, err := wr.ts.GetTablet(ctx, tabletAlias)
if err != nil {
return err
}
if ti.Type != from {
return fmt.Errorf("tablet %v is not of the right type (got %v expected %v), not changing it to %v", topoproto.TabletAliasString(tabletAlias), ti.Type, from, to)
}
if !topo.IsTrivialTypeChange(ti.Type, to) {
return fmt.Errorf("tablet %v type change %v -> %v is not an allowed transition for ChangeSlaveType", topoproto.TabletAliasString(tabletAlias), ti.Type, to)
}
// ask the tablet to make the change
return wr.tmc.ChangeType(ctx, ti.Tablet, to)
})
} | [
"func",
"RecordChangeSlaveTypeAction",
"(",
"cleaner",
"*",
"Cleaner",
",",
"tabletAlias",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"from",
"topodatapb",
".",
"TabletType",
",",
"to",
"topodatapb",
".",
"TabletType",
")",
"{",
"cleaner",
".",
"Record",
"(",
... | // RecordChangeSlaveTypeAction records a new ChangeSlaveTypeAction
// into the specified Cleaner | [
"RecordChangeSlaveTypeAction",
"records",
"a",
"new",
"ChangeSlaveTypeAction",
"into",
"the",
"specified",
"Cleaner"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/cleaner.go#L132-L148 |
158,088 | vitessio/vitess | go/vt/wrangler/cleaner.go | RecordStartSlaveAction | func RecordStartSlaveAction(cleaner *Cleaner, tablet *topodatapb.Tablet) {
cleaner.Record(StartSlaveActionName, topoproto.TabletAliasString(tablet.Alias), func(ctx context.Context, wr *Wrangler) error {
return wr.TabletManagerClient().StartSlave(ctx, tablet)
})
} | go | func RecordStartSlaveAction(cleaner *Cleaner, tablet *topodatapb.Tablet) {
cleaner.Record(StartSlaveActionName, topoproto.TabletAliasString(tablet.Alias), func(ctx context.Context, wr *Wrangler) error {
return wr.TabletManagerClient().StartSlave(ctx, tablet)
})
} | [
"func",
"RecordStartSlaveAction",
"(",
"cleaner",
"*",
"Cleaner",
",",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"{",
"cleaner",
".",
"Record",
"(",
"StartSlaveActionName",
",",
"topoproto",
".",
"TabletAliasString",
"(",
"tablet",
".",
"Alias",
")",
",... | // RecordStartSlaveAction records a new action to restart binlog replication on a server
// into the specified Cleaner | [
"RecordStartSlaveAction",
"records",
"a",
"new",
"action",
"to",
"restart",
"binlog",
"replication",
"on",
"a",
"server",
"into",
"the",
"specified",
"Cleaner"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/cleaner.go#L171-L175 |
158,089 | vitessio/vitess | go/vt/wrangler/cleaner.go | RecordVReplicationAction | func RecordVReplicationAction(cleaner *Cleaner, tablet *topodatapb.Tablet, query string) {
cleaner.Record(VReplicationActionName, topoproto.TabletAliasString(tablet.Alias), func(ctx context.Context, wr *Wrangler) error {
_, err := wr.TabletManagerClient().VReplicationExec(ctx, tablet, query)
return err
})
} | go | func RecordVReplicationAction(cleaner *Cleaner, tablet *topodatapb.Tablet, query string) {
cleaner.Record(VReplicationActionName, topoproto.TabletAliasString(tablet.Alias), func(ctx context.Context, wr *Wrangler) error {
_, err := wr.TabletManagerClient().VReplicationExec(ctx, tablet, query)
return err
})
} | [
"func",
"RecordVReplicationAction",
"(",
"cleaner",
"*",
"Cleaner",
",",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
",",
"query",
"string",
")",
"{",
"cleaner",
".",
"Record",
"(",
"VReplicationActionName",
",",
"topoproto",
".",
"TabletAliasString",
"(",
"tabl... | // RecordVReplicationAction records an action to restart binlog replication on a server
// into the specified Cleaner | [
"RecordVReplicationAction",
"records",
"an",
"action",
"to",
"restart",
"binlog",
"replication",
"on",
"a",
"server",
"into",
"the",
"specified",
"Cleaner"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/cleaner.go#L179-L184 |
158,090 | vitessio/vitess | go/vt/srvtopo/keyspace_filtering_server.go | NewKeyspaceFilteringServer | func NewKeyspaceFilteringServer(underlying Server, selectedKeyspaces []string) (Server, error) {
if underlying == nil {
return nil, ErrNilUnderlyingServer
}
keyspaces := map[string]bool{}
for _, ks := range selectedKeyspaces {
keyspaces[ks] = true
}
return keyspaceFilteringServer{
server: underlying,
selectKeyspaces: keyspaces,
}, nil
} | go | func NewKeyspaceFilteringServer(underlying Server, selectedKeyspaces []string) (Server, error) {
if underlying == nil {
return nil, ErrNilUnderlyingServer
}
keyspaces := map[string]bool{}
for _, ks := range selectedKeyspaces {
keyspaces[ks] = true
}
return keyspaceFilteringServer{
server: underlying,
selectKeyspaces: keyspaces,
}, nil
} | [
"func",
"NewKeyspaceFilteringServer",
"(",
"underlying",
"Server",
",",
"selectedKeyspaces",
"[",
"]",
"string",
")",
"(",
"Server",
",",
"error",
")",
"{",
"if",
"underlying",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrNilUnderlyingServer",
"\n",
"}",
"\n\n"... | // NewKeyspaceFilteringServer constructs a new server based on the provided
// implementation that prevents the specified keyspaces from being exposed
// to consumers of the new Server.
//
// A filtering server will not allow access to the topo.Server to prevent
// updates that may corrupt the global VSchema keyspace. | [
"NewKeyspaceFilteringServer",
"constructs",
"a",
"new",
"server",
"based",
"on",
"the",
"provided",
"implementation",
"that",
"prevents",
"the",
"specified",
"keyspaces",
"from",
"being",
"exposed",
"to",
"consumers",
"of",
"the",
"new",
"Server",
".",
"A",
"filte... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/keyspace_filtering_server.go#L45-L59 |
158,091 | vitessio/vitess | go/vt/worker/vertical_split_clone_cmd.go | keyspacesWithServedFrom | func keyspacesWithServedFrom(ctx context.Context, wr *wrangler.Wrangler) ([]string, error) {
shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
keyspaces, err := wr.TopoServer().GetKeyspaces(shortCtx)
cancel()
if err != nil {
return nil, vterrors.Wrap(err, "failed to get list of keyspaces")
}
wg := sync.WaitGroup{}
mu := sync.Mutex{} // protects result
result := make([]string, 0, len(keyspaces))
rec := concurrency.AllErrorRecorder{}
for _, keyspace := range keyspaces {
wg.Add(1)
go func(keyspace string) {
defer wg.Done()
shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
ki, err := wr.TopoServer().GetKeyspace(shortCtx, keyspace)
cancel()
if err != nil {
rec.RecordError(vterrors.Wrapf(err, "failed to get details for keyspace '%v'", keyspace))
return
}
if len(ki.ServedFroms) > 0 {
mu.Lock()
result = append(result, keyspace)
mu.Unlock()
}
}(keyspace)
}
wg.Wait()
if rec.HasErrors() {
return nil, rec.Error()
}
if len(result) == 0 {
return nil, fmt.Errorf("there are no keyspaces with ServedFrom")
}
return result, nil
} | go | func keyspacesWithServedFrom(ctx context.Context, wr *wrangler.Wrangler) ([]string, error) {
shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
keyspaces, err := wr.TopoServer().GetKeyspaces(shortCtx)
cancel()
if err != nil {
return nil, vterrors.Wrap(err, "failed to get list of keyspaces")
}
wg := sync.WaitGroup{}
mu := sync.Mutex{} // protects result
result := make([]string, 0, len(keyspaces))
rec := concurrency.AllErrorRecorder{}
for _, keyspace := range keyspaces {
wg.Add(1)
go func(keyspace string) {
defer wg.Done()
shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
ki, err := wr.TopoServer().GetKeyspace(shortCtx, keyspace)
cancel()
if err != nil {
rec.RecordError(vterrors.Wrapf(err, "failed to get details for keyspace '%v'", keyspace))
return
}
if len(ki.ServedFroms) > 0 {
mu.Lock()
result = append(result, keyspace)
mu.Unlock()
}
}(keyspace)
}
wg.Wait()
if rec.HasErrors() {
return nil, rec.Error()
}
if len(result) == 0 {
return nil, fmt.Errorf("there are no keyspaces with ServedFrom")
}
return result, nil
} | [
"func",
"keyspacesWithServedFrom",
"(",
"ctx",
"context",
".",
"Context",
",",
"wr",
"*",
"wrangler",
".",
"Wrangler",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"shortCtx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
... | // keyspacesWithServedFrom returns all the keyspaces that have ServedFrom set
// to one value. | [
"keyspacesWithServedFrom",
"returns",
"all",
"the",
"keyspaces",
"that",
"have",
"ServedFrom",
"set",
"to",
"one",
"value",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/vertical_split_clone_cmd.go#L154-L193 |
158,092 | vitessio/vitess | go/vt/vttablet/tabletmanager/orchestrator.go | newOrcClient | func newOrcClient() (*orcClient, error) {
if *orcAddr == "" {
// Orchestrator integration is disabled.
return nil, nil
}
apiRoot, err := url.Parse(*orcAddr)
if err != nil {
return nil, vterrors.Wrapf(err, "can't parse -orc_api_url flag value (%v)", *orcAddr)
}
return &orcClient{
apiRoot: apiRoot,
httpClient: &http.Client{Timeout: *orcTimeout},
}, nil
} | go | func newOrcClient() (*orcClient, error) {
if *orcAddr == "" {
// Orchestrator integration is disabled.
return nil, nil
}
apiRoot, err := url.Parse(*orcAddr)
if err != nil {
return nil, vterrors.Wrapf(err, "can't parse -orc_api_url flag value (%v)", *orcAddr)
}
return &orcClient{
apiRoot: apiRoot,
httpClient: &http.Client{Timeout: *orcTimeout},
}, nil
} | [
"func",
"newOrcClient",
"(",
")",
"(",
"*",
"orcClient",
",",
"error",
")",
"{",
"if",
"*",
"orcAddr",
"==",
"\"",
"\"",
"{",
"// Orchestrator integration is disabled.",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"apiRoot",
",",
"err",
":=",
"url",
".... | // newOrcClient creates a client for the Orchestrator HTTP API.
// It should only be called after flags have been parsed. | [
"newOrcClient",
"creates",
"a",
"client",
"for",
"the",
"Orchestrator",
"HTTP",
"API",
".",
"It",
"should",
"only",
"be",
"called",
"after",
"flags",
"have",
"been",
"parsed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/orchestrator.go#L51-L64 |
158,093 | vitessio/vitess | go/vt/vttablet/tabletmanager/orchestrator.go | Discover | func (orc *orcClient) Discover(tablet *topodatapb.Tablet) error {
host, port, err := mysqlHostPort(tablet)
if err != nil {
return err
}
_, err = orc.apiGet("discover", host, port)
return err
} | go | func (orc *orcClient) Discover(tablet *topodatapb.Tablet) error {
host, port, err := mysqlHostPort(tablet)
if err != nil {
return err
}
_, err = orc.apiGet("discover", host, port)
return err
} | [
"func",
"(",
"orc",
"*",
"orcClient",
")",
"Discover",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"error",
"{",
"host",
",",
"port",
",",
"err",
":=",
"mysqlHostPort",
"(",
"tablet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err... | // Discover executes a single attempt to self-register with Orchestrator. | [
"Discover",
"executes",
"a",
"single",
"attempt",
"to",
"self",
"-",
"register",
"with",
"Orchestrator",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/orchestrator.go#L103-L110 |
158,094 | vitessio/vitess | go/vt/worker/row_aggregator.go | NewRowAggregator | func NewRowAggregator(ctx context.Context, maxRows, maxSize int, insertChannel chan string, dbName string, td *tabletmanagerdatapb.TableDefinition, diffType DiffType, statsCounters *stats.CountersWithSingleLabel) *RowAggregator {
// Construct head and tail base commands for the reconciliation statement.
var builder QueryBuilder
switch diffType {
case DiffMissing:
// Example: INSERT INTO test (id, sub_id, msg) VALUES (0, 10, 'a'), (1, 11, 'b')
builder = NewInsertsQueryBuilder(dbName, td)
case DiffNotEqual:
// Example: UPDATE test SET msg='a' WHERE id=0 AND sub_id=10
builder = NewUpdatesQueryBuilder(dbName, td)
// UPDATE ... SET does not support multiple rows as input.
maxRows = 1
case DiffExtraneous:
// Example: DELETE FROM test WHERE (id, sub_id) IN ((0, 10), (1, 11))
builder = NewDeletesQueryBuilder(dbName, td)
default:
panic(fmt.Sprintf("unknown DiffType: %v", diffType))
}
return &RowAggregator{
ctx: ctx,
maxRows: maxRows,
maxSize: maxSize,
insertChannel: insertChannel,
td: td,
diffType: diffType,
builder: builder,
statsCounters: statsCounters,
}
} | go | func NewRowAggregator(ctx context.Context, maxRows, maxSize int, insertChannel chan string, dbName string, td *tabletmanagerdatapb.TableDefinition, diffType DiffType, statsCounters *stats.CountersWithSingleLabel) *RowAggregator {
// Construct head and tail base commands for the reconciliation statement.
var builder QueryBuilder
switch diffType {
case DiffMissing:
// Example: INSERT INTO test (id, sub_id, msg) VALUES (0, 10, 'a'), (1, 11, 'b')
builder = NewInsertsQueryBuilder(dbName, td)
case DiffNotEqual:
// Example: UPDATE test SET msg='a' WHERE id=0 AND sub_id=10
builder = NewUpdatesQueryBuilder(dbName, td)
// UPDATE ... SET does not support multiple rows as input.
maxRows = 1
case DiffExtraneous:
// Example: DELETE FROM test WHERE (id, sub_id) IN ((0, 10), (1, 11))
builder = NewDeletesQueryBuilder(dbName, td)
default:
panic(fmt.Sprintf("unknown DiffType: %v", diffType))
}
return &RowAggregator{
ctx: ctx,
maxRows: maxRows,
maxSize: maxSize,
insertChannel: insertChannel,
td: td,
diffType: diffType,
builder: builder,
statsCounters: statsCounters,
}
} | [
"func",
"NewRowAggregator",
"(",
"ctx",
"context",
".",
"Context",
",",
"maxRows",
",",
"maxSize",
"int",
",",
"insertChannel",
"chan",
"string",
",",
"dbName",
"string",
",",
"td",
"*",
"tabletmanagerdatapb",
".",
"TableDefinition",
",",
"diffType",
"DiffType",... | // NewRowAggregator returns a RowAggregator.
// The index of the elements in statCounters must match the elements
// in "DiffTypes" i.e. the first counter is for inserts, second for updates
// and the third for deletes. | [
"NewRowAggregator",
"returns",
"a",
"RowAggregator",
".",
"The",
"index",
"of",
"the",
"elements",
"in",
"statCounters",
"must",
"match",
"the",
"elements",
"in",
"DiffTypes",
"i",
".",
"e",
".",
"the",
"first",
"counter",
"is",
"for",
"inserts",
"second",
"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/row_aggregator.go#L62-L91 |
158,095 | vitessio/vitess | go/vt/worker/row_aggregator.go | Add | func (ra *RowAggregator) Add(row []sqltypes.Value) error {
if ra.buffer.Len() == 0 {
ra.builder.WriteHead(&ra.buffer)
}
if ra.bufferedRows >= 1 {
ra.builder.WriteSeparator(&ra.buffer)
}
ra.builder.WriteRow(&ra.buffer, row)
ra.bufferedRows++
if ra.bufferedRows >= ra.maxRows || ra.buffer.Len() >= ra.maxSize {
if err := ra.Flush(); err != nil {
return err
}
}
return nil
} | go | func (ra *RowAggregator) Add(row []sqltypes.Value) error {
if ra.buffer.Len() == 0 {
ra.builder.WriteHead(&ra.buffer)
}
if ra.bufferedRows >= 1 {
ra.builder.WriteSeparator(&ra.buffer)
}
ra.builder.WriteRow(&ra.buffer, row)
ra.bufferedRows++
if ra.bufferedRows >= ra.maxRows || ra.buffer.Len() >= ra.maxSize {
if err := ra.Flush(); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"ra",
"*",
"RowAggregator",
")",
"Add",
"(",
"row",
"[",
"]",
"sqltypes",
".",
"Value",
")",
"error",
"{",
"if",
"ra",
".",
"buffer",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"ra",
".",
"builder",
".",
"WriteHead",
"(",
"&",
"ra",
"."... | // Add will add a new row which must be reconciled.
// If an error is returned, RowAggregator will be in an undefined state and must
// not be used any longer. | [
"Add",
"will",
"add",
"a",
"new",
"row",
"which",
"must",
"be",
"reconciled",
".",
"If",
"an",
"error",
"is",
"returned",
"RowAggregator",
"will",
"be",
"in",
"an",
"undefined",
"state",
"and",
"must",
"not",
"be",
"used",
"any",
"longer",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/row_aggregator.go#L96-L114 |
158,096 | vitessio/vitess | go/vt/worker/row_aggregator.go | Flush | func (ra *RowAggregator) Flush() error {
if ra.buffer.Len() == 0 {
// Already flushed.
return nil
}
ra.builder.WriteTail(&ra.buffer)
// select blocks until sending the SQL succeeded or the context was canceled.
select {
case ra.insertChannel <- ra.buffer.String():
case <-ra.ctx.Done():
return vterrors.Wrap(ra.ctx.Err(), "failed to flush RowAggregator and send the query to a writer thread channel")
}
// Update our statistics.
ra.statsCounters.Add(ra.td.Name, int64(ra.bufferedRows))
ra.buffer.Reset()
ra.bufferedRows = 0
return nil
} | go | func (ra *RowAggregator) Flush() error {
if ra.buffer.Len() == 0 {
// Already flushed.
return nil
}
ra.builder.WriteTail(&ra.buffer)
// select blocks until sending the SQL succeeded or the context was canceled.
select {
case ra.insertChannel <- ra.buffer.String():
case <-ra.ctx.Done():
return vterrors.Wrap(ra.ctx.Err(), "failed to flush RowAggregator and send the query to a writer thread channel")
}
// Update our statistics.
ra.statsCounters.Add(ra.td.Name, int64(ra.bufferedRows))
ra.buffer.Reset()
ra.bufferedRows = 0
return nil
} | [
"func",
"(",
"ra",
"*",
"RowAggregator",
")",
"Flush",
"(",
")",
"error",
"{",
"if",
"ra",
".",
"buffer",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"// Already flushed.",
"return",
"nil",
"\n",
"}",
"\n\n",
"ra",
".",
"builder",
".",
"WriteTail",
"(",
... | // Flush sends out the current aggregation buffer. | [
"Flush",
"sends",
"out",
"the",
"current",
"aggregation",
"buffer",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/row_aggregator.go#L117-L137 |
158,097 | vitessio/vitess | go/vt/worker/row_aggregator.go | WriteHead | func (b *BaseQueryBuilder) WriteHead(buffer *bytes.Buffer) {
buffer.WriteString(b.head)
} | go | func (b *BaseQueryBuilder) WriteHead(buffer *bytes.Buffer) {
buffer.WriteString(b.head)
} | [
"func",
"(",
"b",
"*",
"BaseQueryBuilder",
")",
"WriteHead",
"(",
"buffer",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"buffer",
".",
"WriteString",
"(",
"b",
".",
"head",
")",
"\n",
"}"
] | // WriteHead implements the QueryBuilder interface. | [
"WriteHead",
"implements",
"the",
"QueryBuilder",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/row_aggregator.go#L162-L164 |
158,098 | vitessio/vitess | go/vt/worker/row_aggregator.go | WriteTail | func (b *BaseQueryBuilder) WriteTail(buffer *bytes.Buffer) {
buffer.WriteString(b.tail)
} | go | func (b *BaseQueryBuilder) WriteTail(buffer *bytes.Buffer) {
buffer.WriteString(b.tail)
} | [
"func",
"(",
"b",
"*",
"BaseQueryBuilder",
")",
"WriteTail",
"(",
"buffer",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"buffer",
".",
"WriteString",
"(",
"b",
".",
"tail",
")",
"\n",
"}"
] | // WriteTail implements the QueryBuilder interface. | [
"WriteTail",
"implements",
"the",
"QueryBuilder",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/row_aggregator.go#L167-L169 |
158,099 | vitessio/vitess | go/vt/worker/row_aggregator.go | WriteSeparator | func (b *BaseQueryBuilder) WriteSeparator(buffer *bytes.Buffer) {
if b.separator == "" {
panic("BaseQueryBuilder.WriteSeparator(): separator not defined")
}
buffer.WriteString(b.separator)
} | go | func (b *BaseQueryBuilder) WriteSeparator(buffer *bytes.Buffer) {
if b.separator == "" {
panic("BaseQueryBuilder.WriteSeparator(): separator not defined")
}
buffer.WriteString(b.separator)
} | [
"func",
"(",
"b",
"*",
"BaseQueryBuilder",
")",
"WriteSeparator",
"(",
"buffer",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"if",
"b",
".",
"separator",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"buffer",
".",
"WriteString",
... | // WriteSeparator implements the QueryBuilder interface. | [
"WriteSeparator",
"implements",
"the",
"QueryBuilder",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/row_aggregator.go#L172-L177 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.