id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
135,500 | vitessio/vitess | go/vt/vttablet/tabletserver/txserializer/tx_serializer.go | lockLocked | func (t *TxSerializer) lockLocked(ctx context.Context, key, table string) (bool, error) {
q, ok := t.queues[key]
if !ok {
// First transaction in the queue i.e. we don't wait and return immediately.
t.queues[key] = newQueueForFirstTransaction(t.concurrentTransactions)
t.globalSize++
return false, nil
}
if ... | go | func (t *TxSerializer) lockLocked(ctx context.Context, key, table string) (bool, error) {
q, ok := t.queues[key]
if !ok {
// First transaction in the queue i.e. we don't wait and return immediately.
t.queues[key] = newQueueForFirstTransaction(t.concurrentTransactions)
t.globalSize++
return false, nil
}
if ... | [
"func",
"(",
"t",
"*",
"TxSerializer",
")",
"lockLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
",",
"table",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"q",
",",
"ok",
":=",
"t",
".",
"queues",
"[",
"key",
"]",
"\n",
"if",
... | // lockLocked queues this transaction. It will unblock immediately if this
// transaction is the first in the queue or when it acquired a slot.
// The method has the suffix "Locked" to clarify that "t.mu" must be locked. | [
"lockLocked",
"queues",
"this",
"transaction",
".",
"It",
"will",
"unblock",
"immediately",
"if",
"this",
"transaction",
"is",
"the",
"first",
"in",
"the",
"queue",
"or",
"when",
"it",
"acquired",
"a",
"slot",
".",
"The",
"method",
"has",
"the",
"suffix",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/txserializer/tx_serializer.go#L157-L237 |
135,501 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | NewReader | func NewReader(checker connpool.MySQLChecker, config tabletenv.TabletConfig) *Reader {
if !config.HeartbeatEnable {
return &Reader{}
}
return &Reader{
enabled: true,
now: time.Now,
interval: config.HeartbeatInterval,
ticks: timer.NewTimer(config.HeartbeatInterval),
errorLog: logutil.NewThrottle... | go | func NewReader(checker connpool.MySQLChecker, config tabletenv.TabletConfig) *Reader {
if !config.HeartbeatEnable {
return &Reader{}
}
return &Reader{
enabled: true,
now: time.Now,
interval: config.HeartbeatInterval,
ticks: timer.NewTimer(config.HeartbeatInterval),
errorLog: logutil.NewThrottle... | [
"func",
"NewReader",
"(",
"checker",
"connpool",
".",
"MySQLChecker",
",",
"config",
"tabletenv",
".",
"TabletConfig",
")",
"*",
"Reader",
"{",
"if",
"!",
"config",
".",
"HeartbeatEnable",
"{",
"return",
"&",
"Reader",
"{",
"}",
"\n",
"}",
"\n\n",
"return"... | // NewReader returns a new heartbeat reader. | [
"NewReader",
"returns",
"a",
"new",
"heartbeat",
"reader",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L72-L85 |
135,502 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | Init | func (r *Reader) Init(target querypb.Target) {
if !r.enabled {
return
}
r.dbName = sqlescape.EscapeID(r.dbconfigs.SidecarDBName.Get())
r.keyspaceShard = fmt.Sprintf("%s:%s", target.Keyspace, target.Shard)
} | go | func (r *Reader) Init(target querypb.Target) {
if !r.enabled {
return
}
r.dbName = sqlescape.EscapeID(r.dbconfigs.SidecarDBName.Get())
r.keyspaceShard = fmt.Sprintf("%s:%s", target.Keyspace, target.Shard)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Init",
"(",
"target",
"querypb",
".",
"Target",
")",
"{",
"if",
"!",
"r",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"r",
".",
"dbName",
"=",
"sqlescape",
".",
"EscapeID",
"(",
"r",
".",
"dbconfigs",
".... | // Init does last minute initialization of db settings, such as dbName
// and keyspaceShard | [
"Init",
"does",
"last",
"minute",
"initialization",
"of",
"db",
"settings",
"such",
"as",
"dbName",
"and",
"keyspaceShard"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L94-L100 |
135,503 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | Open | func (r *Reader) Open() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if r.isOpen {
return
}
log.Info("Beginning heartbeat reads")
r.pool.Open(r.dbconfigs.AppWithDB(), r.dbconfigs.DbaWithDB(), r.dbconfigs.AppDebugWithDB())
r.ticks.Start(func() { r.readHeartbeat() })
r.isOpen = true
} | go | func (r *Reader) Open() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if r.isOpen {
return
}
log.Info("Beginning heartbeat reads")
r.pool.Open(r.dbconfigs.AppWithDB(), r.dbconfigs.DbaWithDB(), r.dbconfigs.AppDebugWithDB())
r.ticks.Start(func() { r.readHeartbeat() })
r.isOpen = true
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Open",
"(",
")",
"{",
"if",
"!",
"r",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"r",
".",
"runMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"runMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"r... | // Open starts the heartbeat ticker and opens the db pool. It may be called multiple
// times, as long as it was closed since last invocation. | [
"Open",
"starts",
"the",
"heartbeat",
"ticker",
"and",
"opens",
"the",
"db",
"pool",
".",
"It",
"may",
"be",
"called",
"multiple",
"times",
"as",
"long",
"as",
"it",
"was",
"closed",
"since",
"last",
"invocation",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L104-L118 |
135,504 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | Close | func (r *Reader) Close() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if !r.isOpen {
return
}
r.ticks.Stop()
r.pool.Close()
log.Info("Stopped heartbeat reads")
r.isOpen = false
} | go | func (r *Reader) Close() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if !r.isOpen {
return
}
r.ticks.Stop()
r.pool.Close()
log.Info("Stopped heartbeat reads")
r.isOpen = false
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Close",
"(",
")",
"{",
"if",
"!",
"r",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"r",
".",
"runMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"runMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"... | // Close cancels the watchHeartbeat periodic ticker and closes the db pool.
// A reader object can be re-opened after closing. | [
"Close",
"cancels",
"the",
"watchHeartbeat",
"periodic",
"ticker",
"and",
"closes",
"the",
"db",
"pool",
".",
"A",
"reader",
"object",
"can",
"be",
"re",
"-",
"opened",
"after",
"closing",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L122-L135 |
135,505 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | fetchMostRecentHeartbeat | func (r *Reader) fetchMostRecentHeartbeat(ctx context.Context) (*sqltypes.Result, error) {
conn, err := r.pool.Get(ctx)
if err != nil {
return nil, err
}
defer conn.Recycle()
sel, err := r.bindHeartbeatFetch()
if err != nil {
return nil, err
}
return conn.Exec(ctx, sel, 1, false)
} | go | func (r *Reader) fetchMostRecentHeartbeat(ctx context.Context) (*sqltypes.Result, error) {
conn, err := r.pool.Get(ctx)
if err != nil {
return nil, err
}
defer conn.Recycle()
sel, err := r.bindHeartbeatFetch()
if err != nil {
return nil, err
}
return conn.Exec(ctx, sel, 1, false)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"fetchMostRecentHeartbeat",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"r",
".",
"pool",
".",
"Get",
"(",
"ctx",
")",
"\n"... | // fetchMostRecentHeartbeat fetches the most recently recorded heartbeat from the heartbeat table,
// returning a result with the timestamp of the heartbeat. | [
"fetchMostRecentHeartbeat",
"fetches",
"the",
"most",
"recently",
"recorded",
"heartbeat",
"from",
"the",
"heartbeat",
"table",
"returning",
"a",
"result",
"with",
"the",
"timestamp",
"of",
"the",
"heartbeat",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L179-L190 |
135,506 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | bindHeartbeatFetch | func (r *Reader) bindHeartbeatFetch() (string, error) {
bindVars := map[string]*querypb.BindVariable{
"ks": sqltypes.StringBindVariable(r.keyspaceShard),
}
parsed := sqlparser.BuildParsedQuery(sqlFetchMostRecentHeartbeat, r.dbName, ":ks")
bound, err := parsed.GenerateQuery(bindVars, nil)
if err != nil {
return... | go | func (r *Reader) bindHeartbeatFetch() (string, error) {
bindVars := map[string]*querypb.BindVariable{
"ks": sqltypes.StringBindVariable(r.keyspaceShard),
}
parsed := sqlparser.BuildParsedQuery(sqlFetchMostRecentHeartbeat, r.dbName, ":ks")
bound, err := parsed.GenerateQuery(bindVars, nil)
if err != nil {
return... | [
"func",
"(",
"r",
"*",
"Reader",
")",
"bindHeartbeatFetch",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"bindVars",
":=",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
"{",
"\"",
"\"",
":",
"sqltypes",
".",
"StringBindVariable",
... | // bindHeartbeatFetch takes a heartbeat read and adds the necessary
// fields to the query as bind vars. This is done to protect ourselves
// against a badly formed keyspace or shard name. | [
"bindHeartbeatFetch",
"takes",
"a",
"heartbeat",
"read",
"and",
"adds",
"the",
"necessary",
"fields",
"to",
"the",
"query",
"as",
"bind",
"vars",
".",
"This",
"is",
"done",
"to",
"protect",
"ourselves",
"against",
"a",
"badly",
"formed",
"keyspace",
"or",
"s... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L195-L205 |
135,507 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | parseHeartbeatResult | func parseHeartbeatResult(res *sqltypes.Result) (int64, error) {
if len(res.Rows) != 1 {
return 0, fmt.Errorf("failed to read heartbeat: writer query did not result in 1 row. Got %v", len(res.Rows))
}
ts, err := sqltypes.ToInt64(res.Rows[0][0])
if err != nil {
return 0, err
}
return ts, nil
} | go | func parseHeartbeatResult(res *sqltypes.Result) (int64, error) {
if len(res.Rows) != 1 {
return 0, fmt.Errorf("failed to read heartbeat: writer query did not result in 1 row. Got %v", len(res.Rows))
}
ts, err := sqltypes.ToInt64(res.Rows[0][0])
if err != nil {
return 0, err
}
return ts, nil
} | [
"func",
"parseHeartbeatResult",
"(",
"res",
"*",
"sqltypes",
".",
"Result",
")",
"(",
"int64",
",",
"error",
")",
"{",
"if",
"len",
"(",
"res",
".",
"Rows",
")",
"!=",
"1",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len... | // parseHeartbeatResult turns a raw result into the timestamp for processing. | [
"parseHeartbeatResult",
"turns",
"a",
"raw",
"result",
"into",
"the",
"timestamp",
"for",
"processing",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L208-L217 |
135,508 | vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | recordError | func (r *Reader) recordError(err error) {
r.lagMu.Lock()
r.lastKnownError = err
r.lagMu.Unlock()
r.errorLog.Errorf("%v", err)
readErrors.Add(1)
} | go | func (r *Reader) recordError(err error) {
r.lagMu.Lock()
r.lastKnownError = err
r.lagMu.Unlock()
r.errorLog.Errorf("%v", err)
readErrors.Add(1)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"recordError",
"(",
"err",
"error",
")",
"{",
"r",
".",
"lagMu",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"lastKnownError",
"=",
"err",
"\n",
"r",
".",
"lagMu",
".",
"Unlock",
"(",
")",
"\n",
"r",
".",
"error... | // recordError keeps track of the lastKnown error for reporting to the healthcheck.
// Errors tracked here are logged with throttling to cut down on log spam since
// operations can happen very frequently in this package. | [
"recordError",
"keeps",
"track",
"of",
"the",
"lastKnown",
"error",
"for",
"reporting",
"to",
"the",
"healthcheck",
".",
"Errors",
"tracked",
"here",
"are",
"logged",
"with",
"throttling",
"to",
"cut",
"down",
"on",
"log",
"spam",
"since",
"operations",
"can",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L222-L228 |
135,509 | vitessio/vitess | go/vt/servenv/rpc_utils.go | HandlePanic | func HandlePanic(component string, err *error) {
if x := recover(); x != nil {
// gRPC 0.13 chokes when you return a streaming error that contains newlines.
*err = fmt.Errorf("uncaught %v panic: %v, %s", component, x,
strings.Replace(string(tb.Stack(4)), "\n", ";", -1))
}
} | go | func HandlePanic(component string, err *error) {
if x := recover(); x != nil {
// gRPC 0.13 chokes when you return a streaming error that contains newlines.
*err = fmt.Errorf("uncaught %v panic: %v, %s", component, x,
strings.Replace(string(tb.Stack(4)), "\n", ";", -1))
}
} | [
"func",
"HandlePanic",
"(",
"component",
"string",
",",
"err",
"*",
"error",
")",
"{",
"if",
"x",
":=",
"recover",
"(",
")",
";",
"x",
"!=",
"nil",
"{",
"// gRPC 0.13 chokes when you return a streaming error that contains newlines.",
"*",
"err",
"=",
"fmt",
".",... | // HandlePanic should be called using 'defer' in the RPC code that executes the command. | [
"HandlePanic",
"should",
"be",
"called",
"using",
"defer",
"in",
"the",
"RPC",
"code",
"that",
"executes",
"the",
"command",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/servenv/rpc_utils.go#L27-L33 |
135,510 | vitessio/vitess | go/vt/topo/consultopo/server.go | NewServer | func NewServer(cell, serverAddr, root string) (*Server, error) {
creds, err := getClientCreds()
if err != nil {
return nil, err
}
cfg := api.DefaultConfig()
cfg.Address = serverAddr
if creds != nil {
if creds[cell] != nil {
cfg.Token = creds[cell].ACLToken
} else {
log.Warningf("Client auth not config... | go | func NewServer(cell, serverAddr, root string) (*Server, error) {
creds, err := getClientCreds()
if err != nil {
return nil, err
}
cfg := api.DefaultConfig()
cfg.Address = serverAddr
if creds != nil {
if creds[cell] != nil {
cfg.Token = creds[cell].ACLToken
} else {
log.Warningf("Client auth not config... | [
"func",
"NewServer",
"(",
"cell",
",",
"serverAddr",
",",
"root",
"string",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"creds",
",",
"err",
":=",
"getClientCreds",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\... | // NewServer returns a new consultopo.Server. | [
"NewServer",
"returns",
"a",
"new",
"consultopo",
".",
"Server",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/consultopo/server.go#L107-L133 |
135,511 | vitessio/vitess | go/vt/topo/consultopo/server.go | Close | func (s *Server) Close() {
s.client = nil
s.kv = nil
s.mu.Lock()
defer s.mu.Unlock()
s.locks = nil
} | go | func (s *Server) Close() {
s.client = nil
s.kv = nil
s.mu.Lock()
defer s.mu.Unlock()
s.locks = nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Close",
"(",
")",
"{",
"s",
".",
"client",
"=",
"nil",
"\n",
"s",
".",
"kv",
"=",
"nil",
"\n",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"s"... | // Close implements topo.Server.Close.
// It will nil out the global and cells fields, so any attempt to
// re-use this server will panic. | [
"Close",
"implements",
"topo",
".",
"Server",
".",
"Close",
".",
"It",
"will",
"nil",
"out",
"the",
"global",
"and",
"cells",
"fields",
"so",
"any",
"attempt",
"to",
"re",
"-",
"use",
"this",
"server",
"will",
"panic",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/consultopo/server.go#L138-L144 |
135,512 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | MarshalJSON | func (ks *KeyspaceSchema) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Sharded bool `json:"sharded,omitempty"`
Tables map[string]*Table `json:"tables,omitempty"`
Vindexes map[string]Vindex `json:"vindexes,omitempty"`
Error string `json:"error,omitempty"`
}{
Shar... | go | func (ks *KeyspaceSchema) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Sharded bool `json:"sharded,omitempty"`
Tables map[string]*Table `json:"tables,omitempty"`
Vindexes map[string]Vindex `json:"vindexes,omitempty"`
Error string `json:"error,omitempty"`
}{
Shar... | [
"func",
"(",
"ks",
"*",
"KeyspaceSchema",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"struct",
"{",
"Sharded",
"bool",
"`json:\"sharded,omitempty\"`",
"\n",
"Tables",
"map",
"[",
"s... | // MarshalJSON returns a JSON representation of KeyspaceSchema. | [
"MarshalJSON",
"returns",
"a",
"JSON",
"representation",
"of",
"KeyspaceSchema",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L136-L153 |
135,513 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | BuildVSchema | func BuildVSchema(source *vschemapb.SrvVSchema) (vschema *VSchema, err error) {
vschema = &VSchema{
RoutingRules: make(map[string]*RoutingRule),
uniqueTables: make(map[string]*Table),
uniqueVindexes: make(map[string]Vindex),
Keyspaces: make(map[string]*KeyspaceSchema),
}
buildKeyspaces(source, vsche... | go | func BuildVSchema(source *vschemapb.SrvVSchema) (vschema *VSchema, err error) {
vschema = &VSchema{
RoutingRules: make(map[string]*RoutingRule),
uniqueTables: make(map[string]*Table),
uniqueVindexes: make(map[string]Vindex),
Keyspaces: make(map[string]*KeyspaceSchema),
}
buildKeyspaces(source, vsche... | [
"func",
"BuildVSchema",
"(",
"source",
"*",
"vschemapb",
".",
"SrvVSchema",
")",
"(",
"vschema",
"*",
"VSchema",
",",
"err",
"error",
")",
"{",
"vschema",
"=",
"&",
"VSchema",
"{",
"RoutingRules",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Rout... | // BuildVSchema builds a VSchema from a SrvVSchema. | [
"BuildVSchema",
"builds",
"a",
"VSchema",
"from",
"a",
"SrvVSchema",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L162-L174 |
135,514 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | BuildKeyspaceSchema | func BuildKeyspaceSchema(input *vschemapb.Keyspace, keyspace string) (*KeyspaceSchema, error) {
if input == nil {
input = &vschemapb.Keyspace{}
}
formal := &vschemapb.SrvVSchema{
Keyspaces: map[string]*vschemapb.Keyspace{
keyspace: input,
},
}
vschema := &VSchema{
uniqueTables: make(map[string]*Table)... | go | func BuildKeyspaceSchema(input *vschemapb.Keyspace, keyspace string) (*KeyspaceSchema, error) {
if input == nil {
input = &vschemapb.Keyspace{}
}
formal := &vschemapb.SrvVSchema{
Keyspaces: map[string]*vschemapb.Keyspace{
keyspace: input,
},
}
vschema := &VSchema{
uniqueTables: make(map[string]*Table)... | [
"func",
"BuildKeyspaceSchema",
"(",
"input",
"*",
"vschemapb",
".",
"Keyspace",
",",
"keyspace",
"string",
")",
"(",
"*",
"KeyspaceSchema",
",",
"error",
")",
"{",
"if",
"input",
"==",
"nil",
"{",
"input",
"=",
"&",
"vschemapb",
".",
"Keyspace",
"{",
"}"... | // BuildKeyspaceSchema builds the vschema portion for one keyspace.
// The build ignores sequence references because those dependencies can
// go cross-keyspace. | [
"BuildKeyspaceSchema",
"builds",
"the",
"vschema",
"portion",
"for",
"one",
"keyspace",
".",
"The",
"build",
"ignores",
"sequence",
"references",
"because",
"those",
"dependencies",
"can",
"go",
"cross",
"-",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L179-L196 |
135,515 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | addDual | func addDual(vschema *VSchema) {
first := ""
for ksname, ks := range vschema.Keyspaces {
t := &Table{
Name: sqlparser.NewTableIdent("dual"),
Keyspace: ks.Keyspace,
}
if ks.Keyspace.Sharded {
t.Pinned = []byte{0}
}
ks.Tables["dual"] = t
if first == "" || first > ksname {
// In case of a ref... | go | func addDual(vschema *VSchema) {
first := ""
for ksname, ks := range vschema.Keyspaces {
t := &Table{
Name: sqlparser.NewTableIdent("dual"),
Keyspace: ks.Keyspace,
}
if ks.Keyspace.Sharded {
t.Pinned = []byte{0}
}
ks.Tables["dual"] = t
if first == "" || first > ksname {
// In case of a ref... | [
"func",
"addDual",
"(",
"vschema",
"*",
"VSchema",
")",
"{",
"first",
":=",
"\"",
"\"",
"\n",
"for",
"ksname",
",",
"ks",
":=",
"range",
"vschema",
".",
"Keyspaces",
"{",
"t",
":=",
"&",
"Table",
"{",
"Name",
":",
"sqlparser",
".",
"NewTableIdent",
"... | // addDual adds dual as a valid table to all keyspaces.
// For sharded keyspaces, it gets pinned against keyspace id '0x00'. | [
"addDual",
"adds",
"dual",
"as",
"a",
"valid",
"table",
"to",
"all",
"keyspaces",
".",
"For",
"sharded",
"keyspaces",
"it",
"gets",
"pinned",
"against",
"keyspace",
"id",
"0x00",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L355-L375 |
135,516 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | findQualified | func (vschema *VSchema) findQualified(name string) (*Table, error) {
splits := strings.Split(name, ".")
switch len(splits) {
case 1:
return vschema.FindTable("", splits[0])
case 2:
return vschema.FindTable(splits[0], splits[1])
}
return nil, fmt.Errorf("table %s not found", name)
} | go | func (vschema *VSchema) findQualified(name string) (*Table, error) {
splits := strings.Split(name, ".")
switch len(splits) {
case 1:
return vschema.FindTable("", splits[0])
case 2:
return vschema.FindTable(splits[0], splits[1])
}
return nil, fmt.Errorf("table %s not found", name)
} | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"findQualified",
"(",
"name",
"string",
")",
"(",
"*",
"Table",
",",
"error",
")",
"{",
"splits",
":=",
"strings",
".",
"Split",
"(",
"name",
",",
"\"",
"\"",
")",
"\n",
"switch",
"len",
"(",
"splits",
"... | // findQualified finds a table t or k.t. | [
"findQualified",
"finds",
"a",
"table",
"t",
"or",
"k",
".",
"t",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L420-L429 |
135,517 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | findTable | func (vschema *VSchema) findTable(keyspace, tablename string) (*Table, error) {
if keyspace == "" {
table, ok := vschema.uniqueTables[tablename]
if table == nil {
if ok {
return nil, fmt.Errorf("ambiguous table reference: %s", tablename)
}
if len(vschema.Keyspaces) != 1 {
return nil, nil
}
/... | go | func (vschema *VSchema) findTable(keyspace, tablename string) (*Table, error) {
if keyspace == "" {
table, ok := vschema.uniqueTables[tablename]
if table == nil {
if ok {
return nil, fmt.Errorf("ambiguous table reference: %s", tablename)
}
if len(vschema.Keyspaces) != 1 {
return nil, nil
}
/... | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"findTable",
"(",
"keyspace",
",",
"tablename",
"string",
")",
"(",
"*",
"Table",
",",
"error",
")",
"{",
"if",
"keyspace",
"==",
"\"",
"\"",
"{",
"table",
",",
"ok",
":=",
"vschema",
".",
"uniqueTables",
... | // findTable is like FindTable, but does not return an error if a table is not found. | [
"findTable",
"is",
"like",
"FindTable",
"but",
"does",
"not",
"return",
"an",
"error",
"if",
"a",
"table",
"is",
"not",
"found",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L451-L483 |
135,518 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | FindTablesOrVindex | func (vschema *VSchema) FindTablesOrVindex(keyspace, name string, tabletType topodatapb.TabletType) ([]*Table, Vindex, error) {
tables, err := vschema.findTables(keyspace, name, tabletType)
if err != nil {
return nil, nil, err
}
if tables != nil {
return tables, nil, nil
}
v, err := vschema.FindVindex(keyspac... | go | func (vschema *VSchema) FindTablesOrVindex(keyspace, name string, tabletType topodatapb.TabletType) ([]*Table, Vindex, error) {
tables, err := vschema.findTables(keyspace, name, tabletType)
if err != nil {
return nil, nil, err
}
if tables != nil {
return tables, nil, nil
}
v, err := vschema.FindVindex(keyspac... | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"FindTablesOrVindex",
"(",
"keyspace",
",",
"name",
"string",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"(",
"[",
"]",
"*",
"Table",
",",
"Vindex",
",",
"error",
")",
"{",
"tables",
",",
"err",
... | // FindTablesOrVindex finds a table or a Vindex by name using Find and FindVindex. | [
"FindTablesOrVindex",
"finds",
"a",
"table",
"or",
"a",
"Vindex",
"by",
"name",
"using",
"Find",
"and",
"FindVindex",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L516-L532 |
135,519 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | FindVindex | func (vschema *VSchema) FindVindex(keyspace, name string) (Vindex, error) {
if keyspace == "" {
vindex, ok := vschema.uniqueVindexes[name]
if vindex == nil && ok {
return nil, fmt.Errorf("ambiguous vindex reference: %s", name)
}
return vindex, nil
}
ks, ok := vschema.Keyspaces[keyspace]
if !ok {
return... | go | func (vschema *VSchema) FindVindex(keyspace, name string) (Vindex, error) {
if keyspace == "" {
vindex, ok := vschema.uniqueVindexes[name]
if vindex == nil && ok {
return nil, fmt.Errorf("ambiguous vindex reference: %s", name)
}
return vindex, nil
}
ks, ok := vschema.Keyspaces[keyspace]
if !ok {
return... | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"FindVindex",
"(",
"keyspace",
",",
"name",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"if",
"keyspace",
"==",
"\"",
"\"",
"{",
"vindex",
",",
"ok",
":=",
"vschema",
".",
"uniqueVindexes",
"[",
... | // FindVindex finds a vindex by name. If a keyspace is specified, only vindexes
// from that keyspace are searched. If no kesypace is specified, then a vindex
// is returned only if its name is unique across all keyspaces. The function
// returns an error only if the vindex name is ambiguous. | [
"FindVindex",
"finds",
"a",
"vindex",
"by",
"name",
".",
"If",
"a",
"keyspace",
"is",
"specified",
"only",
"vindexes",
"from",
"that",
"keyspace",
"are",
"searched",
".",
"If",
"no",
"kesypace",
"is",
"specified",
"then",
"a",
"vindex",
"is",
"returned",
"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L538-L551 |
135,520 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | LoadFormal | func LoadFormal(filename string) (*vschemapb.SrvVSchema, error) {
formal := &vschemapb.SrvVSchema{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, nil
} | go | func LoadFormal(filename string) (*vschemapb.SrvVSchema, error) {
formal := &vschemapb.SrvVSchema{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, nil
} | [
"func",
"LoadFormal",
"(",
"filename",
"string",
")",
"(",
"*",
"vschemapb",
".",
"SrvVSchema",
",",
"error",
")",
"{",
"formal",
":=",
"&",
"vschemapb",
".",
"SrvVSchema",
"{",
"}",
"\n",
"if",
"filename",
"==",
"\"",
"\"",
"{",
"return",
"formal",
",... | // LoadFormal loads the JSON representation of VSchema from a file. | [
"LoadFormal",
"loads",
"the",
"JSON",
"representation",
"of",
"VSchema",
"from",
"a",
"file",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L568-L582 |
135,521 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | LoadFormalKeyspace | func LoadFormalKeyspace(filename string) (*vschemapb.Keyspace, error) {
formal := &vschemapb.Keyspace{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, n... | go | func LoadFormalKeyspace(filename string) (*vschemapb.Keyspace, error) {
formal := &vschemapb.Keyspace{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, n... | [
"func",
"LoadFormalKeyspace",
"(",
"filename",
"string",
")",
"(",
"*",
"vschemapb",
".",
"Keyspace",
",",
"error",
")",
"{",
"formal",
":=",
"&",
"vschemapb",
".",
"Keyspace",
"{",
"}",
"\n",
"if",
"filename",
"==",
"\"",
"\"",
"{",
"return",
"formal",
... | // LoadFormalKeyspace loads the JSON representation of VSchema from a file,
// for a single keyspace. | [
"LoadFormalKeyspace",
"loads",
"the",
"JSON",
"representation",
"of",
"VSchema",
"from",
"a",
"file",
"for",
"a",
"single",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L586-L600 |
135,522 | vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | FindVindexForSharding | func FindVindexForSharding(tableName string, colVindexes []*ColumnVindex) (*ColumnVindex, error) {
if len(colVindexes) == 0 {
return nil, fmt.Errorf("no vindex definition for table %v", tableName)
}
result := colVindexes[0]
for _, colVindex := range colVindexes {
if colVindex.Vindex.Cost() < result.Vindex.Cost(... | go | func FindVindexForSharding(tableName string, colVindexes []*ColumnVindex) (*ColumnVindex, error) {
if len(colVindexes) == 0 {
return nil, fmt.Errorf("no vindex definition for table %v", tableName)
}
result := colVindexes[0]
for _, colVindex := range colVindexes {
if colVindex.Vindex.Cost() < result.Vindex.Cost(... | [
"func",
"FindVindexForSharding",
"(",
"tableName",
"string",
",",
"colVindexes",
"[",
"]",
"*",
"ColumnVindex",
")",
"(",
"*",
"ColumnVindex",
",",
"error",
")",
"{",
"if",
"len",
"(",
"colVindexes",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",... | // FindVindexForSharding searches through the given slice
// to find the lowest cost unique vindex
// primary vindex is always unique
// if two have the same cost, use the one that occurs earlier in the definition
// if the final result is too expensive, return nil | [
"FindVindexForSharding",
"searches",
"through",
"the",
"given",
"slice",
"to",
"find",
"the",
"lowest",
"cost",
"unique",
"vindex",
"primary",
"vindex",
"is",
"always",
"unique",
"if",
"two",
"have",
"the",
"same",
"cost",
"use",
"the",
"one",
"that",
"occurs"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L607-L621 |
135,523 | vitessio/vitess | go/cmd/vtclient/vtclient.go | merge | func (r *results) merge(other *results) {
if other == nil {
return
}
r.mu.Lock()
defer r.mu.Unlock()
r.rowsAffected += other.rowsAffected
if other.lastInsertID > r.lastInsertID {
r.lastInsertID = other.lastInsertID
}
r.cumulativeDuration += other.duration
} | go | func (r *results) merge(other *results) {
if other == nil {
return
}
r.mu.Lock()
defer r.mu.Unlock()
r.rowsAffected += other.rowsAffected
if other.lastInsertID > r.lastInsertID {
r.lastInsertID = other.lastInsertID
}
r.cumulativeDuration += other.duration
} | [
"func",
"(",
"r",
"*",
"results",
")",
"merge",
"(",
"other",
"*",
"results",
")",
"{",
"if",
"other",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"r",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"mu",
".",
"Unlock",
"(",
")... | // merge aggregates "other" into "r".
// This is only used for executing DMLs concurrently and repeatedly.
// Therefore, "Fields" and "Rows" are not merged. | [
"merge",
"aggregates",
"other",
"into",
"r",
".",
"This",
"is",
"only",
"used",
"for",
"executing",
"DMLs",
"concurrently",
"and",
"repeatedly",
".",
"Therefore",
"Fields",
"and",
"Rows",
"are",
"not",
"merged",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/cmd/vtclient/vtclient.go#L317-L330 |
135,524 | vitessio/vitess | go/vt/dbconfigs/credentials.go | GetCredentialsServer | func GetCredentialsServer() CredentialsServer {
cs, ok := AllCredentialsServers[*dbCredentialsServer]
if !ok {
log.Exitf("Invalid credential server: %v", *dbCredentialsServer)
}
return cs
} | go | func GetCredentialsServer() CredentialsServer {
cs, ok := AllCredentialsServers[*dbCredentialsServer]
if !ok {
log.Exitf("Invalid credential server: %v", *dbCredentialsServer)
}
return cs
} | [
"func",
"GetCredentialsServer",
"(",
")",
"CredentialsServer",
"{",
"cs",
",",
"ok",
":=",
"AllCredentialsServers",
"[",
"*",
"dbCredentialsServer",
"]",
"\n",
"if",
"!",
"ok",
"{",
"log",
".",
"Exitf",
"(",
"\"",
"\"",
",",
"*",
"dbCredentialsServer",
")",
... | // GetCredentialsServer returns the current CredentialsServer. Only valid
// after flag.Init was called. | [
"GetCredentialsServer",
"returns",
"the",
"current",
"CredentialsServer",
".",
"Only",
"valid",
"after",
"flag",
".",
"Init",
"was",
"called",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/credentials.go#L67-L73 |
135,525 | vitessio/vitess | go/vt/dbconfigs/credentials.go | GetUserAndPassword | func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error) {
fcs.mu.Lock()
defer fcs.mu.Unlock()
if *dbCredentialsFile == "" {
return "", "", ErrUnknownUser
}
// read the json file only once
if fcs.dbCredentials == nil {
fcs.dbCredentials = make(map[string][]string)
data, e... | go | func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error) {
fcs.mu.Lock()
defer fcs.mu.Unlock()
if *dbCredentialsFile == "" {
return "", "", ErrUnknownUser
}
// read the json file only once
if fcs.dbCredentials == nil {
fcs.dbCredentials = make(map[string][]string)
data, e... | [
"func",
"(",
"fcs",
"*",
"FileCredentialsServer",
")",
"GetUserAndPassword",
"(",
"user",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"fcs",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fcs",
".",
"mu",
".",
"Unlock",
"(... | // GetUserAndPassword is part of the CredentialsServer interface | [
"GetUserAndPassword",
"is",
"part",
"of",
"the",
"CredentialsServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/credentials.go#L83-L112 |
135,526 | vitessio/vitess | go/vt/dbconfigs/credentials.go | WithCredentials | func WithCredentials(cp *mysql.ConnParams) (*mysql.ConnParams, error) {
result := *cp
user, passwd, err := GetCredentialsServer().GetUserAndPassword(cp.Uname)
switch err {
case nil:
result.Uname = user
result.Pass = passwd
case ErrUnknownUser:
// we just use what we have, and will fail later anyway
err = n... | go | func WithCredentials(cp *mysql.ConnParams) (*mysql.ConnParams, error) {
result := *cp
user, passwd, err := GetCredentialsServer().GetUserAndPassword(cp.Uname)
switch err {
case nil:
result.Uname = user
result.Pass = passwd
case ErrUnknownUser:
// we just use what we have, and will fail later anyway
err = n... | [
"func",
"WithCredentials",
"(",
"cp",
"*",
"mysql",
".",
"ConnParams",
")",
"(",
"*",
"mysql",
".",
"ConnParams",
",",
"error",
")",
"{",
"result",
":=",
"*",
"cp",
"\n",
"user",
",",
"passwd",
",",
"err",
":=",
"GetCredentialsServer",
"(",
")",
".",
... | // WithCredentials returns a copy of the provided ConnParams that we can use
// to connect, after going through the CredentialsServer. | [
"WithCredentials",
"returns",
"a",
"copy",
"of",
"the",
"provided",
"ConnParams",
"that",
"we",
"can",
"use",
"to",
"connect",
"after",
"going",
"through",
"the",
"CredentialsServer",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/credentials.go#L116-L128 |
135,527 | vitessio/vitess | go/vt/topo/memorytopo/file.go | Create | func (c *Conn) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p... | go | func (c *Conn) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
",",
"contents",
"[",
"]",
"byte",
")",
"(",
"topo",
".",
"Version",
",",
"error",
")",
"{",
"if",
"contents",
"==",
"nil",
"{",
"conten... | // Create is part of topo.Conn interface. | [
"Create",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L31-L59 |
135,528 | vitessio/vitess | go/vt/topo/memorytopo/file.go | Update | func (c *Conn) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir, we'll need it i... | go | func (c *Conn) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir, we'll need it i... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
",",
"contents",
"[",
"]",
"byte",
",",
"version",
"topo",
".",
"Version",
")",
"(",
"topo",
".",
"Version",
",",
"error",
")",
"{",
"if... | // Update is part of topo.Conn interface. | [
"Update",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L62-L123 |
135,529 | vitessio/vitess | go/vt/topo/memorytopo/file.go | Get | func (c *Conn) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error) {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, nil, c.factory.err
}
// Get the node.
n := c.factory.nodeByPath(c.cell, filePath)
if n == nil {
return nil, nil, topo.NewError(topo.... | go | func (c *Conn) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error) {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, nil, c.factory.err
}
// Get the node.
n := c.factory.nodeByPath(c.cell, filePath)
if n == nil {
return nil, nil, topo.NewError(topo.... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"topo",
".",
"Version",
",",
"error",
")",
"{",
"c",
".",
"factory",
".",
"mu",
".",
"Lock",
"(",
")",... | // Get is part of topo.Conn interface. | [
"Get",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L126-L144 |
135,530 | vitessio/vitess | go/vt/topo/memorytopo/file.go | Delete | func (c *Conn) Delete(ctx context.Context, filePath string, version topo.Version) error {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p := c.factory.nodeByPath(c.cell, dir)
if p == nil {
return to... | go | func (c *Conn) Delete(ctx context.Context, filePath string, version topo.Version) error {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p := c.factory.nodeByPath(c.cell, dir)
if p == nil {
return to... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
",",
"version",
"topo",
".",
"Version",
")",
"error",
"{",
"c",
".",
"factory",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
... | // Delete is part of topo.Conn interface. | [
"Delete",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L147-L191 |
135,531 | vitessio/vitess | go/mysql/flavor_mysql.go | masterGTIDSet | func (mysqlFlavor) masterGTIDSet(c *Conn) (GTIDSet, error) {
qr, err := c.ExecuteFetch("SELECT @@GLOBAL.gtid_executed", 1, false)
if err != nil {
return nil, err
}
if len(qr.Rows) != 1 || len(qr.Rows[0]) != 1 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "unexpected result format for gtid_executed: %#v", q... | go | func (mysqlFlavor) masterGTIDSet(c *Conn) (GTIDSet, error) {
qr, err := c.ExecuteFetch("SELECT @@GLOBAL.gtid_executed", 1, false)
if err != nil {
return nil, err
}
if len(qr.Rows) != 1 || len(qr.Rows[0]) != 1 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "unexpected result format for gtid_executed: %#v", q... | [
"func",
"(",
"mysqlFlavor",
")",
"masterGTIDSet",
"(",
"c",
"*",
"Conn",
")",
"(",
"GTIDSet",
",",
"error",
")",
"{",
"qr",
",",
"err",
":=",
"c",
".",
"ExecuteFetch",
"(",
"\"",
"\"",
",",
"1",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // masterGTIDSet is part of the Flavor interface. | [
"masterGTIDSet",
"is",
"part",
"of",
"the",
"Flavor",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor_mysql.go#L33-L42 |
135,532 | vitessio/vitess | go/mysql/flavor_mysql.go | status | func (mysqlFlavor) status(c *Conn) (SlaveStatus, error) {
qr, err := c.ExecuteFetch("SHOW SLAVE STATUS", 100, true /* wantfields */)
if err != nil {
return SlaveStatus{}, err
}
if len(qr.Rows) == 0 {
// The query returned no data, meaning the server
// is not configured as a slave.
return SlaveStatus{}, Err... | go | func (mysqlFlavor) status(c *Conn) (SlaveStatus, error) {
qr, err := c.ExecuteFetch("SHOW SLAVE STATUS", 100, true /* wantfields */)
if err != nil {
return SlaveStatus{}, err
}
if len(qr.Rows) == 0 {
// The query returned no data, meaning the server
// is not configured as a slave.
return SlaveStatus{}, Err... | [
"func",
"(",
"mysqlFlavor",
")",
"status",
"(",
"c",
"*",
"Conn",
")",
"(",
"SlaveStatus",
",",
"error",
")",
"{",
"qr",
",",
"err",
":=",
"c",
".",
"ExecuteFetch",
"(",
"\"",
"\"",
",",
"100",
",",
"true",
"/* wantfields */",
")",
"\n",
"if",
"err... | // status is part of the Flavor interface. | [
"status",
"is",
"part",
"of",
"the",
"Flavor",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor_mysql.go#L92-L114 |
135,533 | vitessio/vitess | go/mysql/flavor_mysql.go | waitUntilPositionCommand | func (mysqlFlavor) waitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
// A timeout of 0 means wait indefinitely.
timeoutSeconds := 0
if deadline, ok := ctx.Deadline(); ok {
timeout := time.Until(deadline)
if timeout <= 0 {
return "", vterrors.Errorf(vtrpc.Code_DEADLINE_EXCEEDED, "ti... | go | func (mysqlFlavor) waitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
// A timeout of 0 means wait indefinitely.
timeoutSeconds := 0
if deadline, ok := ctx.Deadline(); ok {
timeout := time.Until(deadline)
if timeout <= 0 {
return "", vterrors.Errorf(vtrpc.Code_DEADLINE_EXCEEDED, "ti... | [
"func",
"(",
"mysqlFlavor",
")",
"waitUntilPositionCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"pos",
"Position",
")",
"(",
"string",
",",
"error",
")",
"{",
"// A timeout of 0 means wait indefinitely.",
"timeoutSeconds",
":=",
"0",
"\n",
"if",
"deadline... | // waitUntilPositionCommand is part of the Flavor interface. | [
"waitUntilPositionCommand",
"is",
"part",
"of",
"the",
"Flavor",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor_mysql.go#L117-L135 |
135,534 | vitessio/vitess | go/mysql/flavor_mysql.go | readBinlogEvent | func (mysqlFlavor) readBinlogEvent(c *Conn) (BinlogEvent, error) {
result, err := c.ReadPacket()
if err != nil {
return nil, err
}
switch result[0] {
case EOFPacket:
return nil, NewSQLError(CRServerLost, SSUnknownSQLState, "%v", io.EOF)
case ErrPacket:
return nil, ParseErrorPacket(result)
}
return NewMysq... | go | func (mysqlFlavor) readBinlogEvent(c *Conn) (BinlogEvent, error) {
result, err := c.ReadPacket()
if err != nil {
return nil, err
}
switch result[0] {
case EOFPacket:
return nil, NewSQLError(CRServerLost, SSUnknownSQLState, "%v", io.EOF)
case ErrPacket:
return nil, ParseErrorPacket(result)
}
return NewMysq... | [
"func",
"(",
"mysqlFlavor",
")",
"readBinlogEvent",
"(",
"c",
"*",
"Conn",
")",
"(",
"BinlogEvent",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"c",
".",
"ReadPacket",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"er... | // readBinlogEvent is part of the Flavor interface. | [
"readBinlogEvent",
"is",
"part",
"of",
"the",
"Flavor",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor_mysql.go#L138-L150 |
135,535 | vitessio/vitess | go/vt/vttablet/tabletmanager/vreplication/controller.go | newController | func newController(ctx context.Context, params map[string]string, dbClientFactory func() binlogplayer.DBClient, mysqld mysqlctl.MysqlDaemon, ts *topo.Server, cell, tabletTypesStr string, blpStats *binlogplayer.Stats) (*controller, error) {
if blpStats == nil {
blpStats = binlogplayer.NewStats()
}
ct := &controller... | go | func newController(ctx context.Context, params map[string]string, dbClientFactory func() binlogplayer.DBClient, mysqld mysqlctl.MysqlDaemon, ts *topo.Server, cell, tabletTypesStr string, blpStats *binlogplayer.Stats) (*controller, error) {
if blpStats == nil {
blpStats = binlogplayer.NewStats()
}
ct := &controller... | [
"func",
"newController",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"map",
"[",
"string",
"]",
"string",
",",
"dbClientFactory",
"func",
"(",
")",
"binlogplayer",
".",
"DBClient",
",",
"mysqld",
"mysqlctl",
".",
"MysqlDaemon",
",",
"ts",
"*",
"t... | // newController creates a new controller. Unless a stream is explicitly 'Stopped',
// this function launches a goroutine to perform continuous vreplication. | [
"newController",
"creates",
"a",
"new",
"controller",
".",
"Unless",
"a",
"stream",
"is",
"explicitly",
"Stopped",
"this",
"function",
"launches",
"a",
"goroutine",
"to",
"perform",
"continuous",
"vreplication",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/vreplication/controller.go#L64-L114 |
135,536 | vitessio/vitess | go/ioutil2/ioutil.go | WriteFileAtomic | func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error {
dir, name := path.Split(filename)
f, err := ioutil.TempFile(dir, name)
if err != nil {
return err
}
_, err = f.Write(data)
if err == nil {
err = f.Sync()
}
if closeErr := f.Close(); err == nil {
err = closeErr
}
if permErr := o... | go | func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error {
dir, name := path.Split(filename)
f, err := ioutil.TempFile(dir, name)
if err != nil {
return err
}
_, err = f.Write(data)
if err == nil {
err = f.Sync()
}
if closeErr := f.Close(); err == nil {
err = closeErr
}
if permErr := o... | [
"func",
"WriteFileAtomic",
"(",
"filename",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"dir",
",",
"name",
":=",
"path",
".",
"Split",
"(",
"filename",
")",
"\n",
"f",
",",
"err",
":=",
"ioutil",
... | // WriteFileAtomic writes the data to a temp file and atomically move if everything else succeeds. | [
"WriteFileAtomic",
"writes",
"the",
"data",
"to",
"a",
"temp",
"file",
"and",
"atomically",
"move",
"if",
"everything",
"else",
"succeeds",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/ioutil2/ioutil.go#L27-L51 |
135,537 | vitessio/vitess | go/vt/dbconnpool/pooled_connection.go | Recycle | func (pc *PooledDBConnection) Recycle() {
if pc.IsClosed() {
pc.pool.Put(nil)
} else {
pc.pool.Put(pc)
}
} | go | func (pc *PooledDBConnection) Recycle() {
if pc.IsClosed() {
pc.pool.Put(nil)
} else {
pc.pool.Put(pc)
}
} | [
"func",
"(",
"pc",
"*",
"PooledDBConnection",
")",
"Recycle",
"(",
")",
"{",
"if",
"pc",
".",
"IsClosed",
"(",
")",
"{",
"pc",
".",
"pool",
".",
"Put",
"(",
"nil",
")",
"\n",
"}",
"else",
"{",
"pc",
".",
"pool",
".",
"Put",
"(",
"pc",
")",
"\... | // Recycle should be called to return the PooledDBConnection to the pool. | [
"Recycle",
"should",
"be",
"called",
"to",
"return",
"the",
"PooledDBConnection",
"to",
"the",
"pool",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconnpool/pooled_connection.go#L26-L32 |
135,538 | vitessio/vitess | go/vt/dbconnpool/pooled_connection.go | Reconnect | func (pc *PooledDBConnection) Reconnect() error {
pc.DBConnection.Close()
newConn, err := NewDBConnection(pc.pool.info, pc.mysqlStats)
if err != nil {
return err
}
pc.DBConnection = newConn
return nil
} | go | func (pc *PooledDBConnection) Reconnect() error {
pc.DBConnection.Close()
newConn, err := NewDBConnection(pc.pool.info, pc.mysqlStats)
if err != nil {
return err
}
pc.DBConnection = newConn
return nil
} | [
"func",
"(",
"pc",
"*",
"PooledDBConnection",
")",
"Reconnect",
"(",
")",
"error",
"{",
"pc",
".",
"DBConnection",
".",
"Close",
"(",
")",
"\n",
"newConn",
",",
"err",
":=",
"NewDBConnection",
"(",
"pc",
".",
"pool",
".",
"info",
",",
"pc",
".",
"mys... | // Reconnect replaces the existing underlying connection with a new one,
// if possible. Recycle should still be called afterwards. | [
"Reconnect",
"replaces",
"the",
"existing",
"underlying",
"connection",
"with",
"a",
"new",
"one",
"if",
"possible",
".",
"Recycle",
"should",
"still",
"be",
"called",
"afterwards",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconnpool/pooled_connection.go#L36-L44 |
135,539 | vitessio/vitess | go/vt/vttablet/tabletserver/txlimiter/tx_limiter.go | extractKey | func (txl *Impl) extractKey(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID) string {
var parts []string
if txl.byUsername {
if immediate != nil {
parts = append(parts, callerid.GetUsername(immediate))
} else {
parts = append(parts, unknown)
}
}
if txl.byEffectiveUser {
if effective != ... | go | func (txl *Impl) extractKey(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID) string {
var parts []string
if txl.byUsername {
if immediate != nil {
parts = append(parts, callerid.GetUsername(immediate))
} else {
parts = append(parts, unknown)
}
}
if txl.byEffectiveUser {
if effective != ... | [
"func",
"(",
"txl",
"*",
"Impl",
")",
"extractKey",
"(",
"immediate",
"*",
"querypb",
".",
"VTGateCallerID",
",",
"effective",
"*",
"vtrpcpb",
".",
"CallerID",
")",
"string",
"{",
"var",
"parts",
"[",
"]",
"string",
"\n",
"if",
"txl",
".",
"byUsername",
... | // extractKey builds a string key used to differentiate users, based
// on fields specified in configuration and their values from caller ID. | [
"extractKey",
"builds",
"a",
"string",
"key",
"used",
"to",
"differentiate",
"users",
"based",
"on",
"fields",
"specified",
"in",
"configuration",
"and",
"their",
"values",
"from",
"caller",
"ID",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/txlimiter/tx_limiter.go#L152-L178 |
135,540 | vitessio/vitess | go/vt/vtgate/vindexes/vindex.go | Register | func Register(vindexType string, newVindexFunc NewVindexFunc) {
if _, ok := registry[vindexType]; ok {
panic(fmt.Sprintf("%s is already registered", vindexType))
}
registry[vindexType] = newVindexFunc
} | go | func Register(vindexType string, newVindexFunc NewVindexFunc) {
if _, ok := registry[vindexType]; ok {
panic(fmt.Sprintf("%s is already registered", vindexType))
}
registry[vindexType] = newVindexFunc
} | [
"func",
"Register",
"(",
"vindexType",
"string",
",",
"newVindexFunc",
"NewVindexFunc",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"registry",
"[",
"vindexType",
"]",
";",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"vindexType",
"... | // Register registers a vindex under the specified vindexType.
// A duplicate vindexType will generate a panic.
// New vindexes will be created using these functions at the
// time of vschema loading. | [
"Register",
"registers",
"a",
"vindex",
"under",
"the",
"specified",
"vindexType",
".",
"A",
"duplicate",
"vindexType",
"will",
"generate",
"a",
"panic",
".",
"New",
"vindexes",
"will",
"be",
"created",
"using",
"these",
"functions",
"at",
"the",
"time",
"of",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vindex.go#L116-L121 |
135,541 | vitessio/vitess | go/vt/vtgate/vindexes/vindex.go | CreateVindex | func CreateVindex(vindexType, name string, params map[string]string) (Vindex, error) {
f, ok := registry[vindexType]
if !ok {
return nil, fmt.Errorf("vindexType %q not found", vindexType)
}
return f(name, params)
} | go | func CreateVindex(vindexType, name string, params map[string]string) (Vindex, error) {
f, ok := registry[vindexType]
if !ok {
return nil, fmt.Errorf("vindexType %q not found", vindexType)
}
return f(name, params)
} | [
"func",
"CreateVindex",
"(",
"vindexType",
",",
"name",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"f",
",",
"ok",
":=",
"registry",
"[",
"vindexType",
"]",
"\n",
"if",
"!",
"ok",
"{",
... | // CreateVindex creates a vindex of the specified type using the
// supplied params. The type must have been previously registered. | [
"CreateVindex",
"creates",
"a",
"vindex",
"of",
"the",
"specified",
"type",
"using",
"the",
"supplied",
"params",
".",
"The",
"type",
"must",
"have",
"been",
"previously",
"registered",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vindex.go#L125-L131 |
135,542 | vitessio/vitess | go/vt/dbconfigs/dbconfigs.go | RegisterFlags | func RegisterFlags(userKeys ...string) {
registerBaseFlags()
for _, userKey := range userKeys {
uc := &userConfig{}
dbConfigs.userConfigs[userKey] = uc
registerPerUserFlags(uc, userKey)
}
} | go | func RegisterFlags(userKeys ...string) {
registerBaseFlags()
for _, userKey := range userKeys {
uc := &userConfig{}
dbConfigs.userConfigs[userKey] = uc
registerPerUserFlags(uc, userKey)
}
} | [
"func",
"RegisterFlags",
"(",
"userKeys",
"...",
"string",
")",
"{",
"registerBaseFlags",
"(",
")",
"\n",
"for",
"_",
",",
"userKey",
":=",
"range",
"userKeys",
"{",
"uc",
":=",
"&",
"userConfig",
"{",
"}",
"\n",
"dbConfigs",
".",
"userConfigs",
"[",
"us... | // RegisterFlags registers the flags for the given DBConfigFlag.
// For instance, vttablet will register client, dba and repl.
// Returns all registered flags. | [
"RegisterFlags",
"registers",
"the",
"flags",
"for",
"the",
"given",
"DBConfigFlag",
".",
"For",
"instance",
"vttablet",
"will",
"register",
"client",
"dba",
"and",
"repl",
".",
"Returns",
"all",
"registered",
"flags",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/dbconfigs.go#L84-L91 |
135,543 | vitessio/vitess | go/vt/dbconfigs/dbconfigs.go | makeParams | func (dbcfgs *DBConfigs) makeParams(userKey string, withDB bool) *mysql.ConnParams {
orig := dbcfgs.userConfigs[userKey]
if orig == nil {
return &mysql.ConnParams{}
}
result := orig.param
if withDB {
result.DbName = dbcfgs.DBName.Get()
}
return &result
} | go | func (dbcfgs *DBConfigs) makeParams(userKey string, withDB bool) *mysql.ConnParams {
orig := dbcfgs.userConfigs[userKey]
if orig == nil {
return &mysql.ConnParams{}
}
result := orig.param
if withDB {
result.DbName = dbcfgs.DBName.Get()
}
return &result
} | [
"func",
"(",
"dbcfgs",
"*",
"DBConfigs",
")",
"makeParams",
"(",
"userKey",
"string",
",",
"withDB",
"bool",
")",
"*",
"mysql",
".",
"ConnParams",
"{",
"orig",
":=",
"dbcfgs",
".",
"userConfigs",
"[",
"userKey",
"]",
"\n",
"if",
"orig",
"==",
"nil",
"{... | // AppWithDB returns connection parameters for app with dbname set. | [
"AppWithDB",
"returns",
"connection",
"parameters",
"for",
"app",
"with",
"dbname",
"set",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/dbconfigs.go#L171-L181 |
135,544 | vitessio/vitess | go/vt/dbconfigs/dbconfigs.go | Copy | func (dbcfgs *DBConfigs) Copy() *DBConfigs {
result := &DBConfigs{userConfigs: make(map[string]*userConfig)}
for k, u := range dbcfgs.userConfigs {
newu := *u
result.userConfigs[k] = &newu
}
result.DBName.Set(dbcfgs.DBName.Get())
result.SidecarDBName.Set(dbcfgs.SidecarDBName.Get())
return result
} | go | func (dbcfgs *DBConfigs) Copy() *DBConfigs {
result := &DBConfigs{userConfigs: make(map[string]*userConfig)}
for k, u := range dbcfgs.userConfigs {
newu := *u
result.userConfigs[k] = &newu
}
result.DBName.Set(dbcfgs.DBName.Get())
result.SidecarDBName.Set(dbcfgs.SidecarDBName.Get())
return result
} | [
"func",
"(",
"dbcfgs",
"*",
"DBConfigs",
")",
"Copy",
"(",
")",
"*",
"DBConfigs",
"{",
"result",
":=",
"&",
"DBConfigs",
"{",
"userConfigs",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"userConfig",
")",
"}",
"\n",
"for",
"k",
",",
"u",
":=",... | // Copy returns a copy of the DBConfig. | [
"Copy",
"returns",
"a",
"copy",
"of",
"the",
"DBConfig",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/dbconfigs.go#L212-L221 |
135,545 | vitessio/vitess | go/vt/mysqlctl/query.go | getPoolReconnect | func getPoolReconnect(ctx context.Context, pool *dbconnpool.ConnectionPool) (*dbconnpool.PooledDBConnection, error) {
conn, err := pool.Get(ctx)
if err != nil {
return conn, err
}
// Run a test query to see if this connection is still good.
if _, err := conn.ExecuteFetch("SELECT 1", 1, false); err != nil {
// ... | go | func getPoolReconnect(ctx context.Context, pool *dbconnpool.ConnectionPool) (*dbconnpool.PooledDBConnection, error) {
conn, err := pool.Get(ctx)
if err != nil {
return conn, err
}
// Run a test query to see if this connection is still good.
if _, err := conn.ExecuteFetch("SELECT 1", 1, false); err != nil {
// ... | [
"func",
"getPoolReconnect",
"(",
"ctx",
"context",
".",
"Context",
",",
"pool",
"*",
"dbconnpool",
".",
"ConnectionPool",
")",
"(",
"*",
"dbconnpool",
".",
"PooledDBConnection",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"pool",
".",
"Get",
"(",
"... | // getPoolReconnect gets a connection from a pool, tests it, and reconnects if
// the connection is lost. | [
"getPoolReconnect",
"gets",
"a",
"connection",
"from",
"a",
"pool",
"tests",
"it",
"and",
"reconnects",
"if",
"the",
"connection",
"is",
"lost",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/query.go#L34-L53 |
135,546 | vitessio/vitess | go/vt/mysqlctl/query.go | ExecuteSuperQuery | func (mysqld *Mysqld) ExecuteSuperQuery(ctx context.Context, query string) error {
return mysqld.ExecuteSuperQueryList(ctx, []string{query})
} | go | func (mysqld *Mysqld) ExecuteSuperQuery(ctx context.Context, query string) error {
return mysqld.ExecuteSuperQueryList(ctx, []string{query})
} | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"ExecuteSuperQuery",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
")",
"error",
"{",
"return",
"mysqld",
".",
"ExecuteSuperQueryList",
"(",
"ctx",
",",
"[",
"]",
"string",
"{",
"query",
"}",
")... | // ExecuteSuperQuery allows the user to execute a query as a super user. | [
"ExecuteSuperQuery",
"allows",
"the",
"user",
"to",
"execute",
"a",
"query",
"as",
"a",
"super",
"user",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/query.go#L56-L58 |
135,547 | vitessio/vitess | go/vt/mysqlctl/query.go | ExecuteSuperQueryList | func (mysqld *Mysqld) ExecuteSuperQueryList(ctx context.Context, queryList []string) error {
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
return mysqld.executeSuperQueryListConn(ctx, conn, queryList)
} | go | func (mysqld *Mysqld) ExecuteSuperQueryList(ctx context.Context, queryList []string) error {
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
return mysqld.executeSuperQueryListConn(ctx, conn, queryList)
} | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"ExecuteSuperQueryList",
"(",
"ctx",
"context",
".",
"Context",
",",
"queryList",
"[",
"]",
"string",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"ctx",
",",
"mysqld",
".",
"dbaPool",
"... | // ExecuteSuperQueryList alows the user to execute queries as a super user. | [
"ExecuteSuperQueryList",
"alows",
"the",
"user",
"to",
"execute",
"queries",
"as",
"a",
"super",
"user",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/query.go#L61-L69 |
135,548 | vitessio/vitess | go/vt/mysqlctl/query.go | FetchSuperQuery | func (mysqld *Mysqld) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error) {
conn, connErr := getPoolReconnect(ctx, mysqld.dbaPool)
if connErr != nil {
return nil, connErr
}
defer conn.Recycle()
log.V(6).Infof("fetch %v", query)
qr, err := mysqld.executeFetchContext(ctx, conn, query, 100... | go | func (mysqld *Mysqld) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error) {
conn, connErr := getPoolReconnect(ctx, mysqld.dbaPool)
if connErr != nil {
return nil, connErr
}
defer conn.Recycle()
log.V(6).Infof("fetch %v", query)
qr, err := mysqld.executeFetchContext(ctx, conn, query, 100... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"FetchSuperQuery",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"conn",
",",
"connErr",
":=",
"getPoolReconnect",
"(",
"ctx",
... | // FetchSuperQuery returns the results of executing a query as a super user. | [
"FetchSuperQuery",
"returns",
"the",
"results",
"of",
"executing",
"a",
"query",
"as",
"a",
"super",
"user",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/query.go#L82-L94 |
135,549 | vitessio/vitess | go/vt/mysqlctl/query.go | killConnection | func (mysqld *Mysqld) killConnection(connID int64) error {
// There's no other interface that both types of connection implement.
// We only care about one method anyway.
var killConn interface {
ExecuteFetch(query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
}
// Get another connection with ... | go | func (mysqld *Mysqld) killConnection(connID int64) error {
// There's no other interface that both types of connection implement.
// We only care about one method anyway.
var killConn interface {
ExecuteFetch(query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
}
// Get another connection with ... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"killConnection",
"(",
"connID",
"int64",
")",
"error",
"{",
"// There's no other interface that both types of connection implement.",
"// We only care about one method anyway.",
"var",
"killConn",
"interface",
"{",
"ExecuteFetch",
"... | // killConnection issues a MySQL KILL command for the given connection ID. | [
"killConnection",
"issues",
"a",
"MySQL",
"KILL",
"command",
"for",
"the",
"given",
"connection",
"ID",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/query.go#L153-L182 |
135,550 | vitessio/vitess | go/vt/mysqlctl/query.go | fetchVariables | func (mysqld *Mysqld) fetchVariables(ctx context.Context, pattern string) (map[string]string, error) {
query := fmt.Sprintf("SHOW VARIABLES LIKE '%s'", pattern)
qr, err := mysqld.FetchSuperQuery(ctx, query)
if err != nil {
return nil, err
}
if len(qr.Fields) != 2 {
return nil, fmt.Errorf("query %#v returned %d... | go | func (mysqld *Mysqld) fetchVariables(ctx context.Context, pattern string) (map[string]string, error) {
query := fmt.Sprintf("SHOW VARIABLES LIKE '%s'", pattern)
qr, err := mysqld.FetchSuperQuery(ctx, query)
if err != nil {
return nil, err
}
if len(qr.Fields) != 2 {
return nil, fmt.Errorf("query %#v returned %d... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"fetchVariables",
"(",
"ctx",
"context",
".",
"Context",
",",
"pattern",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\""... | // fetchVariables returns a map from MySQL variable names to variable value
// for variables that match the given pattern. | [
"fetchVariables",
"returns",
"a",
"map",
"from",
"MySQL",
"variable",
"names",
"to",
"variable",
"value",
"for",
"variables",
"that",
"match",
"the",
"given",
"pattern",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/query.go#L186-L200 |
135,551 | vitessio/vitess | go/streamlog/streamlog.go | New | func New(name string, size int) *StreamLogger {
return &StreamLogger{
name: name,
size: size,
subscribed: make(map[chan interface{}]string),
}
} | go | func New(name string, size int) *StreamLogger {
return &StreamLogger{
name: name,
size: size,
subscribed: make(map[chan interface{}]string),
}
} | [
"func",
"New",
"(",
"name",
"string",
",",
"size",
"int",
")",
"*",
"StreamLogger",
"{",
"return",
"&",
"StreamLogger",
"{",
"name",
":",
"name",
",",
"size",
":",
"size",
",",
"subscribed",
":",
"make",
"(",
"map",
"[",
"chan",
"interface",
"{",
"}"... | // New returns a new StreamLogger that can stream events to subscribers.
// The size parameter defines the channel size for the subscribers. | [
"New",
"returns",
"a",
"new",
"StreamLogger",
"that",
"can",
"stream",
"events",
"to",
"subscribers",
".",
"The",
"size",
"parameter",
"defines",
"the",
"channel",
"size",
"for",
"the",
"subscribers",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/streamlog/streamlog.go#L77-L83 |
135,552 | vitessio/vitess | go/streamlog/streamlog.go | Send | func (logger *StreamLogger) Send(message interface{}) {
logger.mu.Lock()
defer logger.mu.Unlock()
for ch, name := range logger.subscribed {
select {
case ch <- message:
deliveredCount.Add([]string{logger.name, name}, 1)
default:
deliveryDropCount.Add([]string{logger.name, name}, 1)
}
}
sendCount.Add... | go | func (logger *StreamLogger) Send(message interface{}) {
logger.mu.Lock()
defer logger.mu.Unlock()
for ch, name := range logger.subscribed {
select {
case ch <- message:
deliveredCount.Add([]string{logger.name, name}, 1)
default:
deliveryDropCount.Add([]string{logger.name, name}, 1)
}
}
sendCount.Add... | [
"func",
"(",
"logger",
"*",
"StreamLogger",
")",
"Send",
"(",
"message",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"logger",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"ch",
",",
"name",
"... | // Send sends message to all the writers subscribed to logger. Calling
// Send does not block. | [
"Send",
"sends",
"message",
"to",
"all",
"the",
"writers",
"subscribed",
"to",
"logger",
".",
"Calling",
"Send",
"does",
"not",
"block",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/streamlog/streamlog.go#L87-L100 |
135,553 | vitessio/vitess | go/streamlog/streamlog.go | Subscribe | func (logger *StreamLogger) Subscribe(name string) chan interface{} {
logger.mu.Lock()
defer logger.mu.Unlock()
ch := make(chan interface{}, logger.size)
logger.subscribed[ch] = name
return ch
} | go | func (logger *StreamLogger) Subscribe(name string) chan interface{} {
logger.mu.Lock()
defer logger.mu.Unlock()
ch := make(chan interface{}, logger.size)
logger.subscribed[ch] = name
return ch
} | [
"func",
"(",
"logger",
"*",
"StreamLogger",
")",
"Subscribe",
"(",
"name",
"string",
")",
"chan",
"interface",
"{",
"}",
"{",
"logger",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"logger",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"ch",
":=... | // Subscribe returns a channel which can be used to listen
// for messages. | [
"Subscribe",
"returns",
"a",
"channel",
"which",
"can",
"be",
"used",
"to",
"listen",
"for",
"messages",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/streamlog/streamlog.go#L104-L111 |
135,554 | vitessio/vitess | go/streamlog/streamlog.go | Unsubscribe | func (logger *StreamLogger) Unsubscribe(ch chan interface{}) {
logger.mu.Lock()
defer logger.mu.Unlock()
delete(logger.subscribed, ch)
} | go | func (logger *StreamLogger) Unsubscribe(ch chan interface{}) {
logger.mu.Lock()
defer logger.mu.Unlock()
delete(logger.subscribed, ch)
} | [
"func",
"(",
"logger",
"*",
"StreamLogger",
")",
"Unsubscribe",
"(",
"ch",
"chan",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"logger",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"log... | // Unsubscribe removes the channel from the subscription. | [
"Unsubscribe",
"removes",
"the",
"channel",
"from",
"the",
"subscription",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/streamlog/streamlog.go#L114-L119 |
135,555 | vitessio/vitess | go/streamlog/streamlog.go | ServeLogs | func (logger *StreamLogger) ServeLogs(url string, logf LogFormatter) {
http.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {
acl.SendError(w, err)
return
}
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.St... | go | func (logger *StreamLogger) ServeLogs(url string, logf LogFormatter) {
http.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {
acl.SendError(w, err)
return
}
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.St... | [
"func",
"(",
"logger",
"*",
"StreamLogger",
")",
"ServeLogs",
"(",
"url",
"string",
",",
"logf",
"LogFormatter",
")",
"{",
"http",
".",
"HandleFunc",
"(",
"url",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request... | // ServeLogs registers the URL on which messages will be broadcast.
// It is safe to register multiple URLs for the same StreamLogger. | [
"ServeLogs",
"registers",
"the",
"URL",
"on",
"which",
"messages",
"will",
"be",
"broadcast",
".",
"It",
"is",
"safe",
"to",
"register",
"multiple",
"URLs",
"for",
"the",
"same",
"StreamLogger",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/streamlog/streamlog.go#L128-L152 |
135,556 | vitessio/vitess | go/streamlog/streamlog.go | LogToFile | func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan interface{}, error) {
rotateChan := make(chan os.Signal, 1)
signal.Notify(rotateChan, syscall.SIGUSR2)
logChan := logger.Subscribe("FileLog")
formatParams := map[string][]string{"full": {}}
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CR... | go | func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan interface{}, error) {
rotateChan := make(chan os.Signal, 1)
signal.Notify(rotateChan, syscall.SIGUSR2)
logChan := logger.Subscribe("FileLog")
formatParams := map[string][]string{"full": {}}
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CR... | [
"func",
"(",
"logger",
"*",
"StreamLogger",
")",
"LogToFile",
"(",
"path",
"string",
",",
"logf",
"LogFormatter",
")",
"(",
"chan",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"rotateChan",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
... | // LogToFile starts logging to the specified file path and will reopen the
// file in response to SIGUSR2.
//
// Returns the channel used for the subscription which can be used to close
// it. | [
"LogToFile",
"starts",
"logging",
"to",
"the",
"specified",
"file",
"path",
"and",
"will",
"reopen",
"the",
"file",
"in",
"response",
"to",
"SIGUSR2",
".",
"Returns",
"the",
"channel",
"used",
"for",
"the",
"subscription",
"which",
"can",
"be",
"used",
"to",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/streamlog/streamlog.go#L159-L184 |
135,557 | vitessio/vitess | go/streamlog/streamlog.go | GetFormatter | func GetFormatter(logger *StreamLogger) LogFormatter {
return func(w io.Writer, params url.Values, val interface{}) error {
fmter, ok := val.(Formatter)
if !ok {
_, err := fmt.Fprintf(w, "Error: unexpected value of type %T in %s!", val, logger.Name())
return err
}
return fmter.Logf(w, params)
}
} | go | func GetFormatter(logger *StreamLogger) LogFormatter {
return func(w io.Writer, params url.Values, val interface{}) error {
fmter, ok := val.(Formatter)
if !ok {
_, err := fmt.Fprintf(w, "Error: unexpected value of type %T in %s!", val, logger.Name())
return err
}
return fmter.Logf(w, params)
}
} | [
"func",
"GetFormatter",
"(",
"logger",
"*",
"StreamLogger",
")",
"LogFormatter",
"{",
"return",
"func",
"(",
"w",
"io",
".",
"Writer",
",",
"params",
"url",
".",
"Values",
",",
"val",
"interface",
"{",
"}",
")",
"error",
"{",
"fmter",
",",
"ok",
":=",
... | // GetFormatter returns a formatter function for objects conforming to the
// Formatter interface | [
"GetFormatter",
"returns",
"a",
"formatter",
"function",
"for",
"objects",
"conforming",
"to",
"the",
"Formatter",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/streamlog/streamlog.go#L194-L203 |
135,558 | vitessio/vitess | go/mysql/mariadb_gtid.go | parseMariadbGTID | func parseMariadbGTID(s string) (GTID, error) {
// Split into parts.
parts := strings.Split(s, "-")
if len(parts) != 3 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "invalid MariaDB GTID (%v): expecting Domain-Server-Sequence", s)
}
// Parse Domain ID.
Domain, err := strconv.ParseUint(parts[0], 10, 32)
i... | go | func parseMariadbGTID(s string) (GTID, error) {
// Split into parts.
parts := strings.Split(s, "-")
if len(parts) != 3 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "invalid MariaDB GTID (%v): expecting Domain-Server-Sequence", s)
}
// Parse Domain ID.
Domain, err := strconv.ParseUint(parts[0], 10, 32)
i... | [
"func",
"parseMariadbGTID",
"(",
"s",
"string",
")",
"(",
"GTID",
",",
"error",
")",
"{",
"// Split into parts.",
"parts",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"3",
"{",
"return",
... | // parseMariadbGTID is registered as a GTID parser. | [
"parseMariadbGTID",
"is",
"registered",
"as",
"a",
"GTID",
"parser",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/mariadb_gtid.go#L31-L61 |
135,559 | vitessio/vitess | go/mysql/mariadb_gtid.go | parseMariadbGTIDSet | func parseMariadbGTIDSet(s string) (GTIDSet, error) {
gtidStrings := strings.Split(s, ",")
gtidSet := make(MariadbGTIDSet, len(gtidStrings))
for i, gtidString := range gtidStrings {
gtid, err := parseMariadbGTID(gtidString)
if err != nil {
return nil, err
}
gtidSet[i] = gtid.(MariadbGTID)
}
return gtidS... | go | func parseMariadbGTIDSet(s string) (GTIDSet, error) {
gtidStrings := strings.Split(s, ",")
gtidSet := make(MariadbGTIDSet, len(gtidStrings))
for i, gtidString := range gtidStrings {
gtid, err := parseMariadbGTID(gtidString)
if err != nil {
return nil, err
}
gtidSet[i] = gtid.(MariadbGTID)
}
return gtidS... | [
"func",
"parseMariadbGTIDSet",
"(",
"s",
"string",
")",
"(",
"GTIDSet",
",",
"error",
")",
"{",
"gtidStrings",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"gtidSet",
":=",
"make",
"(",
"MariadbGTIDSet",
",",
"len",
"(",
"gtidSt... | // parseMariadbGTIDSet is registered as a GTIDSet parser. | [
"parseMariadbGTIDSet",
"is",
"registered",
"as",
"a",
"GTIDSet",
"parser",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/mariadb_gtid.go#L64-L75 |
135,560 | vitessio/vitess | go/vt/vttablet/tabletserver/tx_executor.go | Prepare | func (txe *TxExecutor) Prepare(transactionID int64, dtid string) error {
if !txe.te.twopcEnabled {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
defer tabletenv.QueryStats.Record("PREPARE", time.Now())
txe.logStats.TransactionID = transactionID
conn, err := txe.te.txPool.Get(tran... | go | func (txe *TxExecutor) Prepare(transactionID int64, dtid string) error {
if !txe.te.twopcEnabled {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
defer tabletenv.QueryStats.Record("PREPARE", time.Now())
txe.logStats.TransactionID = transactionID
conn, err := txe.te.txPool.Get(tran... | [
"func",
"(",
"txe",
"*",
"TxExecutor",
")",
"Prepare",
"(",
"transactionID",
"int64",
",",
"dtid",
"string",
")",
"error",
"{",
"if",
"!",
"txe",
".",
"te",
".",
"twopcEnabled",
"{",
"return",
"vterrors",
".",
"Errorf",
"(",
"vtrpcpb",
".",
"Code_INVALID... | // Prepare performs a prepare on a connection including the redo log work.
// If there is any failure, an error is returned. No cleanup is performed.
// A subsequent call to RollbackPrepared, which is required by the 2PC
// protocol, will perform all the cleanup. | [
"Prepare",
"performs",
"a",
"prepare",
"on",
"a",
"connection",
"including",
"the",
"redo",
"log",
"work",
".",
"If",
"there",
"is",
"any",
"failure",
"an",
"error",
"is",
"returned",
".",
"No",
"cleanup",
"is",
"performed",
".",
"A",
"subsequent",
"call",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tx_executor.go#L47-L88 |
135,561 | vitessio/vitess | go/vt/vttablet/tabletserver/tx_executor.go | CommitPrepared | func (txe *TxExecutor) CommitPrepared(dtid string) error {
if !txe.te.twopcEnabled {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
defer tabletenv.QueryStats.Record("COMMIT_PREPARED", time.Now())
conn, err := txe.te.preparedPool.FetchForCommit(dtid)
if err != nil {
return vterro... | go | func (txe *TxExecutor) CommitPrepared(dtid string) error {
if !txe.te.twopcEnabled {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
defer tabletenv.QueryStats.Record("COMMIT_PREPARED", time.Now())
conn, err := txe.te.preparedPool.FetchForCommit(dtid)
if err != nil {
return vterro... | [
"func",
"(",
"txe",
"*",
"TxExecutor",
")",
"CommitPrepared",
"(",
"dtid",
"string",
")",
"error",
"{",
"if",
"!",
"txe",
".",
"te",
".",
"twopcEnabled",
"{",
"return",
"vterrors",
".",
"Errorf",
"(",
"vtrpcpb",
".",
"Code_INVALID_ARGUMENT",
",",
"\"",
"... | // CommitPrepared commits a prepared transaction. If the operation
// fails, an error counter is incremented and the transaction is
// marked as failed in the redo log. | [
"CommitPrepared",
"commits",
"a",
"prepared",
"transaction",
".",
"If",
"the",
"operation",
"fails",
"an",
"error",
"counter",
"is",
"incremented",
"and",
"the",
"transaction",
"is",
"marked",
"as",
"failed",
"in",
"the",
"redo",
"log",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tx_executor.go#L93-L121 |
135,562 | vitessio/vitess | go/vt/vttablet/tabletserver/tx_executor.go | markFailed | func (txe *TxExecutor) markFailed(ctx context.Context, dtid string) {
tabletenv.InternalErrors.Add("TwopcCommit", 1)
txe.te.preparedPool.SetFailed(dtid)
conn, _, err := txe.te.txPool.LocalBegin(ctx, &querypb.ExecuteOptions{})
if err != nil {
log.Errorf("markFailed: Begin failed for dtid %s: %v", dtid, err)
retu... | go | func (txe *TxExecutor) markFailed(ctx context.Context, dtid string) {
tabletenv.InternalErrors.Add("TwopcCommit", 1)
txe.te.preparedPool.SetFailed(dtid)
conn, _, err := txe.te.txPool.LocalBegin(ctx, &querypb.ExecuteOptions{})
if err != nil {
log.Errorf("markFailed: Begin failed for dtid %s: %v", dtid, err)
retu... | [
"func",
"(",
"txe",
"*",
"TxExecutor",
")",
"markFailed",
"(",
"ctx",
"context",
".",
"Context",
",",
"dtid",
"string",
")",
"{",
"tabletenv",
".",
"InternalErrors",
".",
"Add",
"(",
"\"",
"\"",
",",
"1",
")",
"\n",
"txe",
".",
"te",
".",
"preparedPo... | // markFailed does the necessary work to mark a CommitPrepared
// as failed. It marks the dtid as failed in the prepared pool,
// increments the InternalErros counter, and also changes the
// state of the transaction in the redo log as failed. If the
// state change does not succeed, it just logs the event.
// The func... | [
"markFailed",
"does",
"the",
"necessary",
"work",
"to",
"mark",
"a",
"CommitPrepared",
"as",
"failed",
".",
"It",
"marks",
"the",
"dtid",
"as",
"failed",
"in",
"the",
"prepared",
"pool",
"increments",
"the",
"InternalErros",
"counter",
"and",
"also",
"changes"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tx_executor.go#L130-L148 |
135,563 | vitessio/vitess | go/vt/vttablet/tabletserver/tx_executor.go | RollbackPrepared | func (txe *TxExecutor) RollbackPrepared(dtid string, originalID int64) error {
if !txe.te.twopcEnabled {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
defer tabletenv.QueryStats.Record("ROLLBACK_PREPARED", time.Now())
conn, _, err := txe.te.txPool.LocalBegin(txe.ctx, &querypb.Execu... | go | func (txe *TxExecutor) RollbackPrepared(dtid string, originalID int64) error {
if !txe.te.twopcEnabled {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
defer tabletenv.QueryStats.Record("ROLLBACK_PREPARED", time.Now())
conn, _, err := txe.te.txPool.LocalBegin(txe.ctx, &querypb.Execu... | [
"func",
"(",
"txe",
"*",
"TxExecutor",
")",
"RollbackPrepared",
"(",
"dtid",
"string",
",",
"originalID",
"int64",
")",
"error",
"{",
"if",
"!",
"txe",
".",
"te",
".",
"twopcEnabled",
"{",
"return",
"vterrors",
".",
"Errorf",
"(",
"vtrpcpb",
".",
"Code_I... | // RollbackPrepared rolls back a prepared transaction. This function handles
// the case of an incomplete prepare.
//
// If the prepare completely failed, it will just rollback the original
// transaction identified by originalID.
//
// If the connection was moved to the prepared pool, but redo log
// creation failed, ... | [
"RollbackPrepared",
"rolls",
"back",
"a",
"prepared",
"transaction",
".",
"This",
"function",
"handles",
"the",
"case",
"of",
"an",
"incomplete",
"prepare",
".",
"If",
"the",
"prepare",
"completely",
"failed",
"it",
"will",
"just",
"rollback",
"the",
"original",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tx_executor.go#L168-L195 |
135,564 | vitessio/vitess | go/vt/vttablet/tabletserver/tx_executor.go | ReadTwopcInflight | func (txe *TxExecutor) ReadTwopcInflight() (distributed []*DistributedTx, prepared, failed []*PreparedTx, err error) {
if !txe.te.twopcEnabled {
return nil, nil, nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
prepared, failed, err = txe.te.twoPC.ReadAllRedo(txe.ctx)
if err != nil {
... | go | func (txe *TxExecutor) ReadTwopcInflight() (distributed []*DistributedTx, prepared, failed []*PreparedTx, err error) {
if !txe.te.twopcEnabled {
return nil, nil, nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
prepared, failed, err = txe.te.twoPC.ReadAllRedo(txe.ctx)
if err != nil {
... | [
"func",
"(",
"txe",
"*",
"TxExecutor",
")",
"ReadTwopcInflight",
"(",
")",
"(",
"distributed",
"[",
"]",
"*",
"DistributedTx",
",",
"prepared",
",",
"failed",
"[",
"]",
"*",
"PreparedTx",
",",
"err",
"error",
")",
"{",
"if",
"!",
"txe",
".",
"te",
".... | // ReadTwopcInflight returns info about all in-flight 2pc transactions. | [
"ReadTwopcInflight",
"returns",
"info",
"about",
"all",
"in",
"-",
"flight",
"2pc",
"transactions",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tx_executor.go#L303-L316 |
135,565 | vitessio/vitess | go/vt/vtgate/engine/update.go | MarshalJSON | func (upd *Update) MarshalJSON() ([]byte, error) {
var tname, vindexName string
if upd.Table != nil {
tname = upd.Table.Name.String()
}
if upd.Vindex != nil {
vindexName = upd.Vindex.String()
}
marshalUpdate := struct {
Opcode UpdateOpcode
Keyspace *vindexes.Keyspace ... | go | func (upd *Update) MarshalJSON() ([]byte, error) {
var tname, vindexName string
if upd.Table != nil {
tname = upd.Table.Name.String()
}
if upd.Vindex != nil {
vindexName = upd.Vindex.String()
}
marshalUpdate := struct {
Opcode UpdateOpcode
Keyspace *vindexes.Keyspace ... | [
"func",
"(",
"upd",
"*",
"Update",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"tname",
",",
"vindexName",
"string",
"\n",
"if",
"upd",
".",
"Table",
"!=",
"nil",
"{",
"tname",
"=",
"upd",
".",
"Table",
"."... | // MarshalJSON serializes the Update into a JSON representation.
// It's used for testing and diagnostics. | [
"MarshalJSON",
"serializes",
"the",
"Update",
"into",
"a",
"JSON",
"representation",
".",
"It",
"s",
"used",
"for",
"testing",
"and",
"diagnostics",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/update.go#L77-L109 |
135,566 | vitessio/vitess | go/vt/mysqlctl/mysqlctlclient/interface.go | New | func New(network, addr string) (MysqlctlClient, error) {
factory, ok := factories[*protocol]
if !ok {
return nil, fmt.Errorf("unknown mysqlctl client protocol: %v", *protocol)
}
return factory(network, addr)
} | go | func New(network, addr string) (MysqlctlClient, error) {
factory, ok := factories[*protocol]
if !ok {
return nil, fmt.Errorf("unknown mysqlctl client protocol: %v", *protocol)
}
return factory(network, addr)
} | [
"func",
"New",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"MysqlctlClient",
",",
"error",
")",
"{",
"factory",
",",
"ok",
":=",
"factories",
"[",
"*",
"protocol",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(... | // New creates a client implementation as specified by a flag. | [
"New",
"creates",
"a",
"client",
"implementation",
"as",
"specified",
"by",
"a",
"flag",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/mysqlctlclient/interface.go#L66-L72 |
135,567 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | NewStreamHealthQueryService | func NewStreamHealthQueryService(target querypb.Target) *StreamHealthQueryService {
return &StreamHealthQueryService{
QueryService: ErrorQueryService,
healthResponses: make(chan *querypb.StreamHealthResponse, 1000),
target: target,
}
} | go | func NewStreamHealthQueryService(target querypb.Target) *StreamHealthQueryService {
return &StreamHealthQueryService{
QueryService: ErrorQueryService,
healthResponses: make(chan *querypb.StreamHealthResponse, 1000),
target: target,
}
} | [
"func",
"NewStreamHealthQueryService",
"(",
"target",
"querypb",
".",
"Target",
")",
"*",
"StreamHealthQueryService",
"{",
"return",
"&",
"StreamHealthQueryService",
"{",
"QueryService",
":",
"ErrorQueryService",
",",
"healthResponses",
":",
"make",
"(",
"chan",
"*",
... | // NewStreamHealthQueryService creates a new fake query service for the target. | [
"NewStreamHealthQueryService",
"creates",
"a",
"new",
"fake",
"query",
"service",
"for",
"the",
"target",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L50-L56 |
135,568 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | Begin | func (q *StreamHealthQueryService) Begin(ctx context.Context, target *querypb.Target, options *querypb.ExecuteOptions) (int64, error) {
return 0, nil
} | go | func (q *StreamHealthQueryService) Begin(ctx context.Context, target *querypb.Target, options *querypb.ExecuteOptions) (int64, error) {
return 0, nil
} | [
"func",
"(",
"q",
"*",
"StreamHealthQueryService",
")",
"Begin",
"(",
"ctx",
"context",
".",
"Context",
",",
"target",
"*",
"querypb",
".",
"Target",
",",
"options",
"*",
"querypb",
".",
"ExecuteOptions",
")",
"(",
"int64",
",",
"error",
")",
"{",
"retur... | // Begin implemented as a no op | [
"Begin",
"implemented",
"as",
"a",
"no",
"op"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L59-L61 |
135,569 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | Execute | func (q *StreamHealthQueryService) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) (*sqltypes.Result, error) {
return &sqltypes.Result{}, nil
} | go | func (q *StreamHealthQueryService) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) (*sqltypes.Result, error) {
return &sqltypes.Result{}, nil
} | [
"func",
"(",
"q",
"*",
"StreamHealthQueryService",
")",
"Execute",
"(",
"ctx",
"context",
".",
"Context",
",",
"target",
"*",
"querypb",
".",
"Target",
",",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariabl... | // Execute implemented as a no op | [
"Execute",
"implemented",
"as",
"a",
"no",
"op"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L64-L66 |
135,570 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | AddDefaultHealthResponse | func (q *StreamHealthQueryService) AddDefaultHealthResponse() {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: true,
RealtimeStats: &querypb.RealtimeStats{
SecondsBehindMaster: DefaultSecondsBehindMaster,
},
}
} | go | func (q *StreamHealthQueryService) AddDefaultHealthResponse() {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: true,
RealtimeStats: &querypb.RealtimeStats{
SecondsBehindMaster: DefaultSecondsBehindMaster,
},
}
} | [
"func",
"(",
"q",
"*",
"StreamHealthQueryService",
")",
"AddDefaultHealthResponse",
"(",
")",
"{",
"q",
".",
"healthResponses",
"<-",
"&",
"querypb",
".",
"StreamHealthResponse",
"{",
"Target",
":",
"proto",
".",
"Clone",
"(",
"&",
"q",
".",
"target",
")",
... | // AddDefaultHealthResponse adds a faked health response to the buffer channel.
// The response will have default values typical for a healthy tablet. | [
"AddDefaultHealthResponse",
"adds",
"a",
"faked",
"health",
"response",
"to",
"the",
"buffer",
"channel",
".",
"The",
"response",
"will",
"have",
"default",
"values",
"typical",
"for",
"a",
"healthy",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L80-L88 |
135,571 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | AddHealthResponseWithQPS | func (q *StreamHealthQueryService) AddHealthResponseWithQPS(qps float64) {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: true,
RealtimeStats: &querypb.RealtimeStats{
Qps: qps,
SecondsBehindMaster: DefaultSecondsBehindMaster,
... | go | func (q *StreamHealthQueryService) AddHealthResponseWithQPS(qps float64) {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: true,
RealtimeStats: &querypb.RealtimeStats{
Qps: qps,
SecondsBehindMaster: DefaultSecondsBehindMaster,
... | [
"func",
"(",
"q",
"*",
"StreamHealthQueryService",
")",
"AddHealthResponseWithQPS",
"(",
"qps",
"float64",
")",
"{",
"q",
".",
"healthResponses",
"<-",
"&",
"querypb",
".",
"StreamHealthResponse",
"{",
"Target",
":",
"proto",
".",
"Clone",
"(",
"&",
"q",
"."... | // AddHealthResponseWithQPS adds a faked health response to the buffer channel.
// Only "qps" is different in this message. | [
"AddHealthResponseWithQPS",
"adds",
"a",
"faked",
"health",
"response",
"to",
"the",
"buffer",
"channel",
".",
"Only",
"qps",
"is",
"different",
"in",
"this",
"message",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L92-L101 |
135,572 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | AddHealthResponseWithSecondsBehindMaster | func (q *StreamHealthQueryService) AddHealthResponseWithSecondsBehindMaster(replicationLag uint32) {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: true,
RealtimeStats: &querypb.RealtimeStats{
SecondsBehindMaster: replicationLag,
},
}
} | go | func (q *StreamHealthQueryService) AddHealthResponseWithSecondsBehindMaster(replicationLag uint32) {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: true,
RealtimeStats: &querypb.RealtimeStats{
SecondsBehindMaster: replicationLag,
},
}
} | [
"func",
"(",
"q",
"*",
"StreamHealthQueryService",
")",
"AddHealthResponseWithSecondsBehindMaster",
"(",
"replicationLag",
"uint32",
")",
"{",
"q",
".",
"healthResponses",
"<-",
"&",
"querypb",
".",
"StreamHealthResponse",
"{",
"Target",
":",
"proto",
".",
"Clone",
... | // AddHealthResponseWithSecondsBehindMaster adds a faked health response to the
// buffer channel. Only "seconds_behind_master" is different in this message. | [
"AddHealthResponseWithSecondsBehindMaster",
"adds",
"a",
"faked",
"health",
"response",
"to",
"the",
"buffer",
"channel",
".",
"Only",
"seconds_behind_master",
"is",
"different",
"in",
"this",
"message",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L105-L113 |
135,573 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | AddHealthResponseWithNotServing | func (q *StreamHealthQueryService) AddHealthResponseWithNotServing() {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: false,
RealtimeStats: &querypb.RealtimeStats{
SecondsBehindMaster: DefaultSecondsBehindMaster,
},
}
} | go | func (q *StreamHealthQueryService) AddHealthResponseWithNotServing() {
q.healthResponses <- &querypb.StreamHealthResponse{
Target: proto.Clone(&q.target).(*querypb.Target),
Serving: false,
RealtimeStats: &querypb.RealtimeStats{
SecondsBehindMaster: DefaultSecondsBehindMaster,
},
}
} | [
"func",
"(",
"q",
"*",
"StreamHealthQueryService",
")",
"AddHealthResponseWithNotServing",
"(",
")",
"{",
"q",
".",
"healthResponses",
"<-",
"&",
"querypb",
".",
"StreamHealthResponse",
"{",
"Target",
":",
"proto",
".",
"Clone",
"(",
"&",
"q",
".",
"target",
... | // AddHealthResponseWithNotServing adds a faked health response to the
// buffer channel. Only "Serving" is different in this message. | [
"AddHealthResponseWithNotServing",
"adds",
"a",
"faked",
"health",
"response",
"to",
"the",
"buffer",
"channel",
".",
"Only",
"Serving",
"is",
"different",
"in",
"this",
"message",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L117-L125 |
135,574 | vitessio/vitess | go/vt/vttablet/queryservice/fakes/stream_health_query_service.go | UpdateType | func (q *StreamHealthQueryService) UpdateType(tabletType topodatapb.TabletType) {
q.target.TabletType = tabletType
} | go | func (q *StreamHealthQueryService) UpdateType(tabletType topodatapb.TabletType) {
q.target.TabletType = tabletType
} | [
"func",
"(",
"q",
"*",
"StreamHealthQueryService",
")",
"UpdateType",
"(",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"{",
"q",
".",
"target",
".",
"TabletType",
"=",
"tabletType",
"\n",
"}"
] | // UpdateType changes the type of the query service.
// Only newly sent health messages will use the new type. | [
"UpdateType",
"changes",
"the",
"type",
"of",
"the",
"query",
"service",
".",
"Only",
"newly",
"sent",
"health",
"messages",
"will",
"use",
"the",
"new",
"type",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go#L129-L131 |
135,575 | vitessio/vitess | go/vt/topo/topoproto/shard.go | SourceShardString | func SourceShardString(source *topodatapb.Shard_SourceShard) string {
return fmt.Sprintf("SourceShard(%v,%v/%v)", source.Uid, source.Keyspace, source.Shard)
} | go | func SourceShardString(source *topodatapb.Shard_SourceShard) string {
return fmt.Sprintf("SourceShard(%v,%v/%v)", source.Uid, source.Keyspace, source.Shard)
} | [
"func",
"SourceShardString",
"(",
"source",
"*",
"topodatapb",
".",
"Shard_SourceShard",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"source",
".",
"Uid",
",",
"source",
".",
"Keyspace",
",",
"source",
".",
"Shard",
")",
"\... | // SourceShardString returns a printable view of a SourceShard. | [
"SourceShardString",
"returns",
"a",
"printable",
"view",
"of",
"a",
"SourceShard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/topoproto/shard.go#L46-L48 |
135,576 | vitessio/vitess | go/vt/topo/topoproto/shard.go | SourceShardAsHTML | func SourceShardAsHTML(source *topodatapb.Shard_SourceShard) template.HTML {
result := fmt.Sprintf("<b>Uid</b>: %v</br>\n<b>Source</b>: %v/%v</br>\n", source.Uid, source.Keyspace, source.Shard)
if key.KeyRangeIsPartial(source.KeyRange) {
result += fmt.Sprintf("<b>KeyRange</b>: %v-%v</br>\n",
hex.EncodeToString(s... | go | func SourceShardAsHTML(source *topodatapb.Shard_SourceShard) template.HTML {
result := fmt.Sprintf("<b>Uid</b>: %v</br>\n<b>Source</b>: %v/%v</br>\n", source.Uid, source.Keyspace, source.Shard)
if key.KeyRangeIsPartial(source.KeyRange) {
result += fmt.Sprintf("<b>KeyRange</b>: %v-%v</br>\n",
hex.EncodeToString(s... | [
"func",
"SourceShardAsHTML",
"(",
"source",
"*",
"topodatapb",
".",
"Shard_SourceShard",
")",
"template",
".",
"HTML",
"{",
"result",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"source",
".",
"Uid",
",",
"source",
".",
"Keyspace",
"... | // SourceShardAsHTML returns a HTML version of the object. | [
"SourceShardAsHTML",
"returns",
"a",
"HTML",
"version",
"of",
"the",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/topoproto/shard.go#L51-L63 |
135,577 | vitessio/vitess | go/vt/worker/chunk.go | String | func (c chunk) String() string {
// Pad the chunk number such that all log messages align nicely.
digits := digits(c.total)
return fmt.Sprintf("%*d/%d", digits, c.number, c.total)
} | go | func (c chunk) String() string {
// Pad the chunk number such that all log messages align nicely.
digits := digits(c.total)
return fmt.Sprintf("%*d/%d", digits, c.number, c.total)
} | [
"func",
"(",
"c",
"chunk",
")",
"String",
"(",
")",
"string",
"{",
"// Pad the chunk number such that all log messages align nicely.",
"digits",
":=",
"digits",
"(",
"c",
".",
"total",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"digits",... | // String returns a human-readable presentation of the chunk range. | [
"String",
"returns",
"a",
"human",
"-",
"readable",
"presentation",
"of",
"the",
"chunk",
"range",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/chunk.go#L56-L60 |
135,578 | vitessio/vitess | go/vt/vttablet/tmclient/rpc_client_api.go | NewTabletManagerClient | func NewTabletManagerClient() TabletManagerClient {
f, ok := tabletManagerClientFactories[*TabletManagerProtocol]
if !ok {
log.Exitf("No TabletManagerProtocol registered with name %s", *TabletManagerProtocol)
}
return f()
} | go | func NewTabletManagerClient() TabletManagerClient {
f, ok := tabletManagerClientFactories[*TabletManagerProtocol]
if !ok {
log.Exitf("No TabletManagerProtocol registered with name %s", *TabletManagerProtocol)
}
return f()
} | [
"func",
"NewTabletManagerClient",
"(",
")",
"TabletManagerClient",
"{",
"f",
",",
"ok",
":=",
"tabletManagerClientFactories",
"[",
"*",
"TabletManagerProtocol",
"]",
"\n",
"if",
"!",
"ok",
"{",
"log",
".",
"Exitf",
"(",
"\"",
"\"",
",",
"*",
"TabletManagerProt... | // NewTabletManagerClient creates a new TabletManagerClient. Should be
// called after flags are parsed. | [
"NewTabletManagerClient",
"creates",
"a",
"new",
"TabletManagerClient",
".",
"Should",
"be",
"called",
"after",
"flags",
"are",
"parsed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tmclient/rpc_client_api.go#L235-L242 |
135,579 | vitessio/vitess | go/vt/sqlparser/comments.go | leadingCommentEnd | func leadingCommentEnd(text string) (end int) {
hasComment := false
pos := 0
for pos < len(text) {
// Eat up any whitespace. Trailing whitespace will be considered part of
// the leading comments.
nextVisibleOffset := strings.IndexFunc(text[pos:], isNonSpace)
if nextVisibleOffset < 0 {
break
}
pos += ... | go | func leadingCommentEnd(text string) (end int) {
hasComment := false
pos := 0
for pos < len(text) {
// Eat up any whitespace. Trailing whitespace will be considered part of
// the leading comments.
nextVisibleOffset := strings.IndexFunc(text[pos:], isNonSpace)
if nextVisibleOffset < 0 {
break
}
pos += ... | [
"func",
"leadingCommentEnd",
"(",
"text",
"string",
")",
"(",
"end",
"int",
")",
"{",
"hasComment",
":=",
"false",
"\n",
"pos",
":=",
"0",
"\n",
"for",
"pos",
"<",
"len",
"(",
"text",
")",
"{",
"// Eat up any whitespace. Trailing whitespace will be considered pa... | // leadingCommentEnd returns the first index after all leading comments, or
// 0 if there are no leading comments. | [
"leadingCommentEnd",
"returns",
"the",
"first",
"index",
"after",
"all",
"leading",
"comments",
"or",
"0",
"if",
"there",
"are",
"no",
"leading",
"comments",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/comments.go#L43-L75 |
135,580 | vitessio/vitess | go/vt/sqlparser/comments.go | trailingCommentStart | func trailingCommentStart(text string) (start int) {
hasComment := false
reducedLen := len(text)
for reducedLen > 0 {
// Eat up any whitespace. Leading whitespace will be considered part of
// the trailing comments.
nextReducedLen := strings.LastIndexFunc(text[:reducedLen], isNonSpace) + 1
if nextReducedLen ... | go | func trailingCommentStart(text string) (start int) {
hasComment := false
reducedLen := len(text)
for reducedLen > 0 {
// Eat up any whitespace. Leading whitespace will be considered part of
// the trailing comments.
nextReducedLen := strings.LastIndexFunc(text[:reducedLen], isNonSpace) + 1
if nextReducedLen ... | [
"func",
"trailingCommentStart",
"(",
"text",
"string",
")",
"(",
"start",
"int",
")",
"{",
"hasComment",
":=",
"false",
"\n",
"reducedLen",
":=",
"len",
"(",
"text",
")",
"\n",
"for",
"reducedLen",
">",
"0",
"{",
"// Eat up any whitespace. Leading whitespace wil... | // trailingCommentStart returns the first index of trailing comments.
// If there are no trailing comments, returns the length of the input string. | [
"trailingCommentStart",
"returns",
"the",
"first",
"index",
"of",
"trailing",
"comments",
".",
"If",
"there",
"are",
"no",
"trailing",
"comments",
"returns",
"the",
"length",
"of",
"the",
"input",
"string",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/comments.go#L79-L109 |
135,581 | vitessio/vitess | go/vt/sqlparser/comments.go | StripLeadingComments | func StripLeadingComments(sql string) string {
sql = strings.TrimFunc(sql, unicode.IsSpace)
for hasCommentPrefix(sql) {
switch sql[0] {
case '/':
// Multi line comment
index := strings.Index(sql, "*/")
if index <= 1 {
return sql
}
// don't strip /*! ... */ or /*!50700 ... */
if len(sql) > 2... | go | func StripLeadingComments(sql string) string {
sql = strings.TrimFunc(sql, unicode.IsSpace)
for hasCommentPrefix(sql) {
switch sql[0] {
case '/':
// Multi line comment
index := strings.Index(sql, "*/")
if index <= 1 {
return sql
}
// don't strip /*! ... */ or /*!50700 ... */
if len(sql) > 2... | [
"func",
"StripLeadingComments",
"(",
"sql",
"string",
")",
"string",
"{",
"sql",
"=",
"strings",
".",
"TrimFunc",
"(",
"sql",
",",
"unicode",
".",
"IsSpace",
")",
"\n\n",
"for",
"hasCommentPrefix",
"(",
"sql",
")",
"{",
"switch",
"sql",
"[",
"0",
"]",
... | // StripLeadingComments trims the SQL string and removes any leading comments | [
"StripLeadingComments",
"trims",
"the",
"SQL",
"string",
"and",
"removes",
"any",
"leading",
"comments"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/comments.go#L130-L159 |
135,582 | vitessio/vitess | go/vt/sqlparser/comments.go | StripComments | func StripComments(sql string) string {
sql = StripLeadingComments(sql) // handle -- or /* ... */ at the beginning
for {
start := strings.Index(sql, "/*")
if start == -1 {
break
}
end := strings.Index(sql, "*/")
if end <= 1 {
break
}
sql = sql[:start] + sql[end+2:]
}
sql = strings.TrimFunc(sql... | go | func StripComments(sql string) string {
sql = StripLeadingComments(sql) // handle -- or /* ... */ at the beginning
for {
start := strings.Index(sql, "/*")
if start == -1 {
break
}
end := strings.Index(sql, "*/")
if end <= 1 {
break
}
sql = sql[:start] + sql[end+2:]
}
sql = strings.TrimFunc(sql... | [
"func",
"StripComments",
"(",
"sql",
"string",
")",
"string",
"{",
"sql",
"=",
"StripLeadingComments",
"(",
"sql",
")",
"// handle -- or /* ... */ at the beginning",
"\n\n",
"for",
"{",
"start",
":=",
"strings",
".",
"Index",
"(",
"sql",
",",
"\"",
"\"",
")",
... | // StripComments removes all comments from the string regardless
// of where they occur | [
"StripComments",
"removes",
"all",
"comments",
"from",
"the",
"string",
"regardless",
"of",
"where",
"they",
"occur"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/comments.go#L167-L185 |
135,583 | vitessio/vitess | go/vt/sqlparser/comments.go | SkipQueryPlanCacheDirective | func SkipQueryPlanCacheDirective(stmt Statement) bool {
switch stmt := stmt.(type) {
case *Select:
directives := ExtractCommentDirectives(stmt.Comments)
if directives.IsSet(DirectiveSkipQueryPlanCache) {
return true
}
case *Insert:
directives := ExtractCommentDirectives(stmt.Comments)
if directives.IsSe... | go | func SkipQueryPlanCacheDirective(stmt Statement) bool {
switch stmt := stmt.(type) {
case *Select:
directives := ExtractCommentDirectives(stmt.Comments)
if directives.IsSet(DirectiveSkipQueryPlanCache) {
return true
}
case *Insert:
directives := ExtractCommentDirectives(stmt.Comments)
if directives.IsSe... | [
"func",
"SkipQueryPlanCacheDirective",
"(",
"stmt",
"Statement",
")",
"bool",
"{",
"switch",
"stmt",
":=",
"stmt",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Select",
":",
"directives",
":=",
"ExtractCommentDirectives",
"(",
"stmt",
".",
"Comments",
")",
"\n"... | // SkipQueryPlanCacheDirective returns true if skip query plan cache directive is set to true in query. | [
"SkipQueryPlanCacheDirective",
"returns",
"true",
"if",
"skip",
"query",
"plan",
"cache",
"directive",
"is",
"set",
"to",
"true",
"in",
"query",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/comments.go#L291-L317 |
135,584 | vitessio/vitess | go/vt/vttablet/tabletserver/planbuilder/ddl.go | DDLParse | func DDLParse(sql string) (plan *DDLPlan) {
statement, err := sqlparser.Parse(sql)
if err != nil {
return &DDLPlan{Action: ""}
}
stmt, ok := statement.(*sqlparser.DDL)
if !ok {
return &DDLPlan{Action: ""}
}
return &DDLPlan{
Action: stmt.Action,
}
} | go | func DDLParse(sql string) (plan *DDLPlan) {
statement, err := sqlparser.Parse(sql)
if err != nil {
return &DDLPlan{Action: ""}
}
stmt, ok := statement.(*sqlparser.DDL)
if !ok {
return &DDLPlan{Action: ""}
}
return &DDLPlan{
Action: stmt.Action,
}
} | [
"func",
"DDLParse",
"(",
"sql",
"string",
")",
"(",
"plan",
"*",
"DDLPlan",
")",
"{",
"statement",
",",
"err",
":=",
"sqlparser",
".",
"Parse",
"(",
"sql",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"DDLPlan",
"{",
"Action",
":",
"\""... | // DDLParse parses a DDL and produces a DDLPlan. | [
"DDLParse",
"parses",
"a",
"DDL",
"and",
"produces",
"a",
"DDLPlan",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/planbuilder/ddl.go#L30-L42 |
135,585 | vitessio/vitess | go/vt/vtctl/vtctl.go | tabletParamsToTabletAliases | func tabletParamsToTabletAliases(params []string) ([]*topodatapb.TabletAlias, error) {
result := make([]*topodatapb.TabletAlias, len(params))
var err error
for i, param := range params {
result[i], err = topoproto.ParseTabletAlias(param)
if err != nil {
return nil, err
}
}
return result, nil
} | go | func tabletParamsToTabletAliases(params []string) ([]*topodatapb.TabletAlias, error) {
result := make([]*topodatapb.TabletAlias, len(params))
var err error
for i, param := range params {
result[i], err = topoproto.ParseTabletAlias(param)
if err != nil {
return nil, err
}
}
return result, nil
} | [
"func",
"tabletParamsToTabletAliases",
"(",
"params",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"error",
")",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"len",
"(",
... | // tabletParamsToTabletAliases takes multiple params and converts them
// to tablet aliases. | [
"tabletParamsToTabletAliases",
"takes",
"multiple",
"params",
"and",
"converts",
"them",
"to",
"tablet",
"aliases",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctl/vtctl.go#L603-L613 |
135,586 | vitessio/vitess | go/vt/vtctl/vtctl.go | parseTabletType | func parseTabletType(param string, types []topodatapb.TabletType) (topodatapb.TabletType, error) {
tabletType, err := topoproto.ParseTabletType(param)
if err != nil {
return topodatapb.TabletType_UNKNOWN, fmt.Errorf("invalid tablet type %v: %v", param, err)
}
if !topoproto.IsTypeInList(topodatapb.TabletType(table... | go | func parseTabletType(param string, types []topodatapb.TabletType) (topodatapb.TabletType, error) {
tabletType, err := topoproto.ParseTabletType(param)
if err != nil {
return topodatapb.TabletType_UNKNOWN, fmt.Errorf("invalid tablet type %v: %v", param, err)
}
if !topoproto.IsTypeInList(topodatapb.TabletType(table... | [
"func",
"parseTabletType",
"(",
"param",
"string",
",",
"types",
"[",
"]",
"topodatapb",
".",
"TabletType",
")",
"(",
"topodatapb",
".",
"TabletType",
",",
"error",
")",
"{",
"tabletType",
",",
"err",
":=",
"topoproto",
".",
"ParseTabletType",
"(",
"param",
... | // parseTabletType parses the string tablet type and verifies
// it is an accepted one | [
"parseTabletType",
"parses",
"the",
"string",
"tablet",
"type",
"and",
"verifies",
"it",
"is",
"an",
"accepted",
"one"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctl/vtctl.go#L617-L626 |
135,587 | vitessio/vitess | go/vt/vtctl/vtctl.go | printJSON | func printJSON(logger logutil.Logger, val interface{}) error {
data, err := MarshalJSON(val)
if err != nil {
return fmt.Errorf("cannot marshal data: %v", err)
}
logger.Printf("%v\n", string(data))
return nil
} | go | func printJSON(logger logutil.Logger, val interface{}) error {
data, err := MarshalJSON(val)
if err != nil {
return fmt.Errorf("cannot marshal data: %v", err)
}
logger.Printf("%v\n", string(data))
return nil
} | [
"func",
"printJSON",
"(",
"logger",
"logutil",
".",
"Logger",
",",
"val",
"interface",
"{",
"}",
")",
"error",
"{",
"data",
",",
"err",
":=",
"MarshalJSON",
"(",
"val",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // printJSON will print the JSON version of the structure to the logger. | [
"printJSON",
"will",
"print",
"the",
"JSON",
"version",
"of",
"the",
"structure",
"to",
"the",
"logger",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctl/vtctl.go#L2531-L2538 |
135,588 | vitessio/vitess | go/vt/vtctl/vtctl.go | RunCommand | func RunCommand(ctx context.Context, wr *wrangler.Wrangler, args []string) error {
if len(args) == 0 {
wr.Logger().Printf("No command specified. Please see the list below:\n\n")
PrintAllCommands(wr.Logger())
return fmt.Errorf("no command was specified")
}
action := args[0]
actionLowerCase := strings.ToLower(... | go | func RunCommand(ctx context.Context, wr *wrangler.Wrangler, args []string) error {
if len(args) == 0 {
wr.Logger().Printf("No command specified. Please see the list below:\n\n")
PrintAllCommands(wr.Logger())
return fmt.Errorf("no command was specified")
}
action := args[0]
actionLowerCase := strings.ToLower(... | [
"func",
"RunCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"wr",
"*",
"wrangler",
".",
"Wrangler",
",",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"{",
"wr",
".",
"Logger",
"(",
")",
".",
"Prin... | // RunCommand will execute the command using the provided wrangler.
// It will return the actionPath to wait on for long remote actions if
// applicable. | [
"RunCommand",
"will",
"execute",
"the",
"command",
"using",
"the",
"provided",
"wrangler",
".",
"It",
"will",
"return",
"the",
"actionPath",
"to",
"wait",
"on",
"for",
"long",
"remote",
"actions",
"if",
"applicable",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctl/vtctl.go#L2588-L2614 |
135,589 | vitessio/vitess | go/vt/vtctl/vtctl.go | PrintAllCommands | func PrintAllCommands(logger logutil.Logger) {
for _, group := range commands {
logger.Printf("%s:\n", group.name)
for _, cmd := range group.commands {
if strings.HasPrefix(cmd.help, "HIDDEN") {
continue
}
logger.Printf(" %s %s\n", cmd.name, cmd.params)
}
logger.Printf("\n")
}
} | go | func PrintAllCommands(logger logutil.Logger) {
for _, group := range commands {
logger.Printf("%s:\n", group.name)
for _, cmd := range group.commands {
if strings.HasPrefix(cmd.help, "HIDDEN") {
continue
}
logger.Printf(" %s %s\n", cmd.name, cmd.params)
}
logger.Printf("\n")
}
} | [
"func",
"PrintAllCommands",
"(",
"logger",
"logutil",
".",
"Logger",
")",
"{",
"for",
"_",
",",
"group",
":=",
"range",
"commands",
"{",
"logger",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"group",
".",
"name",
")",
"\n",
"for",
"_",
",",
"cmd",
... | // PrintAllCommands will print the list of commands to the logger | [
"PrintAllCommands",
"will",
"print",
"the",
"list",
"of",
"commands",
"to",
"the",
"logger"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctl/vtctl.go#L2617-L2628 |
135,590 | vitessio/vitess | go/vt/worker/split_diff.go | NewSplitDiffWorker | func NewSplitDiffWorker(wr *wrangler.Wrangler, cell, keyspace, shard string, sourceUID uint32, excludeTables []string, minHealthyRdonlyTablets, parallelDiffsCount int, tabletType topodatapb.TabletType) Worker {
return &SplitDiffWorker{
StatusWorker: NewStatusWorker(),
wr: wr,
cell... | go | func NewSplitDiffWorker(wr *wrangler.Wrangler, cell, keyspace, shard string, sourceUID uint32, excludeTables []string, minHealthyRdonlyTablets, parallelDiffsCount int, tabletType topodatapb.TabletType) Worker {
return &SplitDiffWorker{
StatusWorker: NewStatusWorker(),
wr: wr,
cell... | [
"func",
"NewSplitDiffWorker",
"(",
"wr",
"*",
"wrangler",
".",
"Wrangler",
",",
"cell",
",",
"keyspace",
",",
"shard",
"string",
",",
"sourceUID",
"uint32",
",",
"excludeTables",
"[",
"]",
"string",
",",
"minHealthyRdonlyTablets",
",",
"parallelDiffsCount",
"int... | // NewSplitDiffWorker returns a new SplitDiffWorker object. | [
"NewSplitDiffWorker",
"returns",
"a",
"new",
"SplitDiffWorker",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/split_diff.go#L74-L88 |
135,591 | vitessio/vitess | go/vt/mysqlproxy/mysqlproxy.go | NewProxy | func NewProxy(target *querypb.Target, qs queryservice.QueryService, normalize bool) *Proxy {
return &Proxy{
target: target,
qs: qs,
normalize: normalize,
}
} | go | func NewProxy(target *querypb.Target, qs queryservice.QueryService, normalize bool) *Proxy {
return &Proxy{
target: target,
qs: qs,
normalize: normalize,
}
} | [
"func",
"NewProxy",
"(",
"target",
"*",
"querypb",
".",
"Target",
",",
"qs",
"queryservice",
".",
"QueryService",
",",
"normalize",
"bool",
")",
"*",
"Proxy",
"{",
"return",
"&",
"Proxy",
"{",
"target",
":",
"target",
",",
"qs",
":",
"qs",
",",
"normal... | // NewProxy creates a new proxy | [
"NewProxy",
"creates",
"a",
"new",
"proxy"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlproxy/mysqlproxy.go#L50-L56 |
135,592 | vitessio/vitess | go/vt/mysqlproxy/mysqlproxy.go | Execute | func (mp *Proxy) Execute(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*ProxySession, *sqltypes.Result, error) {
var err error
result := &sqltypes.Result{}
switch sqlparser.Preview(sql) {
case sqlparser.StmtBegin:
err = mp.doBegin(ctx, session)
case sql... | go | func (mp *Proxy) Execute(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*ProxySession, *sqltypes.Result, error) {
var err error
result := &sqltypes.Result{}
switch sqlparser.Preview(sql) {
case sqlparser.StmtBegin:
err = mp.doBegin(ctx, session)
case sql... | [
"func",
"(",
"mp",
"*",
"Proxy",
")",
"Execute",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"ProxySession",
",",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"(",
"*",
"Pro... | // Execute runs the given sql query in the specified session | [
"Execute",
"runs",
"the",
"given",
"sql",
"query",
"in",
"the",
"specified",
"session"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlproxy/mysqlproxy.go#L59-L84 |
135,593 | vitessio/vitess | go/vt/mysqlproxy/mysqlproxy.go | doSet | func (mp *Proxy) doSet(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
vals, _, err := sqlparser.ExtractSetValues(sql)
if err != nil {
return nil, err
}
for k, v := range vals {
switch k.Key {
case "autocommit":
val, ok :=... | go | func (mp *Proxy) doSet(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
vals, _, err := sqlparser.ExtractSetValues(sql)
if err != nil {
return nil, err
}
for k, v := range vals {
switch k.Key {
case "autocommit":
val, ok :=... | [
"func",
"(",
"mp",
"*",
"Proxy",
")",
"doSet",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"ProxySession",
",",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"(",
"*",
"sqlty... | // Set is currently ignored | [
"Set",
"is",
"currently",
"ignored"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlproxy/mysqlproxy.go#L128-L171 |
135,594 | vitessio/vitess | go/vt/mysqlproxy/mysqlproxy.go | executeSelect | func (mp *Proxy) executeSelect(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
if mp.normalize {
query, comments := sqlparser.SplitMarginComments(sql)
stmt, err := sqlparser.Parse(query)
if err != nil {
return nil, err
}
s... | go | func (mp *Proxy) executeSelect(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
if mp.normalize {
query, comments := sqlparser.SplitMarginComments(sql)
stmt, err := sqlparser.Parse(query)
if err != nil {
return nil, err
}
s... | [
"func",
"(",
"mp",
"*",
"Proxy",
")",
"executeSelect",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"ProxySession",
",",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"(",
"*",
... | // executeSelect runs the given select statement | [
"executeSelect",
"runs",
"the",
"given",
"select",
"statement"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlproxy/mysqlproxy.go#L174-L187 |
135,595 | vitessio/vitess | go/vt/mysqlproxy/mysqlproxy.go | executeDML | func (mp *Proxy) executeDML(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
if mp.normalize {
query, comments := sqlparser.SplitMarginComments(sql)
stmt, err := sqlparser.Parse(query)
if err != nil {
return nil, err
}
sqlp... | go | func (mp *Proxy) executeDML(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
if mp.normalize {
query, comments := sqlparser.SplitMarginComments(sql)
stmt, err := sqlparser.Parse(query)
if err != nil {
return nil, err
}
sqlp... | [
"func",
"(",
"mp",
"*",
"Proxy",
")",
"executeDML",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"ProxySession",
",",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"(",
"*",
"... | // executeDML runs the given query handling autocommit semantics | [
"executeDML",
"runs",
"the",
"given",
"query",
"handling",
"autocommit",
"semantics"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlproxy/mysqlproxy.go#L190-L226 |
135,596 | vitessio/vitess | go/vt/mysqlproxy/mysqlproxy.go | executeOther | func (mp *Proxy) executeOther(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
return mp.qs.Execute(ctx, mp.target, sql, bindVariables, session.TransactionID, session.Options)
} | go | func (mp *Proxy) executeOther(ctx context.Context, session *ProxySession, sql string, bindVariables map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
return mp.qs.Execute(ctx, mp.target, sql, bindVariables, session.TransactionID, session.Options)
} | [
"func",
"(",
"mp",
"*",
"Proxy",
")",
"executeOther",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"ProxySession",
",",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"(",
"*",
... | // executeOther runs the given other statement bypassing the normalizer | [
"executeOther",
"runs",
"the",
"given",
"other",
"statement",
"bypassing",
"the",
"normalizer"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlproxy/mysqlproxy.go#L229-L231 |
135,597 | vitessio/vitess | go/vt/vtqueryserver/plugin_mysql_server.go | newMysqlUnixSocket | func newMysqlUnixSocket(address string, authServer mysql.AuthServer, handler mysql.Handler) (*mysql.Listener, error) {
listener, err := mysql.NewListener("unix", address, authServer, handler, *mysqlConnReadTimeout, *mysqlConnWriteTimeout)
switch err := err.(type) {
case nil:
return listener, nil
case *net.OpError... | go | func newMysqlUnixSocket(address string, authServer mysql.AuthServer, handler mysql.Handler) (*mysql.Listener, error) {
listener, err := mysql.NewListener("unix", address, authServer, handler, *mysqlConnReadTimeout, *mysqlConnWriteTimeout)
switch err := err.(type) {
case nil:
return listener, nil
case *net.OpError... | [
"func",
"newMysqlUnixSocket",
"(",
"address",
"string",
",",
"authServer",
"mysql",
".",
"AuthServer",
",",
"handler",
"mysql",
".",
"Handler",
")",
"(",
"*",
"mysql",
".",
"Listener",
",",
"error",
")",
"{",
"listener",
",",
"err",
":=",
"mysql",
".",
"... | // newMysqlUnixSocket creates a new unix socket mysql listener. If a socket file already exists, attempts
// to clean it up. | [
"newMysqlUnixSocket",
"creates",
"a",
"new",
"unix",
"socket",
"mysql",
"listener",
".",
"If",
"a",
"socket",
"file",
"already",
"exists",
"attempts",
"to",
"clean",
"it",
"up",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtqueryserver/plugin_mysql_server.go#L208-L235 |
135,598 | vitessio/vitess | go/cacheservice/cacheservice.go | Register | func Register(name string, fn NewConnFunc) {
mu.Lock()
defer mu.Unlock()
if _, ok := services[name]; ok {
panic(fmt.Sprintf("register a registered key: %s", name))
}
services[name] = fn
} | go | func Register(name string, fn NewConnFunc) {
mu.Lock()
defer mu.Unlock()
if _, ok := services[name]; ok {
panic(fmt.Sprintf("register a registered key: %s", name))
}
services[name] = fn
} | [
"func",
"Register",
"(",
"name",
"string",
",",
"fn",
"NewConnFunc",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"services",
"[",
"name",
"]",
";",
"ok",
"{",
"panic",
"... | // Register a db connection. | [
"Register",
"a",
"db",
"connection",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/cacheservice/cacheservice.go#L83-L90 |
135,599 | vitessio/vitess | go/cacheservice/cacheservice.go | Connect | func Connect(config Config) (CacheService, error) {
mu.Lock()
defer mu.Unlock()
if DefaultCacheService == "" {
if len(services) == 1 {
for _, fn := range services {
return fn(config)
}
}
panic("there are more than one service connect func " +
"registered but no default cache service has been speci... | go | func Connect(config Config) (CacheService, error) {
mu.Lock()
defer mu.Unlock()
if DefaultCacheService == "" {
if len(services) == 1 {
for _, fn := range services {
return fn(config)
}
}
panic("there are more than one service connect func " +
"registered but no default cache service has been speci... | [
"func",
"Connect",
"(",
"config",
"Config",
")",
"(",
"CacheService",
",",
"error",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"DefaultCacheService",
"==",
"\"",
"\"",
"{",
"if",
"len",
"(",
"se... | // Connect returns a CacheService using the given config. | [
"Connect",
"returns",
"a",
"CacheService",
"using",
"the",
"given",
"config",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/cacheservice/cacheservice.go#L93-L110 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.