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
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | SetSuperReadOnly | func (fmd *FakeMysqlDaemon) SetSuperReadOnly(on bool) error {
fmd.SuperReadOnly = on
fmd.ReadOnly = on
return nil
} | go | func (fmd *FakeMysqlDaemon) SetSuperReadOnly(on bool) error {
fmd.SuperReadOnly = on
fmd.ReadOnly = on
return nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"SetSuperReadOnly",
"(",
"on",
"bool",
")",
"error",
"{",
"fmd",
".",
"SuperReadOnly",
"=",
"on",
"\n",
"fmd",
".",
"ReadOnly",
"=",
"on",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetSuperReadOnly is part of the MysqlDaemon interface | [
"SetSuperReadOnly",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L247-L251 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | StartSlave | func (fmd *FakeMysqlDaemon) StartSlave(hookExtraEnv map[string]string) error {
return fmd.ExecuteSuperQueryList(context.Background(), []string{
"START SLAVE",
})
} | go | func (fmd *FakeMysqlDaemon) StartSlave(hookExtraEnv map[string]string) error {
return fmd.ExecuteSuperQueryList(context.Background(), []string{
"START SLAVE",
})
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"StartSlave",
"(",
"hookExtraEnv",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"return",
"fmd",
".",
"ExecuteSuperQueryList",
"(",
"context",
".",
"Background",
"(",
")",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"}",
")",
"\n",
"}"
] | // StartSlave is part of the MysqlDaemon interface. | [
"StartSlave",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L254-L258 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | StartSlaveUntilAfter | func (fmd *FakeMysqlDaemon) StartSlaveUntilAfter(ctx context.Context, pos mysql.Position) error {
if !reflect.DeepEqual(fmd.StartSlaveUntilAfterPos, pos) {
return fmt.Errorf("wrong pos for StartSlaveUntilAfter: expected %v got %v", fmd.SetSlavePositionPos, pos)
}
return fmd.ExecuteSuperQueryList(context.Background(), []string{
"START SLAVE UNTIL AFTER",
})
} | go | func (fmd *FakeMysqlDaemon) StartSlaveUntilAfter(ctx context.Context, pos mysql.Position) error {
if !reflect.DeepEqual(fmd.StartSlaveUntilAfterPos, pos) {
return fmt.Errorf("wrong pos for StartSlaveUntilAfter: expected %v got %v", fmd.SetSlavePositionPos, pos)
}
return fmd.ExecuteSuperQueryList(context.Background(), []string{
"START SLAVE UNTIL AFTER",
})
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"StartSlaveUntilAfter",
"(",
"ctx",
"context",
".",
"Context",
",",
"pos",
"mysql",
".",
"Position",
")",
"error",
"{",
"if",
"!",
"reflect",
".",
"DeepEqual",
"(",
"fmd",
".",
"StartSlaveUntilAfterPos",
",",
"pos",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fmd",
".",
"SetSlavePositionPos",
",",
"pos",
")",
"\n",
"}",
"\n\n",
"return",
"fmd",
".",
"ExecuteSuperQueryList",
"(",
"context",
".",
"Background",
"(",
")",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"}",
")",
"\n",
"}"
] | // StartSlaveUntilAfter is part of the MysqlDaemon interface. | [
"StartSlaveUntilAfter",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L261-L269 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | SetMaster | func (fmd *FakeMysqlDaemon) SetMaster(ctx context.Context, masterHost string, masterPort int, slaveStopBefore bool, slaveStartAfter bool) error {
input := fmt.Sprintf("%v:%v", masterHost, masterPort)
if fmd.SetMasterInput != input {
return fmt.Errorf("wrong input for SetMasterCommands: expected %v got %v", fmd.SetMasterInput, input)
}
cmds := []string{}
if slaveStopBefore {
cmds = append(cmds, "STOP SLAVE")
}
cmds = append(cmds, "FAKE SET MASTER")
if slaveStartAfter {
cmds = append(cmds, "START SLAVE")
}
return fmd.ExecuteSuperQueryList(ctx, cmds)
} | go | func (fmd *FakeMysqlDaemon) SetMaster(ctx context.Context, masterHost string, masterPort int, slaveStopBefore bool, slaveStartAfter bool) error {
input := fmt.Sprintf("%v:%v", masterHost, masterPort)
if fmd.SetMasterInput != input {
return fmt.Errorf("wrong input for SetMasterCommands: expected %v got %v", fmd.SetMasterInput, input)
}
cmds := []string{}
if slaveStopBefore {
cmds = append(cmds, "STOP SLAVE")
}
cmds = append(cmds, "FAKE SET MASTER")
if slaveStartAfter {
cmds = append(cmds, "START SLAVE")
}
return fmd.ExecuteSuperQueryList(ctx, cmds)
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"SetMaster",
"(",
"ctx",
"context",
".",
"Context",
",",
"masterHost",
"string",
",",
"masterPort",
"int",
",",
"slaveStopBefore",
"bool",
",",
"slaveStartAfter",
"bool",
")",
"error",
"{",
"input",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"masterHost",
",",
"masterPort",
")",
"\n",
"if",
"fmd",
".",
"SetMasterInput",
"!=",
"input",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fmd",
".",
"SetMasterInput",
",",
"input",
")",
"\n",
"}",
"\n",
"cmds",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"if",
"slaveStopBefore",
"{",
"cmds",
"=",
"append",
"(",
"cmds",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"cmds",
"=",
"append",
"(",
"cmds",
",",
"\"",
"\"",
")",
"\n",
"if",
"slaveStartAfter",
"{",
"cmds",
"=",
"append",
"(",
"cmds",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"fmd",
".",
"ExecuteSuperQueryList",
"(",
"ctx",
",",
"cmds",
")",
"\n",
"}"
] | // SetMaster is part of the MysqlDaemon interface. | [
"SetMaster",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L289-L303 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | WaitForReparentJournal | func (fmd *FakeMysqlDaemon) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error {
return nil
} | go | func (fmd *FakeMysqlDaemon) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error {
return nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"WaitForReparentJournal",
"(",
"ctx",
"context",
".",
"Context",
",",
"timeCreatedNS",
"int64",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // WaitForReparentJournal is part of the MysqlDaemon interface | [
"WaitForReparentJournal",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L306-L308 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | WaitMasterPos | func (fmd *FakeMysqlDaemon) WaitMasterPos(_ context.Context, pos mysql.Position) error {
if fmd.TimeoutHook != nil {
return fmd.TimeoutHook()
}
if reflect.DeepEqual(fmd.WaitMasterPosition, pos) {
return nil
}
return fmt.Errorf("wrong input for WaitMasterPos: expected %v got %v", fmd.WaitMasterPosition, pos)
} | go | func (fmd *FakeMysqlDaemon) WaitMasterPos(_ context.Context, pos mysql.Position) error {
if fmd.TimeoutHook != nil {
return fmd.TimeoutHook()
}
if reflect.DeepEqual(fmd.WaitMasterPosition, pos) {
return nil
}
return fmt.Errorf("wrong input for WaitMasterPos: expected %v got %v", fmd.WaitMasterPosition, pos)
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"WaitMasterPos",
"(",
"_",
"context",
".",
"Context",
",",
"pos",
"mysql",
".",
"Position",
")",
"error",
"{",
"if",
"fmd",
".",
"TimeoutHook",
"!=",
"nil",
"{",
"return",
"fmd",
".",
"TimeoutHook",
"(",
")",
"\n",
"}",
"\n",
"if",
"reflect",
".",
"DeepEqual",
"(",
"fmd",
".",
"WaitMasterPosition",
",",
"pos",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fmd",
".",
"WaitMasterPosition",
",",
"pos",
")",
"\n",
"}"
] | // WaitMasterPos is part of the MysqlDaemon interface | [
"WaitMasterPos",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L316-L324 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | PromoteSlave | func (fmd *FakeMysqlDaemon) PromoteSlave(hookExtraEnv map[string]string) (mysql.Position, error) {
return fmd.PromoteSlaveResult, nil
} | go | func (fmd *FakeMysqlDaemon) PromoteSlave(hookExtraEnv map[string]string) (mysql.Position, error) {
return fmd.PromoteSlaveResult, nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"PromoteSlave",
"(",
"hookExtraEnv",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"mysql",
".",
"Position",
",",
"error",
")",
"{",
"return",
"fmd",
".",
"PromoteSlaveResult",
",",
"nil",
"\n",
"}"
] | // PromoteSlave is part of the MysqlDaemon interface | [
"PromoteSlave",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L327-L329 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | ExecuteSuperQueryList | func (fmd *FakeMysqlDaemon) ExecuteSuperQueryList(ctx context.Context, queryList []string) error {
for _, query := range queryList {
// test we still have a query to compare
if fmd.ExpectedExecuteSuperQueryCurrent >= len(fmd.ExpectedExecuteSuperQueryList) {
return fmt.Errorf("unexpected extra query in ExecuteSuperQueryList: %v", query)
}
// compare the query
expected := fmd.ExpectedExecuteSuperQueryList[fmd.ExpectedExecuteSuperQueryCurrent]
fmd.ExpectedExecuteSuperQueryCurrent++
if strings.HasPrefix(expected, "SUB") {
// remove the SUB from the expected,
// and truncate the query to length(expected)
expected = expected[3:]
if len(query) > len(expected) {
query = query[:len(expected)]
}
}
if expected != query {
return fmt.Errorf("wrong query for ExecuteSuperQueryList: expected %v got %v", expected, query)
}
// intercept some queries to update our status
switch query {
case "START SLAVE":
fmd.Replicating = true
case "STOP SLAVE":
fmd.Replicating = false
}
}
return nil
} | go | func (fmd *FakeMysqlDaemon) ExecuteSuperQueryList(ctx context.Context, queryList []string) error {
for _, query := range queryList {
// test we still have a query to compare
if fmd.ExpectedExecuteSuperQueryCurrent >= len(fmd.ExpectedExecuteSuperQueryList) {
return fmt.Errorf("unexpected extra query in ExecuteSuperQueryList: %v", query)
}
// compare the query
expected := fmd.ExpectedExecuteSuperQueryList[fmd.ExpectedExecuteSuperQueryCurrent]
fmd.ExpectedExecuteSuperQueryCurrent++
if strings.HasPrefix(expected, "SUB") {
// remove the SUB from the expected,
// and truncate the query to length(expected)
expected = expected[3:]
if len(query) > len(expected) {
query = query[:len(expected)]
}
}
if expected != query {
return fmt.Errorf("wrong query for ExecuteSuperQueryList: expected %v got %v", expected, query)
}
// intercept some queries to update our status
switch query {
case "START SLAVE":
fmd.Replicating = true
case "STOP SLAVE":
fmd.Replicating = false
}
}
return nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"ExecuteSuperQueryList",
"(",
"ctx",
"context",
".",
"Context",
",",
"queryList",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"_",
",",
"query",
":=",
"range",
"queryList",
"{",
"// test we still have a query to compare",
"if",
"fmd",
".",
"ExpectedExecuteSuperQueryCurrent",
">=",
"len",
"(",
"fmd",
".",
"ExpectedExecuteSuperQueryList",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"query",
")",
"\n",
"}",
"\n\n",
"// compare the query",
"expected",
":=",
"fmd",
".",
"ExpectedExecuteSuperQueryList",
"[",
"fmd",
".",
"ExpectedExecuteSuperQueryCurrent",
"]",
"\n",
"fmd",
".",
"ExpectedExecuteSuperQueryCurrent",
"++",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"expected",
",",
"\"",
"\"",
")",
"{",
"// remove the SUB from the expected,",
"// and truncate the query to length(expected)",
"expected",
"=",
"expected",
"[",
"3",
":",
"]",
"\n",
"if",
"len",
"(",
"query",
")",
">",
"len",
"(",
"expected",
")",
"{",
"query",
"=",
"query",
"[",
":",
"len",
"(",
"expected",
")",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"expected",
"!=",
"query",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"expected",
",",
"query",
")",
"\n",
"}",
"\n\n",
"// intercept some queries to update our status",
"switch",
"query",
"{",
"case",
"\"",
"\"",
":",
"fmd",
".",
"Replicating",
"=",
"true",
"\n",
"case",
"\"",
"\"",
":",
"fmd",
".",
"Replicating",
"=",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ExecuteSuperQueryList is part of the MysqlDaemon interface | [
"ExecuteSuperQueryList",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L332-L363 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | FetchSuperQuery | func (fmd *FakeMysqlDaemon) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error) {
if fmd.FetchSuperQueryMap == nil {
return nil, fmt.Errorf("unexpected query: %v", query)
}
qr, ok := fmd.FetchSuperQueryMap[query]
if !ok {
return nil, fmt.Errorf("unexpected query: %v", query)
}
return qr, nil
} | go | func (fmd *FakeMysqlDaemon) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error) {
if fmd.FetchSuperQueryMap == nil {
return nil, fmt.Errorf("unexpected query: %v", query)
}
qr, ok := fmd.FetchSuperQueryMap[query]
if !ok {
return nil, fmt.Errorf("unexpected query: %v", query)
}
return qr, nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"FetchSuperQuery",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"if",
"fmd",
".",
"FetchSuperQueryMap",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"query",
")",
"\n",
"}",
"\n\n",
"qr",
",",
"ok",
":=",
"fmd",
".",
"FetchSuperQueryMap",
"[",
"query",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"query",
")",
"\n",
"}",
"\n",
"return",
"qr",
",",
"nil",
"\n",
"}"
] | // FetchSuperQuery returns the results from the map, if any | [
"FetchSuperQuery",
"returns",
"the",
"results",
"from",
"the",
"map",
"if",
"any"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L366-L376 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | CheckSuperQueryList | func (fmd *FakeMysqlDaemon) CheckSuperQueryList() error {
if fmd.ExpectedExecuteSuperQueryCurrent != len(fmd.ExpectedExecuteSuperQueryList) {
return fmt.Errorf("SuperQueryList wasn't consumed, saw %v queries, was expecting %v", fmd.ExpectedExecuteSuperQueryCurrent, len(fmd.ExpectedExecuteSuperQueryList))
}
return nil
} | go | func (fmd *FakeMysqlDaemon) CheckSuperQueryList() error {
if fmd.ExpectedExecuteSuperQueryCurrent != len(fmd.ExpectedExecuteSuperQueryList) {
return fmt.Errorf("SuperQueryList wasn't consumed, saw %v queries, was expecting %v", fmd.ExpectedExecuteSuperQueryCurrent, len(fmd.ExpectedExecuteSuperQueryList))
}
return nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"CheckSuperQueryList",
"(",
")",
"error",
"{",
"if",
"fmd",
".",
"ExpectedExecuteSuperQueryCurrent",
"!=",
"len",
"(",
"fmd",
".",
"ExpectedExecuteSuperQueryList",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fmd",
".",
"ExpectedExecuteSuperQueryCurrent",
",",
"len",
"(",
"fmd",
".",
"ExpectedExecuteSuperQueryList",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // CheckSuperQueryList returns an error if all the queries we expected
// haven't been seen. | [
"CheckSuperQueryList",
"returns",
"an",
"error",
"if",
"all",
"the",
"queries",
"we",
"expected",
"haven",
"t",
"been",
"seen",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L399-L404 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | GetSchema | func (fmd *FakeMysqlDaemon) GetSchema(dbName string, tables, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error) {
if fmd.SchemaFunc != nil {
return fmd.SchemaFunc()
}
if fmd.Schema == nil {
return nil, fmt.Errorf("no schema defined")
}
return tmutils.FilterTables(fmd.Schema, tables, excludeTables, includeViews)
} | go | func (fmd *FakeMysqlDaemon) GetSchema(dbName string, tables, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error) {
if fmd.SchemaFunc != nil {
return fmd.SchemaFunc()
}
if fmd.Schema == nil {
return nil, fmt.Errorf("no schema defined")
}
return tmutils.FilterTables(fmd.Schema, tables, excludeTables, includeViews)
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"GetSchema",
"(",
"dbName",
"string",
",",
"tables",
",",
"excludeTables",
"[",
"]",
"string",
",",
"includeViews",
"bool",
")",
"(",
"*",
"tabletmanagerdatapb",
".",
"SchemaDefinition",
",",
"error",
")",
"{",
"if",
"fmd",
".",
"SchemaFunc",
"!=",
"nil",
"{",
"return",
"fmd",
".",
"SchemaFunc",
"(",
")",
"\n",
"}",
"\n",
"if",
"fmd",
".",
"Schema",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"tmutils",
".",
"FilterTables",
"(",
"fmd",
".",
"Schema",
",",
"tables",
",",
"excludeTables",
",",
"includeViews",
")",
"\n",
"}"
] | // GetSchema is part of the MysqlDaemon interface | [
"GetSchema",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L407-L415 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | GetColumns | func (fmd *FakeMysqlDaemon) GetColumns(dbName, table string) ([]string, error) {
return []string{}, nil
} | go | func (fmd *FakeMysqlDaemon) GetColumns(dbName, table string) ([]string, error) {
return []string{}, nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"GetColumns",
"(",
"dbName",
",",
"table",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"nil",
"\n",
"}"
] | // GetColumns is part of the MysqlDaemon interface | [
"GetColumns",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L418-L420 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | GetPrimaryKeyColumns | func (fmd *FakeMysqlDaemon) GetPrimaryKeyColumns(dbName, table string) ([]string, error) {
return []string{}, nil
} | go | func (fmd *FakeMysqlDaemon) GetPrimaryKeyColumns(dbName, table string) ([]string, error) {
return []string{}, nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"GetPrimaryKeyColumns",
"(",
"dbName",
",",
"table",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"nil",
"\n",
"}"
] | // GetPrimaryKeyColumns is part of the MysqlDaemon interface | [
"GetPrimaryKeyColumns",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L423-L425 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | PreflightSchemaChange | func (fmd *FakeMysqlDaemon) PreflightSchemaChange(dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error) {
if fmd.PreflightSchemaChangeResult == nil {
return nil, fmt.Errorf("no preflight result defined")
}
return fmd.PreflightSchemaChangeResult, nil
} | go | func (fmd *FakeMysqlDaemon) PreflightSchemaChange(dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error) {
if fmd.PreflightSchemaChangeResult == nil {
return nil, fmt.Errorf("no preflight result defined")
}
return fmd.PreflightSchemaChangeResult, nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"PreflightSchemaChange",
"(",
"dbName",
"string",
",",
"changes",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"tabletmanagerdatapb",
".",
"SchemaChangeResult",
",",
"error",
")",
"{",
"if",
"fmd",
".",
"PreflightSchemaChangeResult",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"fmd",
".",
"PreflightSchemaChangeResult",
",",
"nil",
"\n",
"}"
] | // PreflightSchemaChange is part of the MysqlDaemon interface | [
"PreflightSchemaChange",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L428-L433 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | ApplySchemaChange | func (fmd *FakeMysqlDaemon) ApplySchemaChange(dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error) {
if fmd.ApplySchemaChangeResult == nil {
return nil, fmt.Errorf("no apply schema defined")
}
return fmd.ApplySchemaChangeResult, nil
} | go | func (fmd *FakeMysqlDaemon) ApplySchemaChange(dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error) {
if fmd.ApplySchemaChangeResult == nil {
return nil, fmt.Errorf("no apply schema defined")
}
return fmd.ApplySchemaChangeResult, nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"ApplySchemaChange",
"(",
"dbName",
"string",
",",
"change",
"*",
"tmutils",
".",
"SchemaChange",
")",
"(",
"*",
"tabletmanagerdatapb",
".",
"SchemaChangeResult",
",",
"error",
")",
"{",
"if",
"fmd",
".",
"ApplySchemaChangeResult",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"fmd",
".",
"ApplySchemaChangeResult",
",",
"nil",
"\n",
"}"
] | // ApplySchemaChange is part of the MysqlDaemon interface | [
"ApplySchemaChange",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L436-L441 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | GetAppConnection | func (fmd *FakeMysqlDaemon) GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error) {
return fmd.appPool.Get(ctx)
} | go | func (fmd *FakeMysqlDaemon) GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error) {
return fmd.appPool.Get(ctx)
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"GetAppConnection",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"dbconnpool",
".",
"PooledDBConnection",
",",
"error",
")",
"{",
"return",
"fmd",
".",
"appPool",
".",
"Get",
"(",
"ctx",
")",
"\n",
"}"
] | // GetAppConnection is part of the MysqlDaemon interface. | [
"GetAppConnection",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L444-L446 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | GetAllPrivsConnection | func (fmd *FakeMysqlDaemon) GetAllPrivsConnection() (*dbconnpool.DBConnection, error) {
return dbconnpool.NewDBConnection(fmd.db.ConnParams(), stats.NewTimings("", "", ""))
} | go | func (fmd *FakeMysqlDaemon) GetAllPrivsConnection() (*dbconnpool.DBConnection, error) {
return dbconnpool.NewDBConnection(fmd.db.ConnParams(), stats.NewTimings("", "", ""))
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"GetAllPrivsConnection",
"(",
")",
"(",
"*",
"dbconnpool",
".",
"DBConnection",
",",
"error",
")",
"{",
"return",
"dbconnpool",
".",
"NewDBConnection",
"(",
"fmd",
".",
"db",
".",
"ConnParams",
"(",
")",
",",
"stats",
".",
"NewTimings",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // GetAllPrivsConnection is part of the MysqlDaemon interface. | [
"GetAllPrivsConnection",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L454-L456 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | SetSemiSyncEnabled | func (fmd *FakeMysqlDaemon) SetSemiSyncEnabled(master, slave bool) error {
fmd.SemiSyncMasterEnabled = master
fmd.SemiSyncSlaveEnabled = slave
return nil
} | go | func (fmd *FakeMysqlDaemon) SetSemiSyncEnabled(master, slave bool) error {
fmd.SemiSyncMasterEnabled = master
fmd.SemiSyncSlaveEnabled = slave
return nil
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"SetSemiSyncEnabled",
"(",
"master",
",",
"slave",
"bool",
")",
"error",
"{",
"fmd",
".",
"SemiSyncMasterEnabled",
"=",
"master",
"\n",
"fmd",
".",
"SemiSyncSlaveEnabled",
"=",
"slave",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetSemiSyncEnabled is part of the MysqlDaemon interface. | [
"SetSemiSyncEnabled",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L459-L463 | train |
vitessio/vitess | go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go | SemiSyncEnabled | func (fmd *FakeMysqlDaemon) SemiSyncEnabled() (master, slave bool) {
return fmd.SemiSyncMasterEnabled, fmd.SemiSyncSlaveEnabled
} | go | func (fmd *FakeMysqlDaemon) SemiSyncEnabled() (master, slave bool) {
return fmd.SemiSyncMasterEnabled, fmd.SemiSyncSlaveEnabled
} | [
"func",
"(",
"fmd",
"*",
"FakeMysqlDaemon",
")",
"SemiSyncEnabled",
"(",
")",
"(",
"master",
",",
"slave",
"bool",
")",
"{",
"return",
"fmd",
".",
"SemiSyncMasterEnabled",
",",
"fmd",
".",
"SemiSyncSlaveEnabled",
"\n",
"}"
] | // SemiSyncEnabled is part of the MysqlDaemon interface. | [
"SemiSyncEnabled",
"is",
"part",
"of",
"the",
"MysqlDaemon",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go#L466-L468 | train |
vitessio/vitess | go/vt/schemamanager/plain_controller.go | NewPlainController | func NewPlainController(sqlStr string, keyspace string) *PlainController {
controller := &PlainController{
sqls: make([]string, 0, 32),
keyspace: keyspace,
}
sqls, err := sqlparser.SplitStatementToPieces(sqlStr)
if err != nil {
panic(err.Error())
}
for _, sql := range sqls {
s := strings.TrimSpace(sql)
if s != "" {
controller.sqls = append(controller.sqls, s)
}
}
return controller
} | go | func NewPlainController(sqlStr string, keyspace string) *PlainController {
controller := &PlainController{
sqls: make([]string, 0, 32),
keyspace: keyspace,
}
sqls, err := sqlparser.SplitStatementToPieces(sqlStr)
if err != nil {
panic(err.Error())
}
for _, sql := range sqls {
s := strings.TrimSpace(sql)
if s != "" {
controller.sqls = append(controller.sqls, s)
}
}
return controller
} | [
"func",
"NewPlainController",
"(",
"sqlStr",
"string",
",",
"keyspace",
"string",
")",
"*",
"PlainController",
"{",
"controller",
":=",
"&",
"PlainController",
"{",
"sqls",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"32",
")",
",",
"keyspace",
":",
"keyspace",
",",
"}",
"\n\n",
"sqls",
",",
"err",
":=",
"sqlparser",
".",
"SplitStatementToPieces",
"(",
"sqlStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"sql",
":=",
"range",
"sqls",
"{",
"s",
":=",
"strings",
".",
"TrimSpace",
"(",
"sql",
")",
"\n",
"if",
"s",
"!=",
"\"",
"\"",
"{",
"controller",
".",
"sqls",
"=",
"append",
"(",
"controller",
".",
"sqls",
",",
"s",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"controller",
"\n",
"}"
] | // NewPlainController creates a new PlainController instance. | [
"NewPlainController",
"creates",
"a",
"new",
"PlainController",
"instance",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/plain_controller.go#L36-L54 | train |
vitessio/vitess | go/vt/schemamanager/plain_controller.go | Read | func (controller *PlainController) Read(ctx context.Context) ([]string, error) {
return controller.sqls, nil
} | go | func (controller *PlainController) Read(ctx context.Context) ([]string, error) {
return controller.sqls, nil
} | [
"func",
"(",
"controller",
"*",
"PlainController",
")",
"Read",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"controller",
".",
"sqls",
",",
"nil",
"\n",
"}"
] | // Read reads schema changes | [
"Read",
"reads",
"schema",
"changes"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/plain_controller.go#L62-L64 | train |
vitessio/vitess | go/vt/schemamanager/plain_controller.go | OnReadSuccess | func (controller *PlainController) OnReadSuccess(ctx context.Context) error {
log.Info("Successfully read all schema changes.")
return nil
} | go | func (controller *PlainController) OnReadSuccess(ctx context.Context) error {
log.Info("Successfully read all schema changes.")
return nil
} | [
"func",
"(",
"controller",
"*",
"PlainController",
")",
"OnReadSuccess",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // OnReadSuccess is called when schemamanager successfully
// reads all sql statements. | [
"OnReadSuccess",
"is",
"called",
"when",
"schemamanager",
"successfully",
"reads",
"all",
"sql",
"statements",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/plain_controller.go#L77-L80 | train |
vitessio/vitess | go/vt/schemamanager/plain_controller.go | OnReadFail | func (controller *PlainController) OnReadFail(ctx context.Context, err error) error {
log.Errorf("Failed to read schema changes, error: %v\n", err)
return err
} | go | func (controller *PlainController) OnReadFail(ctx context.Context, err error) error {
log.Errorf("Failed to read schema changes, error: %v\n", err)
return err
} | [
"func",
"(",
"controller",
"*",
"PlainController",
")",
"OnReadFail",
"(",
"ctx",
"context",
".",
"Context",
",",
"err",
"error",
")",
"error",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // OnReadFail is called when schemamanager fails to read all sql statements. | [
"OnReadFail",
"is",
"called",
"when",
"schemamanager",
"fails",
"to",
"read",
"all",
"sql",
"statements",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/plain_controller.go#L83-L86 | train |
vitessio/vitess | go/vt/schemamanager/plain_controller.go | OnExecutorComplete | func (controller *PlainController) OnExecutorComplete(ctx context.Context, result *ExecuteResult) error {
out, _ := json.MarshalIndent(result, "", " ")
log.Infof("Executor finished, result: %s\n", string(out))
return nil
} | go | func (controller *PlainController) OnExecutorComplete(ctx context.Context, result *ExecuteResult) error {
out, _ := json.MarshalIndent(result, "", " ")
log.Infof("Executor finished, result: %s\n", string(out))
return nil
} | [
"func",
"(",
"controller",
"*",
"PlainController",
")",
"OnExecutorComplete",
"(",
"ctx",
"context",
".",
"Context",
",",
"result",
"*",
"ExecuteResult",
")",
"error",
"{",
"out",
",",
"_",
":=",
"json",
".",
"MarshalIndent",
"(",
"result",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
",",
"string",
"(",
"out",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // OnExecutorComplete is called when schemamanager finishes applying schema changes. | [
"OnExecutorComplete",
"is",
"called",
"when",
"schemamanager",
"finishes",
"applying",
"schema",
"changes",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/plain_controller.go#L101-L105 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | SetListener | func (fhc *FakeHealthCheck) SetListener(listener HealthCheckStatsListener, sendDownEvents bool) {
fhc.listener = listener
} | go | func (fhc *FakeHealthCheck) SetListener(listener HealthCheckStatsListener, sendDownEvents bool) {
fhc.listener = listener
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"SetListener",
"(",
"listener",
"HealthCheckStatsListener",
",",
"sendDownEvents",
"bool",
")",
"{",
"fhc",
".",
"listener",
"=",
"listener",
"\n",
"}"
] | // SetListener is not implemented. | [
"SetListener",
"is",
"not",
"implemented",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L66-L68 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | AddTablet | func (fhc *FakeHealthCheck) AddTablet(tablet *topodatapb.Tablet, name string) {
key := TabletToMapKey(tablet)
item := &fhcItem{
ts: &TabletStats{
Key: key,
Tablet: tablet,
Target: &querypb.Target{
Keyspace: tablet.Keyspace,
Shard: tablet.Shard,
TabletType: tablet.Type,
},
Serving: true,
Up: true,
Name: name,
Stats: &querypb.RealtimeStats{},
},
}
fhc.mu.Lock()
defer fhc.mu.Unlock()
fhc.items[key] = item
if fhc.listener != nil {
fhc.listener.StatsUpdate(item.ts)
}
} | go | func (fhc *FakeHealthCheck) AddTablet(tablet *topodatapb.Tablet, name string) {
key := TabletToMapKey(tablet)
item := &fhcItem{
ts: &TabletStats{
Key: key,
Tablet: tablet,
Target: &querypb.Target{
Keyspace: tablet.Keyspace,
Shard: tablet.Shard,
TabletType: tablet.Type,
},
Serving: true,
Up: true,
Name: name,
Stats: &querypb.RealtimeStats{},
},
}
fhc.mu.Lock()
defer fhc.mu.Unlock()
fhc.items[key] = item
if fhc.listener != nil {
fhc.listener.StatsUpdate(item.ts)
}
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"AddTablet",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
",",
"name",
"string",
")",
"{",
"key",
":=",
"TabletToMapKey",
"(",
"tablet",
")",
"\n",
"item",
":=",
"&",
"fhcItem",
"{",
"ts",
":",
"&",
"TabletStats",
"{",
"Key",
":",
"key",
",",
"Tablet",
":",
"tablet",
",",
"Target",
":",
"&",
"querypb",
".",
"Target",
"{",
"Keyspace",
":",
"tablet",
".",
"Keyspace",
",",
"Shard",
":",
"tablet",
".",
"Shard",
",",
"TabletType",
":",
"tablet",
".",
"Type",
",",
"}",
",",
"Serving",
":",
"true",
",",
"Up",
":",
"true",
",",
"Name",
":",
"name",
",",
"Stats",
":",
"&",
"querypb",
".",
"RealtimeStats",
"{",
"}",
",",
"}",
",",
"}",
"\n\n",
"fhc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fhc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"fhc",
".",
"items",
"[",
"key",
"]",
"=",
"item",
"\n\n",
"if",
"fhc",
".",
"listener",
"!=",
"nil",
"{",
"fhc",
".",
"listener",
".",
"StatsUpdate",
"(",
"item",
".",
"ts",
")",
"\n",
"}",
"\n",
"}"
] | // AddTablet adds the tablet and calls the listener. | [
"AddTablet",
"adds",
"the",
"tablet",
"and",
"calls",
"the",
"listener",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L75-L100 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | RemoveTablet | func (fhc *FakeHealthCheck) RemoveTablet(tablet *topodatapb.Tablet) {
fhc.mu.Lock()
defer fhc.mu.Unlock()
key := TabletToMapKey(tablet)
delete(fhc.items, key)
} | go | func (fhc *FakeHealthCheck) RemoveTablet(tablet *topodatapb.Tablet) {
fhc.mu.Lock()
defer fhc.mu.Unlock()
key := TabletToMapKey(tablet)
delete(fhc.items, key)
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"RemoveTablet",
"(",
"tablet",
"*",
"topodatapb",
".",
"Tablet",
")",
"{",
"fhc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fhc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"key",
":=",
"TabletToMapKey",
"(",
"tablet",
")",
"\n",
"delete",
"(",
"fhc",
".",
"items",
",",
"key",
")",
"\n",
"}"
] | // RemoveTablet removes the tablet. | [
"RemoveTablet",
"removes",
"the",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L103-L108 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | ReplaceTablet | func (fhc *FakeHealthCheck) ReplaceTablet(old, new *topodatapb.Tablet, name string) {
fhc.RemoveTablet(old)
fhc.AddTablet(new, name)
} | go | func (fhc *FakeHealthCheck) ReplaceTablet(old, new *topodatapb.Tablet, name string) {
fhc.RemoveTablet(old)
fhc.AddTablet(new, name)
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"ReplaceTablet",
"(",
"old",
",",
"new",
"*",
"topodatapb",
".",
"Tablet",
",",
"name",
"string",
")",
"{",
"fhc",
".",
"RemoveTablet",
"(",
"old",
")",
"\n",
"fhc",
".",
"AddTablet",
"(",
"new",
",",
"name",
")",
"\n",
"}"
] | // ReplaceTablet removes the old tablet and adds the new. | [
"ReplaceTablet",
"removes",
"the",
"old",
"tablet",
"and",
"adds",
"the",
"new",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L111-L114 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | CacheStatus | func (fhc *FakeHealthCheck) CacheStatus() TabletsCacheStatusList {
fhc.mu.Lock()
defer fhc.mu.Unlock()
stats := make(TabletsCacheStatusList, 0, len(fhc.items))
for _, item := range fhc.items {
stats = append(stats, &TabletsCacheStatus{
Cell: "FakeCell",
Target: item.ts.Target,
TabletsStats: TabletStatsList{item.ts},
})
}
sort.Sort(stats)
return stats
} | go | func (fhc *FakeHealthCheck) CacheStatus() TabletsCacheStatusList {
fhc.mu.Lock()
defer fhc.mu.Unlock()
stats := make(TabletsCacheStatusList, 0, len(fhc.items))
for _, item := range fhc.items {
stats = append(stats, &TabletsCacheStatus{
Cell: "FakeCell",
Target: item.ts.Target,
TabletsStats: TabletStatsList{item.ts},
})
}
sort.Sort(stats)
return stats
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"CacheStatus",
"(",
")",
"TabletsCacheStatusList",
"{",
"fhc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fhc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"stats",
":=",
"make",
"(",
"TabletsCacheStatusList",
",",
"0",
",",
"len",
"(",
"fhc",
".",
"items",
")",
")",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"fhc",
".",
"items",
"{",
"stats",
"=",
"append",
"(",
"stats",
",",
"&",
"TabletsCacheStatus",
"{",
"Cell",
":",
"\"",
"\"",
",",
"Target",
":",
"item",
".",
"ts",
".",
"Target",
",",
"TabletsStats",
":",
"TabletStatsList",
"{",
"item",
".",
"ts",
"}",
",",
"}",
")",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"stats",
")",
"\n",
"return",
"stats",
"\n",
"}"
] | // CacheStatus returns the status for each tablet | [
"CacheStatus",
"returns",
"the",
"status",
"for",
"each",
"tablet"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L127-L141 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | Reset | func (fhc *FakeHealthCheck) Reset() {
fhc.mu.Lock()
defer fhc.mu.Unlock()
fhc.items = make(map[string]*fhcItem)
} | go | func (fhc *FakeHealthCheck) Reset() {
fhc.mu.Lock()
defer fhc.mu.Unlock()
fhc.items = make(map[string]*fhcItem)
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"Reset",
"(",
")",
"{",
"fhc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fhc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"fhc",
".",
"items",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"fhcItem",
")",
"\n",
"}"
] | //
// Management methods
//
// Reset cleans up the internal state. | [
"Management",
"methods",
"Reset",
"cleans",
"up",
"the",
"internal",
"state",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L153-L158 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | AddFakeTablet | func (fhc *FakeHealthCheck) AddFakeTablet(cell, host string, port int32, keyspace, shard string, tabletType topodatapb.TabletType, serving bool, reparentTS int64, err error, connFactory func(*topodatapb.Tablet) queryservice.QueryService) queryservice.QueryService {
t := topo.NewTablet(0, cell, host)
t.Keyspace = keyspace
t.Shard = shard
t.Type = tabletType
t.PortMap["vt"] = port
key := TabletToMapKey(t)
fhc.mu.Lock()
defer fhc.mu.Unlock()
item := fhc.items[key]
if item == nil {
item = &fhcItem{
ts: &TabletStats{
Key: key,
Tablet: t,
Up: true,
},
}
fhc.items[key] = item
}
item.ts.Target = &querypb.Target{
Keyspace: keyspace,
Shard: shard,
TabletType: tabletType,
}
item.ts.Serving = serving
item.ts.TabletExternallyReparentedTimestamp = reparentTS
item.ts.Stats = &querypb.RealtimeStats{}
item.ts.LastError = err
conn := connFactory(t)
item.conn = conn
if fhc.listener != nil {
fhc.listener.StatsUpdate(item.ts)
}
return conn
} | go | func (fhc *FakeHealthCheck) AddFakeTablet(cell, host string, port int32, keyspace, shard string, tabletType topodatapb.TabletType, serving bool, reparentTS int64, err error, connFactory func(*topodatapb.Tablet) queryservice.QueryService) queryservice.QueryService {
t := topo.NewTablet(0, cell, host)
t.Keyspace = keyspace
t.Shard = shard
t.Type = tabletType
t.PortMap["vt"] = port
key := TabletToMapKey(t)
fhc.mu.Lock()
defer fhc.mu.Unlock()
item := fhc.items[key]
if item == nil {
item = &fhcItem{
ts: &TabletStats{
Key: key,
Tablet: t,
Up: true,
},
}
fhc.items[key] = item
}
item.ts.Target = &querypb.Target{
Keyspace: keyspace,
Shard: shard,
TabletType: tabletType,
}
item.ts.Serving = serving
item.ts.TabletExternallyReparentedTimestamp = reparentTS
item.ts.Stats = &querypb.RealtimeStats{}
item.ts.LastError = err
conn := connFactory(t)
item.conn = conn
if fhc.listener != nil {
fhc.listener.StatsUpdate(item.ts)
}
return conn
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"AddFakeTablet",
"(",
"cell",
",",
"host",
"string",
",",
"port",
"int32",
",",
"keyspace",
",",
"shard",
"string",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
",",
"serving",
"bool",
",",
"reparentTS",
"int64",
",",
"err",
"error",
",",
"connFactory",
"func",
"(",
"*",
"topodatapb",
".",
"Tablet",
")",
"queryservice",
".",
"QueryService",
")",
"queryservice",
".",
"QueryService",
"{",
"t",
":=",
"topo",
".",
"NewTablet",
"(",
"0",
",",
"cell",
",",
"host",
")",
"\n",
"t",
".",
"Keyspace",
"=",
"keyspace",
"\n",
"t",
".",
"Shard",
"=",
"shard",
"\n",
"t",
".",
"Type",
"=",
"tabletType",
"\n",
"t",
".",
"PortMap",
"[",
"\"",
"\"",
"]",
"=",
"port",
"\n",
"key",
":=",
"TabletToMapKey",
"(",
"t",
")",
"\n\n",
"fhc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fhc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"item",
":=",
"fhc",
".",
"items",
"[",
"key",
"]",
"\n",
"if",
"item",
"==",
"nil",
"{",
"item",
"=",
"&",
"fhcItem",
"{",
"ts",
":",
"&",
"TabletStats",
"{",
"Key",
":",
"key",
",",
"Tablet",
":",
"t",
",",
"Up",
":",
"true",
",",
"}",
",",
"}",
"\n",
"fhc",
".",
"items",
"[",
"key",
"]",
"=",
"item",
"\n",
"}",
"\n",
"item",
".",
"ts",
".",
"Target",
"=",
"&",
"querypb",
".",
"Target",
"{",
"Keyspace",
":",
"keyspace",
",",
"Shard",
":",
"shard",
",",
"TabletType",
":",
"tabletType",
",",
"}",
"\n",
"item",
".",
"ts",
".",
"Serving",
"=",
"serving",
"\n",
"item",
".",
"ts",
".",
"TabletExternallyReparentedTimestamp",
"=",
"reparentTS",
"\n",
"item",
".",
"ts",
".",
"Stats",
"=",
"&",
"querypb",
".",
"RealtimeStats",
"{",
"}",
"\n",
"item",
".",
"ts",
".",
"LastError",
"=",
"err",
"\n",
"conn",
":=",
"connFactory",
"(",
"t",
")",
"\n",
"item",
".",
"conn",
"=",
"conn",
"\n\n",
"if",
"fhc",
".",
"listener",
"!=",
"nil",
"{",
"fhc",
".",
"listener",
".",
"StatsUpdate",
"(",
"item",
".",
"ts",
")",
"\n",
"}",
"\n",
"return",
"conn",
"\n",
"}"
] | // AddFakeTablet inserts a fake entry into FakeHealthCheck.
// The Tablet can be talked to using the provided connection.
// The Listener is called, as if AddTablet had been called.
// For flexibility the connection is created via a connFactory callback | [
"AddFakeTablet",
"inserts",
"a",
"fake",
"entry",
"into",
"FakeHealthCheck",
".",
"The",
"Tablet",
"can",
"be",
"talked",
"to",
"using",
"the",
"provided",
"connection",
".",
"The",
"Listener",
"is",
"called",
"as",
"if",
"AddTablet",
"had",
"been",
"called",
".",
"For",
"flexibility",
"the",
"connection",
"is",
"created",
"via",
"a",
"connFactory",
"callback"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L164-L201 | train |
vitessio/vitess | go/vt/discovery/fake_healthcheck.go | GetAllTablets | func (fhc *FakeHealthCheck) GetAllTablets() map[string]*topodatapb.Tablet {
res := make(map[string]*topodatapb.Tablet)
fhc.mu.RLock()
defer fhc.mu.RUnlock()
for key, t := range fhc.items {
res[key] = t.ts.Tablet
}
return res
} | go | func (fhc *FakeHealthCheck) GetAllTablets() map[string]*topodatapb.Tablet {
res := make(map[string]*topodatapb.Tablet)
fhc.mu.RLock()
defer fhc.mu.RUnlock()
for key, t := range fhc.items {
res[key] = t.ts.Tablet
}
return res
} | [
"func",
"(",
"fhc",
"*",
"FakeHealthCheck",
")",
"GetAllTablets",
"(",
")",
"map",
"[",
"string",
"]",
"*",
"topodatapb",
".",
"Tablet",
"{",
"res",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"topodatapb",
".",
"Tablet",
")",
"\n",
"fhc",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"fhc",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"key",
",",
"t",
":=",
"range",
"fhc",
".",
"items",
"{",
"res",
"[",
"key",
"]",
"=",
"t",
".",
"ts",
".",
"Tablet",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] | // GetAllTablets returns all the tablets we have. | [
"GetAllTablets",
"returns",
"all",
"the",
"tablets",
"we",
"have",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/fake_healthcheck.go#L213-L221 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/expr.go | splitAndExpression | func splitAndExpression(filters []sqlparser.Expr, node sqlparser.Expr) []sqlparser.Expr {
if node == nil {
return filters
}
switch node := node.(type) {
case *sqlparser.AndExpr:
filters = splitAndExpression(filters, node.Left)
return splitAndExpression(filters, node.Right)
case *sqlparser.ParenExpr:
// If the inner expression is AndExpr, then we can remove
// the parenthesis because they are unnecessary.
if node, ok := node.Expr.(*sqlparser.AndExpr); ok {
return splitAndExpression(filters, node)
}
}
return append(filters, node)
} | go | func splitAndExpression(filters []sqlparser.Expr, node sqlparser.Expr) []sqlparser.Expr {
if node == nil {
return filters
}
switch node := node.(type) {
case *sqlparser.AndExpr:
filters = splitAndExpression(filters, node.Left)
return splitAndExpression(filters, node.Right)
case *sqlparser.ParenExpr:
// If the inner expression is AndExpr, then we can remove
// the parenthesis because they are unnecessary.
if node, ok := node.Expr.(*sqlparser.AndExpr); ok {
return splitAndExpression(filters, node)
}
}
return append(filters, node)
} | [
"func",
"splitAndExpression",
"(",
"filters",
"[",
"]",
"sqlparser",
".",
"Expr",
",",
"node",
"sqlparser",
".",
"Expr",
")",
"[",
"]",
"sqlparser",
".",
"Expr",
"{",
"if",
"node",
"==",
"nil",
"{",
"return",
"filters",
"\n",
"}",
"\n",
"switch",
"node",
":=",
"node",
".",
"(",
"type",
")",
"{",
"case",
"*",
"sqlparser",
".",
"AndExpr",
":",
"filters",
"=",
"splitAndExpression",
"(",
"filters",
",",
"node",
".",
"Left",
")",
"\n",
"return",
"splitAndExpression",
"(",
"filters",
",",
"node",
".",
"Right",
")",
"\n",
"case",
"*",
"sqlparser",
".",
"ParenExpr",
":",
"// If the inner expression is AndExpr, then we can remove",
"// the parenthesis because they are unnecessary.",
"if",
"node",
",",
"ok",
":=",
"node",
".",
"Expr",
".",
"(",
"*",
"sqlparser",
".",
"AndExpr",
")",
";",
"ok",
"{",
"return",
"splitAndExpression",
"(",
"filters",
",",
"node",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"append",
"(",
"filters",
",",
"node",
")",
"\n",
"}"
] | // splitAndExpression breaks up the Expr into AND-separated conditions
// and appends them to filters, which can be shuffled and recombined
// as needed. | [
"splitAndExpression",
"breaks",
"up",
"the",
"Expr",
"into",
"AND",
"-",
"separated",
"conditions",
"and",
"appends",
"them",
"to",
"filters",
"which",
"can",
"be",
"shuffled",
"and",
"recombined",
"as",
"needed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/expr.go#L31-L47 | train |
vitessio/vitess | go/proc/proc.go | Listen | func Listen(port string) (l net.Listener, err error) {
if port != "" {
killPredecessor(port)
}
return listen(port)
} | go | func Listen(port string) (l net.Listener, err error) {
if port != "" {
killPredecessor(port)
}
return listen(port)
} | [
"func",
"Listen",
"(",
"port",
"string",
")",
"(",
"l",
"net",
".",
"Listener",
",",
"err",
"error",
")",
"{",
"if",
"port",
"!=",
"\"",
"\"",
"{",
"killPredecessor",
"(",
"port",
")",
"\n",
"}",
"\n",
"return",
"listen",
"(",
"port",
")",
"\n",
"}"
] | // Listen tries to create a listener on the specified tcp port.
// Before creating the listener, it checks to see if there is another
// server already using the port. If there is one, it sends a USR1
// signal requesting the server to shutdown, and then attempts to
// to create the listener. | [
"Listen",
"tries",
"to",
"create",
"a",
"listener",
"on",
"the",
"specified",
"tcp",
"port",
".",
"Before",
"creating",
"the",
"listener",
"it",
"checks",
"to",
"see",
"if",
"there",
"is",
"another",
"server",
"already",
"using",
"the",
"port",
".",
"If",
"there",
"is",
"one",
"it",
"sends",
"a",
"USR1",
"signal",
"requesting",
"the",
"server",
"to",
"shutdown",
"and",
"then",
"attempts",
"to",
"to",
"create",
"the",
"listener",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/proc/proc.go#L43-L48 | train |
vitessio/vitess | go/proc/proc.go | Wait | func Wait() os.Signal {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM, syscall.SIGUSR1, syscall.SIGINT)
http.HandleFunc(pidURL, func(r http.ResponseWriter, req *http.Request) {
r.Write(strconv.AppendInt(nil, int64(os.Getpid()), 10))
})
return <-c
} | go | func Wait() os.Signal {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM, syscall.SIGUSR1, syscall.SIGINT)
http.HandleFunc(pidURL, func(r http.ResponseWriter, req *http.Request) {
r.Write(strconv.AppendInt(nil, int64(os.Getpid()), 10))
})
return <-c
} | [
"func",
"Wait",
"(",
")",
"os",
".",
"Signal",
"{",
"c",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"signal",
".",
"Notify",
"(",
"c",
",",
"syscall",
".",
"SIGTERM",
",",
"syscall",
".",
"SIGUSR1",
",",
"syscall",
".",
"SIGINT",
")",
"\n\n",
"http",
".",
"HandleFunc",
"(",
"pidURL",
",",
"func",
"(",
"r",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"r",
".",
"Write",
"(",
"strconv",
".",
"AppendInt",
"(",
"nil",
",",
"int64",
"(",
"os",
".",
"Getpid",
"(",
")",
")",
",",
"10",
")",
")",
"\n",
"}",
")",
"\n\n",
"return",
"<-",
"c",
"\n",
"}"
] | // Wait creates an HTTP handler on pidURL, and serves the current process
// pid on it. It then creates a signal handler and waits for SIGTERM or
// SIGUSR1, and returns when the signal is received. A new server that comes
// up will query this URL. If it receives a valid response, it will send a
// SIGUSR1 signal and attempt to bind to the port the current server is using. | [
"Wait",
"creates",
"an",
"HTTP",
"handler",
"on",
"pidURL",
"and",
"serves",
"the",
"current",
"process",
"pid",
"on",
"it",
".",
"It",
"then",
"creates",
"a",
"signal",
"handler",
"and",
"waits",
"for",
"SIGTERM",
"or",
"SIGUSR1",
"and",
"returns",
"when",
"the",
"signal",
"is",
"received",
".",
"A",
"new",
"server",
"that",
"comes",
"up",
"will",
"query",
"this",
"URL",
".",
"If",
"it",
"receives",
"a",
"valid",
"response",
"it",
"will",
"send",
"a",
"SIGUSR1",
"signal",
"and",
"attempt",
"to",
"bind",
"to",
"the",
"port",
"the",
"current",
"server",
"is",
"using",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/proc/proc.go#L55-L64 | train |
vitessio/vitess | go/proc/proc.go | ListenAndServe | func ListenAndServe(port string) os.Signal {
l, err := Listen(port)
if err != nil {
log.Fatalf("%s", err)
}
go http.Serve(l, nil)
s := Wait()
l.Close()
return s
} | go | func ListenAndServe(port string) os.Signal {
l, err := Listen(port)
if err != nil {
log.Fatalf("%s", err)
}
go http.Serve(l, nil)
s := Wait()
l.Close()
return s
} | [
"func",
"ListenAndServe",
"(",
"port",
"string",
")",
"os",
".",
"Signal",
"{",
"l",
",",
"err",
":=",
"Listen",
"(",
"port",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"go",
"http",
".",
"Serve",
"(",
"l",
",",
"nil",
")",
"\n",
"s",
":=",
"Wait",
"(",
")",
"\n",
"l",
".",
"Close",
"(",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // ListenAndServe combines Listen and Wait to also run an http
// server on the specified port. If it fails to obtain a listener,
// the program is fatally terminated. The return value is the signal
// received for termination | [
"ListenAndServe",
"combines",
"Listen",
"and",
"Wait",
"to",
"also",
"run",
"an",
"http",
"server",
"on",
"the",
"specified",
"port",
".",
"If",
"it",
"fails",
"to",
"obtain",
"a",
"listener",
"the",
"program",
"is",
"fatally",
"terminated",
".",
"The",
"return",
"value",
"is",
"the",
"signal",
"received",
"for",
"termination"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/proc/proc.go#L70-L79 | train |
vitessio/vitess | go/vt/callerid/callerid.go | NewEffectiveCallerID | func NewEffectiveCallerID(principal string, component string, subComponent string) *vtrpcpb.CallerID {
return &vtrpcpb.CallerID{Principal: principal, Component: component, Subcomponent: subComponent}
} | go | func NewEffectiveCallerID(principal string, component string, subComponent string) *vtrpcpb.CallerID {
return &vtrpcpb.CallerID{Principal: principal, Component: component, Subcomponent: subComponent}
} | [
"func",
"NewEffectiveCallerID",
"(",
"principal",
"string",
",",
"component",
"string",
",",
"subComponent",
"string",
")",
"*",
"vtrpcpb",
".",
"CallerID",
"{",
"return",
"&",
"vtrpcpb",
".",
"CallerID",
"{",
"Principal",
":",
"principal",
",",
"Component",
":",
"component",
",",
"Subcomponent",
":",
"subComponent",
"}",
"\n",
"}"
] | // NewEffectiveCallerID creates a new vtrpcpb.CallerID with principal, component and
// subComponent | [
"NewEffectiveCallerID",
"creates",
"a",
"new",
"vtrpcpb",
".",
"CallerID",
"with",
"principal",
"component",
"and",
"subComponent"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/callerid/callerid.go#L53-L55 | train |
vitessio/vitess | go/mysql/binlog_event_json.go | printJSONData | func printJSONData(data []byte) ([]byte, error) {
// It's possible for data to be empty. If so, we have to
// treat it as 'null'.
// The mysql code also says why, but this wasn't reproduceable:
// https://github.com/mysql/mysql-server/blob/8.0/sql/json_binary.cc#L1070
if len(data) == 0 {
return []byte("'null'"), nil
}
result := &bytes.Buffer{}
typ := data[0]
if err := printJSONValue(typ, data[1:], true /* toplevel */, result); err != nil {
return nil, err
}
return result.Bytes(), nil
} | go | func printJSONData(data []byte) ([]byte, error) {
// It's possible for data to be empty. If so, we have to
// treat it as 'null'.
// The mysql code also says why, but this wasn't reproduceable:
// https://github.com/mysql/mysql-server/blob/8.0/sql/json_binary.cc#L1070
if len(data) == 0 {
return []byte("'null'"), nil
}
result := &bytes.Buffer{}
typ := data[0]
if err := printJSONValue(typ, data[1:], true /* toplevel */, result); err != nil {
return nil, err
}
return result.Bytes(), nil
} | [
"func",
"printJSONData",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// It's possible for data to be empty. If so, we have to",
"// treat it as 'null'.",
"// The mysql code also says why, but this wasn't reproduceable:",
"// https://github.com/mysql/mysql-server/blob/8.0/sql/json_binary.cc#L1070",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
",",
"nil",
"\n",
"}",
"\n",
"result",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"typ",
":=",
"data",
"[",
"0",
"]",
"\n",
"if",
"err",
":=",
"printJSONValue",
"(",
"typ",
",",
"data",
"[",
"1",
":",
"]",
",",
"true",
"/* toplevel */",
",",
"result",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"result",
".",
"Bytes",
"(",
")",
",",
"nil",
"\n",
"}"
] | // printJSONData parses the MySQL binary format for JSON data, and prints
// the result as a string. | [
"printJSONData",
"parses",
"the",
"MySQL",
"binary",
"format",
"for",
"JSON",
"data",
"and",
"prints",
"the",
"result",
"as",
"a",
"string",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_json.go#L55-L69 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/status.go | AddStatusPart | func (tsv *TabletServer) AddStatusPart() {
servenv.AddStatusPart("Queryservice", queryserviceStatusTemplate, func() interface{} {
status := queryserviceStatus{
State: tsv.GetState(),
History: tsv.history.Records(),
}
rates := tabletenv.QPSRates.Get()
if qps, ok := rates["All"]; ok && len(qps) > 0 {
status.CurrentQPS = qps[0]
}
return status
})
} | go | func (tsv *TabletServer) AddStatusPart() {
servenv.AddStatusPart("Queryservice", queryserviceStatusTemplate, func() interface{} {
status := queryserviceStatus{
State: tsv.GetState(),
History: tsv.history.Records(),
}
rates := tabletenv.QPSRates.Get()
if qps, ok := rates["All"]; ok && len(qps) > 0 {
status.CurrentQPS = qps[0]
}
return status
})
} | [
"func",
"(",
"tsv",
"*",
"TabletServer",
")",
"AddStatusPart",
"(",
")",
"{",
"servenv",
".",
"AddStatusPart",
"(",
"\"",
"\"",
",",
"queryserviceStatusTemplate",
",",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"status",
":=",
"queryserviceStatus",
"{",
"State",
":",
"tsv",
".",
"GetState",
"(",
")",
",",
"History",
":",
"tsv",
".",
"history",
".",
"Records",
"(",
")",
",",
"}",
"\n",
"rates",
":=",
"tabletenv",
".",
"QPSRates",
".",
"Get",
"(",
")",
"\n",
"if",
"qps",
",",
"ok",
":=",
"rates",
"[",
"\"",
"\"",
"]",
";",
"ok",
"&&",
"len",
"(",
"qps",
")",
">",
"0",
"{",
"status",
".",
"CurrentQPS",
"=",
"qps",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"status",
"\n",
"}",
")",
"\n",
"}"
] | // AddStatusPart registers the status part for the status page. | [
"AddStatusPart",
"registers",
"the",
"status",
"part",
"for",
"the",
"status",
"page",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/status.go#L130-L142 | train |
vitessio/vitess | go/trace/utils.go | LogErrorsWhenClosing | func LogErrorsWhenClosing(in io.Closer) func() {
return func() {
err := in.Close()
if err != nil {
log.Error(err)
}
}
} | go | func LogErrorsWhenClosing(in io.Closer) func() {
return func() {
err := in.Close()
if err != nil {
log.Error(err)
}
}
} | [
"func",
"LogErrorsWhenClosing",
"(",
"in",
"io",
".",
"Closer",
")",
"func",
"(",
")",
"{",
"return",
"func",
"(",
")",
"{",
"err",
":=",
"in",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Error",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // LogErrorsWhenClosing will close the provided Closer, and log any errors it generates | [
"LogErrorsWhenClosing",
"will",
"close",
"the",
"provided",
"Closer",
"and",
"log",
"any",
"errors",
"it",
"generates"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/trace/utils.go#L26-L33 | train |
vitessio/vitess | go/vt/mysqlctl/mycnf_flag.go | RegisterFlags | func RegisterFlags() {
flagServerID = flag.Int("mycnf_server_id", 0, "mysql server id of the server (if specified, mycnf-file will be ignored)")
flagMysqlPort = flag.Int("mycnf_mysql_port", 0, "port mysql is listening on")
flagDataDir = flag.String("mycnf_data_dir", "", "data directory for mysql")
flagInnodbDataHomeDir = flag.String("mycnf_innodb_data_home_dir", "", "Innodb data home directory")
flagInnodbLogGroupHomeDir = flag.String("mycnf_innodb_log_group_home_dir", "", "Innodb log group home directory")
flagSocketFile = flag.String("mycnf_socket_file", "", "mysql socket file")
flagGeneralLogPath = flag.String("mycnf_general_log_path", "", "mysql general log path")
flagErrorLogPath = flag.String("mycnf_error_log_path", "", "mysql error log path")
flagSlowLogPath = flag.String("mycnf_slow_log_path", "", "mysql slow query log path")
flagRelayLogPath = flag.String("mycnf_relay_log_path", "", "mysql relay log path")
flagRelayLogIndexPath = flag.String("mycnf_relay_log_index_path", "", "mysql relay log index path")
flagRelayLogInfoPath = flag.String("mycnf_relay_log_info_path", "", "mysql relay log info path")
flagBinLogPath = flag.String("mycnf_bin_log_path", "", "mysql binlog path")
flagMasterInfoFile = flag.String("mycnf_master_info_file", "", "mysql master.info file")
flagPidFile = flag.String("mycnf_pid_file", "", "mysql pid file")
flagTmpDir = flag.String("mycnf_tmp_dir", "", "mysql tmp directory")
flagSlaveLoadTmpDir = flag.String("mycnf_slave_load_tmp_dir", "", "slave load tmp directory")
flagMycnfFile = flag.String("mycnf-file", "", "path to my.cnf, if reading all config params from there")
} | go | func RegisterFlags() {
flagServerID = flag.Int("mycnf_server_id", 0, "mysql server id of the server (if specified, mycnf-file will be ignored)")
flagMysqlPort = flag.Int("mycnf_mysql_port", 0, "port mysql is listening on")
flagDataDir = flag.String("mycnf_data_dir", "", "data directory for mysql")
flagInnodbDataHomeDir = flag.String("mycnf_innodb_data_home_dir", "", "Innodb data home directory")
flagInnodbLogGroupHomeDir = flag.String("mycnf_innodb_log_group_home_dir", "", "Innodb log group home directory")
flagSocketFile = flag.String("mycnf_socket_file", "", "mysql socket file")
flagGeneralLogPath = flag.String("mycnf_general_log_path", "", "mysql general log path")
flagErrorLogPath = flag.String("mycnf_error_log_path", "", "mysql error log path")
flagSlowLogPath = flag.String("mycnf_slow_log_path", "", "mysql slow query log path")
flagRelayLogPath = flag.String("mycnf_relay_log_path", "", "mysql relay log path")
flagRelayLogIndexPath = flag.String("mycnf_relay_log_index_path", "", "mysql relay log index path")
flagRelayLogInfoPath = flag.String("mycnf_relay_log_info_path", "", "mysql relay log info path")
flagBinLogPath = flag.String("mycnf_bin_log_path", "", "mysql binlog path")
flagMasterInfoFile = flag.String("mycnf_master_info_file", "", "mysql master.info file")
flagPidFile = flag.String("mycnf_pid_file", "", "mysql pid file")
flagTmpDir = flag.String("mycnf_tmp_dir", "", "mysql tmp directory")
flagSlaveLoadTmpDir = flag.String("mycnf_slave_load_tmp_dir", "", "slave load tmp directory")
flagMycnfFile = flag.String("mycnf-file", "", "path to my.cnf, if reading all config params from there")
} | [
"func",
"RegisterFlags",
"(",
")",
"{",
"flagServerID",
"=",
"flag",
".",
"Int",
"(",
"\"",
"\"",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"flagMysqlPort",
"=",
"flag",
".",
"Int",
"(",
"\"",
"\"",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"flagDataDir",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagInnodbDataHomeDir",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagInnodbLogGroupHomeDir",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagSocketFile",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagGeneralLogPath",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagErrorLogPath",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagSlowLogPath",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagRelayLogPath",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagRelayLogIndexPath",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagRelayLogInfoPath",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagBinLogPath",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagMasterInfoFile",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagPidFile",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagTmpDir",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flagSlaveLoadTmpDir",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"flagMycnfFile",
"=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // RegisterFlags registers the command line flags for
// specifying the values of a mycnf config file. See NewMycnfFromFlags
// to get the supported modes. | [
"RegisterFlags",
"registers",
"the",
"command",
"line",
"flags",
"for",
"specifying",
"the",
"values",
"of",
"a",
"mycnf",
"config",
"file",
".",
"See",
"NewMycnfFromFlags",
"to",
"get",
"the",
"supported",
"modes",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/mycnf_flag.go#L56-L76 | train |
vitessio/vitess | go/stats/timings.go | NewTimings | func NewTimings(name, help, label string, categories ...string) *Timings {
t := &Timings{
histograms: make(map[string]*Histogram),
help: help,
label: label,
}
for _, cat := range categories {
t.histograms[cat] = NewGenericHistogram("", "", bucketCutoffs, bucketLabels, "Count", "Time")
}
if name != "" {
publish(name, t)
}
return t
} | go | func NewTimings(name, help, label string, categories ...string) *Timings {
t := &Timings{
histograms: make(map[string]*Histogram),
help: help,
label: label,
}
for _, cat := range categories {
t.histograms[cat] = NewGenericHistogram("", "", bucketCutoffs, bucketLabels, "Count", "Time")
}
if name != "" {
publish(name, t)
}
return t
} | [
"func",
"NewTimings",
"(",
"name",
",",
"help",
",",
"label",
"string",
",",
"categories",
"...",
"string",
")",
"*",
"Timings",
"{",
"t",
":=",
"&",
"Timings",
"{",
"histograms",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Histogram",
")",
",",
"help",
":",
"help",
",",
"label",
":",
"label",
",",
"}",
"\n",
"for",
"_",
",",
"cat",
":=",
"range",
"categories",
"{",
"t",
".",
"histograms",
"[",
"cat",
"]",
"=",
"NewGenericHistogram",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"bucketCutoffs",
",",
"bucketLabels",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"name",
"!=",
"\"",
"\"",
"{",
"publish",
"(",
"name",
",",
"t",
")",
"\n",
"}",
"\n\n",
"return",
"t",
"\n",
"}"
] | // NewTimings creates a new Timings object, and publishes it if name is set.
// categories is an optional list of categories to initialize to 0.
// Categories that aren't initialized will be missing from the map until the
// first time they are updated. | [
"NewTimings",
"creates",
"a",
"new",
"Timings",
"object",
"and",
"publishes",
"it",
"if",
"name",
"is",
"set",
".",
"categories",
"is",
"an",
"optional",
"list",
"of",
"categories",
"to",
"initialize",
"to",
"0",
".",
"Categories",
"that",
"aren",
"t",
"initialized",
"will",
"be",
"missing",
"from",
"the",
"map",
"until",
"the",
"first",
"time",
"they",
"are",
"updated",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/timings.go#L48-L62 | train |
vitessio/vitess | go/stats/timings.go | safeJoinLabels | func safeJoinLabels(labels []string) string {
sanitizedLabels := make([]string, len(labels))
for idx, label := range labels {
sanitizedLabels[idx] = safeLabel(label)
}
return strings.Join(sanitizedLabels, ".")
} | go | func safeJoinLabels(labels []string) string {
sanitizedLabels := make([]string, len(labels))
for idx, label := range labels {
sanitizedLabels[idx] = safeLabel(label)
}
return strings.Join(sanitizedLabels, ".")
} | [
"func",
"safeJoinLabels",
"(",
"labels",
"[",
"]",
"string",
")",
"string",
"{",
"sanitizedLabels",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"labels",
")",
")",
"\n",
"for",
"idx",
",",
"label",
":=",
"range",
"labels",
"{",
"sanitizedLabels",
"[",
"idx",
"]",
"=",
"safeLabel",
"(",
"label",
")",
"\n",
"}",
"\n",
"return",
"strings",
".",
"Join",
"(",
"sanitizedLabels",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // safeJoinLabels joins the label values with ".", but first replaces any existing
// "." characters in the labels with the proper replacement, to avoid issues parsing
// them apart later. | [
"safeJoinLabels",
"joins",
"the",
"label",
"values",
"with",
".",
"but",
"first",
"replaces",
"any",
"existing",
".",
"characters",
"in",
"the",
"labels",
"with",
"the",
"proper",
"replacement",
"to",
"avoid",
"issues",
"parsing",
"them",
"apart",
"later",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/timings.go#L214-L220 | train |
vitessio/vitess | go/vt/vtgate/buffer/buffer.go | mode | func (b *Buffer) mode(keyspace, shard string) bufferMode {
// Actual buffering is enabled if
// a) no keyspaces and shards were listed in particular,
if *enabled && len(b.keyspaces) == 0 && len(b.shards) == 0 {
// No explicit whitelist given i.e. all shards should be buffered.
return bufferEnabled
}
// b) or this keyspace is listed,
if b.keyspaces[keyspace] {
return bufferEnabled
}
// c) or this shard is listed.
keyspaceShard := topoproto.KeyspaceShardString(keyspace, shard)
if b.shards[keyspaceShard] {
return bufferEnabled
}
if *enabledDryRun {
return bufferDryRun
}
return bufferDisabled
} | go | func (b *Buffer) mode(keyspace, shard string) bufferMode {
// Actual buffering is enabled if
// a) no keyspaces and shards were listed in particular,
if *enabled && len(b.keyspaces) == 0 && len(b.shards) == 0 {
// No explicit whitelist given i.e. all shards should be buffered.
return bufferEnabled
}
// b) or this keyspace is listed,
if b.keyspaces[keyspace] {
return bufferEnabled
}
// c) or this shard is listed.
keyspaceShard := topoproto.KeyspaceShardString(keyspace, shard)
if b.shards[keyspaceShard] {
return bufferEnabled
}
if *enabledDryRun {
return bufferDryRun
}
return bufferDisabled
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"mode",
"(",
"keyspace",
",",
"shard",
"string",
")",
"bufferMode",
"{",
"// Actual buffering is enabled if",
"// a) no keyspaces and shards were listed in particular,",
"if",
"*",
"enabled",
"&&",
"len",
"(",
"b",
".",
"keyspaces",
")",
"==",
"0",
"&&",
"len",
"(",
"b",
".",
"shards",
")",
"==",
"0",
"{",
"// No explicit whitelist given i.e. all shards should be buffered.",
"return",
"bufferEnabled",
"\n",
"}",
"\n",
"// b) or this keyspace is listed,",
"if",
"b",
".",
"keyspaces",
"[",
"keyspace",
"]",
"{",
"return",
"bufferEnabled",
"\n",
"}",
"\n",
"// c) or this shard is listed.",
"keyspaceShard",
":=",
"topoproto",
".",
"KeyspaceShardString",
"(",
"keyspace",
",",
"shard",
")",
"\n",
"if",
"b",
".",
"shards",
"[",
"keyspaceShard",
"]",
"{",
"return",
"bufferEnabled",
"\n",
"}",
"\n\n",
"if",
"*",
"enabledDryRun",
"{",
"return",
"bufferDryRun",
"\n",
"}",
"\n\n",
"return",
"bufferDisabled",
"\n",
"}"
] | // mode determines for the given keyspace and shard if buffering, dry-run
// buffering or no buffering at all should be enabled. | [
"mode",
"determines",
"for",
"the",
"given",
"keyspace",
"and",
"shard",
"if",
"buffering",
"dry",
"-",
"run",
"buffering",
"or",
"no",
"buffering",
"at",
"all",
"should",
"be",
"enabled",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/buffer/buffer.go#L158-L180 | train |
vitessio/vitess | go/vt/vtgate/buffer/buffer.go | StatsUpdate | func (b *Buffer) StatsUpdate(ts *discovery.TabletStats) {
if ts.Target.TabletType != topodatapb.TabletType_MASTER {
panic(fmt.Sprintf("BUG: non MASTER TabletStats object must not be forwarded: %#v", ts))
}
timestamp := ts.TabletExternallyReparentedTimestamp
if timestamp == 0 {
// Masters where TabletExternallyReparented was never called will return 0.
// Ignore them.
return
}
sb := b.getOrCreateBuffer(ts.Target.Keyspace, ts.Target.Shard)
if sb == nil {
// Buffer is shut down. Ignore all calls.
return
}
sb.recordExternallyReparentedTimestamp(timestamp, ts.Tablet.Alias)
} | go | func (b *Buffer) StatsUpdate(ts *discovery.TabletStats) {
if ts.Target.TabletType != topodatapb.TabletType_MASTER {
panic(fmt.Sprintf("BUG: non MASTER TabletStats object must not be forwarded: %#v", ts))
}
timestamp := ts.TabletExternallyReparentedTimestamp
if timestamp == 0 {
// Masters where TabletExternallyReparented was never called will return 0.
// Ignore them.
return
}
sb := b.getOrCreateBuffer(ts.Target.Keyspace, ts.Target.Shard)
if sb == nil {
// Buffer is shut down. Ignore all calls.
return
}
sb.recordExternallyReparentedTimestamp(timestamp, ts.Tablet.Alias)
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"StatsUpdate",
"(",
"ts",
"*",
"discovery",
".",
"TabletStats",
")",
"{",
"if",
"ts",
".",
"Target",
".",
"TabletType",
"!=",
"topodatapb",
".",
"TabletType_MASTER",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ts",
")",
")",
"\n",
"}",
"\n\n",
"timestamp",
":=",
"ts",
".",
"TabletExternallyReparentedTimestamp",
"\n",
"if",
"timestamp",
"==",
"0",
"{",
"// Masters where TabletExternallyReparented was never called will return 0.",
"// Ignore them.",
"return",
"\n",
"}",
"\n\n",
"sb",
":=",
"b",
".",
"getOrCreateBuffer",
"(",
"ts",
".",
"Target",
".",
"Keyspace",
",",
"ts",
".",
"Target",
".",
"Shard",
")",
"\n",
"if",
"sb",
"==",
"nil",
"{",
"// Buffer is shut down. Ignore all calls.",
"return",
"\n",
"}",
"\n",
"sb",
".",
"recordExternallyReparentedTimestamp",
"(",
"timestamp",
",",
"ts",
".",
"Tablet",
".",
"Alias",
")",
"\n",
"}"
] | // StatsUpdate keeps track of the "tablet_externally_reparented_timestamp" of
// each master. This way we can detect the end of a failover.
// It is part of the discovery.HealthCheckStatsListener interface. | [
"StatsUpdate",
"keeps",
"track",
"of",
"the",
"tablet_externally_reparented_timestamp",
"of",
"each",
"master",
".",
"This",
"way",
"we",
"can",
"detect",
"the",
"end",
"of",
"a",
"failover",
".",
"It",
"is",
"part",
"of",
"the",
"discovery",
".",
"HealthCheckStatsListener",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/buffer/buffer.go#L219-L237 | train |
vitessio/vitess | go/vt/vtgate/buffer/buffer.go | getOrCreateBuffer | func (b *Buffer) getOrCreateBuffer(keyspace, shard string) *shardBuffer {
key := topoproto.KeyspaceShardString(keyspace, shard)
b.mu.RLock()
sb, ok := b.buffers[key]
stopped := b.stopped
b.mu.RUnlock()
if stopped {
return nil
}
if ok {
return sb
}
b.mu.Lock()
defer b.mu.Unlock()
// Look it up again because it could have been created in the meantime.
sb, ok = b.buffers[key]
if !ok {
sb = newShardBuffer(b.mode(keyspace, shard), keyspace, shard, b.now, b.bufferSizeSema)
b.buffers[key] = sb
}
return sb
} | go | func (b *Buffer) getOrCreateBuffer(keyspace, shard string) *shardBuffer {
key := topoproto.KeyspaceShardString(keyspace, shard)
b.mu.RLock()
sb, ok := b.buffers[key]
stopped := b.stopped
b.mu.RUnlock()
if stopped {
return nil
}
if ok {
return sb
}
b.mu.Lock()
defer b.mu.Unlock()
// Look it up again because it could have been created in the meantime.
sb, ok = b.buffers[key]
if !ok {
sb = newShardBuffer(b.mode(keyspace, shard), keyspace, shard, b.now, b.bufferSizeSema)
b.buffers[key] = sb
}
return sb
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"getOrCreateBuffer",
"(",
"keyspace",
",",
"shard",
"string",
")",
"*",
"shardBuffer",
"{",
"key",
":=",
"topoproto",
".",
"KeyspaceShardString",
"(",
"keyspace",
",",
"shard",
")",
"\n",
"b",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"sb",
",",
"ok",
":=",
"b",
".",
"buffers",
"[",
"key",
"]",
"\n",
"stopped",
":=",
"b",
".",
"stopped",
"\n",
"b",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"stopped",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"ok",
"{",
"return",
"sb",
"\n",
"}",
"\n\n",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"// Look it up again because it could have been created in the meantime.",
"sb",
",",
"ok",
"=",
"b",
".",
"buffers",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"sb",
"=",
"newShardBuffer",
"(",
"b",
".",
"mode",
"(",
"keyspace",
",",
"shard",
")",
",",
"keyspace",
",",
"shard",
",",
"b",
".",
"now",
",",
"b",
".",
"bufferSizeSema",
")",
"\n",
"b",
".",
"buffers",
"[",
"key",
"]",
"=",
"sb",
"\n",
"}",
"\n",
"return",
"sb",
"\n",
"}"
] | // getOrCreateBuffer returns the ShardBuffer for the given keyspace and shard.
// It returns nil if Buffer is shut down and all calls should be ignored. | [
"getOrCreateBuffer",
"returns",
"the",
"ShardBuffer",
"for",
"the",
"given",
"keyspace",
"and",
"shard",
".",
"It",
"returns",
"nil",
"if",
"Buffer",
"is",
"shut",
"down",
"and",
"all",
"calls",
"should",
"be",
"ignored",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/buffer/buffer.go#L272-L295 | train |
vitessio/vitess | go/vt/topo/shard.go | addCells | func addCells(left, right []string) []string {
if len(left) == 0 || len(right) == 0 {
return nil
}
for _, cell := range right {
if !InCellList(cell, left) {
left = append(left, cell)
}
}
return left
} | go | func addCells(left, right []string) []string {
if len(left) == 0 || len(right) == 0 {
return nil
}
for _, cell := range right {
if !InCellList(cell, left) {
left = append(left, cell)
}
}
return left
} | [
"func",
"addCells",
"(",
"left",
",",
"right",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"left",
")",
"==",
"0",
"||",
"len",
"(",
"right",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"cell",
":=",
"range",
"right",
"{",
"if",
"!",
"InCellList",
"(",
"cell",
",",
"left",
")",
"{",
"left",
"=",
"append",
"(",
"left",
",",
"cell",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"left",
"\n",
"}"
] | // Functions for dealing with shard representations in topology.
// addCells will merge both cells list, settling on nil if either list is empty | [
"Functions",
"for",
"dealing",
"with",
"shard",
"representations",
"in",
"topology",
".",
"addCells",
"will",
"merge",
"both",
"cells",
"list",
"settling",
"on",
"nil",
"if",
"either",
"list",
"is",
"empty"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L48-L59 | train |
vitessio/vitess | go/vt/topo/shard.go | removeCellsFromList | func removeCellsFromList(toRemove, fullList []string) []string {
leftoverCells := make([]string, 0)
for _, cell := range fullList {
if !InCellList(cell, toRemove) {
leftoverCells = append(leftoverCells, cell)
}
}
return leftoverCells
} | go | func removeCellsFromList(toRemove, fullList []string) []string {
leftoverCells := make([]string, 0)
for _, cell := range fullList {
if !InCellList(cell, toRemove) {
leftoverCells = append(leftoverCells, cell)
}
}
return leftoverCells
} | [
"func",
"removeCellsFromList",
"(",
"toRemove",
",",
"fullList",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"leftoverCells",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"cell",
":=",
"range",
"fullList",
"{",
"if",
"!",
"InCellList",
"(",
"cell",
",",
"toRemove",
")",
"{",
"leftoverCells",
"=",
"append",
"(",
"leftoverCells",
",",
"cell",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"leftoverCells",
"\n",
"}"
] | // removeCellsFromList will remove the cells from the provided list. It returns
// the new list, and a boolean that indicates the returned list is empty. | [
"removeCellsFromList",
"will",
"remove",
"the",
"cells",
"from",
"the",
"provided",
"list",
".",
"It",
"returns",
"the",
"new",
"list",
"and",
"a",
"boolean",
"that",
"indicates",
"the",
"returned",
"list",
"is",
"empty",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L63-L71 | train |
vitessio/vitess | go/vt/topo/shard.go | removeCells | func removeCells(cells, toRemove, fullList []string) ([]string, bool) {
// The assumption here is we already migrated something,
// and we're reverting that part. So we're gonna remove
// records only.
leftoverCells := make([]string, 0, len(cells))
if len(cells) == 0 {
// we migrated all the cells already, take the full list
// and remove all the ones we're not reverting
for _, cell := range fullList {
if !InCellList(cell, toRemove) {
leftoverCells = append(leftoverCells, cell)
}
}
} else {
// we migrated a subset of the cells,
// remove the ones we're reverting
for _, cell := range cells {
if !InCellList(cell, toRemove) {
leftoverCells = append(leftoverCells, cell)
}
}
}
if len(leftoverCells) == 0 {
// we don't have any cell left, we need to clear this record
return nil, true
}
return leftoverCells, false
} | go | func removeCells(cells, toRemove, fullList []string) ([]string, bool) {
// The assumption here is we already migrated something,
// and we're reverting that part. So we're gonna remove
// records only.
leftoverCells := make([]string, 0, len(cells))
if len(cells) == 0 {
// we migrated all the cells already, take the full list
// and remove all the ones we're not reverting
for _, cell := range fullList {
if !InCellList(cell, toRemove) {
leftoverCells = append(leftoverCells, cell)
}
}
} else {
// we migrated a subset of the cells,
// remove the ones we're reverting
for _, cell := range cells {
if !InCellList(cell, toRemove) {
leftoverCells = append(leftoverCells, cell)
}
}
}
if len(leftoverCells) == 0 {
// we don't have any cell left, we need to clear this record
return nil, true
}
return leftoverCells, false
} | [
"func",
"removeCells",
"(",
"cells",
",",
"toRemove",
",",
"fullList",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"bool",
")",
"{",
"// The assumption here is we already migrated something,",
"// and we're reverting that part. So we're gonna remove",
"// records only.",
"leftoverCells",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"cells",
")",
")",
"\n",
"if",
"len",
"(",
"cells",
")",
"==",
"0",
"{",
"// we migrated all the cells already, take the full list",
"// and remove all the ones we're not reverting",
"for",
"_",
",",
"cell",
":=",
"range",
"fullList",
"{",
"if",
"!",
"InCellList",
"(",
"cell",
",",
"toRemove",
")",
"{",
"leftoverCells",
"=",
"append",
"(",
"leftoverCells",
",",
"cell",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// we migrated a subset of the cells,",
"// remove the ones we're reverting",
"for",
"_",
",",
"cell",
":=",
"range",
"cells",
"{",
"if",
"!",
"InCellList",
"(",
"cell",
",",
"toRemove",
")",
"{",
"leftoverCells",
"=",
"append",
"(",
"leftoverCells",
",",
"cell",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"leftoverCells",
")",
"==",
"0",
"{",
"// we don't have any cell left, we need to clear this record",
"return",
"nil",
",",
"true",
"\n",
"}",
"\n\n",
"return",
"leftoverCells",
",",
"false",
"\n",
"}"
] | // removeCells will remove the cells from the provided list. It returns
// the new list, and a boolean that indicates the returned list is empty. | [
"removeCells",
"will",
"remove",
"the",
"cells",
"from",
"the",
"provided",
"list",
".",
"It",
"returns",
"the",
"new",
"list",
"and",
"a",
"boolean",
"that",
"indicates",
"the",
"returned",
"list",
"is",
"empty",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L75-L104 | train |
vitessio/vitess | go/vt/topo/shard.go | ValidateShardName | func ValidateShardName(shard string) (string, *topodatapb.KeyRange, error) {
if !IsShardUsingRangeBasedSharding(shard) {
return shard, nil, nil
}
parts := strings.Split(shard, "-")
if len(parts) != 2 {
return "", nil, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "invalid shardId, can only contain one '-': %v", shard)
}
keyRange, err := key.ParseKeyRangeParts(parts[0], parts[1])
if err != nil {
return "", nil, err
}
if len(keyRange.End) > 0 && string(keyRange.Start) >= string(keyRange.End) {
return "", nil, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "out of order keys: %v is not strictly smaller than %v", hex.EncodeToString(keyRange.Start), hex.EncodeToString(keyRange.End))
}
return strings.ToLower(shard), keyRange, nil
} | go | func ValidateShardName(shard string) (string, *topodatapb.KeyRange, error) {
if !IsShardUsingRangeBasedSharding(shard) {
return shard, nil, nil
}
parts := strings.Split(shard, "-")
if len(parts) != 2 {
return "", nil, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "invalid shardId, can only contain one '-': %v", shard)
}
keyRange, err := key.ParseKeyRangeParts(parts[0], parts[1])
if err != nil {
return "", nil, err
}
if len(keyRange.End) > 0 && string(keyRange.Start) >= string(keyRange.End) {
return "", nil, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "out of order keys: %v is not strictly smaller than %v", hex.EncodeToString(keyRange.Start), hex.EncodeToString(keyRange.End))
}
return strings.ToLower(shard), keyRange, nil
} | [
"func",
"ValidateShardName",
"(",
"shard",
"string",
")",
"(",
"string",
",",
"*",
"topodatapb",
".",
"KeyRange",
",",
"error",
")",
"{",
"if",
"!",
"IsShardUsingRangeBasedSharding",
"(",
"shard",
")",
"{",
"return",
"shard",
",",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"shard",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"return",
"\"",
"\"",
",",
"nil",
",",
"vterrors",
".",
"Errorf",
"(",
"vtrpc",
".",
"Code_INVALID_ARGUMENT",
",",
"\"",
"\"",
",",
"shard",
")",
"\n",
"}",
"\n\n",
"keyRange",
",",
"err",
":=",
"key",
".",
"ParseKeyRangeParts",
"(",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
"1",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"keyRange",
".",
"End",
")",
">",
"0",
"&&",
"string",
"(",
"keyRange",
".",
"Start",
")",
">=",
"string",
"(",
"keyRange",
".",
"End",
")",
"{",
"return",
"\"",
"\"",
",",
"nil",
",",
"vterrors",
".",
"Errorf",
"(",
"vtrpc",
".",
"Code_INVALID_ARGUMENT",
",",
"\"",
"\"",
",",
"hex",
".",
"EncodeToString",
"(",
"keyRange",
".",
"Start",
")",
",",
"hex",
".",
"EncodeToString",
"(",
"keyRange",
".",
"End",
")",
")",
"\n",
"}",
"\n\n",
"return",
"strings",
".",
"ToLower",
"(",
"shard",
")",
",",
"keyRange",
",",
"nil",
"\n",
"}"
] | // ValidateShardName takes a shard name and sanitizes it, and also returns
// the KeyRange. | [
"ValidateShardName",
"takes",
"a",
"shard",
"name",
"and",
"sanitizes",
"it",
"and",
"also",
"returns",
"the",
"KeyRange",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L114-L134 | train |
vitessio/vitess | go/vt/topo/shard.go | GetShard | func (ts *Server) GetShard(ctx context.Context, keyspace, shard string) (*ShardInfo, error) {
span, ctx := trace.NewSpan(ctx, "TopoServer.GetShard")
span.Annotate("keyspace", keyspace)
span.Annotate("shard", shard)
defer span.Finish()
shardPath := path.Join(KeyspacesPath, keyspace, ShardsPath, shard, ShardFile)
data, version, err := ts.globalCell.Get(ctx, shardPath)
if err != nil {
return nil, err
}
value := &topodatapb.Shard{}
if err = proto.Unmarshal(data, value); err != nil {
return nil, vterrors.Wrapf(err, "GetShard(%v,%v): bad shard data", keyspace, shard)
}
return &ShardInfo{
keyspace: keyspace,
shardName: shard,
version: version,
Shard: value,
}, nil
} | go | func (ts *Server) GetShard(ctx context.Context, keyspace, shard string) (*ShardInfo, error) {
span, ctx := trace.NewSpan(ctx, "TopoServer.GetShard")
span.Annotate("keyspace", keyspace)
span.Annotate("shard", shard)
defer span.Finish()
shardPath := path.Join(KeyspacesPath, keyspace, ShardsPath, shard, ShardFile)
data, version, err := ts.globalCell.Get(ctx, shardPath)
if err != nil {
return nil, err
}
value := &topodatapb.Shard{}
if err = proto.Unmarshal(data, value); err != nil {
return nil, vterrors.Wrapf(err, "GetShard(%v,%v): bad shard data", keyspace, shard)
}
return &ShardInfo{
keyspace: keyspace,
shardName: shard,
version: version,
Shard: value,
}, nil
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
")",
"(",
"*",
"ShardInfo",
",",
"error",
")",
"{",
"span",
",",
"ctx",
":=",
"trace",
".",
"NewSpan",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"span",
".",
"Annotate",
"(",
"\"",
"\"",
",",
"keyspace",
")",
"\n",
"span",
".",
"Annotate",
"(",
"\"",
"\"",
",",
"shard",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"shardPath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
",",
"keyspace",
",",
"ShardsPath",
",",
"shard",
",",
"ShardFile",
")",
"\n",
"data",
",",
"version",
",",
"err",
":=",
"ts",
".",
"globalCell",
".",
"Get",
"(",
"ctx",
",",
"shardPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"value",
":=",
"&",
"topodatapb",
".",
"Shard",
"{",
"}",
"\n",
"if",
"err",
"=",
"proto",
".",
"Unmarshal",
"(",
"data",
",",
"value",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"vterrors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"keyspace",
",",
"shard",
")",
"\n",
"}",
"\n",
"return",
"&",
"ShardInfo",
"{",
"keyspace",
":",
"keyspace",
",",
"shardName",
":",
"shard",
",",
"version",
":",
"version",
",",
"Shard",
":",
"value",
",",
"}",
",",
"nil",
"\n",
"}"
] | // GetShard is a high level function to read shard data.
// It generates trace spans. | [
"GetShard",
"is",
"a",
"high",
"level",
"function",
"to",
"read",
"shard",
"data",
".",
"It",
"generates",
"trace",
"spans",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L179-L201 | train |
vitessio/vitess | go/vt/topo/shard.go | updateShard | func (ts *Server) updateShard(ctx context.Context, si *ShardInfo) error {
span, ctx := trace.NewSpan(ctx, "TopoServer.UpdateShard")
span.Annotate("keyspace", si.keyspace)
span.Annotate("shard", si.shardName)
defer span.Finish()
data, err := proto.Marshal(si.Shard)
if err != nil {
return err
}
shardPath := path.Join(KeyspacesPath, si.keyspace, ShardsPath, si.shardName, ShardFile)
newVersion, err := ts.globalCell.Update(ctx, shardPath, data, si.version)
if err != nil {
return err
}
si.version = newVersion
event.Dispatch(&events.ShardChange{
KeyspaceName: si.Keyspace(),
ShardName: si.ShardName(),
Shard: si.Shard,
Status: "updated",
})
return nil
} | go | func (ts *Server) updateShard(ctx context.Context, si *ShardInfo) error {
span, ctx := trace.NewSpan(ctx, "TopoServer.UpdateShard")
span.Annotate("keyspace", si.keyspace)
span.Annotate("shard", si.shardName)
defer span.Finish()
data, err := proto.Marshal(si.Shard)
if err != nil {
return err
}
shardPath := path.Join(KeyspacesPath, si.keyspace, ShardsPath, si.shardName, ShardFile)
newVersion, err := ts.globalCell.Update(ctx, shardPath, data, si.version)
if err != nil {
return err
}
si.version = newVersion
event.Dispatch(&events.ShardChange{
KeyspaceName: si.Keyspace(),
ShardName: si.ShardName(),
Shard: si.Shard,
Status: "updated",
})
return nil
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"updateShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"si",
"*",
"ShardInfo",
")",
"error",
"{",
"span",
",",
"ctx",
":=",
"trace",
".",
"NewSpan",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"span",
".",
"Annotate",
"(",
"\"",
"\"",
",",
"si",
".",
"keyspace",
")",
"\n",
"span",
".",
"Annotate",
"(",
"\"",
"\"",
",",
"si",
".",
"shardName",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"data",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"si",
".",
"Shard",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"shardPath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
",",
"si",
".",
"keyspace",
",",
"ShardsPath",
",",
"si",
".",
"shardName",
",",
"ShardFile",
")",
"\n",
"newVersion",
",",
"err",
":=",
"ts",
".",
"globalCell",
".",
"Update",
"(",
"ctx",
",",
"shardPath",
",",
"data",
",",
"si",
".",
"version",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"si",
".",
"version",
"=",
"newVersion",
"\n\n",
"event",
".",
"Dispatch",
"(",
"&",
"events",
".",
"ShardChange",
"{",
"KeyspaceName",
":",
"si",
".",
"Keyspace",
"(",
")",
",",
"ShardName",
":",
"si",
".",
"ShardName",
"(",
")",
",",
"Shard",
":",
"si",
".",
"Shard",
",",
"Status",
":",
"\"",
"\"",
",",
"}",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // updateShard updates the shard data, with the right version.
// It also creates a span, and dispatches the event. | [
"updateShard",
"updates",
"the",
"shard",
"data",
"with",
"the",
"right",
"version",
".",
"It",
"also",
"creates",
"a",
"span",
"and",
"dispatches",
"the",
"event",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L205-L229 | train |
vitessio/vitess | go/vt/topo/shard.go | UpdateShardFields | func (ts *Server) UpdateShardFields(ctx context.Context, keyspace, shard string, update func(*ShardInfo) error) (*ShardInfo, error) {
for {
si, err := ts.GetShard(ctx, keyspace, shard)
if err != nil {
return nil, err
}
if err = update(si); err != nil {
if IsErrType(err, NoUpdateNeeded) {
return nil, nil
}
return nil, err
}
if err = ts.updateShard(ctx, si); !IsErrType(err, BadVersion) {
return si, err
}
}
} | go | func (ts *Server) UpdateShardFields(ctx context.Context, keyspace, shard string, update func(*ShardInfo) error) (*ShardInfo, error) {
for {
si, err := ts.GetShard(ctx, keyspace, shard)
if err != nil {
return nil, err
}
if err = update(si); err != nil {
if IsErrType(err, NoUpdateNeeded) {
return nil, nil
}
return nil, err
}
if err = ts.updateShard(ctx, si); !IsErrType(err, BadVersion) {
return si, err
}
}
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"UpdateShardFields",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
",",
"update",
"func",
"(",
"*",
"ShardInfo",
")",
"error",
")",
"(",
"*",
"ShardInfo",
",",
"error",
")",
"{",
"for",
"{",
"si",
",",
"err",
":=",
"ts",
".",
"GetShard",
"(",
"ctx",
",",
"keyspace",
",",
"shard",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"err",
"=",
"update",
"(",
"si",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"IsErrType",
"(",
"err",
",",
"NoUpdateNeeded",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"err",
"=",
"ts",
".",
"updateShard",
"(",
"ctx",
",",
"si",
")",
";",
"!",
"IsErrType",
"(",
"err",
",",
"BadVersion",
")",
"{",
"return",
"si",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // UpdateShardFields is a high level helper to read a shard record, call an
// update function on it, and then write it back. If the write fails due to
// a version mismatch, it will re-read the record and retry the update.
// If the update succeeds, it returns the updated ShardInfo.
// If the update method returns ErrNoUpdateNeeded, nothing is written,
// and nil,nil is returned.
//
// Note the callback method takes a ShardInfo, so it can get the
// keyspace and shard from it, or use all the ShardInfo methods. | [
"UpdateShardFields",
"is",
"a",
"high",
"level",
"helper",
"to",
"read",
"a",
"shard",
"record",
"call",
"an",
"update",
"function",
"on",
"it",
"and",
"then",
"write",
"it",
"back",
".",
"If",
"the",
"write",
"fails",
"due",
"to",
"a",
"version",
"mismatch",
"it",
"will",
"re",
"-",
"read",
"the",
"record",
"and",
"retry",
"the",
"update",
".",
"If",
"the",
"update",
"succeeds",
"it",
"returns",
"the",
"updated",
"ShardInfo",
".",
"If",
"the",
"update",
"method",
"returns",
"ErrNoUpdateNeeded",
"nothing",
"is",
"written",
"and",
"nil",
"nil",
"is",
"returned",
".",
"Note",
"the",
"callback",
"method",
"takes",
"a",
"ShardInfo",
"so",
"it",
"can",
"get",
"the",
"keyspace",
"and",
"shard",
"from",
"it",
"or",
"use",
"all",
"the",
"ShardInfo",
"methods",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L240-L256 | train |
vitessio/vitess | go/vt/topo/shard.go | CreateShard | func (ts *Server) CreateShard(ctx context.Context, keyspace, shard string) (err error) {
// Lock the keyspace, because we'll be looking at ServedTypes.
ctx, unlock, lockErr := ts.LockKeyspace(ctx, keyspace, "CreateShard")
if lockErr != nil {
return lockErr
}
defer unlock(&err)
// validate parameters
name, keyRange, err := ValidateShardName(shard)
if err != nil {
return err
}
value := &topodatapb.Shard{
KeyRange: keyRange,
}
isMasterServing := true
// start the shard IsMasterServing. If it overlaps with
// other shards for some serving types, remove them.
if IsShardUsingRangeBasedSharding(name) {
// if we are using range-based sharding, we don't want
// overlapping shards to all serve and confuse the clients.
sis, err := ts.FindAllShardsInKeyspace(ctx, keyspace)
if err != nil && !IsErrType(err, NoNode) {
return err
}
for _, si := range sis {
if si.KeyRange == nil || key.KeyRangesIntersect(si.KeyRange, keyRange) {
isMasterServing = false
}
}
}
value.IsMasterServing = isMasterServing
// Marshal and save.
data, err := proto.Marshal(value)
if err != nil {
return err
}
shardPath := path.Join(KeyspacesPath, keyspace, ShardsPath, shard, ShardFile)
if _, err := ts.globalCell.Create(ctx, shardPath, data); err != nil {
// Return error as is, we need to propagate
// ErrNodeExists for instance.
return err
}
event.Dispatch(&events.ShardChange{
KeyspaceName: keyspace,
ShardName: shard,
Shard: value,
Status: "created",
})
return nil
} | go | func (ts *Server) CreateShard(ctx context.Context, keyspace, shard string) (err error) {
// Lock the keyspace, because we'll be looking at ServedTypes.
ctx, unlock, lockErr := ts.LockKeyspace(ctx, keyspace, "CreateShard")
if lockErr != nil {
return lockErr
}
defer unlock(&err)
// validate parameters
name, keyRange, err := ValidateShardName(shard)
if err != nil {
return err
}
value := &topodatapb.Shard{
KeyRange: keyRange,
}
isMasterServing := true
// start the shard IsMasterServing. If it overlaps with
// other shards for some serving types, remove them.
if IsShardUsingRangeBasedSharding(name) {
// if we are using range-based sharding, we don't want
// overlapping shards to all serve and confuse the clients.
sis, err := ts.FindAllShardsInKeyspace(ctx, keyspace)
if err != nil && !IsErrType(err, NoNode) {
return err
}
for _, si := range sis {
if si.KeyRange == nil || key.KeyRangesIntersect(si.KeyRange, keyRange) {
isMasterServing = false
}
}
}
value.IsMasterServing = isMasterServing
// Marshal and save.
data, err := proto.Marshal(value)
if err != nil {
return err
}
shardPath := path.Join(KeyspacesPath, keyspace, ShardsPath, shard, ShardFile)
if _, err := ts.globalCell.Create(ctx, shardPath, data); err != nil {
// Return error as is, we need to propagate
// ErrNodeExists for instance.
return err
}
event.Dispatch(&events.ShardChange{
KeyspaceName: keyspace,
ShardName: shard,
Shard: value,
Status: "created",
})
return nil
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"CreateShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Lock the keyspace, because we'll be looking at ServedTypes.",
"ctx",
",",
"unlock",
",",
"lockErr",
":=",
"ts",
".",
"LockKeyspace",
"(",
"ctx",
",",
"keyspace",
",",
"\"",
"\"",
")",
"\n",
"if",
"lockErr",
"!=",
"nil",
"{",
"return",
"lockErr",
"\n",
"}",
"\n",
"defer",
"unlock",
"(",
"&",
"err",
")",
"\n\n",
"// validate parameters",
"name",
",",
"keyRange",
",",
"err",
":=",
"ValidateShardName",
"(",
"shard",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"value",
":=",
"&",
"topodatapb",
".",
"Shard",
"{",
"KeyRange",
":",
"keyRange",
",",
"}",
"\n\n",
"isMasterServing",
":=",
"true",
"\n\n",
"// start the shard IsMasterServing. If it overlaps with",
"// other shards for some serving types, remove them.",
"if",
"IsShardUsingRangeBasedSharding",
"(",
"name",
")",
"{",
"// if we are using range-based sharding, we don't want",
"// overlapping shards to all serve and confuse the clients.",
"sis",
",",
"err",
":=",
"ts",
".",
"FindAllShardsInKeyspace",
"(",
"ctx",
",",
"keyspace",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"IsErrType",
"(",
"err",
",",
"NoNode",
")",
"{",
"return",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"si",
":=",
"range",
"sis",
"{",
"if",
"si",
".",
"KeyRange",
"==",
"nil",
"||",
"key",
".",
"KeyRangesIntersect",
"(",
"si",
".",
"KeyRange",
",",
"keyRange",
")",
"{",
"isMasterServing",
"=",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"value",
".",
"IsMasterServing",
"=",
"isMasterServing",
"\n\n",
"// Marshal and save.",
"data",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"shardPath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
",",
"keyspace",
",",
"ShardsPath",
",",
"shard",
",",
"ShardFile",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"ts",
".",
"globalCell",
".",
"Create",
"(",
"ctx",
",",
"shardPath",
",",
"data",
")",
";",
"err",
"!=",
"nil",
"{",
"// Return error as is, we need to propagate",
"// ErrNodeExists for instance.",
"return",
"err",
"\n",
"}",
"\n\n",
"event",
".",
"Dispatch",
"(",
"&",
"events",
".",
"ShardChange",
"{",
"KeyspaceName",
":",
"keyspace",
",",
"ShardName",
":",
"shard",
",",
"Shard",
":",
"value",
",",
"Status",
":",
"\"",
"\"",
",",
"}",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // CreateShard creates a new shard and tries to fill in the right information.
// This will lock the Keyspace, as we may be looking at other shard servedTypes.
// Using GetOrCreateShard is probably a better idea for most use cases. | [
"CreateShard",
"creates",
"a",
"new",
"shard",
"and",
"tries",
"to",
"fill",
"in",
"the",
"right",
"information",
".",
"This",
"will",
"lock",
"the",
"Keyspace",
"as",
"we",
"may",
"be",
"looking",
"at",
"other",
"shard",
"servedTypes",
".",
"Using",
"GetOrCreateShard",
"is",
"probably",
"a",
"better",
"idea",
"for",
"most",
"use",
"cases",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L261-L319 | train |
vitessio/vitess | go/vt/topo/shard.go | GetOrCreateShard | func (ts *Server) GetOrCreateShard(ctx context.Context, keyspace, shard string) (si *ShardInfo, err error) {
si, err = ts.GetShard(ctx, keyspace, shard)
if !IsErrType(err, NoNode) {
return
}
// create the keyspace, maybe it already exists
if err = ts.CreateKeyspace(ctx, keyspace, &topodatapb.Keyspace{}); err != nil && !IsErrType(err, NodeExists) {
return nil, vterrors.Wrapf(err, "CreateKeyspace(%v) failed", keyspace)
}
// now try to create with the lock, may already exist
if err = ts.CreateShard(ctx, keyspace, shard); err != nil && !IsErrType(err, NodeExists) {
return nil, vterrors.Wrapf(err, "CreateShard(%v/%v) failed", keyspace, shard)
}
// try to read the shard again, maybe someone created it
// in between the original GetShard and the LockKeyspace
return ts.GetShard(ctx, keyspace, shard)
} | go | func (ts *Server) GetOrCreateShard(ctx context.Context, keyspace, shard string) (si *ShardInfo, err error) {
si, err = ts.GetShard(ctx, keyspace, shard)
if !IsErrType(err, NoNode) {
return
}
// create the keyspace, maybe it already exists
if err = ts.CreateKeyspace(ctx, keyspace, &topodatapb.Keyspace{}); err != nil && !IsErrType(err, NodeExists) {
return nil, vterrors.Wrapf(err, "CreateKeyspace(%v) failed", keyspace)
}
// now try to create with the lock, may already exist
if err = ts.CreateShard(ctx, keyspace, shard); err != nil && !IsErrType(err, NodeExists) {
return nil, vterrors.Wrapf(err, "CreateShard(%v/%v) failed", keyspace, shard)
}
// try to read the shard again, maybe someone created it
// in between the original GetShard and the LockKeyspace
return ts.GetShard(ctx, keyspace, shard)
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetOrCreateShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
")",
"(",
"si",
"*",
"ShardInfo",
",",
"err",
"error",
")",
"{",
"si",
",",
"err",
"=",
"ts",
".",
"GetShard",
"(",
"ctx",
",",
"keyspace",
",",
"shard",
")",
"\n",
"if",
"!",
"IsErrType",
"(",
"err",
",",
"NoNode",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"// create the keyspace, maybe it already exists",
"if",
"err",
"=",
"ts",
".",
"CreateKeyspace",
"(",
"ctx",
",",
"keyspace",
",",
"&",
"topodatapb",
".",
"Keyspace",
"{",
"}",
")",
";",
"err",
"!=",
"nil",
"&&",
"!",
"IsErrType",
"(",
"err",
",",
"NodeExists",
")",
"{",
"return",
"nil",
",",
"vterrors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"keyspace",
")",
"\n",
"}",
"\n\n",
"// now try to create with the lock, may already exist",
"if",
"err",
"=",
"ts",
".",
"CreateShard",
"(",
"ctx",
",",
"keyspace",
",",
"shard",
")",
";",
"err",
"!=",
"nil",
"&&",
"!",
"IsErrType",
"(",
"err",
",",
"NodeExists",
")",
"{",
"return",
"nil",
",",
"vterrors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"keyspace",
",",
"shard",
")",
"\n",
"}",
"\n\n",
"// try to read the shard again, maybe someone created it",
"// in between the original GetShard and the LockKeyspace",
"return",
"ts",
".",
"GetShard",
"(",
"ctx",
",",
"keyspace",
",",
"shard",
")",
"\n",
"}"
] | // GetOrCreateShard will return the shard object, or create one if it doesn't
// already exist. Note the shard creation is protected by a keyspace Lock. | [
"GetOrCreateShard",
"will",
"return",
"the",
"shard",
"object",
"or",
"create",
"one",
"if",
"it",
"doesn",
"t",
"already",
"exist",
".",
"Note",
"the",
"shard",
"creation",
"is",
"protected",
"by",
"a",
"keyspace",
"Lock",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L323-L342 | train |
vitessio/vitess | go/vt/topo/shard.go | DeleteShard | func (ts *Server) DeleteShard(ctx context.Context, keyspace, shard string) error {
shardPath := path.Join(KeyspacesPath, keyspace, ShardsPath, shard, ShardFile)
if err := ts.globalCell.Delete(ctx, shardPath, nil); err != nil {
return err
}
event.Dispatch(&events.ShardChange{
KeyspaceName: keyspace,
ShardName: shard,
Shard: nil,
Status: "deleted",
})
return nil
} | go | func (ts *Server) DeleteShard(ctx context.Context, keyspace, shard string) error {
shardPath := path.Join(KeyspacesPath, keyspace, ShardsPath, shard, ShardFile)
if err := ts.globalCell.Delete(ctx, shardPath, nil); err != nil {
return err
}
event.Dispatch(&events.ShardChange{
KeyspaceName: keyspace,
ShardName: shard,
Shard: nil,
Status: "deleted",
})
return nil
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"DeleteShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
")",
"error",
"{",
"shardPath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
",",
"keyspace",
",",
"ShardsPath",
",",
"shard",
",",
"ShardFile",
")",
"\n",
"if",
"err",
":=",
"ts",
".",
"globalCell",
".",
"Delete",
"(",
"ctx",
",",
"shardPath",
",",
"nil",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"event",
".",
"Dispatch",
"(",
"&",
"events",
".",
"ShardChange",
"{",
"KeyspaceName",
":",
"keyspace",
",",
"ShardName",
":",
"shard",
",",
"Shard",
":",
"nil",
",",
"Status",
":",
"\"",
"\"",
",",
"}",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // DeleteShard wraps the underlying conn.Delete
// and dispatches the event. | [
"DeleteShard",
"wraps",
"the",
"underlying",
"conn",
".",
"Delete",
"and",
"dispatches",
"the",
"event",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L346-L358 | train |
vitessio/vitess | go/vt/topo/shard.go | GetTabletControl | func (si *ShardInfo) GetTabletControl(tabletType topodatapb.TabletType) *topodatapb.Shard_TabletControl {
for _, tc := range si.TabletControls {
if tc.TabletType == tabletType {
return tc
}
}
return nil
} | go | func (si *ShardInfo) GetTabletControl(tabletType topodatapb.TabletType) *topodatapb.Shard_TabletControl {
for _, tc := range si.TabletControls {
if tc.TabletType == tabletType {
return tc
}
}
return nil
} | [
"func",
"(",
"si",
"*",
"ShardInfo",
")",
"GetTabletControl",
"(",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"*",
"topodatapb",
".",
"Shard_TabletControl",
"{",
"for",
"_",
",",
"tc",
":=",
"range",
"si",
".",
"TabletControls",
"{",
"if",
"tc",
".",
"TabletType",
"==",
"tabletType",
"{",
"return",
"tc",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetTabletControl returns the Shard_TabletControl for the given tablet type,
// or nil if it is not in the map. | [
"GetTabletControl",
"returns",
"the",
"Shard_TabletControl",
"for",
"the",
"given",
"tablet",
"type",
"or",
"nil",
"if",
"it",
"is",
"not",
"in",
"the",
"map",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L362-L369 | train |
vitessio/vitess | go/vt/topo/shard.go | GetServedType | func (si *ShardInfo) GetServedType(tabletType topodatapb.TabletType) *topodatapb.Shard_ServedType {
for _, st := range si.ServedTypes {
if st.TabletType == tabletType {
return st
}
}
return nil
} | go | func (si *ShardInfo) GetServedType(tabletType topodatapb.TabletType) *topodatapb.Shard_ServedType {
for _, st := range si.ServedTypes {
if st.TabletType == tabletType {
return st
}
}
return nil
} | [
"func",
"(",
"si",
"*",
"ShardInfo",
")",
"GetServedType",
"(",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"*",
"topodatapb",
".",
"Shard_ServedType",
"{",
"for",
"_",
",",
"st",
":=",
"range",
"si",
".",
"ServedTypes",
"{",
"if",
"st",
".",
"TabletType",
"==",
"tabletType",
"{",
"return",
"st",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetServedType returns the Shard_ServedType for a TabletType, or nil | [
"GetServedType",
"returns",
"the",
"Shard_ServedType",
"for",
"a",
"TabletType",
"or",
"nil"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L433-L440 | train |
vitessio/vitess | go/vt/topo/shard.go | InCellList | func InCellList(cell string, cells []string) bool {
if len(cells) == 0 {
return true
}
for _, c := range cells {
if c == cell {
return true
}
}
return false
} | go | func InCellList(cell string, cells []string) bool {
if len(cells) == 0 {
return true
}
for _, c := range cells {
if c == cell {
return true
}
}
return false
} | [
"func",
"InCellList",
"(",
"cell",
"string",
",",
"cells",
"[",
"]",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"cells",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"cells",
"{",
"if",
"c",
"==",
"cell",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | //
// Utility functions for shards
//
// InCellList returns true if the cell list is empty,
// or if the passed cell is in the cell list. | [
"Utility",
"functions",
"for",
"shards",
"InCellList",
"returns",
"true",
"if",
"the",
"cell",
"list",
"is",
"empty",
"or",
"if",
"the",
"passed",
"cell",
"is",
"in",
"the",
"cell",
"list",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L448-L458 | train |
vitessio/vitess | go/vt/topo/shard.go | FindAllTabletAliasesInShard | func (ts *Server) FindAllTabletAliasesInShard(ctx context.Context, keyspace, shard string) ([]*topodatapb.TabletAlias, error) {
return ts.FindAllTabletAliasesInShardByCell(ctx, keyspace, shard, nil)
} | go | func (ts *Server) FindAllTabletAliasesInShard(ctx context.Context, keyspace, shard string) ([]*topodatapb.TabletAlias, error) {
return ts.FindAllTabletAliasesInShardByCell(ctx, keyspace, shard, nil)
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"FindAllTabletAliasesInShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
")",
"(",
"[",
"]",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"error",
")",
"{",
"return",
"ts",
".",
"FindAllTabletAliasesInShardByCell",
"(",
"ctx",
",",
"keyspace",
",",
"shard",
",",
"nil",
")",
"\n",
"}"
] | // FindAllTabletAliasesInShard uses the replication graph to find all the
// tablet aliases in the given shard.
//
// It can return ErrPartialResult if some cells were not fetched,
// in which case the result only contains the cells that were fetched.
//
// The tablet aliases are sorted by cell, then by UID. | [
"FindAllTabletAliasesInShard",
"uses",
"the",
"replication",
"graph",
"to",
"find",
"all",
"the",
"tablet",
"aliases",
"in",
"the",
"given",
"shard",
".",
"It",
"can",
"return",
"ErrPartialResult",
"if",
"some",
"cells",
"were",
"not",
"fetched",
"in",
"which",
"case",
"the",
"result",
"only",
"contains",
"the",
"cells",
"that",
"were",
"fetched",
".",
"The",
"tablet",
"aliases",
"are",
"sorted",
"by",
"cell",
"then",
"by",
"UID",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L467-L469 | train |
vitessio/vitess | go/vt/topo/shard.go | FindAllTabletAliasesInShardByCell | func (ts *Server) FindAllTabletAliasesInShardByCell(ctx context.Context, keyspace, shard string, cells []string) ([]*topodatapb.TabletAlias, error) {
span, ctx := trace.NewSpan(ctx, "topo.FindAllTabletAliasesInShardbyCell")
span.Annotate("keyspace", keyspace)
span.Annotate("shard", shard)
span.Annotate("num_cells", len(cells))
defer span.Finish()
ctx = trace.NewContext(ctx, span)
var err error
// The caller intents to all cells
if len(cells) == 0 {
cells, err = ts.GetCellInfoNames(ctx)
if err != nil {
return nil, err
}
}
// read the shard information to find the cells
si, err := ts.GetShard(ctx, keyspace, shard)
if err != nil {
return nil, err
}
resultAsMap := make(map[string]*topodatapb.TabletAlias)
if si.HasMaster() {
if InCellList(si.MasterAlias.Cell, cells) {
resultAsMap[topoproto.TabletAliasString(si.MasterAlias)] = si.MasterAlias
}
}
// read the replication graph in each cell and add all found tablets
wg := sync.WaitGroup{}
mutex := sync.Mutex{}
rec := concurrency.AllErrorRecorder{}
result := make([]*topodatapb.TabletAlias, 0, len(resultAsMap))
for _, cell := range cells {
wg.Add(1)
go func(cell string) {
defer wg.Done()
sri, err := ts.GetShardReplication(ctx, cell, keyspace, shard)
switch {
case err == nil:
mutex.Lock()
for _, node := range sri.Nodes {
resultAsMap[topoproto.TabletAliasString(node.TabletAlias)] = node.TabletAlias
}
mutex.Unlock()
case IsErrType(err, NoNode):
// There is no shard replication for this shard in this cell. NOOP
default:
rec.RecordError(vterrors.Wrap(err, fmt.Sprintf("GetShardReplication(%v, %v, %v) failed.", cell, keyspace, shard)))
return
}
}(cell)
}
wg.Wait()
err = nil
if rec.HasErrors() {
log.Warningf("FindAllTabletAliasesInShard(%v,%v): got partial result: %v", keyspace, shard, rec.Error())
err = NewError(PartialResult, shard)
}
for _, a := range resultAsMap {
v := *a
result = append(result, &v)
}
sort.Sort(topoproto.TabletAliasList(result))
return result, err
} | go | func (ts *Server) FindAllTabletAliasesInShardByCell(ctx context.Context, keyspace, shard string, cells []string) ([]*topodatapb.TabletAlias, error) {
span, ctx := trace.NewSpan(ctx, "topo.FindAllTabletAliasesInShardbyCell")
span.Annotate("keyspace", keyspace)
span.Annotate("shard", shard)
span.Annotate("num_cells", len(cells))
defer span.Finish()
ctx = trace.NewContext(ctx, span)
var err error
// The caller intents to all cells
if len(cells) == 0 {
cells, err = ts.GetCellInfoNames(ctx)
if err != nil {
return nil, err
}
}
// read the shard information to find the cells
si, err := ts.GetShard(ctx, keyspace, shard)
if err != nil {
return nil, err
}
resultAsMap := make(map[string]*topodatapb.TabletAlias)
if si.HasMaster() {
if InCellList(si.MasterAlias.Cell, cells) {
resultAsMap[topoproto.TabletAliasString(si.MasterAlias)] = si.MasterAlias
}
}
// read the replication graph in each cell and add all found tablets
wg := sync.WaitGroup{}
mutex := sync.Mutex{}
rec := concurrency.AllErrorRecorder{}
result := make([]*topodatapb.TabletAlias, 0, len(resultAsMap))
for _, cell := range cells {
wg.Add(1)
go func(cell string) {
defer wg.Done()
sri, err := ts.GetShardReplication(ctx, cell, keyspace, shard)
switch {
case err == nil:
mutex.Lock()
for _, node := range sri.Nodes {
resultAsMap[topoproto.TabletAliasString(node.TabletAlias)] = node.TabletAlias
}
mutex.Unlock()
case IsErrType(err, NoNode):
// There is no shard replication for this shard in this cell. NOOP
default:
rec.RecordError(vterrors.Wrap(err, fmt.Sprintf("GetShardReplication(%v, %v, %v) failed.", cell, keyspace, shard)))
return
}
}(cell)
}
wg.Wait()
err = nil
if rec.HasErrors() {
log.Warningf("FindAllTabletAliasesInShard(%v,%v): got partial result: %v", keyspace, shard, rec.Error())
err = NewError(PartialResult, shard)
}
for _, a := range resultAsMap {
v := *a
result = append(result, &v)
}
sort.Sort(topoproto.TabletAliasList(result))
return result, err
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"FindAllTabletAliasesInShardByCell",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
",",
"cells",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"error",
")",
"{",
"span",
",",
"ctx",
":=",
"trace",
".",
"NewSpan",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"span",
".",
"Annotate",
"(",
"\"",
"\"",
",",
"keyspace",
")",
"\n",
"span",
".",
"Annotate",
"(",
"\"",
"\"",
",",
"shard",
")",
"\n",
"span",
".",
"Annotate",
"(",
"\"",
"\"",
",",
"len",
"(",
"cells",
")",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n",
"ctx",
"=",
"trace",
".",
"NewContext",
"(",
"ctx",
",",
"span",
")",
"\n",
"var",
"err",
"error",
"\n\n",
"// The caller intents to all cells",
"if",
"len",
"(",
"cells",
")",
"==",
"0",
"{",
"cells",
",",
"err",
"=",
"ts",
".",
"GetCellInfoNames",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// read the shard information to find the cells",
"si",
",",
"err",
":=",
"ts",
".",
"GetShard",
"(",
"ctx",
",",
"keyspace",
",",
"shard",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"resultAsMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"topodatapb",
".",
"TabletAlias",
")",
"\n",
"if",
"si",
".",
"HasMaster",
"(",
")",
"{",
"if",
"InCellList",
"(",
"si",
".",
"MasterAlias",
".",
"Cell",
",",
"cells",
")",
"{",
"resultAsMap",
"[",
"topoproto",
".",
"TabletAliasString",
"(",
"si",
".",
"MasterAlias",
")",
"]",
"=",
"si",
".",
"MasterAlias",
"\n",
"}",
"\n",
"}",
"\n\n",
"// read the replication graph in each cell and add all found tablets",
"wg",
":=",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"mutex",
":=",
"sync",
".",
"Mutex",
"{",
"}",
"\n",
"rec",
":=",
"concurrency",
".",
"AllErrorRecorder",
"{",
"}",
"\n",
"result",
":=",
"make",
"(",
"[",
"]",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"0",
",",
"len",
"(",
"resultAsMap",
")",
")",
"\n",
"for",
"_",
",",
"cell",
":=",
"range",
"cells",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
"(",
"cell",
"string",
")",
"{",
"defer",
"wg",
".",
"Done",
"(",
")",
"\n",
"sri",
",",
"err",
":=",
"ts",
".",
"GetShardReplication",
"(",
"ctx",
",",
"cell",
",",
"keyspace",
",",
"shard",
")",
"\n",
"switch",
"{",
"case",
"err",
"==",
"nil",
":",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"node",
":=",
"range",
"sri",
".",
"Nodes",
"{",
"resultAsMap",
"[",
"topoproto",
".",
"TabletAliasString",
"(",
"node",
".",
"TabletAlias",
")",
"]",
"=",
"node",
".",
"TabletAlias",
"\n",
"}",
"\n",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"case",
"IsErrType",
"(",
"err",
",",
"NoNode",
")",
":",
"// There is no shard replication for this shard in this cell. NOOP",
"default",
":",
"rec",
".",
"RecordError",
"(",
"vterrors",
".",
"Wrap",
"(",
"err",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cell",
",",
"keyspace",
",",
"shard",
")",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"(",
"cell",
")",
"\n",
"}",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"err",
"=",
"nil",
"\n",
"if",
"rec",
".",
"HasErrors",
"(",
")",
"{",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"keyspace",
",",
"shard",
",",
"rec",
".",
"Error",
"(",
")",
")",
"\n",
"err",
"=",
"NewError",
"(",
"PartialResult",
",",
"shard",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"a",
":=",
"range",
"resultAsMap",
"{",
"v",
":=",
"*",
"a",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"&",
"v",
")",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"topoproto",
".",
"TabletAliasList",
"(",
"result",
")",
")",
"\n",
"return",
"result",
",",
"err",
"\n",
"}"
] | // FindAllTabletAliasesInShardByCell uses the replication graph to find all the
// tablet aliases in the given shard.
//
// It can return ErrPartialResult if some cells were not fetched,
// in which case the result only contains the cells that were fetched.
//
// The tablet aliases are sorted by cell, then by UID. | [
"FindAllTabletAliasesInShardByCell",
"uses",
"the",
"replication",
"graph",
"to",
"find",
"all",
"the",
"tablet",
"aliases",
"in",
"the",
"given",
"shard",
".",
"It",
"can",
"return",
"ErrPartialResult",
"if",
"some",
"cells",
"were",
"not",
"fetched",
"in",
"which",
"case",
"the",
"result",
"only",
"contains",
"the",
"cells",
"that",
"were",
"fetched",
".",
"The",
"tablet",
"aliases",
"are",
"sorted",
"by",
"cell",
"then",
"by",
"UID",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/shard.go#L478-L546 | train |
vitessio/vitess | go/mysql/gtid.go | ParseGTID | func ParseGTID(flavor, value string) (GTID, error) {
parser := gtidParsers[flavor]
if parser == nil {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "parse error: unknown GTID flavor %#v", flavor)
}
return parser(value)
} | go | func ParseGTID(flavor, value string) (GTID, error) {
parser := gtidParsers[flavor]
if parser == nil {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "parse error: unknown GTID flavor %#v", flavor)
}
return parser(value)
} | [
"func",
"ParseGTID",
"(",
"flavor",
",",
"value",
"string",
")",
"(",
"GTID",
",",
"error",
")",
"{",
"parser",
":=",
"gtidParsers",
"[",
"flavor",
"]",
"\n",
"if",
"parser",
"==",
"nil",
"{",
"return",
"nil",
",",
"vterrors",
".",
"Errorf",
"(",
"vtrpc",
".",
"Code_INTERNAL",
",",
"\"",
"\"",
",",
"flavor",
")",
"\n",
"}",
"\n",
"return",
"parser",
"(",
"value",
")",
"\n",
"}"
] | // ParseGTID calls the GTID parser for the specified flavor. | [
"ParseGTID",
"calls",
"the",
"GTID",
"parser",
"for",
"the",
"specified",
"flavor",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/gtid.go#L63-L69 | train |
vitessio/vitess | go/mysql/gtid.go | MustParseGTID | func MustParseGTID(flavor, value string) GTID {
gtid, err := ParseGTID(flavor, value)
if err != nil {
panic(err)
}
return gtid
} | go | func MustParseGTID(flavor, value string) GTID {
gtid, err := ParseGTID(flavor, value)
if err != nil {
panic(err)
}
return gtid
} | [
"func",
"MustParseGTID",
"(",
"flavor",
",",
"value",
"string",
")",
"GTID",
"{",
"gtid",
",",
"err",
":=",
"ParseGTID",
"(",
"flavor",
",",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"gtid",
"\n",
"}"
] | // MustParseGTID calls ParseGTID and panics on error. | [
"MustParseGTID",
"calls",
"ParseGTID",
"and",
"panics",
"on",
"error",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/gtid.go#L72-L78 | train |
vitessio/vitess | go/mysql/gtid.go | EncodeGTID | func EncodeGTID(gtid GTID) string {
if gtid == nil {
return ""
}
return fmt.Sprintf("%s/%s", gtid.Flavor(), gtid.String())
} | go | func EncodeGTID(gtid GTID) string {
if gtid == nil {
return ""
}
return fmt.Sprintf("%s/%s", gtid.Flavor(), gtid.String())
} | [
"func",
"EncodeGTID",
"(",
"gtid",
"GTID",
")",
"string",
"{",
"if",
"gtid",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"gtid",
".",
"Flavor",
"(",
")",
",",
"gtid",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // EncodeGTID returns a string that contains both the flavor and value of the
// GTID, so that the correct parser can be selected when that string is passed
// to DecodeGTID. | [
"EncodeGTID",
"returns",
"a",
"string",
"that",
"contains",
"both",
"the",
"flavor",
"and",
"value",
"of",
"the",
"GTID",
"so",
"that",
"the",
"correct",
"parser",
"can",
"be",
"selected",
"when",
"that",
"string",
"is",
"passed",
"to",
"DecodeGTID",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/gtid.go#L83-L89 | train |
vitessio/vitess | go/mysql/gtid.go | DecodeGTID | func DecodeGTID(s string) (GTID, error) {
if s == "" {
return nil, nil
}
parts := strings.SplitN(s, "/", 2)
if len(parts) != 2 {
// There is no flavor. Try looking for a default parser.
return ParseGTID("", s)
}
return ParseGTID(parts[0], parts[1])
} | go | func DecodeGTID(s string) (GTID, error) {
if s == "" {
return nil, nil
}
parts := strings.SplitN(s, "/", 2)
if len(parts) != 2 {
// There is no flavor. Try looking for a default parser.
return ParseGTID("", s)
}
return ParseGTID(parts[0], parts[1])
} | [
"func",
"DecodeGTID",
"(",
"s",
"string",
")",
"(",
"GTID",
",",
"error",
")",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"s",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"// There is no flavor. Try looking for a default parser.",
"return",
"ParseGTID",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n",
"return",
"ParseGTID",
"(",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
"1",
"]",
")",
"\n",
"}"
] | // DecodeGTID converts a string in the format returned by EncodeGTID back into
// a GTID interface value with the correct underlying flavor. | [
"DecodeGTID",
"converts",
"a",
"string",
"in",
"the",
"format",
"returned",
"by",
"EncodeGTID",
"back",
"into",
"a",
"GTID",
"interface",
"value",
"with",
"the",
"correct",
"underlying",
"flavor",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/gtid.go#L93-L104 | train |
vitessio/vitess | go/mysql/gtid.go | MustDecodeGTID | func MustDecodeGTID(s string) GTID {
gtid, err := DecodeGTID(s)
if err != nil {
panic(err)
}
return gtid
} | go | func MustDecodeGTID(s string) GTID {
gtid, err := DecodeGTID(s)
if err != nil {
panic(err)
}
return gtid
} | [
"func",
"MustDecodeGTID",
"(",
"s",
"string",
")",
"GTID",
"{",
"gtid",
",",
"err",
":=",
"DecodeGTID",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"gtid",
"\n",
"}"
] | // MustDecodeGTID calls DecodeGTID and panics on error. | [
"MustDecodeGTID",
"calls",
"DecodeGTID",
"and",
"panics",
"on",
"error",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/gtid.go#L107-L113 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | SetLastPosition | func (bps *Stats) SetLastPosition(pos mysql.Position) {
bps.lastPositionMutex.Lock()
defer bps.lastPositionMutex.Unlock()
bps.lastPosition = pos
} | go | func (bps *Stats) SetLastPosition(pos mysql.Position) {
bps.lastPositionMutex.Lock()
defer bps.lastPositionMutex.Unlock()
bps.lastPosition = pos
} | [
"func",
"(",
"bps",
"*",
"Stats",
")",
"SetLastPosition",
"(",
"pos",
"mysql",
".",
"Position",
")",
"{",
"bps",
".",
"lastPositionMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"bps",
".",
"lastPositionMutex",
".",
"Unlock",
"(",
")",
"\n",
"bps",
".",
"lastPosition",
"=",
"pos",
"\n",
"}"
] | // SetLastPosition sets the last replication position. | [
"SetLastPosition",
"sets",
"the",
"last",
"replication",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L85-L89 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | LastPosition | func (bps *Stats) LastPosition() mysql.Position {
bps.lastPositionMutex.Lock()
defer bps.lastPositionMutex.Unlock()
return bps.lastPosition
} | go | func (bps *Stats) LastPosition() mysql.Position {
bps.lastPositionMutex.Lock()
defer bps.lastPositionMutex.Unlock()
return bps.lastPosition
} | [
"func",
"(",
"bps",
"*",
"Stats",
")",
"LastPosition",
"(",
")",
"mysql",
".",
"Position",
"{",
"bps",
".",
"lastPositionMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"bps",
".",
"lastPositionMutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"bps",
".",
"lastPosition",
"\n",
"}"
] | // LastPosition gets the last replication position. | [
"LastPosition",
"gets",
"the",
"last",
"replication",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L92-L96 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | MessageHistory | func (bps *Stats) MessageHistory() []string {
strs := make([]string, 0, 3)
for _, h := range bps.History.Records() {
h1, _ := h.(*StatsHistoryRecord)
if h1 != nil {
strs = append(strs, h1.Message)
}
}
return strs
} | go | func (bps *Stats) MessageHistory() []string {
strs := make([]string, 0, 3)
for _, h := range bps.History.Records() {
h1, _ := h.(*StatsHistoryRecord)
if h1 != nil {
strs = append(strs, h1.Message)
}
}
return strs
} | [
"func",
"(",
"bps",
"*",
"Stats",
")",
"MessageHistory",
"(",
")",
"[",
"]",
"string",
"{",
"strs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"3",
")",
"\n",
"for",
"_",
",",
"h",
":=",
"range",
"bps",
".",
"History",
".",
"Records",
"(",
")",
"{",
"h1",
",",
"_",
":=",
"h",
".",
"(",
"*",
"StatsHistoryRecord",
")",
"\n",
"if",
"h1",
"!=",
"nil",
"{",
"strs",
"=",
"append",
"(",
"strs",
",",
"h1",
".",
"Message",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"strs",
"\n",
"}"
] | // MessageHistory gets all the messages, we store 3 at a time | [
"MessageHistory",
"gets",
"all",
"the",
"messages",
"we",
"store",
"3",
"at",
"a",
"time"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L99-L108 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | NewStats | func NewStats() *Stats {
bps := &Stats{}
bps.Timings = stats.NewTimings("", "", "")
bps.Rates = stats.NewRates("", bps.Timings, 15, 60e9)
bps.History = history.New(3)
bps.SecondsBehindMaster.Set(math.MaxInt64)
return bps
} | go | func NewStats() *Stats {
bps := &Stats{}
bps.Timings = stats.NewTimings("", "", "")
bps.Rates = stats.NewRates("", bps.Timings, 15, 60e9)
bps.History = history.New(3)
bps.SecondsBehindMaster.Set(math.MaxInt64)
return bps
} | [
"func",
"NewStats",
"(",
")",
"*",
"Stats",
"{",
"bps",
":=",
"&",
"Stats",
"{",
"}",
"\n",
"bps",
".",
"Timings",
"=",
"stats",
".",
"NewTimings",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"bps",
".",
"Rates",
"=",
"stats",
".",
"NewRates",
"(",
"\"",
"\"",
",",
"bps",
".",
"Timings",
",",
"15",
",",
"60e9",
")",
"\n",
"bps",
".",
"History",
"=",
"history",
".",
"New",
"(",
"3",
")",
"\n",
"bps",
".",
"SecondsBehindMaster",
".",
"Set",
"(",
"math",
".",
"MaxInt64",
")",
"\n",
"return",
"bps",
"\n",
"}"
] | // NewStats creates a new Stats structure. | [
"NewStats",
"creates",
"a",
"new",
"Stats",
"structure",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L111-L118 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | ApplyBinlogEvents | func (blp *BinlogPlayer) ApplyBinlogEvents(ctx context.Context) error {
if err := SetVReplicationState(blp.dbClient, blp.uid, BlpRunning, ""); err != nil {
log.Errorf("Error writing Running state: %v", err)
}
if err := blp.applyEvents(ctx); err != nil {
msg := err.Error()
blp.blplStats.History.Add(&StatsHistoryRecord{
Time: time.Now(),
Message: msg,
})
if err := SetVReplicationState(blp.dbClient, blp.uid, BlpError, msg); err != nil {
log.Errorf("Error writing stop state: %v", err)
}
return err
}
return nil
} | go | func (blp *BinlogPlayer) ApplyBinlogEvents(ctx context.Context) error {
if err := SetVReplicationState(blp.dbClient, blp.uid, BlpRunning, ""); err != nil {
log.Errorf("Error writing Running state: %v", err)
}
if err := blp.applyEvents(ctx); err != nil {
msg := err.Error()
blp.blplStats.History.Add(&StatsHistoryRecord{
Time: time.Now(),
Message: msg,
})
if err := SetVReplicationState(blp.dbClient, blp.uid, BlpError, msg); err != nil {
log.Errorf("Error writing stop state: %v", err)
}
return err
}
return nil
} | [
"func",
"(",
"blp",
"*",
"BinlogPlayer",
")",
"ApplyBinlogEvents",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"SetVReplicationState",
"(",
"blp",
".",
"dbClient",
",",
"blp",
".",
"uid",
",",
"BlpRunning",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"blp",
".",
"applyEvents",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"msg",
":=",
"err",
".",
"Error",
"(",
")",
"\n",
"blp",
".",
"blplStats",
".",
"History",
".",
"Add",
"(",
"&",
"StatsHistoryRecord",
"{",
"Time",
":",
"time",
".",
"Now",
"(",
")",
",",
"Message",
":",
"msg",
",",
"}",
")",
"\n",
"if",
"err",
":=",
"SetVReplicationState",
"(",
"blp",
".",
"dbClient",
",",
"blp",
".",
"uid",
",",
"BlpError",
",",
"msg",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ApplyBinlogEvents makes an RPC request to BinlogServer
// and processes the events. It returns nil if the provided context
// was canceled, or if we reached the stopping point.
// If an error is encountered, it updates the vreplication state to "Error".
// If a stop position was specifed, and reached, the state is updated to "Stopped". | [
"ApplyBinlogEvents",
"makes",
"an",
"RPC",
"request",
"to",
"BinlogServer",
"and",
"processes",
"the",
"events",
".",
"It",
"returns",
"nil",
"if",
"the",
"provided",
"context",
"was",
"canceled",
"or",
"if",
"we",
"reached",
"the",
"stopping",
"point",
".",
"If",
"an",
"error",
"is",
"encountered",
"it",
"updates",
"the",
"vreplication",
"state",
"to",
"Error",
".",
"If",
"a",
"stop",
"position",
"was",
"specifed",
"and",
"reached",
"the",
"state",
"is",
"updated",
"to",
"Stopped",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L178-L195 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | SetVReplicationState | func SetVReplicationState(dbClient DBClient, uid uint32, state, message string) error {
query := fmt.Sprintf("update _vt.vreplication set state='%v', message=%v where id=%v", state, encodeString(message), uid)
if _, err := dbClient.ExecuteFetch(query, 1); err != nil {
return fmt.Errorf("could not set state: %v: %v", query, err)
}
return nil
} | go | func SetVReplicationState(dbClient DBClient, uid uint32, state, message string) error {
query := fmt.Sprintf("update _vt.vreplication set state='%v', message=%v where id=%v", state, encodeString(message), uid)
if _, err := dbClient.ExecuteFetch(query, 1); err != nil {
return fmt.Errorf("could not set state: %v: %v", query, err)
}
return nil
} | [
"func",
"SetVReplicationState",
"(",
"dbClient",
"DBClient",
",",
"uid",
"uint32",
",",
"state",
",",
"message",
"string",
")",
"error",
"{",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"state",
",",
"encodeString",
"(",
"message",
")",
",",
"uid",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"dbClient",
".",
"ExecuteFetch",
"(",
"query",
",",
"1",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"query",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetVReplicationState updates the state in the _vt.vreplication table. | [
"SetVReplicationState",
"updates",
"the",
"state",
"in",
"the",
"_vt",
".",
"vreplication",
"table",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L510-L516 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | ReadVRSettings | func ReadVRSettings(dbClient DBClient, uid uint32) (VRSettings, error) {
query := fmt.Sprintf("select pos, stop_pos, max_tps, max_replication_lag, state from _vt.vreplication where id=%v", uid)
qr, err := dbClient.ExecuteFetch(query, 1)
if err != nil {
return VRSettings{}, fmt.Errorf("error %v in selecting vreplication settings %v", err, query)
}
if len(qr.Rows) != 1 {
return VRSettings{}, fmt.Errorf("checkpoint information not available in db for %v", uid)
}
vrRow := qr.Rows[0]
maxTPS, err := sqltypes.ToInt64(vrRow[2])
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse max_tps column: %v", err)
}
maxReplicationLag, err := sqltypes.ToInt64(vrRow[3])
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse max_replication_lag column: %v", err)
}
startPos, err := mysql.DecodePosition(vrRow[0].ToString())
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse pos column: %v", err)
}
stopPos, err := mysql.DecodePosition(vrRow[1].ToString())
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse stop_pos column: %v", err)
}
return VRSettings{
StartPos: startPos,
StopPos: stopPos,
MaxTPS: maxTPS,
MaxReplicationLag: maxReplicationLag,
State: vrRow[4].ToString(),
}, nil
} | go | func ReadVRSettings(dbClient DBClient, uid uint32) (VRSettings, error) {
query := fmt.Sprintf("select pos, stop_pos, max_tps, max_replication_lag, state from _vt.vreplication where id=%v", uid)
qr, err := dbClient.ExecuteFetch(query, 1)
if err != nil {
return VRSettings{}, fmt.Errorf("error %v in selecting vreplication settings %v", err, query)
}
if len(qr.Rows) != 1 {
return VRSettings{}, fmt.Errorf("checkpoint information not available in db for %v", uid)
}
vrRow := qr.Rows[0]
maxTPS, err := sqltypes.ToInt64(vrRow[2])
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse max_tps column: %v", err)
}
maxReplicationLag, err := sqltypes.ToInt64(vrRow[3])
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse max_replication_lag column: %v", err)
}
startPos, err := mysql.DecodePosition(vrRow[0].ToString())
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse pos column: %v", err)
}
stopPos, err := mysql.DecodePosition(vrRow[1].ToString())
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse stop_pos column: %v", err)
}
return VRSettings{
StartPos: startPos,
StopPos: stopPos,
MaxTPS: maxTPS,
MaxReplicationLag: maxReplicationLag,
State: vrRow[4].ToString(),
}, nil
} | [
"func",
"ReadVRSettings",
"(",
"dbClient",
"DBClient",
",",
"uid",
"uint32",
")",
"(",
"VRSettings",
",",
"error",
")",
"{",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"uid",
")",
"\n",
"qr",
",",
"err",
":=",
"dbClient",
".",
"ExecuteFetch",
"(",
"query",
",",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"VRSettings",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
",",
"query",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"qr",
".",
"Rows",
")",
"!=",
"1",
"{",
"return",
"VRSettings",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"uid",
")",
"\n",
"}",
"\n",
"vrRow",
":=",
"qr",
".",
"Rows",
"[",
"0",
"]",
"\n\n",
"maxTPS",
",",
"err",
":=",
"sqltypes",
".",
"ToInt64",
"(",
"vrRow",
"[",
"2",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"VRSettings",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"maxReplicationLag",
",",
"err",
":=",
"sqltypes",
".",
"ToInt64",
"(",
"vrRow",
"[",
"3",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"VRSettings",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"startPos",
",",
"err",
":=",
"mysql",
".",
"DecodePosition",
"(",
"vrRow",
"[",
"0",
"]",
".",
"ToString",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"VRSettings",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"stopPos",
",",
"err",
":=",
"mysql",
".",
"DecodePosition",
"(",
"vrRow",
"[",
"1",
"]",
".",
"ToString",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"VRSettings",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"VRSettings",
"{",
"StartPos",
":",
"startPos",
",",
"StopPos",
":",
"stopPos",
",",
"MaxTPS",
":",
"maxTPS",
",",
"MaxReplicationLag",
":",
"maxReplicationLag",
",",
"State",
":",
"vrRow",
"[",
"4",
"]",
".",
"ToString",
"(",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] | // ReadVRSettings retrieves the throttler settings for
// vreplication from the checkpoint table. | [
"ReadVRSettings",
"retrieves",
"the",
"throttler",
"settings",
"for",
"vreplication",
"from",
"the",
"checkpoint",
"table",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L529-L565 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | CreateVReplication | func CreateVReplication(workflow string, source *binlogdatapb.BinlogSource, position string, maxTPS, maxReplicationLag, timeUpdated int64, dbName string) string {
return fmt.Sprintf("insert into _vt.vreplication "+
"(workflow, source, pos, max_tps, max_replication_lag, time_updated, transaction_timestamp, state, db_name) "+
"values (%v, %v, %v, %v, %v, %v, 0, '%v', %v)",
encodeString(workflow), encodeString(source.String()), encodeString(position), maxTPS, maxReplicationLag, timeUpdated, BlpRunning, encodeString(dbName))
} | go | func CreateVReplication(workflow string, source *binlogdatapb.BinlogSource, position string, maxTPS, maxReplicationLag, timeUpdated int64, dbName string) string {
return fmt.Sprintf("insert into _vt.vreplication "+
"(workflow, source, pos, max_tps, max_replication_lag, time_updated, transaction_timestamp, state, db_name) "+
"values (%v, %v, %v, %v, %v, %v, 0, '%v', %v)",
encodeString(workflow), encodeString(source.String()), encodeString(position), maxTPS, maxReplicationLag, timeUpdated, BlpRunning, encodeString(dbName))
} | [
"func",
"CreateVReplication",
"(",
"workflow",
"string",
",",
"source",
"*",
"binlogdatapb",
".",
"BinlogSource",
",",
"position",
"string",
",",
"maxTPS",
",",
"maxReplicationLag",
",",
"timeUpdated",
"int64",
",",
"dbName",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"encodeString",
"(",
"workflow",
")",
",",
"encodeString",
"(",
"source",
".",
"String",
"(",
")",
")",
",",
"encodeString",
"(",
"position",
")",
",",
"maxTPS",
",",
"maxReplicationLag",
",",
"timeUpdated",
",",
"BlpRunning",
",",
"encodeString",
"(",
"dbName",
")",
")",
"\n",
"}"
] | // CreateVReplication returns a statement to populate the first value into
// the _vt.vreplication table. | [
"CreateVReplication",
"returns",
"a",
"statement",
"to",
"populate",
"the",
"first",
"value",
"into",
"the",
"_vt",
".",
"vreplication",
"table",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L569-L574 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | CreateVReplicationState | func CreateVReplicationState(workflow string, source *binlogdatapb.BinlogSource, position, state string, dbName string) string {
return fmt.Sprintf("insert into _vt.vreplication "+
"(workflow, source, pos, max_tps, max_replication_lag, time_updated, transaction_timestamp, state, db_name) "+
"values (%v, %v, %v, %v, %v, %v, 0, '%v', %v)",
encodeString(workflow), encodeString(source.String()), encodeString(position), throttler.MaxRateModuleDisabled, throttler.ReplicationLagModuleDisabled, time.Now().Unix(), state, encodeString(dbName))
} | go | func CreateVReplicationState(workflow string, source *binlogdatapb.BinlogSource, position, state string, dbName string) string {
return fmt.Sprintf("insert into _vt.vreplication "+
"(workflow, source, pos, max_tps, max_replication_lag, time_updated, transaction_timestamp, state, db_name) "+
"values (%v, %v, %v, %v, %v, %v, 0, '%v', %v)",
encodeString(workflow), encodeString(source.String()), encodeString(position), throttler.MaxRateModuleDisabled, throttler.ReplicationLagModuleDisabled, time.Now().Unix(), state, encodeString(dbName))
} | [
"func",
"CreateVReplicationState",
"(",
"workflow",
"string",
",",
"source",
"*",
"binlogdatapb",
".",
"BinlogSource",
",",
"position",
",",
"state",
"string",
",",
"dbName",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"encodeString",
"(",
"workflow",
")",
",",
"encodeString",
"(",
"source",
".",
"String",
"(",
")",
")",
",",
"encodeString",
"(",
"position",
")",
",",
"throttler",
".",
"MaxRateModuleDisabled",
",",
"throttler",
".",
"ReplicationLagModuleDisabled",
",",
"time",
".",
"Now",
"(",
")",
".",
"Unix",
"(",
")",
",",
"state",
",",
"encodeString",
"(",
"dbName",
")",
")",
"\n",
"}"
] | // CreateVReplicationState returns a statement to create a stopped vreplication. | [
"CreateVReplicationState",
"returns",
"a",
"statement",
"to",
"create",
"a",
"stopped",
"vreplication",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L577-L582 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | GenerateUpdatePos | func GenerateUpdatePos(uid uint32, pos mysql.Position, timeUpdated int64, txTimestamp int64) string {
if txTimestamp != 0 {
return fmt.Sprintf(
"update _vt.vreplication set pos=%v, time_updated=%v, transaction_timestamp=%v, message='' where id=%v",
encodeString(mysql.EncodePosition(pos)), timeUpdated, txTimestamp, uid)
}
return fmt.Sprintf(
"update _vt.vreplication set pos=%v, time_updated=%v, message='' where id=%v",
encodeString(mysql.EncodePosition(pos)), timeUpdated, uid)
} | go | func GenerateUpdatePos(uid uint32, pos mysql.Position, timeUpdated int64, txTimestamp int64) string {
if txTimestamp != 0 {
return fmt.Sprintf(
"update _vt.vreplication set pos=%v, time_updated=%v, transaction_timestamp=%v, message='' where id=%v",
encodeString(mysql.EncodePosition(pos)), timeUpdated, txTimestamp, uid)
}
return fmt.Sprintf(
"update _vt.vreplication set pos=%v, time_updated=%v, message='' where id=%v",
encodeString(mysql.EncodePosition(pos)), timeUpdated, uid)
} | [
"func",
"GenerateUpdatePos",
"(",
"uid",
"uint32",
",",
"pos",
"mysql",
".",
"Position",
",",
"timeUpdated",
"int64",
",",
"txTimestamp",
"int64",
")",
"string",
"{",
"if",
"txTimestamp",
"!=",
"0",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"encodeString",
"(",
"mysql",
".",
"EncodePosition",
"(",
"pos",
")",
")",
",",
"timeUpdated",
",",
"txTimestamp",
",",
"uid",
")",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"encodeString",
"(",
"mysql",
".",
"EncodePosition",
"(",
"pos",
")",
")",
",",
"timeUpdated",
",",
"uid",
")",
"\n",
"}"
] | // GenerateUpdatePos returns a statement to update a value in the
// _vt.vreplication table. | [
"GenerateUpdatePos",
"returns",
"a",
"statement",
"to",
"update",
"a",
"value",
"in",
"the",
"_vt",
".",
"vreplication",
"table",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L586-L596 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | StartVReplicationUntil | func StartVReplicationUntil(uid uint32, pos string) string {
return fmt.Sprintf(
"update _vt.vreplication set state='%v', stop_pos=%v where id=%v",
BlpRunning, encodeString(pos), uid)
} | go | func StartVReplicationUntil(uid uint32, pos string) string {
return fmt.Sprintf(
"update _vt.vreplication set state='%v', stop_pos=%v where id=%v",
BlpRunning, encodeString(pos), uid)
} | [
"func",
"StartVReplicationUntil",
"(",
"uid",
"uint32",
",",
"pos",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"BlpRunning",
",",
"encodeString",
"(",
"pos",
")",
",",
"uid",
")",
"\n",
"}"
] | // StartVReplicationUntil returns a statement to start the replication with a stop position. | [
"StartVReplicationUntil",
"returns",
"a",
"statement",
"to",
"start",
"the",
"replication",
"with",
"a",
"stop",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L606-L610 | train |
vitessio/vitess | go/vt/binlog/binlogplayer/binlog_player.go | StopVReplication | func StopVReplication(uid uint32, message string) string {
return fmt.Sprintf(
"update _vt.vreplication set state='%v', message=%v where id=%v",
BlpStopped, encodeString(message), uid)
} | go | func StopVReplication(uid uint32, message string) string {
return fmt.Sprintf(
"update _vt.vreplication set state='%v', message=%v where id=%v",
BlpStopped, encodeString(message), uid)
} | [
"func",
"StopVReplication",
"(",
"uid",
"uint32",
",",
"message",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"BlpStopped",
",",
"encodeString",
"(",
"message",
")",
",",
"uid",
")",
"\n",
"}"
] | // StopVReplication returns a statement to stop the replication. | [
"StopVReplication",
"returns",
"a",
"statement",
"to",
"stop",
"the",
"replication",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/binlogplayer/binlog_player.go#L613-L617 | train |
vitessio/vitess | go/vt/vtctld/action_repository.go | NewActionRepository | func NewActionRepository(ts *topo.Server) *ActionRepository {
return &ActionRepository{
keyspaceActions: make(map[string]actionKeyspaceMethod),
shardActions: make(map[string]actionShardMethod),
tabletActions: make(map[string]actionTabletRecord),
ts: ts,
}
} | go | func NewActionRepository(ts *topo.Server) *ActionRepository {
return &ActionRepository{
keyspaceActions: make(map[string]actionKeyspaceMethod),
shardActions: make(map[string]actionShardMethod),
tabletActions: make(map[string]actionTabletRecord),
ts: ts,
}
} | [
"func",
"NewActionRepository",
"(",
"ts",
"*",
"topo",
".",
"Server",
")",
"*",
"ActionRepository",
"{",
"return",
"&",
"ActionRepository",
"{",
"keyspaceActions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"actionKeyspaceMethod",
")",
",",
"shardActions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"actionShardMethod",
")",
",",
"tabletActions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"actionTabletRecord",
")",
",",
"ts",
":",
"ts",
",",
"}",
"\n",
"}"
] | // NewActionRepository creates and returns a new ActionRepository,
// with no actions. | [
"NewActionRepository",
"creates",
"and",
"returns",
"a",
"new",
"ActionRepository",
"with",
"no",
"actions",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/action_repository.go#L81-L88 | train |
vitessio/vitess | go/vt/vtctld/action_repository.go | RegisterKeyspaceAction | func (ar *ActionRepository) RegisterKeyspaceAction(name string, method actionKeyspaceMethod) {
ar.keyspaceActions[name] = method
} | go | func (ar *ActionRepository) RegisterKeyspaceAction(name string, method actionKeyspaceMethod) {
ar.keyspaceActions[name] = method
} | [
"func",
"(",
"ar",
"*",
"ActionRepository",
")",
"RegisterKeyspaceAction",
"(",
"name",
"string",
",",
"method",
"actionKeyspaceMethod",
")",
"{",
"ar",
".",
"keyspaceActions",
"[",
"name",
"]",
"=",
"method",
"\n",
"}"
] | // RegisterKeyspaceAction registers a new action on a keyspace. | [
"RegisterKeyspaceAction",
"registers",
"a",
"new",
"action",
"on",
"a",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/action_repository.go#L91-L93 | train |
vitessio/vitess | go/vt/vtctld/action_repository.go | RegisterShardAction | func (ar *ActionRepository) RegisterShardAction(name string, method actionShardMethod) {
ar.shardActions[name] = method
} | go | func (ar *ActionRepository) RegisterShardAction(name string, method actionShardMethod) {
ar.shardActions[name] = method
} | [
"func",
"(",
"ar",
"*",
"ActionRepository",
")",
"RegisterShardAction",
"(",
"name",
"string",
",",
"method",
"actionShardMethod",
")",
"{",
"ar",
".",
"shardActions",
"[",
"name",
"]",
"=",
"method",
"\n",
"}"
] | // RegisterShardAction registers a new action on a shard. | [
"RegisterShardAction",
"registers",
"a",
"new",
"action",
"on",
"a",
"shard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/action_repository.go#L96-L98 | train |
vitessio/vitess | go/vt/vtctld/action_repository.go | RegisterTabletAction | func (ar *ActionRepository) RegisterTabletAction(name, role string, method actionTabletMethod) {
ar.tabletActions[name] = actionTabletRecord{
role: role,
method: method,
}
} | go | func (ar *ActionRepository) RegisterTabletAction(name, role string, method actionTabletMethod) {
ar.tabletActions[name] = actionTabletRecord{
role: role,
method: method,
}
} | [
"func",
"(",
"ar",
"*",
"ActionRepository",
")",
"RegisterTabletAction",
"(",
"name",
",",
"role",
"string",
",",
"method",
"actionTabletMethod",
")",
"{",
"ar",
".",
"tabletActions",
"[",
"name",
"]",
"=",
"actionTabletRecord",
"{",
"role",
":",
"role",
",",
"method",
":",
"method",
",",
"}",
"\n",
"}"
] | // RegisterTabletAction registers a new action on a tablet. | [
"RegisterTabletAction",
"registers",
"a",
"new",
"action",
"on",
"a",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/action_repository.go#L101-L106 | train |
vitessio/vitess | go/vt/vtctld/action_repository.go | ApplyKeyspaceAction | func (ar *ActionRepository) ApplyKeyspaceAction(ctx context.Context, actionName, keyspace string, r *http.Request) *ActionResult {
result := &ActionResult{Name: actionName, Parameters: keyspace}
action, ok := ar.keyspaceActions[actionName]
if !ok {
result.error("Unknown keyspace action")
return result
}
ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
output, err := action(ctx, wr, keyspace, r)
cancel()
if err != nil {
result.error(err.Error())
return result
}
result.Output = output
return result
} | go | func (ar *ActionRepository) ApplyKeyspaceAction(ctx context.Context, actionName, keyspace string, r *http.Request) *ActionResult {
result := &ActionResult{Name: actionName, Parameters: keyspace}
action, ok := ar.keyspaceActions[actionName]
if !ok {
result.error("Unknown keyspace action")
return result
}
ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
output, err := action(ctx, wr, keyspace, r)
cancel()
if err != nil {
result.error(err.Error())
return result
}
result.Output = output
return result
} | [
"func",
"(",
"ar",
"*",
"ActionRepository",
")",
"ApplyKeyspaceAction",
"(",
"ctx",
"context",
".",
"Context",
",",
"actionName",
",",
"keyspace",
"string",
",",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"ActionResult",
"{",
"result",
":=",
"&",
"ActionResult",
"{",
"Name",
":",
"actionName",
",",
"Parameters",
":",
"keyspace",
"}",
"\n\n",
"action",
",",
"ok",
":=",
"ar",
".",
"keyspaceActions",
"[",
"actionName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"result",
".",
"error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"result",
"\n",
"}",
"\n\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"*",
"actionTimeout",
")",
"\n",
"wr",
":=",
"wrangler",
".",
"New",
"(",
"logutil",
".",
"NewConsoleLogger",
"(",
")",
",",
"ar",
".",
"ts",
",",
"tmclient",
".",
"NewTabletManagerClient",
"(",
")",
")",
"\n",
"output",
",",
"err",
":=",
"action",
"(",
"ctx",
",",
"wr",
",",
"keyspace",
",",
"r",
")",
"\n",
"cancel",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"result",
".",
"error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"result",
"\n",
"}",
"\n",
"result",
".",
"Output",
"=",
"output",
"\n",
"return",
"result",
"\n",
"}"
] | // ApplyKeyspaceAction applies the provided action to the keyspace. | [
"ApplyKeyspaceAction",
"applies",
"the",
"provided",
"action",
"to",
"the",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/action_repository.go#L109-L128 | train |
vitessio/vitess | go/vt/vtctld/action_repository.go | ApplyTabletAction | func (ar *ActionRepository) ApplyTabletAction(ctx context.Context, actionName string, tabletAlias *topodatapb.TabletAlias, r *http.Request) *ActionResult {
result := &ActionResult{
Name: actionName,
Parameters: topoproto.TabletAliasString(tabletAlias),
}
action, ok := ar.tabletActions[actionName]
if !ok {
result.error("Unknown tablet action")
return result
}
// check the role
if action.role != "" {
if err := acl.CheckAccessHTTP(r, action.role); err != nil {
result.error("Access denied")
return result
}
}
// run the action
ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
output, err := action.method(ctx, wr, tabletAlias, r)
cancel()
if err != nil {
result.error(err.Error())
return result
}
result.Output = output
return result
} | go | func (ar *ActionRepository) ApplyTabletAction(ctx context.Context, actionName string, tabletAlias *topodatapb.TabletAlias, r *http.Request) *ActionResult {
result := &ActionResult{
Name: actionName,
Parameters: topoproto.TabletAliasString(tabletAlias),
}
action, ok := ar.tabletActions[actionName]
if !ok {
result.error("Unknown tablet action")
return result
}
// check the role
if action.role != "" {
if err := acl.CheckAccessHTTP(r, action.role); err != nil {
result.error("Access denied")
return result
}
}
// run the action
ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
output, err := action.method(ctx, wr, tabletAlias, r)
cancel()
if err != nil {
result.error(err.Error())
return result
}
result.Output = output
return result
} | [
"func",
"(",
"ar",
"*",
"ActionRepository",
")",
"ApplyTabletAction",
"(",
"ctx",
"context",
".",
"Context",
",",
"actionName",
"string",
",",
"tabletAlias",
"*",
"topodatapb",
".",
"TabletAlias",
",",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"ActionResult",
"{",
"result",
":=",
"&",
"ActionResult",
"{",
"Name",
":",
"actionName",
",",
"Parameters",
":",
"topoproto",
".",
"TabletAliasString",
"(",
"tabletAlias",
")",
",",
"}",
"\n\n",
"action",
",",
"ok",
":=",
"ar",
".",
"tabletActions",
"[",
"actionName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"result",
".",
"error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"result",
"\n",
"}",
"\n\n",
"// check the role",
"if",
"action",
".",
"role",
"!=",
"\"",
"\"",
"{",
"if",
"err",
":=",
"acl",
".",
"CheckAccessHTTP",
"(",
"r",
",",
"action",
".",
"role",
")",
";",
"err",
"!=",
"nil",
"{",
"result",
".",
"error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"result",
"\n",
"}",
"\n",
"}",
"\n\n",
"// run the action",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"*",
"actionTimeout",
")",
"\n",
"wr",
":=",
"wrangler",
".",
"New",
"(",
"logutil",
".",
"NewConsoleLogger",
"(",
")",
",",
"ar",
".",
"ts",
",",
"tmclient",
".",
"NewTabletManagerClient",
"(",
")",
")",
"\n",
"output",
",",
"err",
":=",
"action",
".",
"method",
"(",
"ctx",
",",
"wr",
",",
"tabletAlias",
",",
"r",
")",
"\n",
"cancel",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"result",
".",
"error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"result",
"\n",
"}",
"\n",
"result",
".",
"Output",
"=",
"output",
"\n",
"return",
"result",
"\n",
"}"
] | // ApplyTabletAction applies the provided action to the tablet. | [
"ApplyTabletAction",
"applies",
"the",
"provided",
"action",
"to",
"the",
"tablet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/action_repository.go#L158-L189 | train |
vitessio/vitess | go/vt/worker/worker.go | resetVars | func resetVars() {
statsState.Set("")
statsRetryCount.Reset()
statsRetryCounters.ResetAll()
statsOnlineInsertsCounters.ResetAll()
statsOnlineUpdatesCounters.ResetAll()
statsOnlineDeletesCounters.ResetAll()
statsOnlineEqualRowsCounters.ResetAll()
statsOfflineInsertsCounters.ResetAll()
statsOfflineUpdatesCounters.ResetAll()
statsOfflineDeletesCounters.ResetAll()
statsOfflineEqualRowsCounters.ResetAll()
statsStreamingQueryCounters.ResetAll()
statsStreamingQueryErrorsCounters.ResetAll()
} | go | func resetVars() {
statsState.Set("")
statsRetryCount.Reset()
statsRetryCounters.ResetAll()
statsOnlineInsertsCounters.ResetAll()
statsOnlineUpdatesCounters.ResetAll()
statsOnlineDeletesCounters.ResetAll()
statsOnlineEqualRowsCounters.ResetAll()
statsOfflineInsertsCounters.ResetAll()
statsOfflineUpdatesCounters.ResetAll()
statsOfflineDeletesCounters.ResetAll()
statsOfflineEqualRowsCounters.ResetAll()
statsStreamingQueryCounters.ResetAll()
statsStreamingQueryErrorsCounters.ResetAll()
} | [
"func",
"resetVars",
"(",
")",
"{",
"statsState",
".",
"Set",
"(",
"\"",
"\"",
")",
"\n",
"statsRetryCount",
".",
"Reset",
"(",
")",
"\n",
"statsRetryCounters",
".",
"ResetAll",
"(",
")",
"\n\n",
"statsOnlineInsertsCounters",
".",
"ResetAll",
"(",
")",
"\n",
"statsOnlineUpdatesCounters",
".",
"ResetAll",
"(",
")",
"\n",
"statsOnlineDeletesCounters",
".",
"ResetAll",
"(",
")",
"\n",
"statsOnlineEqualRowsCounters",
".",
"ResetAll",
"(",
")",
"\n\n",
"statsOfflineInsertsCounters",
".",
"ResetAll",
"(",
")",
"\n",
"statsOfflineUpdatesCounters",
".",
"ResetAll",
"(",
")",
"\n",
"statsOfflineDeletesCounters",
".",
"ResetAll",
"(",
")",
"\n",
"statsOfflineEqualRowsCounters",
".",
"ResetAll",
"(",
")",
"\n\n",
"statsStreamingQueryCounters",
".",
"ResetAll",
"(",
")",
"\n",
"statsStreamingQueryErrorsCounters",
".",
"ResetAll",
"(",
")",
"\n",
"}"
] | // resetVars resets the debug variables that are meant to provide information on a
// per-run basis. This should be called at the beginning of each worker run. | [
"resetVars",
"resets",
"the",
"debug",
"variables",
"that",
"are",
"meant",
"to",
"provide",
"information",
"on",
"a",
"per",
"-",
"run",
"basis",
".",
"This",
"should",
"be",
"called",
"at",
"the",
"beginning",
"of",
"each",
"worker",
"run",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/worker.go#L132-L149 | train |
vitessio/vitess | go/vt/vtgate/engine/route.go | NewSimpleRoute | func NewSimpleRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace) *Route {
return &Route{
Opcode: opcode,
Keyspace: keyspace,
}
} | go | func NewSimpleRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace) *Route {
return &Route{
Opcode: opcode,
Keyspace: keyspace,
}
} | [
"func",
"NewSimpleRoute",
"(",
"opcode",
"RouteOpcode",
",",
"keyspace",
"*",
"vindexes",
".",
"Keyspace",
")",
"*",
"Route",
"{",
"return",
"&",
"Route",
"{",
"Opcode",
":",
"opcode",
",",
"Keyspace",
":",
"keyspace",
",",
"}",
"\n",
"}"
] | // NewSimpleRoute creates a Route with the bare minimum of parameters. | [
"NewSimpleRoute",
"creates",
"a",
"Route",
"with",
"the",
"bare",
"minimum",
"of",
"parameters",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/route.go#L87-L92 | train |
vitessio/vitess | go/vt/vtgate/engine/route.go | NewRoute | func NewRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace, query, fieldQuery string) *Route {
return &Route{
Opcode: opcode,
Keyspace: keyspace,
Query: query,
FieldQuery: fieldQuery,
}
} | go | func NewRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace, query, fieldQuery string) *Route {
return &Route{
Opcode: opcode,
Keyspace: keyspace,
Query: query,
FieldQuery: fieldQuery,
}
} | [
"func",
"NewRoute",
"(",
"opcode",
"RouteOpcode",
",",
"keyspace",
"*",
"vindexes",
".",
"Keyspace",
",",
"query",
",",
"fieldQuery",
"string",
")",
"*",
"Route",
"{",
"return",
"&",
"Route",
"{",
"Opcode",
":",
"opcode",
",",
"Keyspace",
":",
"keyspace",
",",
"Query",
":",
"query",
",",
"FieldQuery",
":",
"fieldQuery",
",",
"}",
"\n",
"}"
] | // NewRoute creates a Route. | [
"NewRoute",
"creates",
"a",
"Route",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/route.go#L95-L102 | train |
vitessio/vitess | go/vt/vtgate/engine/route.go | MarshalJSON | func (route *Route) MarshalJSON() ([]byte, error) {
var vindexName string
if route.Vindex != nil {
vindexName = route.Vindex.String()
}
marshalRoute := struct {
Opcode RouteOpcode
Keyspace *vindexes.Keyspace `json:",omitempty"`
Query string `json:",omitempty"`
FieldQuery string `json:",omitempty"`
Vindex string `json:",omitempty"`
Values []sqltypes.PlanValue `json:",omitempty"`
OrderBy []OrderbyParams `json:",omitempty"`
TruncateColumnCount int `json:",omitempty"`
QueryTimeout int `json:",omitempty"`
ScatterErrorsAsWarnings bool `json:",omitempty"`
}{
Opcode: route.Opcode,
Keyspace: route.Keyspace,
Query: route.Query,
FieldQuery: route.FieldQuery,
Vindex: vindexName,
Values: route.Values,
OrderBy: route.OrderBy,
TruncateColumnCount: route.TruncateColumnCount,
QueryTimeout: route.QueryTimeout,
ScatterErrorsAsWarnings: route.ScatterErrorsAsWarnings,
}
return jsonutil.MarshalNoEscape(marshalRoute)
} | go | func (route *Route) MarshalJSON() ([]byte, error) {
var vindexName string
if route.Vindex != nil {
vindexName = route.Vindex.String()
}
marshalRoute := struct {
Opcode RouteOpcode
Keyspace *vindexes.Keyspace `json:",omitempty"`
Query string `json:",omitempty"`
FieldQuery string `json:",omitempty"`
Vindex string `json:",omitempty"`
Values []sqltypes.PlanValue `json:",omitempty"`
OrderBy []OrderbyParams `json:",omitempty"`
TruncateColumnCount int `json:",omitempty"`
QueryTimeout int `json:",omitempty"`
ScatterErrorsAsWarnings bool `json:",omitempty"`
}{
Opcode: route.Opcode,
Keyspace: route.Keyspace,
Query: route.Query,
FieldQuery: route.FieldQuery,
Vindex: vindexName,
Values: route.Values,
OrderBy: route.OrderBy,
TruncateColumnCount: route.TruncateColumnCount,
QueryTimeout: route.QueryTimeout,
ScatterErrorsAsWarnings: route.ScatterErrorsAsWarnings,
}
return jsonutil.MarshalNoEscape(marshalRoute)
} | [
"func",
"(",
"route",
"*",
"Route",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"vindexName",
"string",
"\n",
"if",
"route",
".",
"Vindex",
"!=",
"nil",
"{",
"vindexName",
"=",
"route",
".",
"Vindex",
".",
"String",
"(",
")",
"\n",
"}",
"\n",
"marshalRoute",
":=",
"struct",
"{",
"Opcode",
"RouteOpcode",
"\n",
"Keyspace",
"*",
"vindexes",
".",
"Keyspace",
"`json:\",omitempty\"`",
"\n",
"Query",
"string",
"`json:\",omitempty\"`",
"\n",
"FieldQuery",
"string",
"`json:\",omitempty\"`",
"\n",
"Vindex",
"string",
"`json:\",omitempty\"`",
"\n",
"Values",
"[",
"]",
"sqltypes",
".",
"PlanValue",
"`json:\",omitempty\"`",
"\n",
"OrderBy",
"[",
"]",
"OrderbyParams",
"`json:\",omitempty\"`",
"\n",
"TruncateColumnCount",
"int",
"`json:\",omitempty\"`",
"\n",
"QueryTimeout",
"int",
"`json:\",omitempty\"`",
"\n",
"ScatterErrorsAsWarnings",
"bool",
"`json:\",omitempty\"`",
"\n",
"}",
"{",
"Opcode",
":",
"route",
".",
"Opcode",
",",
"Keyspace",
":",
"route",
".",
"Keyspace",
",",
"Query",
":",
"route",
".",
"Query",
",",
"FieldQuery",
":",
"route",
".",
"FieldQuery",
",",
"Vindex",
":",
"vindexName",
",",
"Values",
":",
"route",
".",
"Values",
",",
"OrderBy",
":",
"route",
".",
"OrderBy",
",",
"TruncateColumnCount",
":",
"route",
".",
"TruncateColumnCount",
",",
"QueryTimeout",
":",
"route",
".",
"QueryTimeout",
",",
"ScatterErrorsAsWarnings",
":",
"route",
".",
"ScatterErrorsAsWarnings",
",",
"}",
"\n",
"return",
"jsonutil",
".",
"MarshalNoEscape",
"(",
"marshalRoute",
")",
"\n",
"}"
] | // MarshalJSON serializes the Route into a JSON representation.
// It's used for testing and diagnostics. | [
"MarshalJSON",
"serializes",
"the",
"Route",
"into",
"a",
"JSON",
"representation",
".",
"It",
"s",
"used",
"for",
"testing",
"and",
"diagnostics",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/route.go#L113-L142 | train |
vitessio/vitess | go/stats/duration.go | NewCounterDuration | func NewCounterDuration(name, help string) *CounterDuration {
cd := &CounterDuration{
help: help,
}
publish(name, cd)
return cd
} | go | func NewCounterDuration(name, help string) *CounterDuration {
cd := &CounterDuration{
help: help,
}
publish(name, cd)
return cd
} | [
"func",
"NewCounterDuration",
"(",
"name",
",",
"help",
"string",
")",
"*",
"CounterDuration",
"{",
"cd",
":=",
"&",
"CounterDuration",
"{",
"help",
":",
"help",
",",
"}",
"\n",
"publish",
"(",
"name",
",",
"cd",
")",
"\n",
"return",
"cd",
"\n",
"}"
] | // NewCounterDuration returns a new CounterDuration. | [
"NewCounterDuration",
"returns",
"a",
"new",
"CounterDuration",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/duration.go#L33-L39 | train |
vitessio/vitess | go/stats/duration.go | String | func (cd CounterDuration) String() string {
return strconv.FormatInt(int64(cd.i.Get()), 10)
} | go | func (cd CounterDuration) String() string {
return strconv.FormatInt(int64(cd.i.Get()), 10)
} | [
"func",
"(",
"cd",
"CounterDuration",
")",
"String",
"(",
")",
"string",
"{",
"return",
"strconv",
".",
"FormatInt",
"(",
"int64",
"(",
"cd",
".",
"i",
".",
"Get",
"(",
")",
")",
",",
"10",
")",
"\n",
"}"
] | // String is the implementation of expvar.var. | [
"String",
"is",
"the",
"implementation",
"of",
"expvar",
".",
"var",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/duration.go#L47-L49 | train |
vitessio/vitess | go/stats/duration.go | Add | func (cd *CounterDuration) Add(delta time.Duration) {
cd.i.Add(delta)
} | go | func (cd *CounterDuration) Add(delta time.Duration) {
cd.i.Add(delta)
} | [
"func",
"(",
"cd",
"*",
"CounterDuration",
")",
"Add",
"(",
"delta",
"time",
".",
"Duration",
")",
"{",
"cd",
".",
"i",
".",
"Add",
"(",
"delta",
")",
"\n",
"}"
] | // Add adds the provided value to the CounterDuration. | [
"Add",
"adds",
"the",
"provided",
"value",
"to",
"the",
"CounterDuration",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/duration.go#L52-L54 | train |
vitessio/vitess | go/stats/duration.go | NewGaugeDuration | func NewGaugeDuration(name, help string) *GaugeDuration {
gd := &GaugeDuration{
CounterDuration: CounterDuration{
help: help,
},
}
publish(name, gd)
return gd
} | go | func NewGaugeDuration(name, help string) *GaugeDuration {
gd := &GaugeDuration{
CounterDuration: CounterDuration{
help: help,
},
}
publish(name, gd)
return gd
} | [
"func",
"NewGaugeDuration",
"(",
"name",
",",
"help",
"string",
")",
"*",
"GaugeDuration",
"{",
"gd",
":=",
"&",
"GaugeDuration",
"{",
"CounterDuration",
":",
"CounterDuration",
"{",
"help",
":",
"help",
",",
"}",
",",
"}",
"\n",
"publish",
"(",
"name",
",",
"gd",
")",
"\n",
"return",
"gd",
"\n",
"}"
] | // NewGaugeDuration returns a new GaugeDuration. | [
"NewGaugeDuration",
"returns",
"a",
"new",
"GaugeDuration",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/duration.go#L69-L77 | train |
vitessio/vitess | go/stats/duration.go | Set | func (gd *GaugeDuration) Set(value time.Duration) {
gd.i.Set(value)
} | go | func (gd *GaugeDuration) Set(value time.Duration) {
gd.i.Set(value)
} | [
"func",
"(",
"gd",
"*",
"GaugeDuration",
")",
"Set",
"(",
"value",
"time",
".",
"Duration",
")",
"{",
"gd",
".",
"i",
".",
"Set",
"(",
"value",
")",
"\n",
"}"
] | // Set sets the value. | [
"Set",
"sets",
"the",
"value",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/duration.go#L80-L82 | train |
vitessio/vitess | go/stats/duration.go | NewCounterDurationFunc | func NewCounterDurationFunc(name string, help string, f func() time.Duration) *CounterDurationFunc {
cf := &CounterDurationFunc{
F: f,
help: help,
}
if name != "" {
publish(name, cf)
}
return cf
} | go | func NewCounterDurationFunc(name string, help string, f func() time.Duration) *CounterDurationFunc {
cf := &CounterDurationFunc{
F: f,
help: help,
}
if name != "" {
publish(name, cf)
}
return cf
} | [
"func",
"NewCounterDurationFunc",
"(",
"name",
"string",
",",
"help",
"string",
",",
"f",
"func",
"(",
")",
"time",
".",
"Duration",
")",
"*",
"CounterDurationFunc",
"{",
"cf",
":=",
"&",
"CounterDurationFunc",
"{",
"F",
":",
"f",
",",
"help",
":",
"help",
",",
"}",
"\n\n",
"if",
"name",
"!=",
"\"",
"\"",
"{",
"publish",
"(",
"name",
",",
"cf",
")",
"\n",
"}",
"\n",
"return",
"cf",
"\n",
"}"
] | // NewCounterDurationFunc creates a new CounterDurationFunc instance and
// publishes it if name is set. | [
"NewCounterDurationFunc",
"creates",
"a",
"new",
"CounterDurationFunc",
"instance",
"and",
"publishes",
"it",
"if",
"name",
"is",
"set",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/duration.go#L92-L102 | train |
vitessio/vitess | go/stats/duration.go | NewGaugeDurationFunc | func NewGaugeDurationFunc(name string, help string, f func() time.Duration) *GaugeDurationFunc {
gf := &GaugeDurationFunc{
CounterDurationFunc: CounterDurationFunc{
F: f,
help: help,
},
}
if name != "" {
publish(name, gf)
}
return gf
} | go | func NewGaugeDurationFunc(name string, help string, f func() time.Duration) *GaugeDurationFunc {
gf := &GaugeDurationFunc{
CounterDurationFunc: CounterDurationFunc{
F: f,
help: help,
},
}
if name != "" {
publish(name, gf)
}
return gf
} | [
"func",
"NewGaugeDurationFunc",
"(",
"name",
"string",
",",
"help",
"string",
",",
"f",
"func",
"(",
")",
"time",
".",
"Duration",
")",
"*",
"GaugeDurationFunc",
"{",
"gf",
":=",
"&",
"GaugeDurationFunc",
"{",
"CounterDurationFunc",
":",
"CounterDurationFunc",
"{",
"F",
":",
"f",
",",
"help",
":",
"help",
",",
"}",
",",
"}",
"\n\n",
"if",
"name",
"!=",
"\"",
"\"",
"{",
"publish",
"(",
"name",
",",
"gf",
")",
"\n",
"}",
"\n",
"return",
"gf",
"\n",
"}"
] | // NewGaugeDurationFunc creates a new GaugeDurationFunc instance and
// publishes it if name is set. | [
"NewGaugeDurationFunc",
"creates",
"a",
"new",
"GaugeDurationFunc",
"instance",
"and",
"publishes",
"it",
"if",
"name",
"is",
"set",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/duration.go#L121-L133 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/replication_watcher.go | NewReplicationWatcher | func NewReplicationWatcher(se *schema.Engine, config tabletenv.TabletConfig) *ReplicationWatcher {
rpw := &ReplicationWatcher{
watchReplication: config.WatchReplication,
se: se,
}
replOnce.Do(func() {
stats.Publish("EventTokenPosition", stats.StringFunc(func() string {
if e := rpw.EventToken(); e != nil {
return e.Position
}
return ""
}))
stats.NewGaugeFunc(
"EventTokenTimestamp",
"Replication watcher event token timestamp",
func() int64 {
if e := rpw.EventToken(); e != nil {
return e.Timestamp
}
return 0
})
})
return rpw
} | go | func NewReplicationWatcher(se *schema.Engine, config tabletenv.TabletConfig) *ReplicationWatcher {
rpw := &ReplicationWatcher{
watchReplication: config.WatchReplication,
se: se,
}
replOnce.Do(func() {
stats.Publish("EventTokenPosition", stats.StringFunc(func() string {
if e := rpw.EventToken(); e != nil {
return e.Position
}
return ""
}))
stats.NewGaugeFunc(
"EventTokenTimestamp",
"Replication watcher event token timestamp",
func() int64 {
if e := rpw.EventToken(); e != nil {
return e.Timestamp
}
return 0
})
})
return rpw
} | [
"func",
"NewReplicationWatcher",
"(",
"se",
"*",
"schema",
".",
"Engine",
",",
"config",
"tabletenv",
".",
"TabletConfig",
")",
"*",
"ReplicationWatcher",
"{",
"rpw",
":=",
"&",
"ReplicationWatcher",
"{",
"watchReplication",
":",
"config",
".",
"WatchReplication",
",",
"se",
":",
"se",
",",
"}",
"\n",
"replOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"stats",
".",
"Publish",
"(",
"\"",
"\"",
",",
"stats",
".",
"StringFunc",
"(",
"func",
"(",
")",
"string",
"{",
"if",
"e",
":=",
"rpw",
".",
"EventToken",
"(",
")",
";",
"e",
"!=",
"nil",
"{",
"return",
"e",
".",
"Position",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}",
")",
")",
"\n",
"stats",
".",
"NewGaugeFunc",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"func",
"(",
")",
"int64",
"{",
"if",
"e",
":=",
"rpw",
".",
"EventToken",
"(",
")",
";",
"e",
"!=",
"nil",
"{",
"return",
"e",
".",
"Timestamp",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}",
")",
"\n",
"}",
")",
"\n",
"return",
"rpw",
"\n",
"}"
] | // NewReplicationWatcher creates a new ReplicationWatcher. | [
"NewReplicationWatcher",
"creates",
"a",
"new",
"ReplicationWatcher",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/replication_watcher.go#L59-L82 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/replication_watcher.go | Open | func (rpw *ReplicationWatcher) Open() {
if rpw.isOpen || !rpw.watchReplication {
return
}
ctx, cancel := context.WithCancel(tabletenv.LocalContext())
rpw.cancel = cancel
rpw.wg.Add(1)
go rpw.Process(ctx, rpw.dbconfigs)
rpw.isOpen = true
} | go | func (rpw *ReplicationWatcher) Open() {
if rpw.isOpen || !rpw.watchReplication {
return
}
ctx, cancel := context.WithCancel(tabletenv.LocalContext())
rpw.cancel = cancel
rpw.wg.Add(1)
go rpw.Process(ctx, rpw.dbconfigs)
rpw.isOpen = true
} | [
"func",
"(",
"rpw",
"*",
"ReplicationWatcher",
")",
"Open",
"(",
")",
"{",
"if",
"rpw",
".",
"isOpen",
"||",
"!",
"rpw",
".",
"watchReplication",
"{",
"return",
"\n",
"}",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"tabletenv",
".",
"LocalContext",
"(",
")",
")",
"\n",
"rpw",
".",
"cancel",
"=",
"cancel",
"\n",
"rpw",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"rpw",
".",
"Process",
"(",
"ctx",
",",
"rpw",
".",
"dbconfigs",
")",
"\n",
"rpw",
".",
"isOpen",
"=",
"true",
"\n",
"}"
] | // Open starts the ReplicationWatcher service. | [
"Open",
"starts",
"the",
"ReplicationWatcher",
"service",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/replication_watcher.go#L90-L99 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/replication_watcher.go | Close | func (rpw *ReplicationWatcher) Close() {
if !rpw.isOpen {
return
}
rpw.cancel()
rpw.wg.Wait()
rpw.isOpen = false
} | go | func (rpw *ReplicationWatcher) Close() {
if !rpw.isOpen {
return
}
rpw.cancel()
rpw.wg.Wait()
rpw.isOpen = false
} | [
"func",
"(",
"rpw",
"*",
"ReplicationWatcher",
")",
"Close",
"(",
")",
"{",
"if",
"!",
"rpw",
".",
"isOpen",
"{",
"return",
"\n",
"}",
"\n",
"rpw",
".",
"cancel",
"(",
")",
"\n",
"rpw",
".",
"wg",
".",
"Wait",
"(",
")",
"\n",
"rpw",
".",
"isOpen",
"=",
"false",
"\n",
"}"
] | // Close stops the ReplicationWatcher service. | [
"Close",
"stops",
"the",
"ReplicationWatcher",
"service",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/replication_watcher.go#L102-L109 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/replication_watcher.go | Process | func (rpw *ReplicationWatcher) Process(ctx context.Context, dbconfigs *dbconfigs.DBConfigs) {
defer func() {
tabletenv.LogError()
rpw.wg.Done()
}()
for {
log.Infof("Starting a binlog Streamer from current replication position to monitor binlogs")
streamer := binlog.NewStreamer(dbconfigs.DbaWithDB(), rpw.se, nil /*clientCharset*/, mysql.Position{}, 0 /*timestamp*/, func(eventToken *querypb.EventToken, statements []binlog.FullBinlogStatement) error {
// Save the event token.
rpw.mu.Lock()
rpw.eventToken = eventToken
rpw.mu.Unlock()
// If it's a DDL, trigger a schema reload.
for _, statement := range statements {
if statement.Statement.Category != binlogdatapb.BinlogTransaction_Statement_BL_DDL {
continue
}
err := rpw.se.Reload(ctx)
log.Infof("Streamer triggered a schema reload, with result: %v", err)
return nil
}
return nil
})
if err := streamer.Stream(ctx); err != nil {
log.Infof("Streamer stopped: %v", err)
}
select {
case <-ctx.Done():
return
case <-time.After(5 * time.Second):
}
}
} | go | func (rpw *ReplicationWatcher) Process(ctx context.Context, dbconfigs *dbconfigs.DBConfigs) {
defer func() {
tabletenv.LogError()
rpw.wg.Done()
}()
for {
log.Infof("Starting a binlog Streamer from current replication position to monitor binlogs")
streamer := binlog.NewStreamer(dbconfigs.DbaWithDB(), rpw.se, nil /*clientCharset*/, mysql.Position{}, 0 /*timestamp*/, func(eventToken *querypb.EventToken, statements []binlog.FullBinlogStatement) error {
// Save the event token.
rpw.mu.Lock()
rpw.eventToken = eventToken
rpw.mu.Unlock()
// If it's a DDL, trigger a schema reload.
for _, statement := range statements {
if statement.Statement.Category != binlogdatapb.BinlogTransaction_Statement_BL_DDL {
continue
}
err := rpw.se.Reload(ctx)
log.Infof("Streamer triggered a schema reload, with result: %v", err)
return nil
}
return nil
})
if err := streamer.Stream(ctx); err != nil {
log.Infof("Streamer stopped: %v", err)
}
select {
case <-ctx.Done():
return
case <-time.After(5 * time.Second):
}
}
} | [
"func",
"(",
"rpw",
"*",
"ReplicationWatcher",
")",
"Process",
"(",
"ctx",
"context",
".",
"Context",
",",
"dbconfigs",
"*",
"dbconfigs",
".",
"DBConfigs",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"tabletenv",
".",
"LogError",
"(",
")",
"\n",
"rpw",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"for",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"streamer",
":=",
"binlog",
".",
"NewStreamer",
"(",
"dbconfigs",
".",
"DbaWithDB",
"(",
")",
",",
"rpw",
".",
"se",
",",
"nil",
"/*clientCharset*/",
",",
"mysql",
".",
"Position",
"{",
"}",
",",
"0",
"/*timestamp*/",
",",
"func",
"(",
"eventToken",
"*",
"querypb",
".",
"EventToken",
",",
"statements",
"[",
"]",
"binlog",
".",
"FullBinlogStatement",
")",
"error",
"{",
"// Save the event token.",
"rpw",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"rpw",
".",
"eventToken",
"=",
"eventToken",
"\n",
"rpw",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// If it's a DDL, trigger a schema reload.",
"for",
"_",
",",
"statement",
":=",
"range",
"statements",
"{",
"if",
"statement",
".",
"Statement",
".",
"Category",
"!=",
"binlogdatapb",
".",
"BinlogTransaction_Statement_BL_DDL",
"{",
"continue",
"\n",
"}",
"\n",
"err",
":=",
"rpw",
".",
"se",
".",
"Reload",
"(",
"ctx",
")",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}",
")",
"\n\n",
"if",
"err",
":=",
"streamer",
".",
"Stream",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"\n",
"case",
"<-",
"time",
".",
"After",
"(",
"5",
"*",
"time",
".",
"Second",
")",
":",
"}",
"\n",
"}",
"\n",
"}"
] | // Process processes the replication stream. | [
"Process",
"processes",
"the",
"replication",
"stream",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/replication_watcher.go#L112-L148 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/replication_watcher.go | ComputeExtras | func (rpw *ReplicationWatcher) ComputeExtras(options *querypb.ExecuteOptions) *querypb.ResultExtras {
if options == nil {
// No options passed in.
return nil
}
if !options.IncludeEventToken && options.CompareEventToken == nil {
// The flags that make extras exist are not there.
return nil
}
et := rpw.EventToken()
if et == nil {
return nil
}
var extras *querypb.ResultExtras
// See if we need to fill in EventToken.
if options.IncludeEventToken {
extras = &querypb.ResultExtras{
EventToken: et,
}
}
// See if we need to compare.
if options.CompareEventToken != nil {
if eventtoken.Fresher(et, options.CompareEventToken) >= 0 {
// For a query, we are fresher if greater or equal
// to the provided compare_event_token.
if extras == nil {
extras = &querypb.ResultExtras{
Fresher: true,
}
} else {
extras.Fresher = true
}
}
}
return extras
} | go | func (rpw *ReplicationWatcher) ComputeExtras(options *querypb.ExecuteOptions) *querypb.ResultExtras {
if options == nil {
// No options passed in.
return nil
}
if !options.IncludeEventToken && options.CompareEventToken == nil {
// The flags that make extras exist are not there.
return nil
}
et := rpw.EventToken()
if et == nil {
return nil
}
var extras *querypb.ResultExtras
// See if we need to fill in EventToken.
if options.IncludeEventToken {
extras = &querypb.ResultExtras{
EventToken: et,
}
}
// See if we need to compare.
if options.CompareEventToken != nil {
if eventtoken.Fresher(et, options.CompareEventToken) >= 0 {
// For a query, we are fresher if greater or equal
// to the provided compare_event_token.
if extras == nil {
extras = &querypb.ResultExtras{
Fresher: true,
}
} else {
extras.Fresher = true
}
}
}
return extras
} | [
"func",
"(",
"rpw",
"*",
"ReplicationWatcher",
")",
"ComputeExtras",
"(",
"options",
"*",
"querypb",
".",
"ExecuteOptions",
")",
"*",
"querypb",
".",
"ResultExtras",
"{",
"if",
"options",
"==",
"nil",
"{",
"// No options passed in.",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"!",
"options",
".",
"IncludeEventToken",
"&&",
"options",
".",
"CompareEventToken",
"==",
"nil",
"{",
"// The flags that make extras exist are not there.",
"return",
"nil",
"\n",
"}",
"\n\n",
"et",
":=",
"rpw",
".",
"EventToken",
"(",
")",
"\n",
"if",
"et",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"extras",
"*",
"querypb",
".",
"ResultExtras",
"\n\n",
"// See if we need to fill in EventToken.",
"if",
"options",
".",
"IncludeEventToken",
"{",
"extras",
"=",
"&",
"querypb",
".",
"ResultExtras",
"{",
"EventToken",
":",
"et",
",",
"}",
"\n",
"}",
"\n\n",
"// See if we need to compare.",
"if",
"options",
".",
"CompareEventToken",
"!=",
"nil",
"{",
"if",
"eventtoken",
".",
"Fresher",
"(",
"et",
",",
"options",
".",
"CompareEventToken",
")",
">=",
"0",
"{",
"// For a query, we are fresher if greater or equal",
"// to the provided compare_event_token.",
"if",
"extras",
"==",
"nil",
"{",
"extras",
"=",
"&",
"querypb",
".",
"ResultExtras",
"{",
"Fresher",
":",
"true",
",",
"}",
"\n",
"}",
"else",
"{",
"extras",
".",
"Fresher",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"extras",
"\n",
"}"
] | // ComputeExtras returns the requested ResultExtras based on the supplied options. | [
"ComputeExtras",
"returns",
"the",
"requested",
"ResultExtras",
"based",
"on",
"the",
"supplied",
"options",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/replication_watcher.go#L151-L191 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.