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/vtgate/vtgate.go
unambiguousKeyspaceBKSIQ
func unambiguousKeyspaceBKSIQ(queries []*vtgatepb.BoundKeyspaceIdQuery) string { switch len(queries) { case 0: return "" case 1: return queries[0].Keyspace default: keyspace := queries[0].Keyspace for _, q := range queries[1:] { if q.Keyspace != keyspace { // Request targets at least two different keyspaces. return "" } } return keyspace } }
go
func unambiguousKeyspaceBKSIQ(queries []*vtgatepb.BoundKeyspaceIdQuery) string { switch len(queries) { case 0: return "" case 1: return queries[0].Keyspace default: keyspace := queries[0].Keyspace for _, q := range queries[1:] { if q.Keyspace != keyspace { // Request targets at least two different keyspaces. return "" } } return keyspace } }
[ "func", "unambiguousKeyspaceBKSIQ", "(", "queries", "[", "]", "*", "vtgatepb", ".", "BoundKeyspaceIdQuery", ")", "string", "{", "switch", "len", "(", "queries", ")", "{", "case", "0", ":", "return", "\"", "\"", "\n", "case", "1", ":", "return", "queries", "[", "0", "]", ".", "Keyspace", "\n", "default", ":", "keyspace", ":=", "queries", "[", "0", "]", ".", "Keyspace", "\n", "for", "_", ",", "q", ":=", "range", "queries", "[", "1", ":", "]", "{", "if", "q", ".", "Keyspace", "!=", "keyspace", "{", "// Request targets at least two different keyspaces.", "return", "\"", "\"", "\n", "}", "\n", "}", "\n", "return", "keyspace", "\n", "}", "\n", "}" ]
// unambiguousKeyspaceBKSIQ is a helper function used in the // ExecuteBatchKeyspaceIds method to determine the "keyspace" label for the // stats reporting. // If all queries target the same keyspace, it returns that keyspace. // Otherwise it returns an empty string.
[ "unambiguousKeyspaceBKSIQ", "is", "a", "helper", "function", "used", "in", "the", "ExecuteBatchKeyspaceIds", "method", "to", "determine", "the", "keyspace", "label", "for", "the", "stats", "reporting", ".", "If", "all", "queries", "target", "the", "same", "keyspace", "it", "returns", "that", "keyspace", ".", "Otherwise", "it", "returns", "an", "empty", "string", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vtgate.go#L1132-L1148
train
vitessio/vitess
go/vt/vtgate/vtgate.go
unambiguousKeyspaceBSQ
func unambiguousKeyspaceBSQ(queries []*vtgatepb.BoundShardQuery) string { switch len(queries) { case 0: return "" case 1: return queries[0].Keyspace default: keyspace := queries[0].Keyspace for _, q := range queries[1:] { if q.Keyspace != keyspace { // Request targets at least two different keyspaces. return "" } } return keyspace } }
go
func unambiguousKeyspaceBSQ(queries []*vtgatepb.BoundShardQuery) string { switch len(queries) { case 0: return "" case 1: return queries[0].Keyspace default: keyspace := queries[0].Keyspace for _, q := range queries[1:] { if q.Keyspace != keyspace { // Request targets at least two different keyspaces. return "" } } return keyspace } }
[ "func", "unambiguousKeyspaceBSQ", "(", "queries", "[", "]", "*", "vtgatepb", ".", "BoundShardQuery", ")", "string", "{", "switch", "len", "(", "queries", ")", "{", "case", "0", ":", "return", "\"", "\"", "\n", "case", "1", ":", "return", "queries", "[", "0", "]", ".", "Keyspace", "\n", "default", ":", "keyspace", ":=", "queries", "[", "0", "]", ".", "Keyspace", "\n", "for", "_", ",", "q", ":=", "range", "queries", "[", "1", ":", "]", "{", "if", "q", ".", "Keyspace", "!=", "keyspace", "{", "// Request targets at least two different keyspaces.", "return", "\"", "\"", "\n", "}", "\n", "}", "\n", "return", "keyspace", "\n", "}", "\n", "}" ]
// unambiguousKeyspaceBSQ is the same as unambiguousKeyspaceBKSIQ but for the // ExecuteBatchShards method. We are intentionally duplicating the code here and // do not try to generalize it because this may be less performant.
[ "unambiguousKeyspaceBSQ", "is", "the", "same", "as", "unambiguousKeyspaceBKSIQ", "but", "for", "the", "ExecuteBatchShards", "method", ".", "We", "are", "intentionally", "duplicating", "the", "code", "here", "and", "do", "not", "try", "to", "generalize", "it", "because", "this", "may", "be", "less", "performant", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vtgate.go#L1153-L1169
train
vitessio/vitess
go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go
MaxRates
func (c *client) MaxRates(ctx context.Context) (map[string]int64, error) { response, err := c.gRPCClient.MaxRates(ctx, &throttlerdatapb.MaxRatesRequest{}) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Rates, nil }
go
func (c *client) MaxRates(ctx context.Context) (map[string]int64, error) { response, err := c.gRPCClient.MaxRates(ctx, &throttlerdatapb.MaxRatesRequest{}) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Rates, nil }
[ "func", "(", "c", "*", "client", ")", "MaxRates", "(", "ctx", "context", ".", "Context", ")", "(", "map", "[", "string", "]", "int64", ",", "error", ")", "{", "response", ",", "err", ":=", "c", ".", "gRPCClient", ".", "MaxRates", "(", "ctx", ",", "&", "throttlerdatapb", ".", "MaxRatesRequest", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "vterrors", ".", "FromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "response", ".", "Rates", ",", "nil", "\n", "}" ]
// MaxRates is part of the throttlerclient.Client interface and returns the // current max rate for each throttler of the process.
[ "MaxRates", "is", "part", "of", "the", "throttlerclient", ".", "Client", "interface", "and", "returns", "the", "current", "max", "rate", "for", "each", "throttler", "of", "the", "process", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go#L62-L68
train
vitessio/vitess
go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go
SetMaxRate
func (c *client) SetMaxRate(ctx context.Context, rate int64) ([]string, error) { request := &throttlerdatapb.SetMaxRateRequest{ Rate: rate, } response, err := c.gRPCClient.SetMaxRate(ctx, request) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Names, nil }
go
func (c *client) SetMaxRate(ctx context.Context, rate int64) ([]string, error) { request := &throttlerdatapb.SetMaxRateRequest{ Rate: rate, } response, err := c.gRPCClient.SetMaxRate(ctx, request) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Names, nil }
[ "func", "(", "c", "*", "client", ")", "SetMaxRate", "(", "ctx", "context", ".", "Context", ",", "rate", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "request", ":=", "&", "throttlerdatapb", ".", "SetMaxRateRequest", "{", "Rate", ":", "rate", ",", "}", "\n\n", "response", ",", "err", ":=", "c", ".", "gRPCClient", ".", "SetMaxRate", "(", "ctx", ",", "request", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "vterrors", ".", "FromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "response", ".", "Names", ",", "nil", "\n", "}" ]
// SetMaxRate is part of the throttlerclient.Client interface and sets the rate // on all throttlers of the server.
[ "SetMaxRate", "is", "part", "of", "the", "throttlerclient", ".", "Client", "interface", "and", "sets", "the", "rate", "on", "all", "throttlers", "of", "the", "server", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go#L72-L82
train
vitessio/vitess
go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go
GetConfiguration
func (c *client) GetConfiguration(ctx context.Context, throttlerName string) (map[string]*throttlerdatapb.Configuration, error) { response, err := c.gRPCClient.GetConfiguration(ctx, &throttlerdatapb.GetConfigurationRequest{ ThrottlerName: throttlerName, }) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Configurations, nil }
go
func (c *client) GetConfiguration(ctx context.Context, throttlerName string) (map[string]*throttlerdatapb.Configuration, error) { response, err := c.gRPCClient.GetConfiguration(ctx, &throttlerdatapb.GetConfigurationRequest{ ThrottlerName: throttlerName, }) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Configurations, nil }
[ "func", "(", "c", "*", "client", ")", "GetConfiguration", "(", "ctx", "context", ".", "Context", ",", "throttlerName", "string", ")", "(", "map", "[", "string", "]", "*", "throttlerdatapb", ".", "Configuration", ",", "error", ")", "{", "response", ",", "err", ":=", "c", ".", "gRPCClient", ".", "GetConfiguration", "(", "ctx", ",", "&", "throttlerdatapb", ".", "GetConfigurationRequest", "{", "ThrottlerName", ":", "throttlerName", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "vterrors", ".", "FromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "response", ".", "Configurations", ",", "nil", "\n", "}" ]
// GetConfiguration is part of the throttlerclient.Client interface.
[ "GetConfiguration", "is", "part", "of", "the", "throttlerclient", ".", "Client", "interface", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go#L85-L93
train
vitessio/vitess
go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go
UpdateConfiguration
func (c *client) UpdateConfiguration(ctx context.Context, throttlerName string, configuration *throttlerdatapb.Configuration, copyZeroValues bool) ([]string, error) { response, err := c.gRPCClient.UpdateConfiguration(ctx, &throttlerdatapb.UpdateConfigurationRequest{ ThrottlerName: throttlerName, Configuration: configuration, CopyZeroValues: copyZeroValues, }) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Names, nil }
go
func (c *client) UpdateConfiguration(ctx context.Context, throttlerName string, configuration *throttlerdatapb.Configuration, copyZeroValues bool) ([]string, error) { response, err := c.gRPCClient.UpdateConfiguration(ctx, &throttlerdatapb.UpdateConfigurationRequest{ ThrottlerName: throttlerName, Configuration: configuration, CopyZeroValues: copyZeroValues, }) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Names, nil }
[ "func", "(", "c", "*", "client", ")", "UpdateConfiguration", "(", "ctx", "context", ".", "Context", ",", "throttlerName", "string", ",", "configuration", "*", "throttlerdatapb", ".", "Configuration", ",", "copyZeroValues", "bool", ")", "(", "[", "]", "string", ",", "error", ")", "{", "response", ",", "err", ":=", "c", ".", "gRPCClient", ".", "UpdateConfiguration", "(", "ctx", ",", "&", "throttlerdatapb", ".", "UpdateConfigurationRequest", "{", "ThrottlerName", ":", "throttlerName", ",", "Configuration", ":", "configuration", ",", "CopyZeroValues", ":", "copyZeroValues", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "vterrors", ".", "FromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "response", ".", "Names", ",", "nil", "\n", "}" ]
// UpdateConfiguration is part of the throttlerclient.Client interface.
[ "UpdateConfiguration", "is", "part", "of", "the", "throttlerclient", ".", "Client", "interface", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go#L96-L106
train
vitessio/vitess
go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go
ResetConfiguration
func (c *client) ResetConfiguration(ctx context.Context, throttlerName string) ([]string, error) { response, err := c.gRPCClient.ResetConfiguration(ctx, &throttlerdatapb.ResetConfigurationRequest{ ThrottlerName: throttlerName, }) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Names, nil }
go
func (c *client) ResetConfiguration(ctx context.Context, throttlerName string) ([]string, error) { response, err := c.gRPCClient.ResetConfiguration(ctx, &throttlerdatapb.ResetConfigurationRequest{ ThrottlerName: throttlerName, }) if err != nil { return nil, vterrors.FromGRPC(err) } return response.Names, nil }
[ "func", "(", "c", "*", "client", ")", "ResetConfiguration", "(", "ctx", "context", ".", "Context", ",", "throttlerName", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "response", ",", "err", ":=", "c", ".", "gRPCClient", ".", "ResetConfiguration", "(", "ctx", ",", "&", "throttlerdatapb", ".", "ResetConfigurationRequest", "{", "ThrottlerName", ":", "throttlerName", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "vterrors", ".", "FromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "response", ".", "Names", ",", "nil", "\n", "}" ]
// ResetConfiguration is part of the throttlerclient.Client interface.
[ "ResetConfiguration", "is", "part", "of", "the", "throttlerclient", ".", "Client", "interface", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/grpcthrottlerclient/grpcthrottlerclient.go#L109-L117
train
vitessio/vitess
go/vt/mysqlctl/reparent.go
PopulateReparentJournal
func PopulateReparentJournal(timeCreatedNS int64, actionName, masterAlias string, pos mysql.Position) string { posStr := mysql.EncodePosition(pos) if len(posStr) > mysql.MaximumPositionSize { posStr = posStr[:mysql.MaximumPositionSize] } return fmt.Sprintf("INSERT INTO _vt.reparent_journal "+ "(time_created_ns, action_name, master_alias, replication_position) "+ "VALUES (%v, '%v', '%v', '%v')", timeCreatedNS, actionName, masterAlias, posStr) }
go
func PopulateReparentJournal(timeCreatedNS int64, actionName, masterAlias string, pos mysql.Position) string { posStr := mysql.EncodePosition(pos) if len(posStr) > mysql.MaximumPositionSize { posStr = posStr[:mysql.MaximumPositionSize] } return fmt.Sprintf("INSERT INTO _vt.reparent_journal "+ "(time_created_ns, action_name, master_alias, replication_position) "+ "VALUES (%v, '%v', '%v', '%v')", timeCreatedNS, actionName, masterAlias, posStr) }
[ "func", "PopulateReparentJournal", "(", "timeCreatedNS", "int64", ",", "actionName", ",", "masterAlias", "string", ",", "pos", "mysql", ".", "Position", ")", "string", "{", "posStr", ":=", "mysql", ".", "EncodePosition", "(", "pos", ")", "\n", "if", "len", "(", "posStr", ")", ">", "mysql", ".", "MaximumPositionSize", "{", "posStr", "=", "posStr", "[", ":", "mysql", ".", "MaximumPositionSize", "]", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", "+", "\"", "\"", ",", "timeCreatedNS", ",", "actionName", ",", "masterAlias", ",", "posStr", ")", "\n", "}" ]
// PopulateReparentJournal returns the SQL command to use to populate // the _vt.reparent_journal table, as well as the time_created_ns // value used.
[ "PopulateReparentJournal", "returns", "the", "SQL", "command", "to", "use", "to", "populate", "the", "_vt", ".", "reparent_journal", "table", "as", "well", "as", "the", "time_created_ns", "value", "used", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/reparent.go#L56-L65
train
vitessio/vitess
go/vt/mysqlctl/reparent.go
WaitForReparentJournal
func (mysqld *Mysqld) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error { for { qr, err := mysqld.FetchSuperQuery(ctx, queryReparentJournal(timeCreatedNS)) if err == nil && len(qr.Rows) == 1 { // we have the row, we're done return nil } // wait a little bit, interrupt if context is done t := time.After(100 * time.Millisecond) select { case <-ctx.Done(): return ctx.Err() case <-t: } } }
go
func (mysqld *Mysqld) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error { for { qr, err := mysqld.FetchSuperQuery(ctx, queryReparentJournal(timeCreatedNS)) if err == nil && len(qr.Rows) == 1 { // we have the row, we're done return nil } // wait a little bit, interrupt if context is done t := time.After(100 * time.Millisecond) select { case <-ctx.Done(): return ctx.Err() case <-t: } } }
[ "func", "(", "mysqld", "*", "Mysqld", ")", "WaitForReparentJournal", "(", "ctx", "context", ".", "Context", ",", "timeCreatedNS", "int64", ")", "error", "{", "for", "{", "qr", ",", "err", ":=", "mysqld", ".", "FetchSuperQuery", "(", "ctx", ",", "queryReparentJournal", "(", "timeCreatedNS", ")", ")", "\n", "if", "err", "==", "nil", "&&", "len", "(", "qr", ".", "Rows", ")", "==", "1", "{", "// we have the row, we're done", "return", "nil", "\n", "}", "\n\n", "// wait a little bit, interrupt if context is done", "t", ":=", "time", ".", "After", "(", "100", "*", "time", ".", "Millisecond", ")", "\n", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "ctx", ".", "Err", "(", ")", "\n", "case", "<-", "t", ":", "}", "\n", "}", "\n", "}" ]
// WaitForReparentJournal will wait until the context is done for // the row in the reparent_journal table.
[ "WaitForReparentJournal", "will", "wait", "until", "the", "context", "is", "done", "for", "the", "row", "in", "the", "reparent_journal", "table", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/reparent.go#L75-L91
train
vitessio/vitess
go/vt/mysqlctl/reparent.go
DemoteMaster
func (mysqld *Mysqld) DemoteMaster() (rp mysql.Position, err error) { cmds := []string{ "FLUSH TABLES WITH READ LOCK", "UNLOCK TABLES", } if err = mysqld.ExecuteSuperQueryList(context.TODO(), cmds); err != nil { return rp, err } return mysqld.MasterPosition() }
go
func (mysqld *Mysqld) DemoteMaster() (rp mysql.Position, err error) { cmds := []string{ "FLUSH TABLES WITH READ LOCK", "UNLOCK TABLES", } if err = mysqld.ExecuteSuperQueryList(context.TODO(), cmds); err != nil { return rp, err } return mysqld.MasterPosition() }
[ "func", "(", "mysqld", "*", "Mysqld", ")", "DemoteMaster", "(", ")", "(", "rp", "mysql", ".", "Position", ",", "err", "error", ")", "{", "cmds", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "}", "\n", "if", "err", "=", "mysqld", ".", "ExecuteSuperQueryList", "(", "context", ".", "TODO", "(", ")", ",", "cmds", ")", ";", "err", "!=", "nil", "{", "return", "rp", ",", "err", "\n", "}", "\n", "return", "mysqld", ".", "MasterPosition", "(", ")", "\n", "}" ]
// DemoteMaster will gracefully demote a master mysql instance to read only. // If the master is still alive, then we need to demote it gracefully // make it read-only, flush the writes and get the position
[ "DemoteMaster", "will", "gracefully", "demote", "a", "master", "mysql", "instance", "to", "read", "only", ".", "If", "the", "master", "is", "still", "alive", "then", "we", "need", "to", "demote", "it", "gracefully", "make", "it", "read", "-", "only", "flush", "the", "writes", "and", "get", "the", "position" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/reparent.go#L96-L105
train
vitessio/vitess
go/vt/mysqlctl/reparent.go
PromoteSlave
func (mysqld *Mysqld) PromoteSlave(hookExtraEnv map[string]string) (mysql.Position, error) { ctx := context.TODO() conn, err := getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return mysql.Position{}, err } defer conn.Recycle() // Since we handle replication, just stop it. cmds := []string{ conn.StopSlaveCommand(), "RESET SLAVE ALL", // "ALL" makes it forget master host:port. // When using semi-sync and GTID, a replica first connects to the new master with a given GTID set, // it can take a long time to scan the current binlog file to find the corresponding position. // This can cause commits that occur soon after the master is promoted to take a long time waiting // for a semi-sync ACK, since replication is not fully set up. // More details in: https://github.com/vitessio/vitess/issues/4161 "FLUSH BINARY LOGS", } if err := mysqld.executeSuperQueryListConn(ctx, conn, cmds); err != nil { return mysql.Position{}, err } return conn.MasterPosition() }
go
func (mysqld *Mysqld) PromoteSlave(hookExtraEnv map[string]string) (mysql.Position, error) { ctx := context.TODO() conn, err := getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return mysql.Position{}, err } defer conn.Recycle() // Since we handle replication, just stop it. cmds := []string{ conn.StopSlaveCommand(), "RESET SLAVE ALL", // "ALL" makes it forget master host:port. // When using semi-sync and GTID, a replica first connects to the new master with a given GTID set, // it can take a long time to scan the current binlog file to find the corresponding position. // This can cause commits that occur soon after the master is promoted to take a long time waiting // for a semi-sync ACK, since replication is not fully set up. // More details in: https://github.com/vitessio/vitess/issues/4161 "FLUSH BINARY LOGS", } if err := mysqld.executeSuperQueryListConn(ctx, conn, cmds); err != nil { return mysql.Position{}, err } return conn.MasterPosition() }
[ "func", "(", "mysqld", "*", "Mysqld", ")", "PromoteSlave", "(", "hookExtraEnv", "map", "[", "string", "]", "string", ")", "(", "mysql", ".", "Position", ",", "error", ")", "{", "ctx", ":=", "context", ".", "TODO", "(", ")", "\n", "conn", ",", "err", ":=", "getPoolReconnect", "(", "ctx", ",", "mysqld", ".", "dbaPool", ")", "\n", "if", "err", "!=", "nil", "{", "return", "mysql", ".", "Position", "{", "}", ",", "err", "\n", "}", "\n", "defer", "conn", ".", "Recycle", "(", ")", "\n\n", "// Since we handle replication, just stop it.", "cmds", ":=", "[", "]", "string", "{", "conn", ".", "StopSlaveCommand", "(", ")", ",", "\"", "\"", ",", "// \"ALL\" makes it forget master host:port.", "// When using semi-sync and GTID, a replica first connects to the new master with a given GTID set,", "// it can take a long time to scan the current binlog file to find the corresponding position.", "// This can cause commits that occur soon after the master is promoted to take a long time waiting", "// for a semi-sync ACK, since replication is not fully set up.", "// More details in: https://github.com/vitessio/vitess/issues/4161", "\"", "\"", ",", "}", "\n\n", "if", "err", ":=", "mysqld", ".", "executeSuperQueryListConn", "(", "ctx", ",", "conn", ",", "cmds", ")", ";", "err", "!=", "nil", "{", "return", "mysql", ".", "Position", "{", "}", ",", "err", "\n", "}", "\n", "return", "conn", ".", "MasterPosition", "(", ")", "\n", "}" ]
// PromoteSlave will promote a slave to be the new master.
[ "PromoteSlave", "will", "promote", "a", "slave", "to", "be", "the", "new", "master", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/reparent.go#L108-L132
train
vitessio/vitess
go/vt/vtgate/gateway/gateway.go
RegisterCreator
func RegisterCreator(name string, gc Creator) { if _, ok := creators[name]; ok { log.Fatalf("Gateway %s already exists", name) } creators[name] = gc }
go
func RegisterCreator(name string, gc Creator) { if _, ok := creators[name]; ok { log.Fatalf("Gateway %s already exists", name) } creators[name] = gc }
[ "func", "RegisterCreator", "(", "name", "string", ",", "gc", "Creator", ")", "{", "if", "_", ",", "ok", ":=", "creators", "[", "name", "]", ";", "ok", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "creators", "[", "name", "]", "=", "gc", "\n", "}" ]
// RegisterCreator registers a Creator with given name.
[ "RegisterCreator", "registers", "a", "Creator", "with", "given", "name", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/gateway/gateway.go#L88-L93
train
vitessio/vitess
go/vt/vtgate/gateway/gateway.go
GetCreator
func GetCreator() Creator { gc, ok := creators[*implementation] if !ok { log.Exitf("No gateway registered as %s", *implementation) } return gc }
go
func GetCreator() Creator { gc, ok := creators[*implementation] if !ok { log.Exitf("No gateway registered as %s", *implementation) } return gc }
[ "func", "GetCreator", "(", ")", "Creator", "{", "gc", ",", "ok", ":=", "creators", "[", "*", "implementation", "]", "\n", "if", "!", "ok", "{", "log", ".", "Exitf", "(", "\"", "\"", ",", "*", "implementation", ")", "\n", "}", "\n", "return", "gc", "\n", "}" ]
// GetCreator returns the Creator specified by the gateway_implementation flag.
[ "GetCreator", "returns", "the", "Creator", "specified", "by", "the", "gateway_implementation", "flag", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/gateway/gateway.go#L96-L102
train
vitessio/vitess
go/stats/histogram.go
Add
func (h *Histogram) Add(value int64) { for i := range h.labels { if i == len(h.labels)-1 || value <= h.cutoffs[i] { h.buckets[i].Add(1) h.total.Add(value) break } } if h.hook != nil { h.hook(value) } }
go
func (h *Histogram) Add(value int64) { for i := range h.labels { if i == len(h.labels)-1 || value <= h.cutoffs[i] { h.buckets[i].Add(1) h.total.Add(value) break } } if h.hook != nil { h.hook(value) } }
[ "func", "(", "h", "*", "Histogram", ")", "Add", "(", "value", "int64", ")", "{", "for", "i", ":=", "range", "h", ".", "labels", "{", "if", "i", "==", "len", "(", "h", ".", "labels", ")", "-", "1", "||", "value", "<=", "h", ".", "cutoffs", "[", "i", "]", "{", "h", ".", "buckets", "[", "i", "]", ".", "Add", "(", "1", ")", "\n", "h", ".", "total", ".", "Add", "(", "value", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "h", ".", "hook", "!=", "nil", "{", "h", ".", "hook", "(", "value", ")", "\n", "}", "\n", "}" ]
// Add adds a new measurement to the Histogram.
[ "Add", "adds", "a", "new", "measurement", "to", "the", "Histogram", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/histogram.go#L77-L88
train
vitessio/vitess
go/stats/histogram.go
Counts
func (h *Histogram) Counts() map[string]int64 { counts := make(map[string]int64, len(h.labels)) for i, label := range h.labels { counts[label] = h.buckets[i].Get() } return counts }
go
func (h *Histogram) Counts() map[string]int64 { counts := make(map[string]int64, len(h.labels)) for i, label := range h.labels { counts[label] = h.buckets[i].Get() } return counts }
[ "func", "(", "h", "*", "Histogram", ")", "Counts", "(", ")", "map", "[", "string", "]", "int64", "{", "counts", ":=", "make", "(", "map", "[", "string", "]", "int64", ",", "len", "(", "h", ".", "labels", ")", ")", "\n", "for", "i", ",", "label", ":=", "range", "h", ".", "labels", "{", "counts", "[", "label", "]", "=", "h", ".", "buckets", "[", "i", "]", ".", "Get", "(", ")", "\n", "}", "\n", "return", "counts", "\n", "}" ]
// Counts returns a map from labels to the current count in the Histogram for that label.
[ "Counts", "returns", "a", "map", "from", "labels", "to", "the", "current", "count", "in", "the", "Histogram", "for", "that", "label", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/histogram.go#L116-L122
train
vitessio/vitess
go/stats/histogram.go
Count
func (h *Histogram) Count() (count int64) { for i := range h.buckets { count += h.buckets[i].Get() } return }
go
func (h *Histogram) Count() (count int64) { for i := range h.buckets { count += h.buckets[i].Get() } return }
[ "func", "(", "h", "*", "Histogram", ")", "Count", "(", ")", "(", "count", "int64", ")", "{", "for", "i", ":=", "range", "h", ".", "buckets", "{", "count", "+=", "h", ".", "buckets", "[", "i", "]", ".", "Get", "(", ")", "\n", "}", "\n", "return", "\n", "}" ]
// Count returns the number of times Add has been called.
[ "Count", "returns", "the", "number", "of", "times", "Add", "has", "been", "called", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/histogram.go#L130-L135
train
vitessio/vitess
go/stats/histogram.go
Buckets
func (h *Histogram) Buckets() []int64 { buckets := make([]int64, len(h.buckets)) for i := range h.buckets { buckets[i] = h.buckets[i].Get() } return buckets }
go
func (h *Histogram) Buckets() []int64 { buckets := make([]int64, len(h.buckets)) for i := range h.buckets { buckets[i] = h.buckets[i].Get() } return buckets }
[ "func", "(", "h", "*", "Histogram", ")", "Buckets", "(", ")", "[", "]", "int64", "{", "buckets", ":=", "make", "(", "[", "]", "int64", ",", "len", "(", "h", ".", "buckets", ")", ")", "\n", "for", "i", ":=", "range", "h", ".", "buckets", "{", "buckets", "[", "i", "]", "=", "h", ".", "buckets", "[", "i", "]", ".", "Get", "(", ")", "\n", "}", "\n", "return", "buckets", "\n", "}" ]
// Buckets returns a snapshot of the current values in all buckets.
[ "Buckets", "returns", "a", "snapshot", "of", "the", "current", "values", "in", "all", "buckets", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/histogram.go#L158-L164
train
vitessio/vitess
go/vt/callinfo/fakecallinfo/fakecallinfo.go
Text
func (fci *FakeCallInfo) Text() string { return fmt.Sprintf("%s:%s(fakeRPC)", fci.Remote, fci.Method) }
go
func (fci *FakeCallInfo) Text() string { return fmt.Sprintf("%s:%s(fakeRPC)", fci.Remote, fci.Method) }
[ "func", "(", "fci", "*", "FakeCallInfo", ")", "Text", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "fci", ".", "Remote", ",", "fci", ".", "Method", ")", "\n", "}" ]
// Text returns the text.
[ "Text", "returns", "the", "text", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/callinfo/fakecallinfo/fakecallinfo.go#L43-L45
train
vitessio/vitess
go/vt/mysqlctl/gcsbackupstorage/gcs.go
EndBackup
func (bh *GCSBackupHandle) EndBackup(ctx context.Context) error { if bh.readOnly { return fmt.Errorf("EndBackup cannot be called on read-only backup") } return nil }
go
func (bh *GCSBackupHandle) EndBackup(ctx context.Context) error { if bh.readOnly { return fmt.Errorf("EndBackup cannot be called on read-only backup") } return nil }
[ "func", "(", "bh", "*", "GCSBackupHandle", ")", "EndBackup", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "bh", ".", "readOnly", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// EndBackup implements BackupHandle.
[ "EndBackup", "implements", "BackupHandle", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/gcsbackupstorage/gcs.go#L78-L83
train
vitessio/vitess
go/vt/mysqlctl/gcsbackupstorage/gcs.go
client
func (bs *GCSBackupStorage) client(ctx context.Context) (*storage.Client, error) { bs.mu.Lock() defer bs.mu.Unlock() if bs._client == nil { // The context needs to be valid for longer than just // the creation context, so we create a new one, but // keep the span information. ctx = trace.CopySpan(context.Background(), ctx) authClient, err := google.DefaultClient(ctx, storage.ScopeFullControl) if err != nil { return nil, err } client, err := storage.NewClient(ctx, option.WithHTTPClient(authClient)) if err != nil { return nil, err } bs._client = client } return bs._client, nil }
go
func (bs *GCSBackupStorage) client(ctx context.Context) (*storage.Client, error) { bs.mu.Lock() defer bs.mu.Unlock() if bs._client == nil { // The context needs to be valid for longer than just // the creation context, so we create a new one, but // keep the span information. ctx = trace.CopySpan(context.Background(), ctx) authClient, err := google.DefaultClient(ctx, storage.ScopeFullControl) if err != nil { return nil, err } client, err := storage.NewClient(ctx, option.WithHTTPClient(authClient)) if err != nil { return nil, err } bs._client = client } return bs._client, nil }
[ "func", "(", "bs", "*", "GCSBackupStorage", ")", "client", "(", "ctx", "context", ".", "Context", ")", "(", "*", "storage", ".", "Client", ",", "error", ")", "{", "bs", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "bs", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "bs", ".", "_client", "==", "nil", "{", "// The context needs to be valid for longer than just", "// the creation context, so we create a new one, but", "// keep the span information.", "ctx", "=", "trace", ".", "CopySpan", "(", "context", ".", "Background", "(", ")", ",", "ctx", ")", "\n", "authClient", ",", "err", ":=", "google", ".", "DefaultClient", "(", "ctx", ",", "storage", ".", "ScopeFullControl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "client", ",", "err", ":=", "storage", ".", "NewClient", "(", "ctx", ",", "option", ".", "WithHTTPClient", "(", "authClient", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "bs", ".", "_client", "=", "client", "\n", "}", "\n", "return", "bs", ".", "_client", ",", "nil", "\n", "}" ]
// client returns the GCS Storage client instance. // If there isn't one yet, it tries to create one.
[ "client", "returns", "the", "GCS", "Storage", "client", "instance", ".", "If", "there", "isn", "t", "one", "yet", "it", "tries", "to", "create", "one", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/gcsbackupstorage/gcs.go#L224-L244
train
vitessio/vitess
go/vt/mysqlctl/gcsbackupstorage/gcs.go
objName
func objName(parts ...string) string { if *root != "" { return *root + "/" + strings.Join(parts, "/") } return strings.Join(parts, "/") }
go
func objName(parts ...string) string { if *root != "" { return *root + "/" + strings.Join(parts, "/") } return strings.Join(parts, "/") }
[ "func", "objName", "(", "parts", "...", "string", ")", "string", "{", "if", "*", "root", "!=", "\"", "\"", "{", "return", "*", "root", "+", "\"", "\"", "+", "strings", ".", "Join", "(", "parts", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "strings", ".", "Join", "(", "parts", ",", "\"", "\"", ")", "\n", "}" ]
// objName joins path parts into an object name. // Unlike path.Join, it doesn't collapse ".." or strip trailing slashes. // It also adds the value of the -gcs_backup_storage_root flag if set.
[ "objName", "joins", "path", "parts", "into", "an", "object", "name", ".", "Unlike", "path", ".", "Join", "it", "doesn", "t", "collapse", "..", "or", "strip", "trailing", "slashes", ".", "It", "also", "adds", "the", "value", "of", "the", "-", "gcs_backup_storage_root", "flag", "if", "set", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/gcsbackupstorage/gcs.go#L249-L254
train
vitessio/vitess
go/vt/automation/vtctlclient_wrapper.go
ExecuteVtctl
func ExecuteVtctl(ctx context.Context, server string, args []string) (string, error) { var output bytes.Buffer loggerToBufferFunc := createLoggerEventToBufferFunction(&output) outputLogger := newOutputLogger(loggerToBufferFunc) startMsg := fmt.Sprintf("Executing remote vtctl command: %v server: %v", args, server) outputLogger.Infof(startMsg) log.Info(startMsg) err := vtctlclient.RunCommandAndWait( ctx, server, args, loggerToBufferFunc) endMsg := fmt.Sprintf("Executed remote vtctl command: %v server: %v err: %v", args, server, err) outputLogger.Infof(endMsg) // Log full output to log file (but not to the buffer). log.Infof("%v output (starting on next line):\n%v", endMsg, output.String()) return output.String(), err }
go
func ExecuteVtctl(ctx context.Context, server string, args []string) (string, error) { var output bytes.Buffer loggerToBufferFunc := createLoggerEventToBufferFunction(&output) outputLogger := newOutputLogger(loggerToBufferFunc) startMsg := fmt.Sprintf("Executing remote vtctl command: %v server: %v", args, server) outputLogger.Infof(startMsg) log.Info(startMsg) err := vtctlclient.RunCommandAndWait( ctx, server, args, loggerToBufferFunc) endMsg := fmt.Sprintf("Executed remote vtctl command: %v server: %v err: %v", args, server, err) outputLogger.Infof(endMsg) // Log full output to log file (but not to the buffer). log.Infof("%v output (starting on next line):\n%v", endMsg, output.String()) return output.String(), err }
[ "func", "ExecuteVtctl", "(", "ctx", "context", ".", "Context", ",", "server", "string", ",", "args", "[", "]", "string", ")", "(", "string", ",", "error", ")", "{", "var", "output", "bytes", ".", "Buffer", "\n", "loggerToBufferFunc", ":=", "createLoggerEventToBufferFunction", "(", "&", "output", ")", "\n", "outputLogger", ":=", "newOutputLogger", "(", "loggerToBufferFunc", ")", "\n\n", "startMsg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "args", ",", "server", ")", "\n", "outputLogger", ".", "Infof", "(", "startMsg", ")", "\n", "log", ".", "Info", "(", "startMsg", ")", "\n\n", "err", ":=", "vtctlclient", ".", "RunCommandAndWait", "(", "ctx", ",", "server", ",", "args", ",", "loggerToBufferFunc", ")", "\n\n", "endMsg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "args", ",", "server", ",", "err", ")", "\n", "outputLogger", ".", "Infof", "(", "endMsg", ")", "\n", "// Log full output to log file (but not to the buffer).", "log", ".", "Infof", "(", "\"", "\\n", "\"", ",", "endMsg", ",", "output", ".", "String", "(", ")", ")", "\n\n", "return", "output", ".", "String", "(", ")", ",", "err", "\n", "}" ]
// ExecuteVtctl runs vtctl using vtctlclient. The stream of Event // messages is concatenated into one output string. // Additionally, the start and the end of the command will be logged to make // it easier to debug which command was executed and how long it took.
[ "ExecuteVtctl", "runs", "vtctl", "using", "vtctlclient", ".", "The", "stream", "of", "Event", "messages", "is", "concatenated", "into", "one", "output", "string", ".", "Additionally", "the", "start", "and", "the", "end", "of", "the", "command", "will", "be", "logged", "to", "make", "it", "easier", "to", "debug", "which", "command", "was", "executed", "and", "how", "long", "it", "took", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/vtctlclient_wrapper.go#L35-L54
train
vitessio/vitess
go/vt/automation/vtctlclient_wrapper.go
createLoggerEventToBufferFunction
func createLoggerEventToBufferFunction(output *bytes.Buffer) func(*logutilpb.Event) { return func(e *logutilpb.Event) { logutil.EventToBuffer(e, output) output.WriteRune('\n') } }
go
func createLoggerEventToBufferFunction(output *bytes.Buffer) func(*logutilpb.Event) { return func(e *logutilpb.Event) { logutil.EventToBuffer(e, output) output.WriteRune('\n') } }
[ "func", "createLoggerEventToBufferFunction", "(", "output", "*", "bytes", ".", "Buffer", ")", "func", "(", "*", "logutilpb", ".", "Event", ")", "{", "return", "func", "(", "e", "*", "logutilpb", ".", "Event", ")", "{", "logutil", ".", "EventToBuffer", "(", "e", ",", "output", ")", "\n", "output", ".", "WriteRune", "(", "'\\n'", ")", "\n", "}", "\n", "}" ]
// createLoggerEventToBufferFunction returns a function to add LoggerEvent // structs to a given buffer, one line per event. // The buffer can be used to return a multi-line string with all events.
[ "createLoggerEventToBufferFunction", "returns", "a", "function", "to", "add", "LoggerEvent", "structs", "to", "a", "given", "buffer", "one", "line", "per", "event", ".", "The", "buffer", "can", "be", "used", "to", "return", "a", "multi", "-", "line", "string", "with", "all", "events", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/vtctlclient_wrapper.go#L59-L64
train
vitessio/vitess
go/vt/grpcclient/client.go
RegisterGRPCDialOptions
func RegisterGRPCDialOptions(grpcDialOptionsFunc func(opts []grpc.DialOption) ([]grpc.DialOption, error)) { grpcDialOptions = append(grpcDialOptions, grpcDialOptionsFunc) }
go
func RegisterGRPCDialOptions(grpcDialOptionsFunc func(opts []grpc.DialOption) ([]grpc.DialOption, error)) { grpcDialOptions = append(grpcDialOptions, grpcDialOptionsFunc) }
[ "func", "RegisterGRPCDialOptions", "(", "grpcDialOptionsFunc", "func", "(", "opts", "[", "]", "grpc", ".", "DialOption", ")", "(", "[", "]", "grpc", ".", "DialOption", ",", "error", ")", ")", "{", "grpcDialOptions", "=", "append", "(", "grpcDialOptions", ",", "grpcDialOptionsFunc", ")", "\n", "}" ]
// RegisterGRPCDialOptions registers an implementation of AuthServer.
[ "RegisterGRPCDialOptions", "registers", "an", "implementation", "of", "AuthServer", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/grpcclient/client.go#L51-L53
train
vitessio/vitess
go/vt/grpcclient/client.go
Dial
func Dial(target string, failFast FailFast, opts ...grpc.DialOption) (*grpc.ClientConn, error) { grpccommon.EnableTracingOpt() newopts := []grpc.DialOption{ grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(*grpccommon.MaxMessageSize), grpc.MaxCallSendMsgSize(*grpccommon.MaxMessageSize), grpc.FailFast(bool(failFast)), ), } if *keepaliveTime != 0 || *keepaliveTimeout != 0 { kp := keepalive.ClientParameters{ // After a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive. Time: *keepaliveTime, // After having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that // the connection is closed. (This will eagerly fail inflight grpc requests even if they don't have timeouts.) Timeout: *keepaliveTimeout, PermitWithoutStream: true, } newopts = append(newopts, grpc.WithKeepaliveParams(kp)) } if *initialConnWindowSize != 0 { newopts = append(newopts, grpc.WithInitialConnWindowSize(int32(*initialConnWindowSize))) } if *initialWindowSize != 0 { newopts = append(newopts, grpc.WithInitialWindowSize(int32(*initialWindowSize))) } newopts = append(newopts, opts...) var err error for _, grpcDialOptionInitializer := range grpcDialOptions { newopts, err = grpcDialOptionInitializer(newopts) if err != nil { log.Fatalf("There was an error initializing client grpc.DialOption: %v", err) } } newopts = append(newopts, interceptors()...) return grpc.Dial(target, newopts...) }
go
func Dial(target string, failFast FailFast, opts ...grpc.DialOption) (*grpc.ClientConn, error) { grpccommon.EnableTracingOpt() newopts := []grpc.DialOption{ grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(*grpccommon.MaxMessageSize), grpc.MaxCallSendMsgSize(*grpccommon.MaxMessageSize), grpc.FailFast(bool(failFast)), ), } if *keepaliveTime != 0 || *keepaliveTimeout != 0 { kp := keepalive.ClientParameters{ // After a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive. Time: *keepaliveTime, // After having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that // the connection is closed. (This will eagerly fail inflight grpc requests even if they don't have timeouts.) Timeout: *keepaliveTimeout, PermitWithoutStream: true, } newopts = append(newopts, grpc.WithKeepaliveParams(kp)) } if *initialConnWindowSize != 0 { newopts = append(newopts, grpc.WithInitialConnWindowSize(int32(*initialConnWindowSize))) } if *initialWindowSize != 0 { newopts = append(newopts, grpc.WithInitialWindowSize(int32(*initialWindowSize))) } newopts = append(newopts, opts...) var err error for _, grpcDialOptionInitializer := range grpcDialOptions { newopts, err = grpcDialOptionInitializer(newopts) if err != nil { log.Fatalf("There was an error initializing client grpc.DialOption: %v", err) } } newopts = append(newopts, interceptors()...) return grpc.Dial(target, newopts...) }
[ "func", "Dial", "(", "target", "string", ",", "failFast", "FailFast", ",", "opts", "...", "grpc", ".", "DialOption", ")", "(", "*", "grpc", ".", "ClientConn", ",", "error", ")", "{", "grpccommon", ".", "EnableTracingOpt", "(", ")", "\n", "newopts", ":=", "[", "]", "grpc", ".", "DialOption", "{", "grpc", ".", "WithDefaultCallOptions", "(", "grpc", ".", "MaxCallRecvMsgSize", "(", "*", "grpccommon", ".", "MaxMessageSize", ")", ",", "grpc", ".", "MaxCallSendMsgSize", "(", "*", "grpccommon", ".", "MaxMessageSize", ")", ",", "grpc", ".", "FailFast", "(", "bool", "(", "failFast", ")", ")", ",", ")", ",", "}", "\n\n", "if", "*", "keepaliveTime", "!=", "0", "||", "*", "keepaliveTimeout", "!=", "0", "{", "kp", ":=", "keepalive", ".", "ClientParameters", "{", "// After a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.", "Time", ":", "*", "keepaliveTime", ",", "// After having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that", "// the connection is closed. (This will eagerly fail inflight grpc requests even if they don't have timeouts.)", "Timeout", ":", "*", "keepaliveTimeout", ",", "PermitWithoutStream", ":", "true", ",", "}", "\n", "newopts", "=", "append", "(", "newopts", ",", "grpc", ".", "WithKeepaliveParams", "(", "kp", ")", ")", "\n", "}", "\n\n", "if", "*", "initialConnWindowSize", "!=", "0", "{", "newopts", "=", "append", "(", "newopts", ",", "grpc", ".", "WithInitialConnWindowSize", "(", "int32", "(", "*", "initialConnWindowSize", ")", ")", ")", "\n", "}", "\n\n", "if", "*", "initialWindowSize", "!=", "0", "{", "newopts", "=", "append", "(", "newopts", ",", "grpc", ".", "WithInitialWindowSize", "(", "int32", "(", "*", "initialWindowSize", ")", ")", ")", "\n", "}", "\n\n", "newopts", "=", "append", "(", "newopts", ",", "opts", "...", ")", "\n", "var", "err", "error", "\n", "for", "_", ",", "grpcDialOptionInitializer", ":=", "range", "grpcDialOptions", "{", "newopts", ",", "err", "=", "grpcDialOptionInitializer", "(", "newopts", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "newopts", "=", "append", "(", "newopts", ",", "interceptors", "(", ")", "...", ")", "\n\n", "return", "grpc", ".", "Dial", "(", "target", ",", "newopts", "...", ")", "\n", "}" ]
// Dial creates a grpc connection to the given target. // failFast is a non-optional parameter because callers are required to specify // what that should be.
[ "Dial", "creates", "a", "grpc", "connection", "to", "the", "given", "target", ".", "failFast", "is", "a", "non", "-", "optional", "parameter", "because", "callers", "are", "required", "to", "specify", "what", "that", "should", "be", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/grpcclient/client.go#L58-L100
train
vitessio/vitess
go/vt/grpcclient/client.go
SecureDialOption
func SecureDialOption(cert, key, ca, name string) (grpc.DialOption, error) { // No security options set, just return. if (cert == "" || key == "") && ca == "" { return grpc.WithInsecure(), nil } // Load the config. config, err := vttls.ClientConfig(cert, key, ca, name) if err != nil { return nil, err } // Create the creds server options. creds := credentials.NewTLS(config) return grpc.WithTransportCredentials(creds), nil }
go
func SecureDialOption(cert, key, ca, name string) (grpc.DialOption, error) { // No security options set, just return. if (cert == "" || key == "") && ca == "" { return grpc.WithInsecure(), nil } // Load the config. config, err := vttls.ClientConfig(cert, key, ca, name) if err != nil { return nil, err } // Create the creds server options. creds := credentials.NewTLS(config) return grpc.WithTransportCredentials(creds), nil }
[ "func", "SecureDialOption", "(", "cert", ",", "key", ",", "ca", ",", "name", "string", ")", "(", "grpc", ".", "DialOption", ",", "error", ")", "{", "// No security options set, just return.", "if", "(", "cert", "==", "\"", "\"", "||", "key", "==", "\"", "\"", ")", "&&", "ca", "==", "\"", "\"", "{", "return", "grpc", ".", "WithInsecure", "(", ")", ",", "nil", "\n", "}", "\n\n", "// Load the config.", "config", ",", "err", ":=", "vttls", ".", "ClientConfig", "(", "cert", ",", "key", ",", "ca", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Create the creds server options.", "creds", ":=", "credentials", ".", "NewTLS", "(", "config", ")", "\n", "return", "grpc", ".", "WithTransportCredentials", "(", "creds", ")", ",", "nil", "\n", "}" ]
// SecureDialOption returns the gRPC dial option to use for the // given client connection. It is either using TLS, or Insecure if // nothing is set.
[ "SecureDialOption", "returns", "the", "gRPC", "dial", "option", "to", "use", "for", "the", "given", "client", "connection", ".", "It", "is", "either", "using", "TLS", "or", "Insecure", "if", "nothing", "is", "set", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/grpcclient/client.go#L114-L129
train
vitessio/vitess
go/vt/grpcclient/client.go
Add
func (collector *clientInterceptorBuilder) Add(s grpc.StreamClientInterceptor, u grpc.UnaryClientInterceptor) { collector.unaryInterceptors = append(collector.unaryInterceptors, u) collector.streamInterceptors = append(collector.streamInterceptors, s) }
go
func (collector *clientInterceptorBuilder) Add(s grpc.StreamClientInterceptor, u grpc.UnaryClientInterceptor) { collector.unaryInterceptors = append(collector.unaryInterceptors, u) collector.streamInterceptors = append(collector.streamInterceptors, s) }
[ "func", "(", "collector", "*", "clientInterceptorBuilder", ")", "Add", "(", "s", "grpc", ".", "StreamClientInterceptor", ",", "u", "grpc", ".", "UnaryClientInterceptor", ")", "{", "collector", ".", "unaryInterceptors", "=", "append", "(", "collector", ".", "unaryInterceptors", ",", "u", ")", "\n", "collector", ".", "streamInterceptors", "=", "append", "(", "collector", ".", "streamInterceptors", ",", "s", ")", "\n", "}" ]
// Add adds interceptors to the chain of interceptors
[ "Add", "adds", "interceptors", "to", "the", "chain", "of", "interceptors" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/grpcclient/client.go#L138-L141
train
vitessio/vitess
go/sqltypes/type.go
IsSigned
func IsSigned(t querypb.Type) bool { return int(t)&(flagIsIntegral|flagIsUnsigned) == flagIsIntegral }
go
func IsSigned(t querypb.Type) bool { return int(t)&(flagIsIntegral|flagIsUnsigned) == flagIsIntegral }
[ "func", "IsSigned", "(", "t", "querypb", ".", "Type", ")", "bool", "{", "return", "int", "(", "t", ")", "&", "(", "flagIsIntegral", "|", "flagIsUnsigned", ")", "==", "flagIsIntegral", "\n", "}" ]
// IsSigned returns true if querypb.Type is a signed integral. // If you have a Value object, use its member function.
[ "IsSigned", "returns", "true", "if", "querypb", ".", "Type", "is", "a", "signed", "integral", ".", "If", "you", "have", "a", "Value", "object", "use", "its", "member", "function", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/type.go#L49-L51
train
vitessio/vitess
go/sqltypes/type.go
IsQuoted
func IsQuoted(t querypb.Type) bool { return (int(t)&flagIsQuoted == flagIsQuoted) && t != Bit }
go
func IsQuoted(t querypb.Type) bool { return (int(t)&flagIsQuoted == flagIsQuoted) && t != Bit }
[ "func", "IsQuoted", "(", "t", "querypb", ".", "Type", ")", "bool", "{", "return", "(", "int", "(", "t", ")", "&", "flagIsQuoted", "==", "flagIsQuoted", ")", "&&", "t", "!=", "Bit", "\n", "}" ]
// IsQuoted returns true if querypb.Type is a quoted text or binary. // If you have a Value object, use its member function.
[ "IsQuoted", "returns", "true", "if", "querypb", ".", "Type", "is", "a", "quoted", "text", "or", "binary", ".", "If", "you", "have", "a", "Value", "object", "use", "its", "member", "function", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/type.go#L68-L70
train
vitessio/vitess
go/sqltypes/type.go
isNumber
func isNumber(t querypb.Type) bool { return IsIntegral(t) || IsFloat(t) || t == Decimal }
go
func isNumber(t querypb.Type) bool { return IsIntegral(t) || IsFloat(t) || t == Decimal }
[ "func", "isNumber", "(", "t", "querypb", ".", "Type", ")", "bool", "{", "return", "IsIntegral", "(", "t", ")", "||", "IsFloat", "(", "t", ")", "||", "t", "==", "Decimal", "\n", "}" ]
// isNumber returns true if the type is any type of number.
[ "isNumber", "returns", "true", "if", "the", "type", "is", "any", "type", "of", "number", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/type.go#L85-L87
train
vitessio/vitess
go/sqltypes/type.go
modifyType
func modifyType(typ querypb.Type, flags int64) querypb.Type { switch typ { case Int8: if flags&mysqlUnsigned != 0 { return Uint8 } return Int8 case Int16: if flags&mysqlUnsigned != 0 { return Uint16 } return Int16 case Int32: if flags&mysqlUnsigned != 0 { return Uint32 } return Int32 case Int64: if flags&mysqlUnsigned != 0 { return Uint64 } return Int64 case Int24: if flags&mysqlUnsigned != 0 { return Uint24 } return Int24 case Text: if flags&mysqlBinary != 0 { return Blob } return Text case VarChar: if flags&mysqlBinary != 0 { return VarBinary } return VarChar case Char: if flags&mysqlBinary != 0 { return Binary } if flags&mysqlEnum != 0 { return Enum } if flags&mysqlSet != 0 { return Set } return Char } return typ }
go
func modifyType(typ querypb.Type, flags int64) querypb.Type { switch typ { case Int8: if flags&mysqlUnsigned != 0 { return Uint8 } return Int8 case Int16: if flags&mysqlUnsigned != 0 { return Uint16 } return Int16 case Int32: if flags&mysqlUnsigned != 0 { return Uint32 } return Int32 case Int64: if flags&mysqlUnsigned != 0 { return Uint64 } return Int64 case Int24: if flags&mysqlUnsigned != 0 { return Uint24 } return Int24 case Text: if flags&mysqlBinary != 0 { return Blob } return Text case VarChar: if flags&mysqlBinary != 0 { return VarBinary } return VarChar case Char: if flags&mysqlBinary != 0 { return Binary } if flags&mysqlEnum != 0 { return Enum } if flags&mysqlSet != 0 { return Set } return Char } return typ }
[ "func", "modifyType", "(", "typ", "querypb", ".", "Type", ",", "flags", "int64", ")", "querypb", ".", "Type", "{", "switch", "typ", "{", "case", "Int8", ":", "if", "flags", "&", "mysqlUnsigned", "!=", "0", "{", "return", "Uint8", "\n", "}", "\n", "return", "Int8", "\n", "case", "Int16", ":", "if", "flags", "&", "mysqlUnsigned", "!=", "0", "{", "return", "Uint16", "\n", "}", "\n", "return", "Int16", "\n", "case", "Int32", ":", "if", "flags", "&", "mysqlUnsigned", "!=", "0", "{", "return", "Uint32", "\n", "}", "\n", "return", "Int32", "\n", "case", "Int64", ":", "if", "flags", "&", "mysqlUnsigned", "!=", "0", "{", "return", "Uint64", "\n", "}", "\n", "return", "Int64", "\n", "case", "Int24", ":", "if", "flags", "&", "mysqlUnsigned", "!=", "0", "{", "return", "Uint24", "\n", "}", "\n", "return", "Int24", "\n", "case", "Text", ":", "if", "flags", "&", "mysqlBinary", "!=", "0", "{", "return", "Blob", "\n", "}", "\n", "return", "Text", "\n", "case", "VarChar", ":", "if", "flags", "&", "mysqlBinary", "!=", "0", "{", "return", "VarBinary", "\n", "}", "\n", "return", "VarChar", "\n", "case", "Char", ":", "if", "flags", "&", "mysqlBinary", "!=", "0", "{", "return", "Binary", "\n", "}", "\n", "if", "flags", "&", "mysqlEnum", "!=", "0", "{", "return", "Enum", "\n", "}", "\n", "if", "flags", "&", "mysqlSet", "!=", "0", "{", "return", "Set", "\n", "}", "\n", "return", "Char", "\n", "}", "\n", "return", "typ", "\n", "}" ]
// modifyType modifies the vitess type based on the // mysql flag. The function checks specific flags based // on the type. This allows us to ignore stray flags // that MySQL occasionally sets.
[ "modifyType", "modifies", "the", "vitess", "type", "based", "on", "the", "mysql", "flag", ".", "The", "function", "checks", "specific", "flags", "based", "on", "the", "type", ".", "This", "allows", "us", "to", "ignore", "stray", "flags", "that", "MySQL", "occasionally", "sets", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/type.go#L186-L236
train
vitessio/vitess
go/sqltypes/type.go
MySQLToType
func MySQLToType(mysqlType, flags int64) (typ querypb.Type, err error) { result, ok := mysqlToType[mysqlType] if !ok { return 0, fmt.Errorf("unsupported type: %d", mysqlType) } return modifyType(result, flags), nil }
go
func MySQLToType(mysqlType, flags int64) (typ querypb.Type, err error) { result, ok := mysqlToType[mysqlType] if !ok { return 0, fmt.Errorf("unsupported type: %d", mysqlType) } return modifyType(result, flags), nil }
[ "func", "MySQLToType", "(", "mysqlType", ",", "flags", "int64", ")", "(", "typ", "querypb", ".", "Type", ",", "err", "error", ")", "{", "result", ",", "ok", ":=", "mysqlToType", "[", "mysqlType", "]", "\n", "if", "!", "ok", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "mysqlType", ")", "\n", "}", "\n", "return", "modifyType", "(", "result", ",", "flags", ")", ",", "nil", "\n", "}" ]
// MySQLToType computes the vitess type from mysql type and flags.
[ "MySQLToType", "computes", "the", "vitess", "type", "from", "mysql", "type", "and", "flags", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/type.go#L239-L245
train
vitessio/vitess
go/sqltypes/type.go
TypeToMySQL
func TypeToMySQL(typ querypb.Type) (mysqlType, flags int64) { val := typeToMySQL[typ] return val.typ, val.flags }
go
func TypeToMySQL(typ querypb.Type) (mysqlType, flags int64) { val := typeToMySQL[typ] return val.typ, val.flags }
[ "func", "TypeToMySQL", "(", "typ", "querypb", ".", "Type", ")", "(", "mysqlType", ",", "flags", "int64", ")", "{", "val", ":=", "typeToMySQL", "[", "typ", "]", "\n", "return", "val", ".", "typ", ",", "val", ".", "flags", "\n", "}" ]
// TypeToMySQL returns the equivalent mysql type and flag for a vitess type.
[ "TypeToMySQL", "returns", "the", "equivalent", "mysql", "type", "and", "flag", "for", "a", "vitess", "type", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sqltypes/type.go#L285-L288
train
vitessio/vitess
go/vt/tableacl/tableacl.go
Valid
func (tacl *tableACL) Valid() bool { tacl.RLock() defer tacl.RUnlock() return tacl.entries != nil }
go
func (tacl *tableACL) Valid() bool { tacl.RLock() defer tacl.RUnlock() return tacl.entries != nil }
[ "func", "(", "tacl", "*", "tableACL", ")", "Valid", "(", ")", "bool", "{", "tacl", ".", "RLock", "(", ")", "\n", "defer", "tacl", ".", "RUnlock", "(", ")", "\n", "return", "tacl", ".", "entries", "!=", "nil", "\n", "}" ]
// Valid returns whether the tableACL is valid. // Currently it only checks that it has been initialized.
[ "Valid", "returns", "whether", "the", "tableACL", "is", "valid", ".", "Currently", "it", "only", "checks", "that", "it", "has", "been", "initialized", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/tableacl/tableacl.go#L206-L210
train
vitessio/vitess
go/vt/tableacl/tableacl.go
ValidateProto
func ValidateProto(config *tableaclpb.Config) (err error) { t := patricia.NewTrie() for _, group := range config.TableGroups { for _, name := range group.TableNamesOrPrefixes { var prefix patricia.Prefix if strings.HasSuffix(name, "%") { prefix = []byte(strings.TrimSuffix(name, "%")) } else { prefix = []byte(name + "\000") } if bytes.Contains(prefix, []byte("%")) { return fmt.Errorf("got: %s, '%%' means this entry is a prefix and should not appear in the middle of name or prefix", name) } overlapVisitor := func(_ patricia.Prefix, item patricia.Item) error { return fmt.Errorf("conflicting entries: %q overlaps with %q", name, item) } if err := t.VisitSubtree(prefix, overlapVisitor); err != nil { return err } if err := t.VisitPrefixes(prefix, overlapVisitor); err != nil { return err } t.Insert(prefix, name) } } return nil }
go
func ValidateProto(config *tableaclpb.Config) (err error) { t := patricia.NewTrie() for _, group := range config.TableGroups { for _, name := range group.TableNamesOrPrefixes { var prefix patricia.Prefix if strings.HasSuffix(name, "%") { prefix = []byte(strings.TrimSuffix(name, "%")) } else { prefix = []byte(name + "\000") } if bytes.Contains(prefix, []byte("%")) { return fmt.Errorf("got: %s, '%%' means this entry is a prefix and should not appear in the middle of name or prefix", name) } overlapVisitor := func(_ patricia.Prefix, item patricia.Item) error { return fmt.Errorf("conflicting entries: %q overlaps with %q", name, item) } if err := t.VisitSubtree(prefix, overlapVisitor); err != nil { return err } if err := t.VisitPrefixes(prefix, overlapVisitor); err != nil { return err } t.Insert(prefix, name) } } return nil }
[ "func", "ValidateProto", "(", "config", "*", "tableaclpb", ".", "Config", ")", "(", "err", "error", ")", "{", "t", ":=", "patricia", ".", "NewTrie", "(", ")", "\n", "for", "_", ",", "group", ":=", "range", "config", ".", "TableGroups", "{", "for", "_", ",", "name", ":=", "range", "group", ".", "TableNamesOrPrefixes", "{", "var", "prefix", "patricia", ".", "Prefix", "\n", "if", "strings", ".", "HasSuffix", "(", "name", ",", "\"", "\"", ")", "{", "prefix", "=", "[", "]", "byte", "(", "strings", ".", "TrimSuffix", "(", "name", ",", "\"", "\"", ")", ")", "\n", "}", "else", "{", "prefix", "=", "[", "]", "byte", "(", "name", "+", "\"", "\\000", "\"", ")", "\n", "}", "\n", "if", "bytes", ".", "Contains", "(", "prefix", ",", "[", "]", "byte", "(", "\"", "\"", ")", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "overlapVisitor", ":=", "func", "(", "_", "patricia", ".", "Prefix", ",", "item", "patricia", ".", "Item", ")", "error", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "item", ")", "\n", "}", "\n", "if", "err", ":=", "t", ".", "VisitSubtree", "(", "prefix", ",", "overlapVisitor", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "t", ".", "VisitPrefixes", "(", "prefix", ",", "overlapVisitor", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "t", ".", "Insert", "(", "prefix", ",", "name", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ValidateProto returns an error if the given proto has problems // that would cause InitFromProto to fail.
[ "ValidateProto", "returns", "an", "error", "if", "the", "given", "proto", "has", "problems", "that", "would", "cause", "InitFromProto", "to", "fail", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/tableacl/tableacl.go#L214-L240
train
vitessio/vitess
go/vt/tableacl/tableacl.go
Authorized
func Authorized(table string, role Role) *ACLResult { return currentTableACL.Authorized(table, role) }
go
func Authorized(table string, role Role) *ACLResult { return currentTableACL.Authorized(table, role) }
[ "func", "Authorized", "(", "table", "string", ",", "role", "Role", ")", "*", "ACLResult", "{", "return", "currentTableACL", ".", "Authorized", "(", "table", ",", "role", ")", "\n", "}" ]
// Authorized returns the list of entities who have the specified role on a tablel.
[ "Authorized", "returns", "the", "list", "of", "entities", "who", "have", "the", "specified", "role", "on", "a", "tablel", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/tableacl/tableacl.go#L243-L245
train
vitessio/vitess
go/vt/tableacl/tableacl.go
Register
func Register(name string, factory acl.Factory) { mu.Lock() defer mu.Unlock() if _, ok := acls[name]; ok { panic(fmt.Sprintf("register a registered key: %s", name)) } acls[name] = factory }
go
func Register(name string, factory acl.Factory) { mu.Lock() defer mu.Unlock() if _, ok := acls[name]; ok { panic(fmt.Sprintf("register a registered key: %s", name)) } acls[name] = factory }
[ "func", "Register", "(", "name", "string", ",", "factory", "acl", ".", "Factory", ")", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n", "if", "_", ",", "ok", ":=", "acls", "[", "name", "]", ";", "ok", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ")", "\n", "}", "\n", "acls", "[", "name", "]", "=", "factory", "\n", "}" ]
// Register registers an AclFactory.
[ "Register", "registers", "an", "AclFactory", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/tableacl/tableacl.go#L288-L295
train
vitessio/vitess
go/vt/tableacl/tableacl.go
GetCurrentACLFactory
func GetCurrentACLFactory() (acl.Factory, error) { mu.Lock() defer mu.Unlock() if len(acls) == 0 { return nil, fmt.Errorf("no AclFactories registered") } if defaultACL == "" { if len(acls) == 1 { for _, aclFactory := range acls { return aclFactory, nil } } return nil, errors.New("there are more than one AclFactory registered but no default has been given") } if aclFactory, ok := acls[defaultACL]; ok { return aclFactory, nil } return nil, fmt.Errorf("aclFactory for given default: %s is not found", defaultACL) }
go
func GetCurrentACLFactory() (acl.Factory, error) { mu.Lock() defer mu.Unlock() if len(acls) == 0 { return nil, fmt.Errorf("no AclFactories registered") } if defaultACL == "" { if len(acls) == 1 { for _, aclFactory := range acls { return aclFactory, nil } } return nil, errors.New("there are more than one AclFactory registered but no default has been given") } if aclFactory, ok := acls[defaultACL]; ok { return aclFactory, nil } return nil, fmt.Errorf("aclFactory for given default: %s is not found", defaultACL) }
[ "func", "GetCurrentACLFactory", "(", ")", "(", "acl", ".", "Factory", ",", "error", ")", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n", "if", "len", "(", "acls", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "defaultACL", "==", "\"", "\"", "{", "if", "len", "(", "acls", ")", "==", "1", "{", "for", "_", ",", "aclFactory", ":=", "range", "acls", "{", "return", "aclFactory", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "aclFactory", ",", "ok", ":=", "acls", "[", "defaultACL", "]", ";", "ok", "{", "return", "aclFactory", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "defaultACL", ")", "\n", "}" ]
// GetCurrentACLFactory returns current table acl implementation.
[ "GetCurrentACLFactory", "returns", "current", "table", "acl", "implementation", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/tableacl/tableacl.go#L305-L323
train
vitessio/vitess
go/vt/wrangler/tablet.go
InitTablet
func (wr *Wrangler) InitTablet(ctx context.Context, tablet *topodatapb.Tablet, allowMasterOverride, createShardAndKeyspace, allowUpdate bool) error { shard, kr, err := topo.ValidateShardName(tablet.Shard) if err != nil { return err } tablet.Shard = shard tablet.KeyRange = kr // get the shard, possibly creating it var si *topo.ShardInfo if createShardAndKeyspace { // create the parent keyspace and shard if needed si, err = wr.ts.GetOrCreateShard(ctx, tablet.Keyspace, tablet.Shard) } else { si, err = wr.ts.GetShard(ctx, tablet.Keyspace, tablet.Shard) if topo.IsErrType(err, topo.NoNode) { return fmt.Errorf("missing parent shard, use -parent option to create it, or CreateKeyspace / CreateShard") } } // get the shard, checks a couple things if err != nil { return fmt.Errorf("cannot get (or create) shard %v/%v: %v", tablet.Keyspace, tablet.Shard, err) } if !key.KeyRangeEqual(si.KeyRange, tablet.KeyRange) { return fmt.Errorf("shard %v/%v has a different KeyRange: %v != %v", tablet.Keyspace, tablet.Shard, si.KeyRange, tablet.KeyRange) } if tablet.Type == topodatapb.TabletType_MASTER && si.HasMaster() && !topoproto.TabletAliasEqual(si.MasterAlias, tablet.Alias) && !allowMasterOverride { return fmt.Errorf("creating this tablet would override old master %v in shard %v/%v, use allow_master_override flag", topoproto.TabletAliasString(si.MasterAlias), tablet.Keyspace, tablet.Shard) } // update the shard record if needed if err := wr.updateShardMaster(ctx, si, tablet.Alias, tablet.Type, allowMasterOverride); err != nil { return err } err = wr.ts.CreateTablet(ctx, tablet) if topo.IsErrType(err, topo.NodeExists) && allowUpdate { // Try to update then oldTablet, err := wr.ts.GetTablet(ctx, tablet.Alias) if err != nil { return fmt.Errorf("failed reading existing tablet %v: %v", topoproto.TabletAliasString(tablet.Alias), err) } // Check we have the same keyspace / shard, and if not, // require the allowDifferentShard flag. if oldTablet.Keyspace != tablet.Keyspace || oldTablet.Shard != tablet.Shard { return fmt.Errorf("old tablet has shard %v/%v. Cannot override with shard %v/%v. Delete and re-add tablet if you want to change the tablet's keyspace/shard", oldTablet.Keyspace, oldTablet.Shard, tablet.Keyspace, tablet.Shard) } *(oldTablet.Tablet) = *tablet if err := wr.ts.UpdateTablet(ctx, oldTablet); err != nil { return fmt.Errorf("failed updating tablet %v: %v", topoproto.TabletAliasString(tablet.Alias), err) } return nil } return err }
go
func (wr *Wrangler) InitTablet(ctx context.Context, tablet *topodatapb.Tablet, allowMasterOverride, createShardAndKeyspace, allowUpdate bool) error { shard, kr, err := topo.ValidateShardName(tablet.Shard) if err != nil { return err } tablet.Shard = shard tablet.KeyRange = kr // get the shard, possibly creating it var si *topo.ShardInfo if createShardAndKeyspace { // create the parent keyspace and shard if needed si, err = wr.ts.GetOrCreateShard(ctx, tablet.Keyspace, tablet.Shard) } else { si, err = wr.ts.GetShard(ctx, tablet.Keyspace, tablet.Shard) if topo.IsErrType(err, topo.NoNode) { return fmt.Errorf("missing parent shard, use -parent option to create it, or CreateKeyspace / CreateShard") } } // get the shard, checks a couple things if err != nil { return fmt.Errorf("cannot get (or create) shard %v/%v: %v", tablet.Keyspace, tablet.Shard, err) } if !key.KeyRangeEqual(si.KeyRange, tablet.KeyRange) { return fmt.Errorf("shard %v/%v has a different KeyRange: %v != %v", tablet.Keyspace, tablet.Shard, si.KeyRange, tablet.KeyRange) } if tablet.Type == topodatapb.TabletType_MASTER && si.HasMaster() && !topoproto.TabletAliasEqual(si.MasterAlias, tablet.Alias) && !allowMasterOverride { return fmt.Errorf("creating this tablet would override old master %v in shard %v/%v, use allow_master_override flag", topoproto.TabletAliasString(si.MasterAlias), tablet.Keyspace, tablet.Shard) } // update the shard record if needed if err := wr.updateShardMaster(ctx, si, tablet.Alias, tablet.Type, allowMasterOverride); err != nil { return err } err = wr.ts.CreateTablet(ctx, tablet) if topo.IsErrType(err, topo.NodeExists) && allowUpdate { // Try to update then oldTablet, err := wr.ts.GetTablet(ctx, tablet.Alias) if err != nil { return fmt.Errorf("failed reading existing tablet %v: %v", topoproto.TabletAliasString(tablet.Alias), err) } // Check we have the same keyspace / shard, and if not, // require the allowDifferentShard flag. if oldTablet.Keyspace != tablet.Keyspace || oldTablet.Shard != tablet.Shard { return fmt.Errorf("old tablet has shard %v/%v. Cannot override with shard %v/%v. Delete and re-add tablet if you want to change the tablet's keyspace/shard", oldTablet.Keyspace, oldTablet.Shard, tablet.Keyspace, tablet.Shard) } *(oldTablet.Tablet) = *tablet if err := wr.ts.UpdateTablet(ctx, oldTablet); err != nil { return fmt.Errorf("failed updating tablet %v: %v", topoproto.TabletAliasString(tablet.Alias), err) } return nil } return err }
[ "func", "(", "wr", "*", "Wrangler", ")", "InitTablet", "(", "ctx", "context", ".", "Context", ",", "tablet", "*", "topodatapb", ".", "Tablet", ",", "allowMasterOverride", ",", "createShardAndKeyspace", ",", "allowUpdate", "bool", ")", "error", "{", "shard", ",", "kr", ",", "err", ":=", "topo", ".", "ValidateShardName", "(", "tablet", ".", "Shard", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "tablet", ".", "Shard", "=", "shard", "\n", "tablet", ".", "KeyRange", "=", "kr", "\n\n", "// get the shard, possibly creating it", "var", "si", "*", "topo", ".", "ShardInfo", "\n\n", "if", "createShardAndKeyspace", "{", "// create the parent keyspace and shard if needed", "si", ",", "err", "=", "wr", ".", "ts", ".", "GetOrCreateShard", "(", "ctx", ",", "tablet", ".", "Keyspace", ",", "tablet", ".", "Shard", ")", "\n", "}", "else", "{", "si", ",", "err", "=", "wr", ".", "ts", ".", "GetShard", "(", "ctx", ",", "tablet", ".", "Keyspace", ",", "tablet", ".", "Shard", ")", "\n", "if", "topo", ".", "IsErrType", "(", "err", ",", "topo", ".", "NoNode", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "// get the shard, checks a couple things", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tablet", ".", "Keyspace", ",", "tablet", ".", "Shard", ",", "err", ")", "\n", "}", "\n", "if", "!", "key", ".", "KeyRangeEqual", "(", "si", ".", "KeyRange", ",", "tablet", ".", "KeyRange", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tablet", ".", "Keyspace", ",", "tablet", ".", "Shard", ",", "si", ".", "KeyRange", ",", "tablet", ".", "KeyRange", ")", "\n", "}", "\n", "if", "tablet", ".", "Type", "==", "topodatapb", ".", "TabletType_MASTER", "&&", "si", ".", "HasMaster", "(", ")", "&&", "!", "topoproto", ".", "TabletAliasEqual", "(", "si", ".", "MasterAlias", ",", "tablet", ".", "Alias", ")", "&&", "!", "allowMasterOverride", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "topoproto", ".", "TabletAliasString", "(", "si", ".", "MasterAlias", ")", ",", "tablet", ".", "Keyspace", ",", "tablet", ".", "Shard", ")", "\n", "}", "\n\n", "// update the shard record if needed", "if", "err", ":=", "wr", ".", "updateShardMaster", "(", "ctx", ",", "si", ",", "tablet", ".", "Alias", ",", "tablet", ".", "Type", ",", "allowMasterOverride", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "wr", ".", "ts", ".", "CreateTablet", "(", "ctx", ",", "tablet", ")", "\n", "if", "topo", ".", "IsErrType", "(", "err", ",", "topo", ".", "NodeExists", ")", "&&", "allowUpdate", "{", "// Try to update then", "oldTablet", ",", "err", ":=", "wr", ".", "ts", ".", "GetTablet", "(", "ctx", ",", "tablet", ".", "Alias", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "topoproto", ".", "TabletAliasString", "(", "tablet", ".", "Alias", ")", ",", "err", ")", "\n", "}", "\n\n", "// Check we have the same keyspace / shard, and if not,", "// require the allowDifferentShard flag.", "if", "oldTablet", ".", "Keyspace", "!=", "tablet", ".", "Keyspace", "||", "oldTablet", ".", "Shard", "!=", "tablet", ".", "Shard", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "oldTablet", ".", "Keyspace", ",", "oldTablet", ".", "Shard", ",", "tablet", ".", "Keyspace", ",", "tablet", ".", "Shard", ")", "\n", "}", "\n\n", "*", "(", "oldTablet", ".", "Tablet", ")", "=", "*", "tablet", "\n", "if", "err", ":=", "wr", ".", "ts", ".", "UpdateTablet", "(", "ctx", ",", "oldTablet", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "topoproto", ".", "TabletAliasString", "(", "tablet", ".", "Alias", ")", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}" ]
// Tablet related methods for wrangler // InitTablet creates or updates a tablet. If no parent is specified // in the tablet, and the tablet has a slave type, we will find the // appropriate parent. If createShardAndKeyspace is true and the // parent keyspace or shard don't exist, they will be created. If // allowUpdate is true, and a tablet with the same ID exists, just update it. // If a tablet is created as master, and there is already a different // master in the shard, allowMasterOverride must be set.
[ "Tablet", "related", "methods", "for", "wrangler", "InitTablet", "creates", "or", "updates", "a", "tablet", ".", "If", "no", "parent", "is", "specified", "in", "the", "tablet", "and", "the", "tablet", "has", "a", "slave", "type", "we", "will", "find", "the", "appropriate", "parent", ".", "If", "createShardAndKeyspace", "is", "true", "and", "the", "parent", "keyspace", "or", "shard", "don", "t", "exist", "they", "will", "be", "created", ".", "If", "allowUpdate", "is", "true", "and", "a", "tablet", "with", "the", "same", "ID", "exists", "just", "update", "it", ".", "If", "a", "tablet", "is", "created", "as", "master", "and", "there", "is", "already", "a", "different", "master", "in", "the", "shard", "allowMasterOverride", "must", "be", "set", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/tablet.go#L41-L99
train
vitessio/vitess
go/vt/wrangler/tablet.go
ChangeSlaveType
func (wr *Wrangler) ChangeSlaveType(ctx context.Context, tabletAlias *topodatapb.TabletAlias, tabletType topodatapb.TabletType) error { // Load tablet to find endpoint, and keyspace and shard assignment. ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return err } if !topo.IsTrivialTypeChange(ti.Type, tabletType) { return fmt.Errorf("tablet %v type change %v -> %v is not an allowed transition for ChangeSlaveType", tabletAlias, ti.Type, tabletType) } // and ask the tablet to make the change return wr.tmc.ChangeType(ctx, ti.Tablet, tabletType) }
go
func (wr *Wrangler) ChangeSlaveType(ctx context.Context, tabletAlias *topodatapb.TabletAlias, tabletType topodatapb.TabletType) error { // Load tablet to find endpoint, and keyspace and shard assignment. ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return err } if !topo.IsTrivialTypeChange(ti.Type, tabletType) { return fmt.Errorf("tablet %v type change %v -> %v is not an allowed transition for ChangeSlaveType", tabletAlias, ti.Type, tabletType) } // and ask the tablet to make the change return wr.tmc.ChangeType(ctx, ti.Tablet, tabletType) }
[ "func", "(", "wr", "*", "Wrangler", ")", "ChangeSlaveType", "(", "ctx", "context", ".", "Context", ",", "tabletAlias", "*", "topodatapb", ".", "TabletAlias", ",", "tabletType", "topodatapb", ".", "TabletType", ")", "error", "{", "// Load tablet to find endpoint, and keyspace and shard assignment.", "ti", ",", "err", ":=", "wr", ".", "ts", ".", "GetTablet", "(", "ctx", ",", "tabletAlias", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "!", "topo", ".", "IsTrivialTypeChange", "(", "ti", ".", "Type", ",", "tabletType", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tabletAlias", ",", "ti", ".", "Type", ",", "tabletType", ")", "\n", "}", "\n\n", "// and ask the tablet to make the change", "return", "wr", ".", "tmc", ".", "ChangeType", "(", "ctx", ",", "ti", ".", "Tablet", ",", "tabletType", ")", "\n", "}" ]
// ChangeSlaveType changes the type of tablet and recomputes all // necessary derived paths in the serving graph, if necessary. // // Note we don't update the master record in the Shard here, as we // can't ChangeType from and out of master anyway.
[ "ChangeSlaveType", "changes", "the", "type", "of", "tablet", "and", "recomputes", "all", "necessary", "derived", "paths", "in", "the", "serving", "graph", "if", "necessary", ".", "Note", "we", "don", "t", "update", "the", "master", "record", "in", "the", "Shard", "here", "as", "we", "can", "t", "ChangeType", "from", "and", "out", "of", "master", "anyway", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/tablet.go#L149-L162
train
vitessio/vitess
go/vt/wrangler/tablet.go
RefreshTabletState
func (wr *Wrangler) RefreshTabletState(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error { // Load tablet to find endpoint, and keyspace and shard assignment. ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return err } // and ask the tablet to refresh itself return wr.tmc.RefreshState(ctx, ti.Tablet) }
go
func (wr *Wrangler) RefreshTabletState(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error { // Load tablet to find endpoint, and keyspace and shard assignment. ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return err } // and ask the tablet to refresh itself return wr.tmc.RefreshState(ctx, ti.Tablet) }
[ "func", "(", "wr", "*", "Wrangler", ")", "RefreshTabletState", "(", "ctx", "context", ".", "Context", ",", "tabletAlias", "*", "topodatapb", ".", "TabletAlias", ")", "error", "{", "// Load tablet to find endpoint, and keyspace and shard assignment.", "ti", ",", "err", ":=", "wr", ".", "ts", ".", "GetTablet", "(", "ctx", ",", "tabletAlias", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// and ask the tablet to refresh itself", "return", "wr", ".", "tmc", ".", "RefreshState", "(", "ctx", ",", "ti", ".", "Tablet", ")", "\n", "}" ]
// RefreshTabletState refreshes tablet state
[ "RefreshTabletState", "refreshes", "tablet", "state" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/tablet.go#L165-L174
train
vitessio/vitess
go/vt/wrangler/tablet.go
ExecuteFetchAsApp
func (wr *Wrangler) ExecuteFetchAsApp(ctx context.Context, tabletAlias *topodatapb.TabletAlias, usePool bool, query string, maxRows int) (*querypb.QueryResult, error) { ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return nil, err } return wr.tmc.ExecuteFetchAsApp(ctx, ti.Tablet, usePool, []byte(query), maxRows) }
go
func (wr *Wrangler) ExecuteFetchAsApp(ctx context.Context, tabletAlias *topodatapb.TabletAlias, usePool bool, query string, maxRows int) (*querypb.QueryResult, error) { ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return nil, err } return wr.tmc.ExecuteFetchAsApp(ctx, ti.Tablet, usePool, []byte(query), maxRows) }
[ "func", "(", "wr", "*", "Wrangler", ")", "ExecuteFetchAsApp", "(", "ctx", "context", ".", "Context", ",", "tabletAlias", "*", "topodatapb", ".", "TabletAlias", ",", "usePool", "bool", ",", "query", "string", ",", "maxRows", "int", ")", "(", "*", "querypb", ".", "QueryResult", ",", "error", ")", "{", "ti", ",", "err", ":=", "wr", ".", "ts", ".", "GetTablet", "(", "ctx", ",", "tabletAlias", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "wr", ".", "tmc", ".", "ExecuteFetchAsApp", "(", "ctx", ",", "ti", ".", "Tablet", ",", "usePool", ",", "[", "]", "byte", "(", "query", ")", ",", "maxRows", ")", "\n", "}" ]
// ExecuteFetchAsApp executes a query remotely using the App pool
[ "ExecuteFetchAsApp", "executes", "a", "query", "remotely", "using", "the", "App", "pool" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/tablet.go#L177-L183
train
vitessio/vitess
go/vt/wrangler/tablet.go
VReplicationExec
func (wr *Wrangler) VReplicationExec(ctx context.Context, tabletAlias *topodatapb.TabletAlias, query string) (*querypb.QueryResult, error) { ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return nil, err } return wr.tmc.VReplicationExec(ctx, ti.Tablet, query) }
go
func (wr *Wrangler) VReplicationExec(ctx context.Context, tabletAlias *topodatapb.TabletAlias, query string) (*querypb.QueryResult, error) { ti, err := wr.ts.GetTablet(ctx, tabletAlias) if err != nil { return nil, err } return wr.tmc.VReplicationExec(ctx, ti.Tablet, query) }
[ "func", "(", "wr", "*", "Wrangler", ")", "VReplicationExec", "(", "ctx", "context", ".", "Context", ",", "tabletAlias", "*", "topodatapb", ".", "TabletAlias", ",", "query", "string", ")", "(", "*", "querypb", ".", "QueryResult", ",", "error", ")", "{", "ti", ",", "err", ":=", "wr", ".", "ts", ".", "GetTablet", "(", "ctx", ",", "tabletAlias", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "wr", ".", "tmc", ".", "VReplicationExec", "(", "ctx", ",", "ti", ".", "Tablet", ",", "query", ")", "\n", "}" ]
// VReplicationExec executes a query remotely using the DBA pool
[ "VReplicationExec", "executes", "a", "query", "remotely", "using", "the", "DBA", "pool" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/wrangler/tablet.go#L195-L201
train
vitessio/vitess
go/vt/vttablet/tabletserver/splitquery/splitter.go
NewSplitter
func NewSplitter(splitParams *SplitParams, algorithm SplitAlgorithmInterface) *Splitter { var splitter Splitter splitter.splitParams = splitParams splitter.algorithm = algorithm splitter.splitParams = splitParams splitColumns := algorithm.getSplitColumns() splitter.startBindVariableNames = make([]string, 0, len(splitColumns)) splitter.endBindVariableNames = make([]string, 0, len(splitColumns)) for _, splitColumn := range splitColumns { splitter.startBindVariableNames = append( splitter.startBindVariableNames, startBindVariablePrefix+splitColumn.Name.CompliantName()) splitter.endBindVariableNames = append( splitter.endBindVariableNames, endBindVariablePrefix+splitColumn.Name.CompliantName()) } splitter.initQueryPartSQLs() return &splitter }
go
func NewSplitter(splitParams *SplitParams, algorithm SplitAlgorithmInterface) *Splitter { var splitter Splitter splitter.splitParams = splitParams splitter.algorithm = algorithm splitter.splitParams = splitParams splitColumns := algorithm.getSplitColumns() splitter.startBindVariableNames = make([]string, 0, len(splitColumns)) splitter.endBindVariableNames = make([]string, 0, len(splitColumns)) for _, splitColumn := range splitColumns { splitter.startBindVariableNames = append( splitter.startBindVariableNames, startBindVariablePrefix+splitColumn.Name.CompliantName()) splitter.endBindVariableNames = append( splitter.endBindVariableNames, endBindVariablePrefix+splitColumn.Name.CompliantName()) } splitter.initQueryPartSQLs() return &splitter }
[ "func", "NewSplitter", "(", "splitParams", "*", "SplitParams", ",", "algorithm", "SplitAlgorithmInterface", ")", "*", "Splitter", "{", "var", "splitter", "Splitter", "\n", "splitter", ".", "splitParams", "=", "splitParams", "\n", "splitter", ".", "algorithm", "=", "algorithm", "\n", "splitter", ".", "splitParams", "=", "splitParams", "\n\n", "splitColumns", ":=", "algorithm", ".", "getSplitColumns", "(", ")", "\n", "splitter", ".", "startBindVariableNames", "=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "splitColumns", ")", ")", "\n", "splitter", ".", "endBindVariableNames", "=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "splitColumns", ")", ")", "\n", "for", "_", ",", "splitColumn", ":=", "range", "splitColumns", "{", "splitter", ".", "startBindVariableNames", "=", "append", "(", "splitter", ".", "startBindVariableNames", ",", "startBindVariablePrefix", "+", "splitColumn", ".", "Name", ".", "CompliantName", "(", ")", ")", "\n", "splitter", ".", "endBindVariableNames", "=", "append", "(", "splitter", ".", "endBindVariableNames", ",", "endBindVariablePrefix", "+", "splitColumn", ".", "Name", ".", "CompliantName", "(", ")", ")", "\n", "}", "\n", "splitter", ".", "initQueryPartSQLs", "(", ")", "\n", "return", "&", "splitter", "\n", "}" ]
// NewSplitter creates a new Splitter object.
[ "NewSplitter", "creates", "a", "new", "Splitter", "object", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/splitquery/splitter.go#L42-L59
train
vitessio/vitess
go/vt/vttablet/tabletserver/splitquery/splitter.go
initQueryPartSQLs
func (splitter *Splitter) initQueryPartSQLs() { splitColumns := convertColumnsToExpr(splitter.algorithm.getSplitColumns()) startBindVariables := convertBindVariableNamesToExpr(splitter.startBindVariableNames) endBindVariables := convertBindVariableNamesToExpr(splitter.endBindVariableNames) splitColsLessThanEnd := constructTupleInequality( splitColumns, endBindVariables, true /* strict */) splitColsGreaterThanOrEqualToStart := constructTupleInequality( startBindVariables, splitColumns, false /* not strict */) splitter.firstQueryPartSQL = sqlparser.String( queryWithAdditionalWhere(splitter.splitParams.selectAST, splitColsLessThanEnd)) splitter.middleQueryPartSQL = sqlparser.String( queryWithAdditionalWhere(splitter.splitParams.selectAST, &sqlparser.AndExpr{ Left: &sqlparser.ParenExpr{Expr: splitColsGreaterThanOrEqualToStart}, Right: &sqlparser.ParenExpr{Expr: splitColsLessThanEnd}, })) splitter.lastQueryPartSQL = sqlparser.String( queryWithAdditionalWhere(splitter.splitParams.selectAST, splitColsGreaterThanOrEqualToStart)) }
go
func (splitter *Splitter) initQueryPartSQLs() { splitColumns := convertColumnsToExpr(splitter.algorithm.getSplitColumns()) startBindVariables := convertBindVariableNamesToExpr(splitter.startBindVariableNames) endBindVariables := convertBindVariableNamesToExpr(splitter.endBindVariableNames) splitColsLessThanEnd := constructTupleInequality( splitColumns, endBindVariables, true /* strict */) splitColsGreaterThanOrEqualToStart := constructTupleInequality( startBindVariables, splitColumns, false /* not strict */) splitter.firstQueryPartSQL = sqlparser.String( queryWithAdditionalWhere(splitter.splitParams.selectAST, splitColsLessThanEnd)) splitter.middleQueryPartSQL = sqlparser.String( queryWithAdditionalWhere(splitter.splitParams.selectAST, &sqlparser.AndExpr{ Left: &sqlparser.ParenExpr{Expr: splitColsGreaterThanOrEqualToStart}, Right: &sqlparser.ParenExpr{Expr: splitColsLessThanEnd}, })) splitter.lastQueryPartSQL = sqlparser.String( queryWithAdditionalWhere(splitter.splitParams.selectAST, splitColsGreaterThanOrEqualToStart)) }
[ "func", "(", "splitter", "*", "Splitter", ")", "initQueryPartSQLs", "(", ")", "{", "splitColumns", ":=", "convertColumnsToExpr", "(", "splitter", ".", "algorithm", ".", "getSplitColumns", "(", ")", ")", "\n", "startBindVariables", ":=", "convertBindVariableNamesToExpr", "(", "splitter", ".", "startBindVariableNames", ")", "\n", "endBindVariables", ":=", "convertBindVariableNamesToExpr", "(", "splitter", ".", "endBindVariableNames", ")", "\n", "splitColsLessThanEnd", ":=", "constructTupleInequality", "(", "splitColumns", ",", "endBindVariables", ",", "true", "/* strict */", ")", "\n", "splitColsGreaterThanOrEqualToStart", ":=", "constructTupleInequality", "(", "startBindVariables", ",", "splitColumns", ",", "false", "/* not strict */", ")", "\n\n", "splitter", ".", "firstQueryPartSQL", "=", "sqlparser", ".", "String", "(", "queryWithAdditionalWhere", "(", "splitter", ".", "splitParams", ".", "selectAST", ",", "splitColsLessThanEnd", ")", ")", "\n", "splitter", ".", "middleQueryPartSQL", "=", "sqlparser", ".", "String", "(", "queryWithAdditionalWhere", "(", "splitter", ".", "splitParams", ".", "selectAST", ",", "&", "sqlparser", ".", "AndExpr", "{", "Left", ":", "&", "sqlparser", ".", "ParenExpr", "{", "Expr", ":", "splitColsGreaterThanOrEqualToStart", "}", ",", "Right", ":", "&", "sqlparser", ".", "ParenExpr", "{", "Expr", ":", "splitColsLessThanEnd", "}", ",", "}", ")", ")", "\n", "splitter", ".", "lastQueryPartSQL", "=", "sqlparser", ".", "String", "(", "queryWithAdditionalWhere", "(", "splitter", ".", "splitParams", ".", "selectAST", ",", "splitColsGreaterThanOrEqualToStart", ")", ")", "\n", "}" ]
// initQueryPartSQLs initializes the firstQueryPartSQL, middleQueryPartSQL and lastQueryPartSQL // fields.
[ "initQueryPartSQLs", "initializes", "the", "firstQueryPartSQL", "middleQueryPartSQL", "and", "lastQueryPartSQL", "fields", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/splitquery/splitter.go#L83-L106
train
vitessio/vitess
go/vt/vttablet/tabletserver/splitquery/splitter.go
queryWithAdditionalWhere
func queryWithAdditionalWhere( selectAST *sqlparser.Select, addedWhere sqlparser.Expr) *sqlparser.Select { result := *selectAST // Create a shallow-copy of 'selectAST' addAndTermToWhereClause(&result, addedWhere) return &result }
go
func queryWithAdditionalWhere( selectAST *sqlparser.Select, addedWhere sqlparser.Expr) *sqlparser.Select { result := *selectAST // Create a shallow-copy of 'selectAST' addAndTermToWhereClause(&result, addedWhere) return &result }
[ "func", "queryWithAdditionalWhere", "(", "selectAST", "*", "sqlparser", ".", "Select", ",", "addedWhere", "sqlparser", ".", "Expr", ")", "*", "sqlparser", ".", "Select", "{", "result", ":=", "*", "selectAST", "// Create a shallow-copy of 'selectAST'", "\n", "addAndTermToWhereClause", "(", "&", "result", ",", "addedWhere", ")", "\n", "return", "&", "result", "\n", "}" ]
// queryWithAdditionalWhere returns a copy of the given SELECT query with 'addedWhere' ANDed with // the query's WHERE clause. If the query does not already have a WHERE clause, 'addedWhere' // becomes the query's WHERE clause.
[ "queryWithAdditionalWhere", "returns", "a", "copy", "of", "the", "given", "SELECT", "query", "with", "addedWhere", "ANDed", "with", "the", "query", "s", "WHERE", "clause", ".", "If", "the", "query", "does", "not", "already", "have", "a", "WHERE", "clause", "addedWhere", "becomes", "the", "query", "s", "WHERE", "clause", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/splitquery/splitter.go#L249-L254
train
vitessio/vitess
go/vt/vtgate/gateway/shard_error.go
NewShardError
func NewShardError(in error, target *querypb.Target, tablet *topodatapb.Tablet) error { if in == nil { return nil } if tablet != nil { return vterrors.Wrapf(in, "target: %s.%s.%s, used tablet: %s", target.Keyspace, target.Shard, topoproto.TabletTypeLString(target.TabletType), topotools.TabletIdent(tablet)) } if target != nil { return vterrors.Wrapf(in, "target: %s.%s.%s", target.Keyspace, target.Shard, topoproto.TabletTypeLString(target.TabletType)) } return in }
go
func NewShardError(in error, target *querypb.Target, tablet *topodatapb.Tablet) error { if in == nil { return nil } if tablet != nil { return vterrors.Wrapf(in, "target: %s.%s.%s, used tablet: %s", target.Keyspace, target.Shard, topoproto.TabletTypeLString(target.TabletType), topotools.TabletIdent(tablet)) } if target != nil { return vterrors.Wrapf(in, "target: %s.%s.%s", target.Keyspace, target.Shard, topoproto.TabletTypeLString(target.TabletType)) } return in }
[ "func", "NewShardError", "(", "in", "error", ",", "target", "*", "querypb", ".", "Target", ",", "tablet", "*", "topodatapb", ".", "Tablet", ")", "error", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "tablet", "!=", "nil", "{", "return", "vterrors", ".", "Wrapf", "(", "in", ",", "\"", "\"", ",", "target", ".", "Keyspace", ",", "target", ".", "Shard", ",", "topoproto", ".", "TabletTypeLString", "(", "target", ".", "TabletType", ")", ",", "topotools", ".", "TabletIdent", "(", "tablet", ")", ")", "\n", "}", "\n", "if", "target", "!=", "nil", "{", "return", "vterrors", ".", "Wrapf", "(", "in", ",", "\"", "\"", ",", "target", ".", "Keyspace", ",", "target", ".", "Shard", ",", "topoproto", ".", "TabletTypeLString", "(", "target", ".", "TabletType", ")", ")", "\n", "}", "\n", "return", "in", "\n", "}" ]
// NewShardError returns a new error with the shard info amended.
[ "NewShardError", "returns", "a", "new", "error", "with", "the", "shard", "info", "amended", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/gateway/shard_error.go#L29-L40
train
vitessio/vitess
go/vt/vtgate/planbuilder/update.go
buildUpdatePlan
func buildUpdatePlan(upd *sqlparser.Update, vschema ContextVSchema) (*engine.Update, error) { eupd := &engine.Update{ ChangedVindexValues: make(map[string][]sqltypes.PlanValue), } pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(upd))) ro, err := pb.processDMLTable(upd.TableExprs) if err != nil { return nil, err } eupd.Keyspace = ro.eroute.Keyspace if !eupd.Keyspace.Sharded { // We only validate non-table subexpressions because the previous analysis has already validated them. if !pb.finalizeUnshardedDMLSubqueries(upd.Exprs, upd.Where, upd.OrderBy, upd.Limit) { return nil, errors.New("unsupported: sharded subqueries in DML") } eupd.Opcode = engine.UpdateUnsharded // Generate query after all the analysis. Otherwise table name substitutions for // routed tables won't happen. eupd.Query = generateQuery(upd) return eupd, nil } if hasSubquery(upd) { return nil, errors.New("unsupported: subqueries in sharded DML") } if len(pb.st.tables) != 1 { return nil, errors.New("unsupported: multi-table update statement in sharded keyspace") } // Generate query after all the analysis. Otherwise table name substitutions for // routed tables won't happen. eupd.Query = generateQuery(upd) directives := sqlparser.ExtractCommentDirectives(upd.Comments) if directives.IsSet(sqlparser.DirectiveMultiShardAutocommit) { eupd.MultiShardAutocommit = true } eupd.QueryTimeout = queryTimeout(directives) eupd.Table = ro.vschemaTable if eupd.Table == nil { return nil, errors.New("internal error: table.vindexTable is mysteriously nil") } if ro.eroute.TargetDestination != nil { if ro.eroute.TargetTabletType != topodatapb.TabletType_MASTER { return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "unsupported: UPDATE statement with a replica target") } eupd.Opcode = engine.UpdateByDestination eupd.TargetDestination = ro.eroute.TargetDestination return eupd, nil } eupd.Vindex, eupd.Values, err = getDMLRouting(upd.Where, eupd.Table) if err != nil { eupd.Opcode = engine.UpdateScatter } else { eupd.Opcode = engine.UpdateEqual } if eupd.Opcode == engine.UpdateScatter { if len(eupd.Table.Owned) != 0 { return eupd, errors.New("unsupported: multi shard update on a table with owned lookup vindexes") } if upd.Limit != nil { return eupd, errors.New("unsupported: multi shard update with limit") } } if eupd.ChangedVindexValues, err = buildChangedVindexesValues(eupd, upd, eupd.Table.ColumnVindexes); err != nil { return nil, err } if len(eupd.ChangedVindexValues) != 0 { eupd.OwnedVindexQuery = generateUpdateSubquery(upd, eupd.Table) } return eupd, nil }
go
func buildUpdatePlan(upd *sqlparser.Update, vschema ContextVSchema) (*engine.Update, error) { eupd := &engine.Update{ ChangedVindexValues: make(map[string][]sqltypes.PlanValue), } pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(upd))) ro, err := pb.processDMLTable(upd.TableExprs) if err != nil { return nil, err } eupd.Keyspace = ro.eroute.Keyspace if !eupd.Keyspace.Sharded { // We only validate non-table subexpressions because the previous analysis has already validated them. if !pb.finalizeUnshardedDMLSubqueries(upd.Exprs, upd.Where, upd.OrderBy, upd.Limit) { return nil, errors.New("unsupported: sharded subqueries in DML") } eupd.Opcode = engine.UpdateUnsharded // Generate query after all the analysis. Otherwise table name substitutions for // routed tables won't happen. eupd.Query = generateQuery(upd) return eupd, nil } if hasSubquery(upd) { return nil, errors.New("unsupported: subqueries in sharded DML") } if len(pb.st.tables) != 1 { return nil, errors.New("unsupported: multi-table update statement in sharded keyspace") } // Generate query after all the analysis. Otherwise table name substitutions for // routed tables won't happen. eupd.Query = generateQuery(upd) directives := sqlparser.ExtractCommentDirectives(upd.Comments) if directives.IsSet(sqlparser.DirectiveMultiShardAutocommit) { eupd.MultiShardAutocommit = true } eupd.QueryTimeout = queryTimeout(directives) eupd.Table = ro.vschemaTable if eupd.Table == nil { return nil, errors.New("internal error: table.vindexTable is mysteriously nil") } if ro.eroute.TargetDestination != nil { if ro.eroute.TargetTabletType != topodatapb.TabletType_MASTER { return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "unsupported: UPDATE statement with a replica target") } eupd.Opcode = engine.UpdateByDestination eupd.TargetDestination = ro.eroute.TargetDestination return eupd, nil } eupd.Vindex, eupd.Values, err = getDMLRouting(upd.Where, eupd.Table) if err != nil { eupd.Opcode = engine.UpdateScatter } else { eupd.Opcode = engine.UpdateEqual } if eupd.Opcode == engine.UpdateScatter { if len(eupd.Table.Owned) != 0 { return eupd, errors.New("unsupported: multi shard update on a table with owned lookup vindexes") } if upd.Limit != nil { return eupd, errors.New("unsupported: multi shard update with limit") } } if eupd.ChangedVindexValues, err = buildChangedVindexesValues(eupd, upd, eupd.Table.ColumnVindexes); err != nil { return nil, err } if len(eupd.ChangedVindexValues) != 0 { eupd.OwnedVindexQuery = generateUpdateSubquery(upd, eupd.Table) } return eupd, nil }
[ "func", "buildUpdatePlan", "(", "upd", "*", "sqlparser", ".", "Update", ",", "vschema", "ContextVSchema", ")", "(", "*", "engine", ".", "Update", ",", "error", ")", "{", "eupd", ":=", "&", "engine", ".", "Update", "{", "ChangedVindexValues", ":", "make", "(", "map", "[", "string", "]", "[", "]", "sqltypes", ".", "PlanValue", ")", ",", "}", "\n", "pb", ":=", "newPrimitiveBuilder", "(", "vschema", ",", "newJointab", "(", "sqlparser", ".", "GetBindvars", "(", "upd", ")", ")", ")", "\n", "ro", ",", "err", ":=", "pb", ".", "processDMLTable", "(", "upd", ".", "TableExprs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "eupd", ".", "Keyspace", "=", "ro", ".", "eroute", ".", "Keyspace", "\n", "if", "!", "eupd", ".", "Keyspace", ".", "Sharded", "{", "// We only validate non-table subexpressions because the previous analysis has already validated them.", "if", "!", "pb", ".", "finalizeUnshardedDMLSubqueries", "(", "upd", ".", "Exprs", ",", "upd", ".", "Where", ",", "upd", ".", "OrderBy", ",", "upd", ".", "Limit", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "eupd", ".", "Opcode", "=", "engine", ".", "UpdateUnsharded", "\n", "// Generate query after all the analysis. Otherwise table name substitutions for", "// routed tables won't happen.", "eupd", ".", "Query", "=", "generateQuery", "(", "upd", ")", "\n", "return", "eupd", ",", "nil", "\n", "}", "\n\n", "if", "hasSubquery", "(", "upd", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "pb", ".", "st", ".", "tables", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Generate query after all the analysis. Otherwise table name substitutions for", "// routed tables won't happen.", "eupd", ".", "Query", "=", "generateQuery", "(", "upd", ")", "\n\n", "directives", ":=", "sqlparser", ".", "ExtractCommentDirectives", "(", "upd", ".", "Comments", ")", "\n", "if", "directives", ".", "IsSet", "(", "sqlparser", ".", "DirectiveMultiShardAutocommit", ")", "{", "eupd", ".", "MultiShardAutocommit", "=", "true", "\n", "}", "\n\n", "eupd", ".", "QueryTimeout", "=", "queryTimeout", "(", "directives", ")", "\n", "eupd", ".", "Table", "=", "ro", ".", "vschemaTable", "\n", "if", "eupd", ".", "Table", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "ro", ".", "eroute", ".", "TargetDestination", "!=", "nil", "{", "if", "ro", ".", "eroute", ".", "TargetTabletType", "!=", "topodatapb", ".", "TabletType_MASTER", "{", "return", "nil", ",", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_INVALID_ARGUMENT", ",", "\"", "\"", ")", "\n", "}", "\n", "eupd", ".", "Opcode", "=", "engine", ".", "UpdateByDestination", "\n", "eupd", ".", "TargetDestination", "=", "ro", ".", "eroute", ".", "TargetDestination", "\n", "return", "eupd", ",", "nil", "\n", "}", "\n\n", "eupd", ".", "Vindex", ",", "eupd", ".", "Values", ",", "err", "=", "getDMLRouting", "(", "upd", ".", "Where", ",", "eupd", ".", "Table", ")", "\n", "if", "err", "!=", "nil", "{", "eupd", ".", "Opcode", "=", "engine", ".", "UpdateScatter", "\n", "}", "else", "{", "eupd", ".", "Opcode", "=", "engine", ".", "UpdateEqual", "\n", "}", "\n\n", "if", "eupd", ".", "Opcode", "==", "engine", ".", "UpdateScatter", "{", "if", "len", "(", "eupd", ".", "Table", ".", "Owned", ")", "!=", "0", "{", "return", "eupd", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "upd", ".", "Limit", "!=", "nil", "{", "return", "eupd", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "if", "eupd", ".", "ChangedVindexValues", ",", "err", "=", "buildChangedVindexesValues", "(", "eupd", ",", "upd", ",", "eupd", ".", "Table", ".", "ColumnVindexes", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "eupd", ".", "ChangedVindexValues", ")", "!=", "0", "{", "eupd", ".", "OwnedVindexQuery", "=", "generateUpdateSubquery", "(", "upd", ",", "eupd", ".", "Table", ")", "\n", "}", "\n", "return", "eupd", ",", "nil", "\n", "}" ]
// buildUpdatePlan builds the instructions for an UPDATE statement.
[ "buildUpdatePlan", "builds", "the", "instructions", "for", "an", "UPDATE", "statement", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/update.go#L33-L109
train
vitessio/vitess
go/vt/vtgate/planbuilder/update.go
buildChangedVindexesValues
func buildChangedVindexesValues(eupd *engine.Update, update *sqlparser.Update, colVindexes []*vindexes.ColumnVindex) (map[string][]sqltypes.PlanValue, error) { changedVindexes := make(map[string][]sqltypes.PlanValue) for i, vindex := range colVindexes { var vindexValues []sqltypes.PlanValue for _, vcol := range vindex.Columns { // Searching in order of columns in colvindex. found := false for _, assignment := range update.Exprs { if !vcol.Equal(assignment.Name.Name) { continue } if found { return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "column has duplicate set values: '%v'", assignment.Name.Name) } found = true pv, err := extractValueFromUpdate(assignment) if err != nil { return nil, err } vindexValues = append(vindexValues, pv) } } if len(vindexValues) == 0 { // Vindex not changing, continue continue } if len(vindexValues) != len(vindex.Columns) { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: update does not have values for all the columns in vindex (%s)", vindex.Name) } if update.Limit != nil && len(update.OrderBy) == 0 { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: Need to provide order by clause when using limit. Invalid update on vindex: %v", vindex.Name) } if i == 0 { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: You can't update primary vindex columns. Invalid update on vindex: %v", vindex.Name) } if _, ok := vindex.Vindex.(vindexes.Lookup); !ok { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: You can only update lookup vindexes. Invalid update on vindex: %v", vindex.Name) } if !vindex.Owned { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: You can only update owned vindexes. Invalid update on vindex: %v", vindex.Name) } changedVindexes[vindex.Name] = vindexValues } return changedVindexes, nil }
go
func buildChangedVindexesValues(eupd *engine.Update, update *sqlparser.Update, colVindexes []*vindexes.ColumnVindex) (map[string][]sqltypes.PlanValue, error) { changedVindexes := make(map[string][]sqltypes.PlanValue) for i, vindex := range colVindexes { var vindexValues []sqltypes.PlanValue for _, vcol := range vindex.Columns { // Searching in order of columns in colvindex. found := false for _, assignment := range update.Exprs { if !vcol.Equal(assignment.Name.Name) { continue } if found { return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "column has duplicate set values: '%v'", assignment.Name.Name) } found = true pv, err := extractValueFromUpdate(assignment) if err != nil { return nil, err } vindexValues = append(vindexValues, pv) } } if len(vindexValues) == 0 { // Vindex not changing, continue continue } if len(vindexValues) != len(vindex.Columns) { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: update does not have values for all the columns in vindex (%s)", vindex.Name) } if update.Limit != nil && len(update.OrderBy) == 0 { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: Need to provide order by clause when using limit. Invalid update on vindex: %v", vindex.Name) } if i == 0 { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: You can't update primary vindex columns. Invalid update on vindex: %v", vindex.Name) } if _, ok := vindex.Vindex.(vindexes.Lookup); !ok { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: You can only update lookup vindexes. Invalid update on vindex: %v", vindex.Name) } if !vindex.Owned { return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: You can only update owned vindexes. Invalid update on vindex: %v", vindex.Name) } changedVindexes[vindex.Name] = vindexValues } return changedVindexes, nil }
[ "func", "buildChangedVindexesValues", "(", "eupd", "*", "engine", ".", "Update", ",", "update", "*", "sqlparser", ".", "Update", ",", "colVindexes", "[", "]", "*", "vindexes", ".", "ColumnVindex", ")", "(", "map", "[", "string", "]", "[", "]", "sqltypes", ".", "PlanValue", ",", "error", ")", "{", "changedVindexes", ":=", "make", "(", "map", "[", "string", "]", "[", "]", "sqltypes", ".", "PlanValue", ")", "\n", "for", "i", ",", "vindex", ":=", "range", "colVindexes", "{", "var", "vindexValues", "[", "]", "sqltypes", ".", "PlanValue", "\n", "for", "_", ",", "vcol", ":=", "range", "vindex", ".", "Columns", "{", "// Searching in order of columns in colvindex.", "found", ":=", "false", "\n", "for", "_", ",", "assignment", ":=", "range", "update", ".", "Exprs", "{", "if", "!", "vcol", ".", "Equal", "(", "assignment", ".", "Name", ".", "Name", ")", "{", "continue", "\n", "}", "\n", "if", "found", "{", "return", "nil", ",", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_INVALID_ARGUMENT", ",", "\"", "\"", ",", "assignment", ".", "Name", ".", "Name", ")", "\n", "}", "\n", "found", "=", "true", "\n", "pv", ",", "err", ":=", "extractValueFromUpdate", "(", "assignment", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "vindexValues", "=", "append", "(", "vindexValues", ",", "pv", ")", "\n", "}", "\n", "}", "\n", "if", "len", "(", "vindexValues", ")", "==", "0", "{", "// Vindex not changing, continue", "continue", "\n", "}", "\n", "if", "len", "(", "vindexValues", ")", "!=", "len", "(", "vindex", ".", "Columns", ")", "{", "return", "nil", ",", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_UNIMPLEMENTED", ",", "\"", "\"", ",", "vindex", ".", "Name", ")", "\n", "}", "\n\n", "if", "update", ".", "Limit", "!=", "nil", "&&", "len", "(", "update", ".", "OrderBy", ")", "==", "0", "{", "return", "nil", ",", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_UNIMPLEMENTED", ",", "\"", "\"", ",", "vindex", ".", "Name", ")", "\n", "}", "\n", "if", "i", "==", "0", "{", "return", "nil", ",", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_UNIMPLEMENTED", ",", "\"", "\"", ",", "vindex", ".", "Name", ")", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "vindex", ".", "Vindex", ".", "(", "vindexes", ".", "Lookup", ")", ";", "!", "ok", "{", "return", "nil", ",", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_UNIMPLEMENTED", ",", "\"", "\"", ",", "vindex", ".", "Name", ")", "\n", "}", "\n", "if", "!", "vindex", ".", "Owned", "{", "return", "nil", ",", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_UNIMPLEMENTED", ",", "\"", "\"", ",", "vindex", ".", "Name", ")", "\n", "}", "\n", "changedVindexes", "[", "vindex", ".", "Name", "]", "=", "vindexValues", "\n", "}", "\n\n", "return", "changedVindexes", ",", "nil", "\n", "}" ]
// buildChangedVindexesValues adds to the plan all the lookup vindexes that are changing. // Updates can only be performed to secondary lookup vindexes with no complex expressions // in the set clause.
[ "buildChangedVindexesValues", "adds", "to", "the", "plan", "all", "the", "lookup", "vindexes", "that", "are", "changing", ".", "Updates", "can", "only", "be", "performed", "to", "secondary", "lookup", "vindexes", "with", "no", "complex", "expressions", "in", "the", "set", "clause", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/update.go#L114-L160
train
vitessio/vitess
go/vt/vtgate/planbuilder/update.go
dmlFormatter
func dmlFormatter(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) { switch node := node.(type) { case sqlparser.TableName: node.Name.Format(buf) return } node.Format(buf) }
go
func dmlFormatter(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) { switch node := node.(type) { case sqlparser.TableName: node.Name.Format(buf) return } node.Format(buf) }
[ "func", "dmlFormatter", "(", "buf", "*", "sqlparser", ".", "TrackedBuffer", ",", "node", "sqlparser", ".", "SQLNode", ")", "{", "switch", "node", ":=", "node", ".", "(", "type", ")", "{", "case", "sqlparser", ".", "TableName", ":", "node", ".", "Name", ".", "Format", "(", "buf", ")", "\n", "return", "\n", "}", "\n", "node", ".", "Format", "(", "buf", ")", "\n", "}" ]
// dmlFormatter strips out keyspace name from dmls.
[ "dmlFormatter", "strips", "out", "keyspace", "name", "from", "dmls", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/update.go#L190-L197
train
vitessio/vitess
go/vt/vtgate/planbuilder/update.go
getDMLRouting
func getDMLRouting(where *sqlparser.Where, table *vindexes.Table) (vindexes.Vindex, []sqltypes.PlanValue, error) { if where == nil { return nil, nil, errors.New("unsupported: multi-shard where clause in DML") } for _, index := range table.Ordered { if !index.Vindex.IsUnique() { continue } if pv, ok := getMatch(where.Expr, index.Columns[0]); ok { return index.Vindex, []sqltypes.PlanValue{pv}, nil } } return nil, nil, errors.New("unsupported: multi-shard where clause in DML") }
go
func getDMLRouting(where *sqlparser.Where, table *vindexes.Table) (vindexes.Vindex, []sqltypes.PlanValue, error) { if where == nil { return nil, nil, errors.New("unsupported: multi-shard where clause in DML") } for _, index := range table.Ordered { if !index.Vindex.IsUnique() { continue } if pv, ok := getMatch(where.Expr, index.Columns[0]); ok { return index.Vindex, []sqltypes.PlanValue{pv}, nil } } return nil, nil, errors.New("unsupported: multi-shard where clause in DML") }
[ "func", "getDMLRouting", "(", "where", "*", "sqlparser", ".", "Where", ",", "table", "*", "vindexes", ".", "Table", ")", "(", "vindexes", ".", "Vindex", ",", "[", "]", "sqltypes", ".", "PlanValue", ",", "error", ")", "{", "if", "where", "==", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "_", ",", "index", ":=", "range", "table", ".", "Ordered", "{", "if", "!", "index", ".", "Vindex", ".", "IsUnique", "(", ")", "{", "continue", "\n", "}", "\n", "if", "pv", ",", "ok", ":=", "getMatch", "(", "where", ".", "Expr", ",", "index", ".", "Columns", "[", "0", "]", ")", ";", "ok", "{", "return", "index", ".", "Vindex", ",", "[", "]", "sqltypes", ".", "PlanValue", "{", "pv", "}", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// getDMLRouting returns the vindex and values for the DML, // If it cannot find a unique vindex match, it returns an error.
[ "getDMLRouting", "returns", "the", "vindex", "and", "values", "for", "the", "DML", "If", "it", "cannot", "find", "a", "unique", "vindex", "match", "it", "returns", "an", "error", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/update.go#L207-L220
train
vitessio/vitess
go/vt/vtgate/planbuilder/update.go
getMatch
func getMatch(node sqlparser.Expr, col sqlparser.ColIdent) (pv sqltypes.PlanValue, ok bool) { filters := splitAndExpression(nil, node) for _, filter := range filters { filter = skipParenthesis(filter) if parenthesis, ok := node.(*sqlparser.ParenExpr); ok { if pv, ok := getMatch(parenthesis.Expr, col); ok { return pv, ok } continue } comparison, ok := filter.(*sqlparser.ComparisonExpr) if !ok { continue } if comparison.Operator != sqlparser.EqualStr { continue } if !nameMatch(comparison.Left, col) { continue } if !sqlparser.IsValue(comparison.Right) { continue } pv, err := sqlparser.NewPlanValue(comparison.Right) if err != nil { continue } return pv, true } return sqltypes.PlanValue{}, false }
go
func getMatch(node sqlparser.Expr, col sqlparser.ColIdent) (pv sqltypes.PlanValue, ok bool) { filters := splitAndExpression(nil, node) for _, filter := range filters { filter = skipParenthesis(filter) if parenthesis, ok := node.(*sqlparser.ParenExpr); ok { if pv, ok := getMatch(parenthesis.Expr, col); ok { return pv, ok } continue } comparison, ok := filter.(*sqlparser.ComparisonExpr) if !ok { continue } if comparison.Operator != sqlparser.EqualStr { continue } if !nameMatch(comparison.Left, col) { continue } if !sqlparser.IsValue(comparison.Right) { continue } pv, err := sqlparser.NewPlanValue(comparison.Right) if err != nil { continue } return pv, true } return sqltypes.PlanValue{}, false }
[ "func", "getMatch", "(", "node", "sqlparser", ".", "Expr", ",", "col", "sqlparser", ".", "ColIdent", ")", "(", "pv", "sqltypes", ".", "PlanValue", ",", "ok", "bool", ")", "{", "filters", ":=", "splitAndExpression", "(", "nil", ",", "node", ")", "\n", "for", "_", ",", "filter", ":=", "range", "filters", "{", "filter", "=", "skipParenthesis", "(", "filter", ")", "\n", "if", "parenthesis", ",", "ok", ":=", "node", ".", "(", "*", "sqlparser", ".", "ParenExpr", ")", ";", "ok", "{", "if", "pv", ",", "ok", ":=", "getMatch", "(", "parenthesis", ".", "Expr", ",", "col", ")", ";", "ok", "{", "return", "pv", ",", "ok", "\n", "}", "\n", "continue", "\n", "}", "\n", "comparison", ",", "ok", ":=", "filter", ".", "(", "*", "sqlparser", ".", "ComparisonExpr", ")", "\n", "if", "!", "ok", "{", "continue", "\n", "}", "\n", "if", "comparison", ".", "Operator", "!=", "sqlparser", ".", "EqualStr", "{", "continue", "\n", "}", "\n", "if", "!", "nameMatch", "(", "comparison", ".", "Left", ",", "col", ")", "{", "continue", "\n", "}", "\n", "if", "!", "sqlparser", ".", "IsValue", "(", "comparison", ".", "Right", ")", "{", "continue", "\n", "}", "\n", "pv", ",", "err", ":=", "sqlparser", ".", "NewPlanValue", "(", "comparison", ".", "Right", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "return", "pv", ",", "true", "\n", "}", "\n", "return", "sqltypes", ".", "PlanValue", "{", "}", ",", "false", "\n", "}" ]
// getMatch returns the matched value if there is an equality // constraint on the specified column that can be used to // decide on a route.
[ "getMatch", "returns", "the", "matched", "value", "if", "there", "is", "an", "equality", "constraint", "on", "the", "specified", "column", "that", "can", "be", "used", "to", "decide", "on", "a", "route", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/update.go#L225-L255
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
DialTablet
func DialTablet(tablet *topodatapb.Tablet, failFast grpcclient.FailFast) (queryservice.QueryService, error) { // create the RPC client addr := "" if grpcPort, ok := tablet.PortMap["grpc"]; ok { addr = netutil.JoinHostPort(tablet.Hostname, grpcPort) } else { addr = tablet.Hostname } opt, err := grpcclient.SecureDialOption(*cert, *key, *ca, *name) if err != nil { return nil, err } cc, err := grpcclient.Dial(addr, failFast, opt) if err != nil { return nil, err } c := queryservicepb.NewQueryClient(cc) result := &gRPCQueryClient{ tablet: tablet, cc: cc, c: c, } return result, nil }
go
func DialTablet(tablet *topodatapb.Tablet, failFast grpcclient.FailFast) (queryservice.QueryService, error) { // create the RPC client addr := "" if grpcPort, ok := tablet.PortMap["grpc"]; ok { addr = netutil.JoinHostPort(tablet.Hostname, grpcPort) } else { addr = tablet.Hostname } opt, err := grpcclient.SecureDialOption(*cert, *key, *ca, *name) if err != nil { return nil, err } cc, err := grpcclient.Dial(addr, failFast, opt) if err != nil { return nil, err } c := queryservicepb.NewQueryClient(cc) result := &gRPCQueryClient{ tablet: tablet, cc: cc, c: c, } return result, nil }
[ "func", "DialTablet", "(", "tablet", "*", "topodatapb", ".", "Tablet", ",", "failFast", "grpcclient", ".", "FailFast", ")", "(", "queryservice", ".", "QueryService", ",", "error", ")", "{", "// create the RPC client", "addr", ":=", "\"", "\"", "\n", "if", "grpcPort", ",", "ok", ":=", "tablet", ".", "PortMap", "[", "\"", "\"", "]", ";", "ok", "{", "addr", "=", "netutil", ".", "JoinHostPort", "(", "tablet", ".", "Hostname", ",", "grpcPort", ")", "\n", "}", "else", "{", "addr", "=", "tablet", ".", "Hostname", "\n", "}", "\n", "opt", ",", "err", ":=", "grpcclient", ".", "SecureDialOption", "(", "*", "cert", ",", "*", "key", ",", "*", "ca", ",", "*", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "cc", ",", "err", ":=", "grpcclient", ".", "Dial", "(", "addr", ",", "failFast", ",", "opt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "c", ":=", "queryservicepb", ".", "NewQueryClient", "(", "cc", ")", "\n\n", "result", ":=", "&", "gRPCQueryClient", "{", "tablet", ":", "tablet", ",", "cc", ":", "cc", ",", "c", ":", "c", ",", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
// DialTablet creates and initializes gRPCQueryClient.
[ "DialTablet", "creates", "and", "initializes", "gRPCQueryClient", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L64-L89
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
StreamExecute
func (conn *gRPCQueryClient) StreamExecute(ctx context.Context, target *querypb.Target, query string, bindVars map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error { // All streaming clients should follow the code pattern below. // The first part of the function starts the stream while holding // a lock on conn.mu. The second part receives the data and calls // callback. // A new cancelable context is needed because there's currently // no direct API to end a stream from the client side. If callback // returns an error, we return from the function. The deferred // cancel will then cause the stream to be terminated. ctx, cancel := context.WithCancel(ctx) defer cancel() stream, err := func() (queryservicepb.Query_StreamExecuteClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &querypb.StreamExecuteRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: &querypb.BoundQuery{ Sql: query, BindVariables: bindVars, }, Options: options, TransactionId: transactionID, } stream, err := conn.c.StreamExecute(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } var fields []*querypb.Field for { ser, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } if fields == nil { fields = ser.Result.Fields } if err := callback(sqltypes.CustomProto3ToResult(fields, ser.Result)); err != nil { if err == nil || err == io.EOF { return nil } return err } } }
go
func (conn *gRPCQueryClient) StreamExecute(ctx context.Context, target *querypb.Target, query string, bindVars map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error { // All streaming clients should follow the code pattern below. // The first part of the function starts the stream while holding // a lock on conn.mu. The second part receives the data and calls // callback. // A new cancelable context is needed because there's currently // no direct API to end a stream from the client side. If callback // returns an error, we return from the function. The deferred // cancel will then cause the stream to be terminated. ctx, cancel := context.WithCancel(ctx) defer cancel() stream, err := func() (queryservicepb.Query_StreamExecuteClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &querypb.StreamExecuteRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: &querypb.BoundQuery{ Sql: query, BindVariables: bindVars, }, Options: options, TransactionId: transactionID, } stream, err := conn.c.StreamExecute(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } var fields []*querypb.Field for { ser, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } if fields == nil { fields = ser.Result.Fields } if err := callback(sqltypes.CustomProto3ToResult(fields, ser.Result)); err != nil { if err == nil || err == io.EOF { return nil } return err } } }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "StreamExecute", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "query", "string", ",", "bindVars", "map", "[", "string", "]", "*", "querypb", ".", "BindVariable", ",", "transactionID", "int64", ",", "options", "*", "querypb", ".", "ExecuteOptions", ",", "callback", "func", "(", "*", "sqltypes", ".", "Result", ")", "error", ")", "error", "{", "// All streaming clients should follow the code pattern below.", "// The first part of the function starts the stream while holding", "// a lock on conn.mu. The second part receives the data and calls", "// callback.", "// A new cancelable context is needed because there's currently", "// no direct API to end a stream from the client side. If callback", "// returns an error, we return from the function. The deferred", "// cancel will then cause the stream to be terminated.", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "stream", ",", "err", ":=", "func", "(", ")", "(", "queryservicepb", ".", "Query_StreamExecuteClient", ",", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "querypb", ".", "StreamExecuteRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Query", ":", "&", "querypb", ".", "BoundQuery", "{", "Sql", ":", "query", ",", "BindVariables", ":", "bindVars", ",", "}", ",", "Options", ":", "options", ",", "TransactionId", ":", "transactionID", ",", "}", "\n", "stream", ",", "err", ":=", "conn", ".", "c", ".", "StreamExecute", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "stream", ",", "nil", "\n", "}", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "fields", "[", "]", "*", "querypb", ".", "Field", "\n", "for", "{", "ser", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "if", "fields", "==", "nil", "{", "fields", "=", "ser", ".", "Result", ".", "Fields", "\n", "}", "\n", "if", "err", ":=", "callback", "(", "sqltypes", ".", "CustomProto3ToResult", "(", "fields", ",", "ser", ".", "Result", ")", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "nil", "||", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// StreamExecute executes the query and streams results back through callback.
[ "StreamExecute", "executes", "the", "query", "and", "streams", "results", "back", "through", "callback", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L142-L197
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
Begin
func (conn *gRPCQueryClient) Begin(ctx context.Context, target *querypb.Target, options *querypb.ExecuteOptions) (transactionID int64, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return 0, tabletconn.ConnClosed } req := &querypb.BeginRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Options: options, } br, err := conn.c.Begin(ctx, req) if err != nil { return 0, tabletconn.ErrorFromGRPC(err) } return br.TransactionId, nil }
go
func (conn *gRPCQueryClient) Begin(ctx context.Context, target *querypb.Target, options *querypb.ExecuteOptions) (transactionID int64, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return 0, tabletconn.ConnClosed } req := &querypb.BeginRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Options: options, } br, err := conn.c.Begin(ctx, req) if err != nil { return 0, tabletconn.ErrorFromGRPC(err) } return br.TransactionId, nil }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "Begin", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "options", "*", "querypb", ".", "ExecuteOptions", ")", "(", "transactionID", "int64", ",", "err", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "0", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "querypb", ".", "BeginRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Options", ":", "options", ",", "}", "\n", "br", ",", "err", ":=", "conn", ".", "c", ".", "Begin", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "br", ".", "TransactionId", ",", "nil", "\n", "}" ]
// Begin starts a transaction.
[ "Begin", "starts", "a", "transaction", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L200-L218
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
Commit
func (conn *gRPCQueryClient) Commit(ctx context.Context, target *querypb.Target, transactionID int64) error { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return tabletconn.ConnClosed } req := &querypb.CommitRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), TransactionId: transactionID, } _, err := conn.c.Commit(ctx, req) if err != nil { return tabletconn.ErrorFromGRPC(err) } return nil }
go
func (conn *gRPCQueryClient) Commit(ctx context.Context, target *querypb.Target, transactionID int64) error { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return tabletconn.ConnClosed } req := &querypb.CommitRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), TransactionId: transactionID, } _, err := conn.c.Commit(ctx, req) if err != nil { return tabletconn.ErrorFromGRPC(err) } return nil }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "Commit", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "transactionID", "int64", ")", "error", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "querypb", ".", "CommitRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "TransactionId", ":", "transactionID", ",", "}", "\n", "_", ",", "err", ":=", "conn", ".", "c", ".", "Commit", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Commit commits the ongoing transaction.
[ "Commit", "commits", "the", "ongoing", "transaction", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L221-L239
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
BeginExecute
func (conn *gRPCQueryClient) BeginExecute(ctx context.Context, target *querypb.Target, query string, bindVars map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (result *sqltypes.Result, transactionID int64, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, 0, tabletconn.ConnClosed } req := &querypb.BeginExecuteRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: &querypb.BoundQuery{ Sql: query, BindVariables: bindVars, }, Options: options, } reply, err := conn.c.BeginExecute(ctx, req) if err != nil { return nil, 0, tabletconn.ErrorFromGRPC(err) } if reply.Error != nil { return nil, reply.TransactionId, tabletconn.ErrorFromVTRPC(reply.Error) } return sqltypes.Proto3ToResult(reply.Result), reply.TransactionId, nil }
go
func (conn *gRPCQueryClient) BeginExecute(ctx context.Context, target *querypb.Target, query string, bindVars map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (result *sqltypes.Result, transactionID int64, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, 0, tabletconn.ConnClosed } req := &querypb.BeginExecuteRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: &querypb.BoundQuery{ Sql: query, BindVariables: bindVars, }, Options: options, } reply, err := conn.c.BeginExecute(ctx, req) if err != nil { return nil, 0, tabletconn.ErrorFromGRPC(err) } if reply.Error != nil { return nil, reply.TransactionId, tabletconn.ErrorFromVTRPC(reply.Error) } return sqltypes.Proto3ToResult(reply.Result), reply.TransactionId, nil }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "BeginExecute", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "query", "string", ",", "bindVars", "map", "[", "string", "]", "*", "querypb", ".", "BindVariable", ",", "options", "*", "querypb", ".", "ExecuteOptions", ")", "(", "result", "*", "sqltypes", ".", "Result", ",", "transactionID", "int64", ",", "err", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", ",", "0", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "querypb", ".", "BeginExecuteRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Query", ":", "&", "querypb", ".", "BoundQuery", "{", "Sql", ":", "query", ",", "BindVariables", ":", "bindVars", ",", "}", ",", "Options", ":", "options", ",", "}", "\n", "reply", ",", "err", ":=", "conn", ".", "c", ".", "BeginExecute", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "if", "reply", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "reply", ".", "TransactionId", ",", "tabletconn", ".", "ErrorFromVTRPC", "(", "reply", ".", "Error", ")", "\n", "}", "\n", "return", "sqltypes", ".", "Proto3ToResult", "(", "reply", ".", "Result", ")", ",", "reply", ".", "TransactionId", ",", "nil", "\n", "}" ]
// BeginExecute starts a transaction and runs an Execute.
[ "BeginExecute", "starts", "a", "transaction", "and", "runs", "an", "Execute", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L439-L464
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
BeginExecuteBatch
func (conn *gRPCQueryClient) BeginExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, options *querypb.ExecuteOptions) (results []sqltypes.Result, transactionID int64, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, 0, tabletconn.ConnClosed } req := &querypb.BeginExecuteBatchRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Queries: queries, AsTransaction: asTransaction, Options: options, } reply, err := conn.c.BeginExecuteBatch(ctx, req) if err != nil { return nil, 0, tabletconn.ErrorFromGRPC(err) } if reply.Error != nil { return nil, reply.TransactionId, tabletconn.ErrorFromVTRPC(reply.Error) } return sqltypes.Proto3ToResults(reply.Results), reply.TransactionId, nil }
go
func (conn *gRPCQueryClient) BeginExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, options *querypb.ExecuteOptions) (results []sqltypes.Result, transactionID int64, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, 0, tabletconn.ConnClosed } req := &querypb.BeginExecuteBatchRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Queries: queries, AsTransaction: asTransaction, Options: options, } reply, err := conn.c.BeginExecuteBatch(ctx, req) if err != nil { return nil, 0, tabletconn.ErrorFromGRPC(err) } if reply.Error != nil { return nil, reply.TransactionId, tabletconn.ErrorFromVTRPC(reply.Error) } return sqltypes.Proto3ToResults(reply.Results), reply.TransactionId, nil }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "BeginExecuteBatch", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "queries", "[", "]", "*", "querypb", ".", "BoundQuery", ",", "asTransaction", "bool", ",", "options", "*", "querypb", ".", "ExecuteOptions", ")", "(", "results", "[", "]", "sqltypes", ".", "Result", ",", "transactionID", "int64", ",", "err", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", ",", "0", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "querypb", ".", "BeginExecuteBatchRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Queries", ":", "queries", ",", "AsTransaction", ":", "asTransaction", ",", "Options", ":", "options", ",", "}", "\n\n", "reply", ",", "err", ":=", "conn", ".", "c", ".", "BeginExecuteBatch", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "if", "reply", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "reply", ".", "TransactionId", ",", "tabletconn", ".", "ErrorFromVTRPC", "(", "reply", ".", "Error", ")", "\n", "}", "\n", "return", "sqltypes", ".", "Proto3ToResults", "(", "reply", ".", "Results", ")", ",", "reply", ".", "TransactionId", ",", "nil", "\n", "}" ]
// BeginExecuteBatch starts a transaction and runs an ExecuteBatch.
[ "BeginExecuteBatch", "starts", "a", "transaction", "and", "runs", "an", "ExecuteBatch", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L467-L491
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
SplitQuery
func (conn *gRPCQueryClient) SplitQuery( ctx context.Context, target *querypb.Target, query *querypb.BoundQuery, splitColumns []string, splitCount int64, numRowsPerQueryPart int64, algorithm querypb.SplitQueryRequest_Algorithm) (queries []*querypb.QuerySplit, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { err = tabletconn.ConnClosed return } req := &querypb.SplitQueryRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: query, SplitColumn: splitColumns, SplitCount: splitCount, NumRowsPerQueryPart: numRowsPerQueryPart, Algorithm: algorithm, } sqr, err := conn.c.SplitQuery(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return sqr.Queries, nil }
go
func (conn *gRPCQueryClient) SplitQuery( ctx context.Context, target *querypb.Target, query *querypb.BoundQuery, splitColumns []string, splitCount int64, numRowsPerQueryPart int64, algorithm querypb.SplitQueryRequest_Algorithm) (queries []*querypb.QuerySplit, err error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { err = tabletconn.ConnClosed return } req := &querypb.SplitQueryRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: query, SplitColumn: splitColumns, SplitCount: splitCount, NumRowsPerQueryPart: numRowsPerQueryPart, Algorithm: algorithm, } sqr, err := conn.c.SplitQuery(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return sqr.Queries, nil }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "SplitQuery", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "query", "*", "querypb", ".", "BoundQuery", ",", "splitColumns", "[", "]", "string", ",", "splitCount", "int64", ",", "numRowsPerQueryPart", "int64", ",", "algorithm", "querypb", ".", "SplitQueryRequest_Algorithm", ")", "(", "queries", "[", "]", "*", "querypb", ".", "QuerySplit", ",", "err", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "err", "=", "tabletconn", ".", "ConnClosed", "\n", "return", "\n", "}", "\n\n", "req", ":=", "&", "querypb", ".", "SplitQueryRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Query", ":", "query", ",", "SplitColumn", ":", "splitColumns", ",", "SplitCount", ":", "splitCount", ",", "NumRowsPerQueryPart", ":", "numRowsPerQueryPart", ",", "Algorithm", ":", "algorithm", ",", "}", "\n", "sqr", ",", "err", ":=", "conn", ".", "c", ".", "SplitQuery", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "sqr", ".", "Queries", ",", "nil", "\n", "}" ]
// SplitQuery is the stub for TabletServer.SplitQuery RPC
[ "SplitQuery", "is", "the", "stub", "for", "TabletServer", ".", "SplitQuery", "RPC" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L561-L592
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
StreamHealth
func (conn *gRPCQueryClient) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error { // Please see comments in StreamExecute to see how this works. ctx, cancel := context.WithCancel(ctx) defer cancel() stream, err := func() (queryservicepb.Query_StreamHealthClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } stream, err := conn.c.StreamHealth(ctx, &querypb.StreamHealthRequest{}) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { shr, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } if err := callback(shr); err != nil { if err == nil || err == io.EOF { return nil } return err } } }
go
func (conn *gRPCQueryClient) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error { // Please see comments in StreamExecute to see how this works. ctx, cancel := context.WithCancel(ctx) defer cancel() stream, err := func() (queryservicepb.Query_StreamHealthClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } stream, err := conn.c.StreamHealth(ctx, &querypb.StreamHealthRequest{}) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { shr, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } if err := callback(shr); err != nil { if err == nil || err == io.EOF { return nil } return err } } }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "StreamHealth", "(", "ctx", "context", ".", "Context", ",", "callback", "func", "(", "*", "querypb", ".", "StreamHealthResponse", ")", "error", ")", "error", "{", "// Please see comments in StreamExecute to see how this works.", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "stream", ",", "err", ":=", "func", "(", ")", "(", "queryservicepb", ".", "Query_StreamHealthClient", ",", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "stream", ",", "err", ":=", "conn", ".", "c", ".", "StreamHealth", "(", "ctx", ",", "&", "querypb", ".", "StreamHealthRequest", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "stream", ",", "nil", "\n", "}", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "{", "shr", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "callback", "(", "shr", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "nil", "||", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// StreamHealth starts a streaming RPC for VTTablet health status updates.
[ "StreamHealth", "starts", "a", "streaming", "RPC", "for", "VTTablet", "health", "status", "updates", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L595-L628
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
UpdateStream
func (conn *gRPCQueryClient) UpdateStream(ctx context.Context, target *querypb.Target, position string, timestamp int64, callback func(*querypb.StreamEvent) error) error { // Please see comments in StreamExecute to see how this works. ctx, cancel := context.WithCancel(ctx) defer cancel() stream, err := func() (queryservicepb.Query_UpdateStreamClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &querypb.UpdateStreamRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Position: position, Timestamp: timestamp, } stream, err := conn.c.UpdateStream(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { r, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } if err := callback(r.Event); err != nil { if err == nil || err == io.EOF { return nil } return err } } }
go
func (conn *gRPCQueryClient) UpdateStream(ctx context.Context, target *querypb.Target, position string, timestamp int64, callback func(*querypb.StreamEvent) error) error { // Please see comments in StreamExecute to see how this works. ctx, cancel := context.WithCancel(ctx) defer cancel() stream, err := func() (queryservicepb.Query_UpdateStreamClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &querypb.UpdateStreamRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Position: position, Timestamp: timestamp, } stream, err := conn.c.UpdateStream(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { r, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } if err := callback(r.Event); err != nil { if err == nil || err == io.EOF { return nil } return err } } }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "UpdateStream", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "position", "string", ",", "timestamp", "int64", ",", "callback", "func", "(", "*", "querypb", ".", "StreamEvent", ")", "error", ")", "error", "{", "// Please see comments in StreamExecute to see how this works.", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "stream", ",", "err", ":=", "func", "(", ")", "(", "queryservicepb", ".", "Query_UpdateStreamClient", ",", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "querypb", ".", "UpdateStreamRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Position", ":", "position", ",", "Timestamp", ":", "timestamp", ",", "}", "\n", "stream", ",", "err", ":=", "conn", ".", "c", ".", "UpdateStream", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "stream", ",", "nil", "\n", "}", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "{", "r", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "callback", "(", "r", ".", "Event", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "nil", "||", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// UpdateStream starts a streaming query to VTTablet.
[ "UpdateStream", "starts", "a", "streaming", "query", "to", "VTTablet", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L631-L671
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
VStream
func (conn *gRPCQueryClient) VStream(ctx context.Context, target *querypb.Target, position string, filter *binlogdatapb.Filter, send func([]*binlogdatapb.VEvent) error) error { stream, err := func() (queryservicepb.Query_VStreamClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &binlogdatapb.VStreamRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Position: position, Filter: filter, } stream, err := conn.c.VStream(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { r, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } select { case <-ctx.Done(): return nil default: } if err := send(r.Events); err != nil { if err == io.EOF { return nil } return err } } }
go
func (conn *gRPCQueryClient) VStream(ctx context.Context, target *querypb.Target, position string, filter *binlogdatapb.Filter, send func([]*binlogdatapb.VEvent) error) error { stream, err := func() (queryservicepb.Query_VStreamClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &binlogdatapb.VStreamRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Position: position, Filter: filter, } stream, err := conn.c.VStream(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { r, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } select { case <-ctx.Done(): return nil default: } if err := send(r.Events); err != nil { if err == io.EOF { return nil } return err } } }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "VStream", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "position", "string", ",", "filter", "*", "binlogdatapb", ".", "Filter", ",", "send", "func", "(", "[", "]", "*", "binlogdatapb", ".", "VEvent", ")", "error", ")", "error", "{", "stream", ",", "err", ":=", "func", "(", ")", "(", "queryservicepb", ".", "Query_VStreamClient", ",", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "binlogdatapb", ".", "VStreamRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Position", ":", "position", ",", "Filter", ":", "filter", ",", "}", "\n", "stream", ",", "err", ":=", "conn", ".", "c", ".", "VStream", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "stream", ",", "nil", "\n", "}", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "{", "r", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "nil", "\n", "default", ":", "}", "\n", "if", "err", ":=", "send", "(", "r", ".", "Events", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// VStream starts a VReplication stream.
[ "VStream", "starts", "a", "VReplication", "stream", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L674-L715
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
VStreamRows
func (conn *gRPCQueryClient) VStreamRows(ctx context.Context, target *querypb.Target, query string, lastpk *querypb.QueryResult, send func(*binlogdatapb.VStreamRowsResponse) error) error { stream, err := func() (queryservicepb.Query_VStreamRowsClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &binlogdatapb.VStreamRowsRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: query, Lastpk: lastpk, } stream, err := conn.c.VStreamRows(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { r, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } select { case <-ctx.Done(): return ctx.Err() default: } if err := send(r); err != nil { return err } } }
go
func (conn *gRPCQueryClient) VStreamRows(ctx context.Context, target *querypb.Target, query string, lastpk *querypb.QueryResult, send func(*binlogdatapb.VStreamRowsResponse) error) error { stream, err := func() (queryservicepb.Query_VStreamRowsClient, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &binlogdatapb.VStreamRowsRequest{ Target: target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Query: query, Lastpk: lastpk, } stream, err := conn.c.VStreamRows(ctx, req) if err != nil { return nil, tabletconn.ErrorFromGRPC(err) } return stream, nil }() if err != nil { return err } for { r, err := stream.Recv() if err != nil { return tabletconn.ErrorFromGRPC(err) } select { case <-ctx.Done(): return ctx.Err() default: } if err := send(r); err != nil { return err } } }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "VStreamRows", "(", "ctx", "context", ".", "Context", ",", "target", "*", "querypb", ".", "Target", ",", "query", "string", ",", "lastpk", "*", "querypb", ".", "QueryResult", ",", "send", "func", "(", "*", "binlogdatapb", ".", "VStreamRowsResponse", ")", "error", ")", "error", "{", "stream", ",", "err", ":=", "func", "(", ")", "(", "queryservicepb", ".", "Query_VStreamRowsClient", ",", "error", ")", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ConnClosed", "\n", "}", "\n\n", "req", ":=", "&", "binlogdatapb", ".", "VStreamRowsRequest", "{", "Target", ":", "target", ",", "EffectiveCallerId", ":", "callerid", ".", "EffectiveCallerIDFromContext", "(", "ctx", ")", ",", "ImmediateCallerId", ":", "callerid", ".", "ImmediateCallerIDFromContext", "(", "ctx", ")", ",", "Query", ":", "query", ",", "Lastpk", ":", "lastpk", ",", "}", "\n", "stream", ",", "err", ":=", "conn", ".", "c", ".", "VStreamRows", "(", "ctx", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "return", "stream", ",", "nil", "\n", "}", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "{", "r", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "tabletconn", ".", "ErrorFromGRPC", "(", "err", ")", "\n", "}", "\n", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "ctx", ".", "Err", "(", ")", "\n", "default", ":", "}", "\n", "if", "err", ":=", "send", "(", "r", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// VStreamRows streams rows of a query from the specified starting point.
[ "VStreamRows", "streams", "rows", "of", "a", "query", "from", "the", "specified", "starting", "point", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L718-L756
train
vitessio/vitess
go/vt/vttablet/grpctabletconn/conn.go
Close
func (conn *gRPCQueryClient) Close(ctx context.Context) error { conn.mu.Lock() defer conn.mu.Unlock() if conn.cc == nil { return nil } cc := conn.cc conn.cc = nil return cc.Close() }
go
func (conn *gRPCQueryClient) Close(ctx context.Context) error { conn.mu.Lock() defer conn.mu.Unlock() if conn.cc == nil { return nil } cc := conn.cc conn.cc = nil return cc.Close() }
[ "func", "(", "conn", "*", "gRPCQueryClient", ")", "Close", "(", "ctx", "context", ".", "Context", ")", "error", "{", "conn", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "conn", ".", "cc", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "cc", ":=", "conn", ".", "cc", "\n", "conn", ".", "cc", "=", "nil", "\n", "return", "cc", ".", "Close", "(", ")", "\n", "}" ]
// Close closes underlying gRPC channel.
[ "Close", "closes", "underlying", "gRPC", "channel", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/grpctabletconn/conn.go#L763-L773
train
vitessio/vitess
go/mysql/replication_position.go
Equal
func (rp Position) Equal(other Position) bool { if rp.GTIDSet == nil { return other.GTIDSet == nil } return rp.GTIDSet.Equal(other.GTIDSet) }
go
func (rp Position) Equal(other Position) bool { if rp.GTIDSet == nil { return other.GTIDSet == nil } return rp.GTIDSet.Equal(other.GTIDSet) }
[ "func", "(", "rp", "Position", ")", "Equal", "(", "other", "Position", ")", "bool", "{", "if", "rp", ".", "GTIDSet", "==", "nil", "{", "return", "other", ".", "GTIDSet", "==", "nil", "\n", "}", "\n", "return", "rp", ".", "GTIDSet", ".", "Equal", "(", "other", ".", "GTIDSet", ")", "\n", "}" ]
// Equal returns true if this position is equal to another.
[ "Equal", "returns", "true", "if", "this", "position", "is", "equal", "to", "another", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/replication_position.go#L62-L67
train
vitessio/vitess
go/mysql/replication_position.go
AtLeast
func (rp Position) AtLeast(other Position) bool { if rp.GTIDSet == nil { return other.GTIDSet == nil } return rp.GTIDSet.Contains(other.GTIDSet) }
go
func (rp Position) AtLeast(other Position) bool { if rp.GTIDSet == nil { return other.GTIDSet == nil } return rp.GTIDSet.Contains(other.GTIDSet) }
[ "func", "(", "rp", "Position", ")", "AtLeast", "(", "other", "Position", ")", "bool", "{", "if", "rp", ".", "GTIDSet", "==", "nil", "{", "return", "other", ".", "GTIDSet", "==", "nil", "\n", "}", "\n", "return", "rp", ".", "GTIDSet", ".", "Contains", "(", "other", ".", "GTIDSet", ")", "\n", "}" ]
// AtLeast returns true if this position is equal to or after another.
[ "AtLeast", "returns", "true", "if", "this", "position", "is", "equal", "to", "or", "after", "another", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/replication_position.go#L70-L75
train
vitessio/vitess
go/mysql/replication_position.go
AppendGTID
func AppendGTID(rp Position, gtid GTID) Position { if gtid == nil { return rp } if rp.GTIDSet == nil { return Position{GTIDSet: gtid.GTIDSet()} } return Position{GTIDSet: rp.GTIDSet.AddGTID(gtid)} }
go
func AppendGTID(rp Position, gtid GTID) Position { if gtid == nil { return rp } if rp.GTIDSet == nil { return Position{GTIDSet: gtid.GTIDSet()} } return Position{GTIDSet: rp.GTIDSet.AddGTID(gtid)} }
[ "func", "AppendGTID", "(", "rp", "Position", ",", "gtid", "GTID", ")", "Position", "{", "if", "gtid", "==", "nil", "{", "return", "rp", "\n", "}", "\n", "if", "rp", ".", "GTIDSet", "==", "nil", "{", "return", "Position", "{", "GTIDSet", ":", "gtid", ".", "GTIDSet", "(", ")", "}", "\n", "}", "\n", "return", "Position", "{", "GTIDSet", ":", "rp", ".", "GTIDSet", ".", "AddGTID", "(", "gtid", ")", "}", "\n", "}" ]
// AppendGTID returns a new Position that represents the position // after the given GTID is replicated.
[ "AppendGTID", "returns", "a", "new", "Position", "that", "represents", "the", "position", "after", "the", "given", "GTID", "is", "replicated", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/replication_position.go#L93-L101
train
vitessio/vitess
go/mysql/replication_position.go
MustParsePosition
func MustParsePosition(flavor, value string) Position { rp, err := ParsePosition(flavor, value) if err != nil { panic(err) } return rp }
go
func MustParsePosition(flavor, value string) Position { rp, err := ParsePosition(flavor, value) if err != nil { panic(err) } return rp }
[ "func", "MustParsePosition", "(", "flavor", ",", "value", "string", ")", "Position", "{", "rp", ",", "err", ":=", "ParsePosition", "(", "flavor", ",", "value", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "rp", "\n", "}" ]
// MustParsePosition calls ParsePosition and panics // on error.
[ "MustParsePosition", "calls", "ParsePosition", "and", "panics", "on", "error", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/replication_position.go#L105-L111
train
vitessio/vitess
go/mysql/replication_position.go
EncodePosition
func EncodePosition(rp Position) string { if rp.GTIDSet == nil { return "" } return fmt.Sprintf("%s/%s", rp.GTIDSet.Flavor(), rp.GTIDSet.String()) }
go
func EncodePosition(rp Position) string { if rp.GTIDSet == nil { return "" } return fmt.Sprintf("%s/%s", rp.GTIDSet.Flavor(), rp.GTIDSet.String()) }
[ "func", "EncodePosition", "(", "rp", "Position", ")", "string", "{", "if", "rp", ".", "GTIDSet", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "rp", ".", "GTIDSet", ".", "Flavor", "(", ")", ",", "rp", ".", "GTIDSet", ".", "String", "(", ")", ")", "\n", "}" ]
// EncodePosition returns a string that contains both the flavor // and value of the Position, so that the correct parser can be // selected when that string is passed to DecodePosition.
[ "EncodePosition", "returns", "a", "string", "that", "contains", "both", "the", "flavor", "and", "value", "of", "the", "Position", "so", "that", "the", "correct", "parser", "can", "be", "selected", "when", "that", "string", "is", "passed", "to", "DecodePosition", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/replication_position.go#L116-L121
train
vitessio/vitess
go/mysql/replication_position.go
DecodePosition
func DecodePosition(s string) (rp Position, err error) { if s == "" { return rp, nil } parts := strings.SplitN(s, "/", 2) if len(parts) != 2 { // There is no flavor. Try looking for a default parser. return ParsePosition("", s) } return ParsePosition(parts[0], parts[1]) }
go
func DecodePosition(s string) (rp Position, err error) { if s == "" { return rp, nil } parts := strings.SplitN(s, "/", 2) if len(parts) != 2 { // There is no flavor. Try looking for a default parser. return ParsePosition("", s) } return ParsePosition(parts[0], parts[1]) }
[ "func", "DecodePosition", "(", "s", "string", ")", "(", "rp", "Position", ",", "err", "error", ")", "{", "if", "s", "==", "\"", "\"", "{", "return", "rp", ",", "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", "ParsePosition", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n", "return", "ParsePosition", "(", "parts", "[", "0", "]", ",", "parts", "[", "1", "]", ")", "\n", "}" ]
// DecodePosition converts a string in the format returned by // EncodePosition back into a Position value with the // correct underlying flavor.
[ "DecodePosition", "converts", "a", "string", "in", "the", "format", "returned", "by", "EncodePosition", "back", "into", "a", "Position", "value", "with", "the", "correct", "underlying", "flavor", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/replication_position.go#L126-L137
train
vitessio/vitess
go/mysql/replication_position.go
ParsePosition
func ParsePosition(flavor, value string) (rp Position, err error) { parser := gtidSetParsers[flavor] if parser == nil { return rp, vterrors.Errorf(vtrpc.Code_INTERNAL, "parse error: unknown GTIDSet flavor %#v", flavor) } gtidSet, err := parser(value) if err != nil { return rp, err } rp.GTIDSet = gtidSet return rp, err }
go
func ParsePosition(flavor, value string) (rp Position, err error) { parser := gtidSetParsers[flavor] if parser == nil { return rp, vterrors.Errorf(vtrpc.Code_INTERNAL, "parse error: unknown GTIDSet flavor %#v", flavor) } gtidSet, err := parser(value) if err != nil { return rp, err } rp.GTIDSet = gtidSet return rp, err }
[ "func", "ParsePosition", "(", "flavor", ",", "value", "string", ")", "(", "rp", "Position", ",", "err", "error", ")", "{", "parser", ":=", "gtidSetParsers", "[", "flavor", "]", "\n", "if", "parser", "==", "nil", "{", "return", "rp", ",", "vterrors", ".", "Errorf", "(", "vtrpc", ".", "Code_INTERNAL", ",", "\"", "\"", ",", "flavor", ")", "\n", "}", "\n", "gtidSet", ",", "err", ":=", "parser", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "rp", ",", "err", "\n", "}", "\n", "rp", ".", "GTIDSet", "=", "gtidSet", "\n", "return", "rp", ",", "err", "\n", "}" ]
// ParsePosition calls the parser for the specified flavor.
[ "ParsePosition", "calls", "the", "parser", "for", "the", "specified", "flavor", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/replication_position.go#L140-L151
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
Close
func (se *Engine) Close() { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return } se.ticks.Stop() se.conns.Close() se.tables = make(map[string]*Table) se.notifiers = make(map[string]notifier) se.isOpen = false }
go
func (se *Engine) Close() { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return } se.ticks.Stop() se.conns.Close() se.tables = make(map[string]*Table) se.notifiers = make(map[string]notifier) se.isOpen = false }
[ "func", "(", "se", "*", "Engine", ")", "Close", "(", ")", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "!", "se", ".", "isOpen", "{", "return", "\n", "}", "\n", "se", ".", "ticks", ".", "Stop", "(", ")", "\n", "se", ".", "conns", ".", "Close", "(", ")", "\n", "se", ".", "tables", "=", "make", "(", "map", "[", "string", "]", "*", "Table", ")", "\n", "se", ".", "notifiers", "=", "make", "(", "map", "[", "string", "]", "notifier", ")", "\n", "se", ".", "isOpen", "=", "false", "\n", "}" ]
// Close shuts down Engine and is idempotent. // It can be re-opened after Close.
[ "Close", "shuts", "down", "Engine", "and", "is", "idempotent", ".", "It", "can", "be", "re", "-", "opened", "after", "Close", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L195-L206
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
MakeNonMaster
func (se *Engine) MakeNonMaster() { // This function is tested through endtoend test. se.mu.Lock() defer se.mu.Unlock() for _, t := range se.tables { if t.SequenceInfo != nil { t.SequenceInfo.Lock() t.SequenceInfo.NextVal = 0 t.SequenceInfo.LastVal = 0 t.SequenceInfo.Unlock() } } }
go
func (se *Engine) MakeNonMaster() { // This function is tested through endtoend test. se.mu.Lock() defer se.mu.Unlock() for _, t := range se.tables { if t.SequenceInfo != nil { t.SequenceInfo.Lock() t.SequenceInfo.NextVal = 0 t.SequenceInfo.LastVal = 0 t.SequenceInfo.Unlock() } } }
[ "func", "(", "se", "*", "Engine", ")", "MakeNonMaster", "(", ")", "{", "// This function is tested through endtoend test.", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "t", ":=", "range", "se", ".", "tables", "{", "if", "t", ".", "SequenceInfo", "!=", "nil", "{", "t", ".", "SequenceInfo", ".", "Lock", "(", ")", "\n", "t", ".", "SequenceInfo", ".", "NextVal", "=", "0", "\n", "t", ".", "SequenceInfo", ".", "LastVal", "=", "0", "\n", "t", ".", "SequenceInfo", ".", "Unlock", "(", ")", "\n", "}", "\n", "}", "\n", "}" ]
// MakeNonMaster clears the sequence caches to make sure that // they don't get accidentally reused after losing mastership.
[ "MakeNonMaster", "clears", "the", "sequence", "caches", "to", "make", "sure", "that", "they", "don", "t", "get", "accidentally", "reused", "after", "losing", "mastership", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L210-L222
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
Reload
func (se *Engine) Reload(ctx context.Context) error { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return nil } defer tabletenv.LogError() curTime, tableData, err := func() (int64, *sqltypes.Result, error) { conn, err := se.conns.Get(ctx) if err != nil { return 0, nil, err } defer conn.Recycle() curTime, err := se.mysqlTime(ctx, conn) if err != nil { return 0, nil, err } tableData, err := conn.Exec(ctx, mysql.BaseShowTables, maxTableCount, false) if err != nil { return 0, nil, err } return curTime, tableData, nil }() if err != nil { return vterrors.Wrap(err, "could not get table list for reload") } // Reload any tables that have changed. We try every table even if some fail, // but we return success only if all tables succeed. // The following section requires us to hold mu. rec := concurrency.AllErrorRecorder{} curTables := map[string]bool{"dual": true} for _, row := range tableData.Rows { tableName := row[0].ToString() curTables[tableName] = true createTime, _ := sqltypes.ToInt64(row[2]) // Check if we know about the table or it has been recreated. if _, ok := se.tables[tableName]; !ok || createTime >= se.lastChange { log.Infof("Reloading schema for table: %s", tableName) rec.RecordError(se.tableWasCreatedOrAltered(ctx, tableName)) } else { // Only update table_rows, data_length, index_length, max_data_length se.tables[tableName].SetMysqlStats(row[4], row[5], row[6], row[7], row[8]) } } se.lastChange = curTime // Handle table drops var dropped []string for tableName := range se.tables { if curTables[tableName] { continue } delete(se.tables, tableName) dropped = append(dropped, tableName) } // We only need to broadcast dropped tables because // tableWasCreatedOrAltered will broadcast the other changes. if len(dropped) > 0 { se.broadcast(nil, nil, dropped) } return rec.Error() }
go
func (se *Engine) Reload(ctx context.Context) error { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return nil } defer tabletenv.LogError() curTime, tableData, err := func() (int64, *sqltypes.Result, error) { conn, err := se.conns.Get(ctx) if err != nil { return 0, nil, err } defer conn.Recycle() curTime, err := se.mysqlTime(ctx, conn) if err != nil { return 0, nil, err } tableData, err := conn.Exec(ctx, mysql.BaseShowTables, maxTableCount, false) if err != nil { return 0, nil, err } return curTime, tableData, nil }() if err != nil { return vterrors.Wrap(err, "could not get table list for reload") } // Reload any tables that have changed. We try every table even if some fail, // but we return success only if all tables succeed. // The following section requires us to hold mu. rec := concurrency.AllErrorRecorder{} curTables := map[string]bool{"dual": true} for _, row := range tableData.Rows { tableName := row[0].ToString() curTables[tableName] = true createTime, _ := sqltypes.ToInt64(row[2]) // Check if we know about the table or it has been recreated. if _, ok := se.tables[tableName]; !ok || createTime >= se.lastChange { log.Infof("Reloading schema for table: %s", tableName) rec.RecordError(se.tableWasCreatedOrAltered(ctx, tableName)) } else { // Only update table_rows, data_length, index_length, max_data_length se.tables[tableName].SetMysqlStats(row[4], row[5], row[6], row[7], row[8]) } } se.lastChange = curTime // Handle table drops var dropped []string for tableName := range se.tables { if curTables[tableName] { continue } delete(se.tables, tableName) dropped = append(dropped, tableName) } // We only need to broadcast dropped tables because // tableWasCreatedOrAltered will broadcast the other changes. if len(dropped) > 0 { se.broadcast(nil, nil, dropped) } return rec.Error() }
[ "func", "(", "se", "*", "Engine", ")", "Reload", "(", "ctx", "context", ".", "Context", ")", "error", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "!", "se", ".", "isOpen", "{", "return", "nil", "\n", "}", "\n", "defer", "tabletenv", ".", "LogError", "(", ")", "\n\n", "curTime", ",", "tableData", ",", "err", ":=", "func", "(", ")", "(", "int64", ",", "*", "sqltypes", ".", "Result", ",", "error", ")", "{", "conn", ",", "err", ":=", "se", ".", "conns", ".", "Get", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "nil", ",", "err", "\n", "}", "\n", "defer", "conn", ".", "Recycle", "(", ")", "\n", "curTime", ",", "err", ":=", "se", ".", "mysqlTime", "(", "ctx", ",", "conn", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "nil", ",", "err", "\n", "}", "\n", "tableData", ",", "err", ":=", "conn", ".", "Exec", "(", "ctx", ",", "mysql", ".", "BaseShowTables", ",", "maxTableCount", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "nil", ",", "err", "\n", "}", "\n", "return", "curTime", ",", "tableData", ",", "nil", "\n", "}", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "vterrors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Reload any tables that have changed. We try every table even if some fail,", "// but we return success only if all tables succeed.", "// The following section requires us to hold mu.", "rec", ":=", "concurrency", ".", "AllErrorRecorder", "{", "}", "\n", "curTables", ":=", "map", "[", "string", "]", "bool", "{", "\"", "\"", ":", "true", "}", "\n", "for", "_", ",", "row", ":=", "range", "tableData", ".", "Rows", "{", "tableName", ":=", "row", "[", "0", "]", ".", "ToString", "(", ")", "\n", "curTables", "[", "tableName", "]", "=", "true", "\n", "createTime", ",", "_", ":=", "sqltypes", ".", "ToInt64", "(", "row", "[", "2", "]", ")", "\n", "// Check if we know about the table or it has been recreated.", "if", "_", ",", "ok", ":=", "se", ".", "tables", "[", "tableName", "]", ";", "!", "ok", "||", "createTime", ">=", "se", ".", "lastChange", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "tableName", ")", "\n", "rec", ".", "RecordError", "(", "se", ".", "tableWasCreatedOrAltered", "(", "ctx", ",", "tableName", ")", ")", "\n", "}", "else", "{", "// Only update table_rows, data_length, index_length, max_data_length", "se", ".", "tables", "[", "tableName", "]", ".", "SetMysqlStats", "(", "row", "[", "4", "]", ",", "row", "[", "5", "]", ",", "row", "[", "6", "]", ",", "row", "[", "7", "]", ",", "row", "[", "8", "]", ")", "\n", "}", "\n", "}", "\n", "se", ".", "lastChange", "=", "curTime", "\n\n", "// Handle table drops", "var", "dropped", "[", "]", "string", "\n", "for", "tableName", ":=", "range", "se", ".", "tables", "{", "if", "curTables", "[", "tableName", "]", "{", "continue", "\n", "}", "\n", "delete", "(", "se", ".", "tables", ",", "tableName", ")", "\n", "dropped", "=", "append", "(", "dropped", ",", "tableName", ")", "\n", "}", "\n", "// We only need to broadcast dropped tables because", "// tableWasCreatedOrAltered will broadcast the other changes.", "if", "len", "(", "dropped", ")", ">", "0", "{", "se", ".", "broadcast", "(", "nil", ",", "nil", ",", "dropped", ")", "\n", "}", "\n", "return", "rec", ".", "Error", "(", ")", "\n", "}" ]
// Reload reloads the schema info from the db. // Any tables that have changed since the last load are updated. // This is a no-op if the Engine is closed.
[ "Reload", "reloads", "the", "schema", "info", "from", "the", "db", ".", "Any", "tables", "that", "have", "changed", "since", "the", "last", "load", "are", "updated", ".", "This", "is", "a", "no", "-", "op", "if", "the", "Engine", "is", "closed", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L227-L290
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
tableWasCreatedOrAltered
func (se *Engine) tableWasCreatedOrAltered(ctx context.Context, tableName string) error { if !se.isOpen { return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "DDL called on closed schema") } conn, err := se.conns.Get(ctx) if err != nil { return err } defer conn.Recycle() tableData, err := conn.Exec(ctx, mysql.BaseShowTablesForTable(tableName), 1, false) if err != nil { tabletenv.InternalErrors.Add("Schema", 1) return vterrors.Errorf(vtrpcpb.Code_UNKNOWN, "tableWasCreatedOrAltered: information_schema query failed for table %s: %v", tableName, err) } if len(tableData.Rows) != 1 { // This can happen if DDLs race with each other. return nil } row := tableData.Rows[0] table, err := LoadTable( conn, tableName, row[1].ToString(), // table_type row[3].ToString(), // table_comment ) if err != nil { tabletenv.InternalErrors.Add("Schema", 1) return vterrors.Errorf(vtrpcpb.Code_UNKNOWN, "tableWasCreatedOrAltered: failed to load table %s: %v", tableName, err) } // table_rows, data_length, index_length, max_data_length table.SetMysqlStats(row[4], row[5], row[6], row[7], row[8]) var created, altered []string if _, ok := se.tables[tableName]; ok { // If the table already exists, we overwrite it with the latest info. // This also means that the query cache needs to be cleared. // Otherwise, the query plans may not be in sync with the schema. log.Infof("Updating table %s", tableName) altered = append(altered, tableName) } else { created = append(created, tableName) } se.tables[tableName] = table log.Infof("Initialized table: %s, type: %s", tableName, TypeNames[table.Type]) se.broadcast(created, altered, nil) return nil }
go
func (se *Engine) tableWasCreatedOrAltered(ctx context.Context, tableName string) error { if !se.isOpen { return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "DDL called on closed schema") } conn, err := se.conns.Get(ctx) if err != nil { return err } defer conn.Recycle() tableData, err := conn.Exec(ctx, mysql.BaseShowTablesForTable(tableName), 1, false) if err != nil { tabletenv.InternalErrors.Add("Schema", 1) return vterrors.Errorf(vtrpcpb.Code_UNKNOWN, "tableWasCreatedOrAltered: information_schema query failed for table %s: %v", tableName, err) } if len(tableData.Rows) != 1 { // This can happen if DDLs race with each other. return nil } row := tableData.Rows[0] table, err := LoadTable( conn, tableName, row[1].ToString(), // table_type row[3].ToString(), // table_comment ) if err != nil { tabletenv.InternalErrors.Add("Schema", 1) return vterrors.Errorf(vtrpcpb.Code_UNKNOWN, "tableWasCreatedOrAltered: failed to load table %s: %v", tableName, err) } // table_rows, data_length, index_length, max_data_length table.SetMysqlStats(row[4], row[5], row[6], row[7], row[8]) var created, altered []string if _, ok := se.tables[tableName]; ok { // If the table already exists, we overwrite it with the latest info. // This also means that the query cache needs to be cleared. // Otherwise, the query plans may not be in sync with the schema. log.Infof("Updating table %s", tableName) altered = append(altered, tableName) } else { created = append(created, tableName) } se.tables[tableName] = table log.Infof("Initialized table: %s, type: %s", tableName, TypeNames[table.Type]) se.broadcast(created, altered, nil) return nil }
[ "func", "(", "se", "*", "Engine", ")", "tableWasCreatedOrAltered", "(", "ctx", "context", ".", "Context", ",", "tableName", "string", ")", "error", "{", "if", "!", "se", ".", "isOpen", "{", "return", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_INTERNAL", ",", "\"", "\"", ")", "\n", "}", "\n\n", "conn", ",", "err", ":=", "se", ".", "conns", ".", "Get", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "conn", ".", "Recycle", "(", ")", "\n", "tableData", ",", "err", ":=", "conn", ".", "Exec", "(", "ctx", ",", "mysql", ".", "BaseShowTablesForTable", "(", "tableName", ")", ",", "1", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "tabletenv", ".", "InternalErrors", ".", "Add", "(", "\"", "\"", ",", "1", ")", "\n", "return", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_UNKNOWN", ",", "\"", "\"", ",", "tableName", ",", "err", ")", "\n", "}", "\n", "if", "len", "(", "tableData", ".", "Rows", ")", "!=", "1", "{", "// This can happen if DDLs race with each other.", "return", "nil", "\n", "}", "\n", "row", ":=", "tableData", ".", "Rows", "[", "0", "]", "\n", "table", ",", "err", ":=", "LoadTable", "(", "conn", ",", "tableName", ",", "row", "[", "1", "]", ".", "ToString", "(", ")", ",", "// table_type", "row", "[", "3", "]", ".", "ToString", "(", ")", ",", "// table_comment", ")", "\n", "if", "err", "!=", "nil", "{", "tabletenv", ".", "InternalErrors", ".", "Add", "(", "\"", "\"", ",", "1", ")", "\n", "return", "vterrors", ".", "Errorf", "(", "vtrpcpb", ".", "Code_UNKNOWN", ",", "\"", "\"", ",", "tableName", ",", "err", ")", "\n", "}", "\n", "// table_rows, data_length, index_length, max_data_length", "table", ".", "SetMysqlStats", "(", "row", "[", "4", "]", ",", "row", "[", "5", "]", ",", "row", "[", "6", "]", ",", "row", "[", "7", "]", ",", "row", "[", "8", "]", ")", "\n\n", "var", "created", ",", "altered", "[", "]", "string", "\n", "if", "_", ",", "ok", ":=", "se", ".", "tables", "[", "tableName", "]", ";", "ok", "{", "// If the table already exists, we overwrite it with the latest info.", "// This also means that the query cache needs to be cleared.", "// Otherwise, the query plans may not be in sync with the schema.", "log", ".", "Infof", "(", "\"", "\"", ",", "tableName", ")", "\n", "altered", "=", "append", "(", "altered", ",", "tableName", ")", "\n", "}", "else", "{", "created", "=", "append", "(", "created", ",", "tableName", ")", "\n", "}", "\n", "se", ".", "tables", "[", "tableName", "]", "=", "table", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "tableName", ",", "TypeNames", "[", "table", ".", "Type", "]", ")", "\n", "se", ".", "broadcast", "(", "created", ",", "altered", ",", "nil", ")", "\n", "return", "nil", "\n", "}" ]
// tableWasCreatedOrAltered must be called if a DDL was applied to that table. // the se.mu mutex _must_ be locked before entering this method
[ "tableWasCreatedOrAltered", "must", "be", "called", "if", "a", "DDL", "was", "applied", "to", "that", "table", ".", "the", "se", ".", "mu", "mutex", "_must_", "be", "locked", "before", "entering", "this", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L309-L356
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
RegisterNotifier
func (se *Engine) RegisterNotifier(name string, f notifier) { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return } se.notifiers[name] = f var created []string for tableName := range se.tables { created = append(created, tableName) } f(se.tables, created, nil, nil) }
go
func (se *Engine) RegisterNotifier(name string, f notifier) { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return } se.notifiers[name] = f var created []string for tableName := range se.tables { created = append(created, tableName) } f(se.tables, created, nil, nil) }
[ "func", "(", "se", "*", "Engine", ")", "RegisterNotifier", "(", "name", "string", ",", "f", "notifier", ")", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "!", "se", ".", "isOpen", "{", "return", "\n", "}", "\n\n", "se", ".", "notifiers", "[", "name", "]", "=", "f", "\n", "var", "created", "[", "]", "string", "\n", "for", "tableName", ":=", "range", "se", ".", "tables", "{", "created", "=", "append", "(", "created", ",", "tableName", ")", "\n", "}", "\n", "f", "(", "se", ".", "tables", ",", "created", ",", "nil", ",", "nil", ")", "\n", "}" ]
// RegisterNotifier registers the function for schema change notification. // It also causes an immediate notification to the caller. The notified // function must not change the map or its contents. The only exception // is the sequence table where the values can be changed using the lock.
[ "RegisterNotifier", "registers", "the", "function", "for", "schema", "change", "notification", ".", "It", "also", "causes", "an", "immediate", "notification", "to", "the", "caller", ".", "The", "notified", "function", "must", "not", "change", "the", "map", "or", "its", "contents", ".", "The", "only", "exception", "is", "the", "sequence", "table", "where", "the", "values", "can", "be", "changed", "using", "the", "lock", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L362-L375
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
UnregisterNotifier
func (se *Engine) UnregisterNotifier(name string) { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return } delete(se.notifiers, name) }
go
func (se *Engine) UnregisterNotifier(name string) { se.mu.Lock() defer se.mu.Unlock() if !se.isOpen { return } delete(se.notifiers, name) }
[ "func", "(", "se", "*", "Engine", ")", "UnregisterNotifier", "(", "name", "string", ")", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "!", "se", ".", "isOpen", "{", "return", "\n", "}", "\n\n", "delete", "(", "se", ".", "notifiers", ",", "name", ")", "\n", "}" ]
// UnregisterNotifier unregisters the notifier function.
[ "UnregisterNotifier", "unregisters", "the", "notifier", "function", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L378-L386
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
broadcast
func (se *Engine) broadcast(created, altered, dropped []string) { s := make(map[string]*Table, len(se.tables)) for k, v := range se.tables { s[k] = v } for _, f := range se.notifiers { f(s, created, altered, dropped) } }
go
func (se *Engine) broadcast(created, altered, dropped []string) { s := make(map[string]*Table, len(se.tables)) for k, v := range se.tables { s[k] = v } for _, f := range se.notifiers { f(s, created, altered, dropped) } }
[ "func", "(", "se", "*", "Engine", ")", "broadcast", "(", "created", ",", "altered", ",", "dropped", "[", "]", "string", ")", "{", "s", ":=", "make", "(", "map", "[", "string", "]", "*", "Table", ",", "len", "(", "se", ".", "tables", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "se", ".", "tables", "{", "s", "[", "k", "]", "=", "v", "\n", "}", "\n", "for", "_", ",", "f", ":=", "range", "se", ".", "notifiers", "{", "f", "(", "s", ",", "created", ",", "altered", ",", "dropped", ")", "\n", "}", "\n", "}" ]
// broadcast must be called while holding a lock on se.mu.
[ "broadcast", "must", "be", "called", "while", "holding", "a", "lock", "on", "se", ".", "mu", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L389-L397
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
GetTable
func (se *Engine) GetTable(tableName sqlparser.TableIdent) *Table { se.mu.Lock() defer se.mu.Unlock() return se.tables[tableName.String()] }
go
func (se *Engine) GetTable(tableName sqlparser.TableIdent) *Table { se.mu.Lock() defer se.mu.Unlock() return se.tables[tableName.String()] }
[ "func", "(", "se", "*", "Engine", ")", "GetTable", "(", "tableName", "sqlparser", ".", "TableIdent", ")", "*", "Table", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "se", ".", "tables", "[", "tableName", ".", "String", "(", ")", "]", "\n", "}" ]
// GetTable returns the info for a table.
[ "GetTable", "returns", "the", "info", "for", "a", "table", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L400-L404
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
GetSchema
func (se *Engine) GetSchema() map[string]*Table { se.mu.Lock() defer se.mu.Unlock() tables := make(map[string]*Table, len(se.tables)) for k, v := range se.tables { tables[k] = v } return tables }
go
func (se *Engine) GetSchema() map[string]*Table { se.mu.Lock() defer se.mu.Unlock() tables := make(map[string]*Table, len(se.tables)) for k, v := range se.tables { tables[k] = v } return tables }
[ "func", "(", "se", "*", "Engine", ")", "GetSchema", "(", ")", "map", "[", "string", "]", "*", "Table", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "tables", ":=", "make", "(", "map", "[", "string", "]", "*", "Table", ",", "len", "(", "se", ".", "tables", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "se", ".", "tables", "{", "tables", "[", "k", "]", "=", "v", "\n", "}", "\n", "return", "tables", "\n", "}" ]
// GetSchema returns the current The Tables are a shared // data structure and must be treated as read-only.
[ "GetSchema", "returns", "the", "current", "The", "Tables", "are", "a", "shared", "data", "structure", "and", "must", "be", "treated", "as", "read", "-", "only", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L408-L416
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
SetReloadTime
func (se *Engine) SetReloadTime(reloadTime time.Duration) { se.mu.Lock() defer se.mu.Unlock() se.ticks.Trigger() se.ticks.SetInterval(reloadTime) se.reloadTime = reloadTime }
go
func (se *Engine) SetReloadTime(reloadTime time.Duration) { se.mu.Lock() defer se.mu.Unlock() se.ticks.Trigger() se.ticks.SetInterval(reloadTime) se.reloadTime = reloadTime }
[ "func", "(", "se", "*", "Engine", ")", "SetReloadTime", "(", "reloadTime", "time", ".", "Duration", ")", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "se", ".", "ticks", ".", "Trigger", "(", ")", "\n", "se", ".", "ticks", ".", "SetInterval", "(", "reloadTime", ")", "\n", "se", ".", "reloadTime", "=", "reloadTime", "\n", "}" ]
// SetReloadTime changes how often the schema is reloaded. This // call also triggers an immediate reload.
[ "SetReloadTime", "changes", "how", "often", "the", "schema", "is", "reloaded", ".", "This", "call", "also", "triggers", "an", "immediate", "reload", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L420-L426
train
vitessio/vitess
go/vt/vttablet/tabletserver/schema/engine.go
ReloadTime
func (se *Engine) ReloadTime() time.Duration { se.mu.Lock() defer se.mu.Unlock() return se.reloadTime }
go
func (se *Engine) ReloadTime() time.Duration { se.mu.Lock() defer se.mu.Unlock() return se.reloadTime }
[ "func", "(", "se", "*", "Engine", ")", "ReloadTime", "(", ")", "time", ".", "Duration", "{", "se", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "se", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "se", ".", "reloadTime", "\n", "}" ]
// ReloadTime returns schema info reload time.
[ "ReloadTime", "returns", "schema", "info", "reload", "time", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/schema/engine.go#L429-L433
train
vitessio/vitess
go/vt/vtgate/buffer/flags.go
setToString
func setToString(set map[string]bool) string { result := "" for item := range set { if result != "" { result += ", " } result += item } return result }
go
func setToString(set map[string]bool) string { result := "" for item := range set { if result != "" { result += ", " } result += item } return result }
[ "func", "setToString", "(", "set", "map", "[", "string", "]", "bool", ")", "string", "{", "result", ":=", "\"", "\"", "\n", "for", "item", ":=", "range", "set", "{", "if", "result", "!=", "\"", "\"", "{", "result", "+=", "\"", "\"", "\n", "}", "\n", "result", "+=", "item", "\n", "}", "\n", "return", "result", "\n", "}" ]
// setToString joins the set to a ", " separated string.
[ "setToString", "joins", "the", "set", "to", "a", "separated", "string", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/buffer/flags.go#L114-L123
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
withCallerIDContext
func withCallerIDContext(ctx context.Context, effectiveCallerID *vtrpcpb.CallerID) context.Context { immediate, dnsNames := immediateCallerID(ctx) if immediate == "" && *useEffective && effectiveCallerID != nil { immediate = effectiveCallerID.Principal } if immediate == "" { immediate = unsecureClient } return callerid.NewContext(callinfo.GRPCCallInfo(ctx), effectiveCallerID, &querypb.VTGateCallerID{Username: immediate, Groups: dnsNames}) }
go
func withCallerIDContext(ctx context.Context, effectiveCallerID *vtrpcpb.CallerID) context.Context { immediate, dnsNames := immediateCallerID(ctx) if immediate == "" && *useEffective && effectiveCallerID != nil { immediate = effectiveCallerID.Principal } if immediate == "" { immediate = unsecureClient } return callerid.NewContext(callinfo.GRPCCallInfo(ctx), effectiveCallerID, &querypb.VTGateCallerID{Username: immediate, Groups: dnsNames}) }
[ "func", "withCallerIDContext", "(", "ctx", "context", ".", "Context", ",", "effectiveCallerID", "*", "vtrpcpb", ".", "CallerID", ")", "context", ".", "Context", "{", "immediate", ",", "dnsNames", ":=", "immediateCallerID", "(", "ctx", ")", "\n", "if", "immediate", "==", "\"", "\"", "&&", "*", "useEffective", "&&", "effectiveCallerID", "!=", "nil", "{", "immediate", "=", "effectiveCallerID", ".", "Principal", "\n", "}", "\n", "if", "immediate", "==", "\"", "\"", "{", "immediate", "=", "unsecureClient", "\n", "}", "\n", "return", "callerid", ".", "NewContext", "(", "callinfo", ".", "GRPCCallInfo", "(", "ctx", ")", ",", "effectiveCallerID", ",", "&", "querypb", ".", "VTGateCallerID", "{", "Username", ":", "immediate", ",", "Groups", ":", "dnsNames", "}", ")", "\n", "}" ]
// withCallerIDContext creates a context that extracts what we need // from the incoming call and can be forwarded for use when talking to vttablet.
[ "withCallerIDContext", "creates", "a", "context", "that", "extracts", "what", "we", "need", "from", "the", "incoming", "call", "and", "can", "be", "forwarded", "for", "use", "when", "talking", "to", "vttablet", "." ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L87-L98
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
Execute
func (vtg *VTGate) Execute(ctx context.Context, request *vtgatepb.ExecuteRequest) (response *vtgatepb.ExecuteResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) // Handle backward compatibility. session := request.Session if session == nil { session = &vtgatepb.Session{Autocommit: true} } if session.TargetString == "" && request.TabletType != topodatapb.TabletType_UNKNOWN { session.TargetString = request.KeyspaceShard + "@" + topoproto.TabletTypeLString(request.TabletType) } if session.Options == nil { session.Options = request.Options } session, result, err := vtg.server.Execute(ctx, session, request.Query.Sql, request.Query.BindVariables) return &vtgatepb.ExecuteResponse{ Result: sqltypes.ResultToProto3(result), Session: session, Error: vterrors.ToVTRPC(err), }, nil }
go
func (vtg *VTGate) Execute(ctx context.Context, request *vtgatepb.ExecuteRequest) (response *vtgatepb.ExecuteResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) // Handle backward compatibility. session := request.Session if session == nil { session = &vtgatepb.Session{Autocommit: true} } if session.TargetString == "" && request.TabletType != topodatapb.TabletType_UNKNOWN { session.TargetString = request.KeyspaceShard + "@" + topoproto.TabletTypeLString(request.TabletType) } if session.Options == nil { session.Options = request.Options } session, result, err := vtg.server.Execute(ctx, session, request.Query.Sql, request.Query.BindVariables) return &vtgatepb.ExecuteResponse{ Result: sqltypes.ResultToProto3(result), Session: session, Error: vterrors.ToVTRPC(err), }, nil }
[ "func", "(", "vtg", "*", "VTGate", ")", "Execute", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ExecuteRequest", ")", "(", "response", "*", "vtgatepb", ".", "ExecuteResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n\n", "// Handle backward compatibility.", "session", ":=", "request", ".", "Session", "\n", "if", "session", "==", "nil", "{", "session", "=", "&", "vtgatepb", ".", "Session", "{", "Autocommit", ":", "true", "}", "\n", "}", "\n", "if", "session", ".", "TargetString", "==", "\"", "\"", "&&", "request", ".", "TabletType", "!=", "topodatapb", ".", "TabletType_UNKNOWN", "{", "session", ".", "TargetString", "=", "request", ".", "KeyspaceShard", "+", "\"", "\"", "+", "topoproto", ".", "TabletTypeLString", "(", "request", ".", "TabletType", ")", "\n", "}", "\n", "if", "session", ".", "Options", "==", "nil", "{", "session", ".", "Options", "=", "request", ".", "Options", "\n", "}", "\n", "session", ",", "result", ",", "err", ":=", "vtg", ".", "server", ".", "Execute", "(", "ctx", ",", "session", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ")", "\n", "return", "&", "vtgatepb", ".", "ExecuteResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "result", ")", ",", "Session", ":", "session", ",", "Error", ":", "vterrors", ".", "ToVTRPC", "(", "err", ")", ",", "}", ",", "nil", "\n", "}" ]
// Execute is the RPC version of vtgateservice.VTGateService method
[ "Execute", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L101-L122
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
ExecuteBatch
func (vtg *VTGate) ExecuteBatch(ctx context.Context, request *vtgatepb.ExecuteBatchRequest) (response *vtgatepb.ExecuteBatchResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) sqlQueries := make([]string, len(request.Queries)) bindVars := make([]map[string]*querypb.BindVariable, len(request.Queries)) for queryNum, query := range request.Queries { sqlQueries[queryNum] = query.Sql bindVars[queryNum] = query.BindVariables } // Handle backward compatibility. session := request.Session if session == nil { session = &vtgatepb.Session{Autocommit: true} } if session.TargetString == "" { session.TargetString = request.KeyspaceShard + "@" + topoproto.TabletTypeLString(request.TabletType) } if session.Options == nil { session.Options = request.Options } session, results, err := vtg.server.ExecuteBatch(ctx, session, sqlQueries, bindVars) return &vtgatepb.ExecuteBatchResponse{ Results: sqltypes.QueryResponsesToProto3(results), Session: session, Error: vterrors.ToVTRPC(err), }, nil }
go
func (vtg *VTGate) ExecuteBatch(ctx context.Context, request *vtgatepb.ExecuteBatchRequest) (response *vtgatepb.ExecuteBatchResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) sqlQueries := make([]string, len(request.Queries)) bindVars := make([]map[string]*querypb.BindVariable, len(request.Queries)) for queryNum, query := range request.Queries { sqlQueries[queryNum] = query.Sql bindVars[queryNum] = query.BindVariables } // Handle backward compatibility. session := request.Session if session == nil { session = &vtgatepb.Session{Autocommit: true} } if session.TargetString == "" { session.TargetString = request.KeyspaceShard + "@" + topoproto.TabletTypeLString(request.TabletType) } if session.Options == nil { session.Options = request.Options } session, results, err := vtg.server.ExecuteBatch(ctx, session, sqlQueries, bindVars) return &vtgatepb.ExecuteBatchResponse{ Results: sqltypes.QueryResponsesToProto3(results), Session: session, Error: vterrors.ToVTRPC(err), }, nil }
[ "func", "(", "vtg", "*", "VTGate", ")", "ExecuteBatch", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ExecuteBatchRequest", ")", "(", "response", "*", "vtgatepb", ".", "ExecuteBatchResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "sqlQueries", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "request", ".", "Queries", ")", ")", "\n", "bindVars", ":=", "make", "(", "[", "]", "map", "[", "string", "]", "*", "querypb", ".", "BindVariable", ",", "len", "(", "request", ".", "Queries", ")", ")", "\n", "for", "queryNum", ",", "query", ":=", "range", "request", ".", "Queries", "{", "sqlQueries", "[", "queryNum", "]", "=", "query", ".", "Sql", "\n", "bindVars", "[", "queryNum", "]", "=", "query", ".", "BindVariables", "\n", "}", "\n", "// Handle backward compatibility.", "session", ":=", "request", ".", "Session", "\n", "if", "session", "==", "nil", "{", "session", "=", "&", "vtgatepb", ".", "Session", "{", "Autocommit", ":", "true", "}", "\n", "}", "\n", "if", "session", ".", "TargetString", "==", "\"", "\"", "{", "session", ".", "TargetString", "=", "request", ".", "KeyspaceShard", "+", "\"", "\"", "+", "topoproto", ".", "TabletTypeLString", "(", "request", ".", "TabletType", ")", "\n", "}", "\n", "if", "session", ".", "Options", "==", "nil", "{", "session", ".", "Options", "=", "request", ".", "Options", "\n", "}", "\n", "session", ",", "results", ",", "err", ":=", "vtg", ".", "server", ".", "ExecuteBatch", "(", "ctx", ",", "session", ",", "sqlQueries", ",", "bindVars", ")", "\n", "return", "&", "vtgatepb", ".", "ExecuteBatchResponse", "{", "Results", ":", "sqltypes", ".", "QueryResponsesToProto3", "(", "results", ")", ",", "Session", ":", "session", ",", "Error", ":", "vterrors", ".", "ToVTRPC", "(", "err", ")", ",", "}", ",", "nil", "\n", "}" ]
// ExecuteBatch is the RPC version of vtgateservice.VTGateService method
[ "ExecuteBatch", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L125-L151
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
StreamExecute
func (vtg *VTGate) StreamExecute(request *vtgatepb.StreamExecuteRequest, stream vtgateservicepb.Vitess_StreamExecuteServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) // Handle backward compatibility. session := request.Session if session == nil { session = &vtgatepb.Session{Autocommit: true} } if session.TargetString == "" { session.TargetString = request.KeyspaceShard + "@" + topoproto.TabletTypeLString(request.TabletType) } if session.Options == nil { session.Options = request.Options } vtgErr := vtg.server.StreamExecute(ctx, session, request.Query.Sql, request.Query.BindVariables, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) StreamExecute(request *vtgatepb.StreamExecuteRequest, stream vtgateservicepb.Vitess_StreamExecuteServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) // Handle backward compatibility. session := request.Session if session == nil { session = &vtgatepb.Session{Autocommit: true} } if session.TargetString == "" { session.TargetString = request.KeyspaceShard + "@" + topoproto.TabletTypeLString(request.TabletType) } if session.Options == nil { session.Options = request.Options } vtgErr := vtg.server.StreamExecute(ctx, session, request.Query.Sql, request.Query.BindVariables, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "StreamExecute", "(", "request", "*", "vtgatepb", ".", "StreamExecuteRequest", ",", "stream", "vtgateservicepb", ".", "Vitess_StreamExecuteServer", ")", "(", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", ":=", "withCallerIDContext", "(", "stream", ".", "Context", "(", ")", ",", "request", ".", "CallerId", ")", "\n\n", "// Handle backward compatibility.", "session", ":=", "request", ".", "Session", "\n", "if", "session", "==", "nil", "{", "session", "=", "&", "vtgatepb", ".", "Session", "{", "Autocommit", ":", "true", "}", "\n", "}", "\n", "if", "session", ".", "TargetString", "==", "\"", "\"", "{", "session", ".", "TargetString", "=", "request", ".", "KeyspaceShard", "+", "\"", "\"", "+", "topoproto", ".", "TabletTypeLString", "(", "request", ".", "TabletType", ")", "\n", "}", "\n", "if", "session", ".", "Options", "==", "nil", "{", "session", ".", "Options", "=", "request", ".", "Options", "\n", "}", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "StreamExecute", "(", "ctx", ",", "session", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "func", "(", "value", "*", "sqltypes", ".", "Result", ")", "error", "{", "// Send is not safe to call concurrently, but vtgate", "// guarantees that it's not.", "return", "stream", ".", "Send", "(", "&", "vtgatepb", ".", "StreamExecuteResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "value", ")", ",", "}", ")", "\n", "}", ")", "\n", "return", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// StreamExecute is the RPC version of vtgateservice.VTGateService method
[ "StreamExecute", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L154-L177
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
ExecuteShards
func (vtg *VTGate) ExecuteShards(ctx context.Context, request *vtgatepb.ExecuteShardsRequest) (response *vtgatepb.ExecuteShardsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteShards(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.Shards, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteShardsResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
go
func (vtg *VTGate) ExecuteShards(ctx context.Context, request *vtgatepb.ExecuteShardsRequest) (response *vtgatepb.ExecuteShardsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteShards(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.Shards, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteShardsResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
[ "func", "(", "vtg", "*", "VTGate", ")", "ExecuteShards", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ExecuteShardsRequest", ")", "(", "response", "*", "vtgatepb", ".", "ExecuteShardsResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "result", ",", "err", ":=", "vtg", ".", "server", ".", "ExecuteShards", "(", "ctx", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "request", ".", "Keyspace", ",", "request", ".", "Shards", ",", "request", ".", "TabletType", ",", "request", ".", "Session", ",", "request", ".", "NotInTransaction", ",", "request", ".", "Options", ")", "\n", "return", "&", "vtgatepb", ".", "ExecuteShardsResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "result", ")", ",", "Session", ":", "request", ".", "Session", ",", "Error", ":", "vterrors", ".", "ToVTRPC", "(", "err", ")", ",", "}", ",", "nil", "\n", "}" ]
// ExecuteShards is the RPC version of vtgateservice.VTGateService method
[ "ExecuteShards", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L180-L197
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
ExecuteKeyspaceIds
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, request *vtgatepb.ExecuteKeyspaceIdsRequest) (response *vtgatepb.ExecuteKeyspaceIdsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteKeyspaceIds(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyspaceIds, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteKeyspaceIdsResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
go
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, request *vtgatepb.ExecuteKeyspaceIdsRequest) (response *vtgatepb.ExecuteKeyspaceIdsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteKeyspaceIds(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyspaceIds, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteKeyspaceIdsResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
[ "func", "(", "vtg", "*", "VTGate", ")", "ExecuteKeyspaceIds", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ExecuteKeyspaceIdsRequest", ")", "(", "response", "*", "vtgatepb", ".", "ExecuteKeyspaceIdsResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "result", ",", "err", ":=", "vtg", ".", "server", ".", "ExecuteKeyspaceIds", "(", "ctx", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "request", ".", "Keyspace", ",", "request", ".", "KeyspaceIds", ",", "request", ".", "TabletType", ",", "request", ".", "Session", ",", "request", ".", "NotInTransaction", ",", "request", ".", "Options", ")", "\n", "return", "&", "vtgatepb", ".", "ExecuteKeyspaceIdsResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "result", ")", ",", "Session", ":", "request", ".", "Session", ",", "Error", ":", "vterrors", ".", "ToVTRPC", "(", "err", ")", ",", "}", ",", "nil", "\n", "}" ]
// ExecuteKeyspaceIds is the RPC version of vtgateservice.VTGateService method
[ "ExecuteKeyspaceIds", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L200-L217
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
ExecuteKeyRanges
func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, request *vtgatepb.ExecuteKeyRangesRequest) (response *vtgatepb.ExecuteKeyRangesResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteKeyRanges(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyRanges, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteKeyRangesResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
go
func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, request *vtgatepb.ExecuteKeyRangesRequest) (response *vtgatepb.ExecuteKeyRangesResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteKeyRanges(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyRanges, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteKeyRangesResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
[ "func", "(", "vtg", "*", "VTGate", ")", "ExecuteKeyRanges", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ExecuteKeyRangesRequest", ")", "(", "response", "*", "vtgatepb", ".", "ExecuteKeyRangesResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "result", ",", "err", ":=", "vtg", ".", "server", ".", "ExecuteKeyRanges", "(", "ctx", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "request", ".", "Keyspace", ",", "request", ".", "KeyRanges", ",", "request", ".", "TabletType", ",", "request", ".", "Session", ",", "request", ".", "NotInTransaction", ",", "request", ".", "Options", ")", "\n", "return", "&", "vtgatepb", ".", "ExecuteKeyRangesResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "result", ")", ",", "Session", ":", "request", ".", "Session", ",", "Error", ":", "vterrors", ".", "ToVTRPC", "(", "err", ")", ",", "}", ",", "nil", "\n", "}" ]
// ExecuteKeyRanges is the RPC version of vtgateservice.VTGateService method
[ "ExecuteKeyRanges", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L220-L237
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
ExecuteEntityIds
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, request *vtgatepb.ExecuteEntityIdsRequest) (response *vtgatepb.ExecuteEntityIdsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteEntityIds(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.EntityColumnName, request.EntityKeyspaceIds, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteEntityIdsResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
go
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, request *vtgatepb.ExecuteEntityIdsRequest) (response *vtgatepb.ExecuteEntityIdsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteEntityIds(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.EntityColumnName, request.EntityKeyspaceIds, request.TabletType, request.Session, request.NotInTransaction, request.Options) return &vtgatepb.ExecuteEntityIdsResponse{ Result: sqltypes.ResultToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
[ "func", "(", "vtg", "*", "VTGate", ")", "ExecuteEntityIds", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ExecuteEntityIdsRequest", ")", "(", "response", "*", "vtgatepb", ".", "ExecuteEntityIdsResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "result", ",", "err", ":=", "vtg", ".", "server", ".", "ExecuteEntityIds", "(", "ctx", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "request", ".", "Keyspace", ",", "request", ".", "EntityColumnName", ",", "request", ".", "EntityKeyspaceIds", ",", "request", ".", "TabletType", ",", "request", ".", "Session", ",", "request", ".", "NotInTransaction", ",", "request", ".", "Options", ")", "\n", "return", "&", "vtgatepb", ".", "ExecuteEntityIdsResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "result", ")", ",", "Session", ":", "request", ".", "Session", ",", "Error", ":", "vterrors", ".", "ToVTRPC", "(", "err", ")", ",", "}", ",", "nil", "\n", "}" ]
// ExecuteEntityIds is the RPC version of vtgateservice.VTGateService method
[ "ExecuteEntityIds", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L240-L258
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
ExecuteBatchKeyspaceIds
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, request *vtgatepb.ExecuteBatchKeyspaceIdsRequest) (response *vtgatepb.ExecuteBatchKeyspaceIdsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteBatchKeyspaceIds(ctx, request.Queries, request.TabletType, request.AsTransaction, request.Session, request.Options) return &vtgatepb.ExecuteBatchKeyspaceIdsResponse{ Results: sqltypes.ResultsToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
go
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, request *vtgatepb.ExecuteBatchKeyspaceIdsRequest) (response *vtgatepb.ExecuteBatchKeyspaceIdsResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) result, err := vtg.server.ExecuteBatchKeyspaceIds(ctx, request.Queries, request.TabletType, request.AsTransaction, request.Session, request.Options) return &vtgatepb.ExecuteBatchKeyspaceIdsResponse{ Results: sqltypes.ResultsToProto3(result), Session: request.Session, Error: vterrors.ToVTRPC(err), }, nil }
[ "func", "(", "vtg", "*", "VTGate", ")", "ExecuteBatchKeyspaceIds", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ExecuteBatchKeyspaceIdsRequest", ")", "(", "response", "*", "vtgatepb", ".", "ExecuteBatchKeyspaceIdsResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "result", ",", "err", ":=", "vtg", ".", "server", ".", "ExecuteBatchKeyspaceIds", "(", "ctx", ",", "request", ".", "Queries", ",", "request", ".", "TabletType", ",", "request", ".", "AsTransaction", ",", "request", ".", "Session", ",", "request", ".", "Options", ")", "\n", "return", "&", "vtgatepb", ".", "ExecuteBatchKeyspaceIdsResponse", "{", "Results", ":", "sqltypes", ".", "ResultsToProto3", "(", "result", ")", ",", "Session", ":", "request", ".", "Session", ",", "Error", ":", "vterrors", ".", "ToVTRPC", "(", "err", ")", ",", "}", ",", "nil", "\n", "}" ]
// ExecuteBatchKeyspaceIds is the RPC version of // vtgateservice.VTGateService method
[ "ExecuteBatchKeyspaceIds", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L279-L293
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
StreamExecuteShards
func (vtg *VTGate) StreamExecuteShards(request *vtgatepb.StreamExecuteShardsRequest, stream vtgateservicepb.Vitess_StreamExecuteShardsServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.StreamExecuteShards(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.Shards, request.TabletType, request.Options, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteShardsResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) StreamExecuteShards(request *vtgatepb.StreamExecuteShardsRequest, stream vtgateservicepb.Vitess_StreamExecuteShardsServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.StreamExecuteShards(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.Shards, request.TabletType, request.Options, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteShardsResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "StreamExecuteShards", "(", "request", "*", "vtgatepb", ".", "StreamExecuteShardsRequest", ",", "stream", "vtgateservicepb", ".", "Vitess_StreamExecuteShardsServer", ")", "(", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", ":=", "withCallerIDContext", "(", "stream", ".", "Context", "(", ")", ",", "request", ".", "CallerId", ")", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "StreamExecuteShards", "(", "ctx", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "request", ".", "Keyspace", ",", "request", ".", "Shards", ",", "request", ".", "TabletType", ",", "request", ".", "Options", ",", "func", "(", "value", "*", "sqltypes", ".", "Result", ")", "error", "{", "// Send is not safe to call concurrently, but vtgate", "// guarantees that it's not.", "return", "stream", ".", "Send", "(", "&", "vtgatepb", ".", "StreamExecuteShardsResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "value", ")", ",", "}", ")", "\n", "}", ")", "\n", "return", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// StreamExecuteShards is the RPC version of vtgateservice.VTGateService method
[ "StreamExecuteShards", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L296-L314
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
StreamExecuteKeyspaceIds
func (vtg *VTGate) StreamExecuteKeyspaceIds(request *vtgatepb.StreamExecuteKeyspaceIdsRequest, stream vtgateservicepb.Vitess_StreamExecuteKeyspaceIdsServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.StreamExecuteKeyspaceIds(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyspaceIds, request.TabletType, request.Options, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteKeyspaceIdsResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) StreamExecuteKeyspaceIds(request *vtgatepb.StreamExecuteKeyspaceIdsRequest, stream vtgateservicepb.Vitess_StreamExecuteKeyspaceIdsServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.StreamExecuteKeyspaceIds(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyspaceIds, request.TabletType, request.Options, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteKeyspaceIdsResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "StreamExecuteKeyspaceIds", "(", "request", "*", "vtgatepb", ".", "StreamExecuteKeyspaceIdsRequest", ",", "stream", "vtgateservicepb", ".", "Vitess_StreamExecuteKeyspaceIdsServer", ")", "(", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", ":=", "withCallerIDContext", "(", "stream", ".", "Context", "(", ")", ",", "request", ".", "CallerId", ")", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "StreamExecuteKeyspaceIds", "(", "ctx", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "request", ".", "Keyspace", ",", "request", ".", "KeyspaceIds", ",", "request", ".", "TabletType", ",", "request", ".", "Options", ",", "func", "(", "value", "*", "sqltypes", ".", "Result", ")", "error", "{", "// Send is not safe to call concurrently, but vtgate", "// guarantees that it's not.", "return", "stream", ".", "Send", "(", "&", "vtgatepb", ".", "StreamExecuteKeyspaceIdsResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "value", ")", ",", "}", ")", "\n", "}", ")", "\n", "return", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// StreamExecuteKeyspaceIds is the RPC version of // vtgateservice.VTGateService method
[ "StreamExecuteKeyspaceIds", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L318-L336
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
StreamExecuteKeyRanges
func (vtg *VTGate) StreamExecuteKeyRanges(request *vtgatepb.StreamExecuteKeyRangesRequest, stream vtgateservicepb.Vitess_StreamExecuteKeyRangesServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.StreamExecuteKeyRanges(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyRanges, request.TabletType, request.Options, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteKeyRangesResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) StreamExecuteKeyRanges(request *vtgatepb.StreamExecuteKeyRangesRequest, stream vtgateservicepb.Vitess_StreamExecuteKeyRangesServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.StreamExecuteKeyRanges(ctx, request.Query.Sql, request.Query.BindVariables, request.Keyspace, request.KeyRanges, request.TabletType, request.Options, func(value *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&vtgatepb.StreamExecuteKeyRangesResponse{ Result: sqltypes.ResultToProto3(value), }) }) return vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "StreamExecuteKeyRanges", "(", "request", "*", "vtgatepb", ".", "StreamExecuteKeyRangesRequest", ",", "stream", "vtgateservicepb", ".", "Vitess_StreamExecuteKeyRangesServer", ")", "(", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", ":=", "withCallerIDContext", "(", "stream", ".", "Context", "(", ")", ",", "request", ".", "CallerId", ")", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "StreamExecuteKeyRanges", "(", "ctx", ",", "request", ".", "Query", ".", "Sql", ",", "request", ".", "Query", ".", "BindVariables", ",", "request", ".", "Keyspace", ",", "request", ".", "KeyRanges", ",", "request", ".", "TabletType", ",", "request", ".", "Options", ",", "func", "(", "value", "*", "sqltypes", ".", "Result", ")", "error", "{", "// Send is not safe to call concurrently, but vtgate", "// guarantees that it's not.", "return", "stream", ".", "Send", "(", "&", "vtgatepb", ".", "StreamExecuteKeyRangesResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "value", ")", ",", "}", ")", "\n", "}", ")", "\n", "return", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// StreamExecuteKeyRanges is the RPC version of // vtgateservice.VTGateService method
[ "StreamExecuteKeyRanges", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L340-L358
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
Begin
func (vtg *VTGate) Begin(ctx context.Context, request *vtgatepb.BeginRequest) (response *vtgatepb.BeginResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) session, vtgErr := vtg.server.Begin(ctx, request.SingleDb) if vtgErr == nil { return &vtgatepb.BeginResponse{ Session: session, }, nil } return nil, vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) Begin(ctx context.Context, request *vtgatepb.BeginRequest) (response *vtgatepb.BeginResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) session, vtgErr := vtg.server.Begin(ctx, request.SingleDb) if vtgErr == nil { return &vtgatepb.BeginResponse{ Session: session, }, nil } return nil, vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "Begin", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "BeginRequest", ")", "(", "response", "*", "vtgatepb", ".", "BeginResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "session", ",", "vtgErr", ":=", "vtg", ".", "server", ".", "Begin", "(", "ctx", ",", "request", ".", "SingleDb", ")", "\n", "if", "vtgErr", "==", "nil", "{", "return", "&", "vtgatepb", ".", "BeginResponse", "{", "Session", ":", "session", ",", "}", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// Begin is the RPC version of vtgateservice.VTGateService method
[ "Begin", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L361-L371
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
Commit
func (vtg *VTGate) Commit(ctx context.Context, request *vtgatepb.CommitRequest) (response *vtgatepb.CommitResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) vtgErr := vtg.server.Commit(ctx, request.Atomic, request.Session) response = &vtgatepb.CommitResponse{} if vtgErr == nil { return response, nil } return nil, vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) Commit(ctx context.Context, request *vtgatepb.CommitRequest) (response *vtgatepb.CommitResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) vtgErr := vtg.server.Commit(ctx, request.Atomic, request.Session) response = &vtgatepb.CommitResponse{} if vtgErr == nil { return response, nil } return nil, vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "Commit", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "CommitRequest", ")", "(", "response", "*", "vtgatepb", ".", "CommitResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "Commit", "(", "ctx", ",", "request", ".", "Atomic", ",", "request", ".", "Session", ")", "\n", "response", "=", "&", "vtgatepb", ".", "CommitResponse", "{", "}", "\n", "if", "vtgErr", "==", "nil", "{", "return", "response", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// Commit is the RPC version of vtgateservice.VTGateService method
[ "Commit", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L374-L383
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
Rollback
func (vtg *VTGate) Rollback(ctx context.Context, request *vtgatepb.RollbackRequest) (response *vtgatepb.RollbackResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) vtgErr := vtg.server.Rollback(ctx, request.Session) response = &vtgatepb.RollbackResponse{} if vtgErr == nil { return response, nil } return nil, vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) Rollback(ctx context.Context, request *vtgatepb.RollbackRequest) (response *vtgatepb.RollbackResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) vtgErr := vtg.server.Rollback(ctx, request.Session) response = &vtgatepb.RollbackResponse{} if vtgErr == nil { return response, nil } return nil, vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "Rollback", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "RollbackRequest", ")", "(", "response", "*", "vtgatepb", ".", "RollbackResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "Rollback", "(", "ctx", ",", "request", ".", "Session", ")", "\n", "response", "=", "&", "vtgatepb", ".", "RollbackResponse", "{", "}", "\n", "if", "vtgErr", "==", "nil", "{", "return", "response", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// Rollback is the RPC version of vtgateservice.VTGateService method
[ "Rollback", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L386-L395
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
ResolveTransaction
func (vtg *VTGate) ResolveTransaction(ctx context.Context, request *vtgatepb.ResolveTransactionRequest) (response *vtgatepb.ResolveTransactionResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) vtgErr := vtg.server.ResolveTransaction(ctx, request.Dtid) response = &vtgatepb.ResolveTransactionResponse{} if vtgErr == nil { return response, nil } return nil, vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) ResolveTransaction(ctx context.Context, request *vtgatepb.ResolveTransactionRequest) (response *vtgatepb.ResolveTransactionResponse, err error) { defer vtg.server.HandlePanic(&err) ctx = withCallerIDContext(ctx, request.CallerId) vtgErr := vtg.server.ResolveTransaction(ctx, request.Dtid) response = &vtgatepb.ResolveTransactionResponse{} if vtgErr == nil { return response, nil } return nil, vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "ResolveTransaction", "(", "ctx", "context", ".", "Context", ",", "request", "*", "vtgatepb", ".", "ResolveTransactionRequest", ")", "(", "response", "*", "vtgatepb", ".", "ResolveTransactionResponse", ",", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", "=", "withCallerIDContext", "(", "ctx", ",", "request", ".", "CallerId", ")", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "ResolveTransaction", "(", "ctx", ",", "request", ".", "Dtid", ")", "\n", "response", "=", "&", "vtgatepb", ".", "ResolveTransactionResponse", "{", "}", "\n", "if", "vtgErr", "==", "nil", "{", "return", "response", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// ResolveTransaction is the RPC version of vtgateservice.VTGateService method
[ "ResolveTransaction", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L398-L407
train
vitessio/vitess
go/vt/vtgate/grpcvtgateservice/server.go
MessageStream
func (vtg *VTGate) MessageStream(request *vtgatepb.MessageStreamRequest, stream vtgateservicepb.Vitess_MessageStreamServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.MessageStream(ctx, request.Keyspace, request.Shard, request.KeyRange, request.Name, func(qr *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&querypb.MessageStreamResponse{ Result: sqltypes.ResultToProto3(qr), }) }) return vterrors.ToGRPC(vtgErr) }
go
func (vtg *VTGate) MessageStream(request *vtgatepb.MessageStreamRequest, stream vtgateservicepb.Vitess_MessageStreamServer) (err error) { defer vtg.server.HandlePanic(&err) ctx := withCallerIDContext(stream.Context(), request.CallerId) vtgErr := vtg.server.MessageStream(ctx, request.Keyspace, request.Shard, request.KeyRange, request.Name, func(qr *sqltypes.Result) error { // Send is not safe to call concurrently, but vtgate // guarantees that it's not. return stream.Send(&querypb.MessageStreamResponse{ Result: sqltypes.ResultToProto3(qr), }) }) return vterrors.ToGRPC(vtgErr) }
[ "func", "(", "vtg", "*", "VTGate", ")", "MessageStream", "(", "request", "*", "vtgatepb", ".", "MessageStreamRequest", ",", "stream", "vtgateservicepb", ".", "Vitess_MessageStreamServer", ")", "(", "err", "error", ")", "{", "defer", "vtg", ".", "server", ".", "HandlePanic", "(", "&", "err", ")", "\n", "ctx", ":=", "withCallerIDContext", "(", "stream", ".", "Context", "(", ")", ",", "request", ".", "CallerId", ")", "\n", "vtgErr", ":=", "vtg", ".", "server", ".", "MessageStream", "(", "ctx", ",", "request", ".", "Keyspace", ",", "request", ".", "Shard", ",", "request", ".", "KeyRange", ",", "request", ".", "Name", ",", "func", "(", "qr", "*", "sqltypes", ".", "Result", ")", "error", "{", "// Send is not safe to call concurrently, but vtgate", "// guarantees that it's not.", "return", "stream", ".", "Send", "(", "&", "querypb", ".", "MessageStreamResponse", "{", "Result", ":", "sqltypes", ".", "ResultToProto3", "(", "qr", ")", ",", "}", ")", "\n", "}", ")", "\n", "return", "vterrors", ".", "ToGRPC", "(", "vtgErr", ")", "\n", "}" ]
// MessageStream is the RPC version of vtgateservice.VTGateService method
[ "MessageStream", "is", "the", "RPC", "version", "of", "vtgateservice", ".", "VTGateService", "method" ]
d568817542a413611801aa17a1c213aa95592182
https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/grpcvtgateservice/server.go#L410-L421
train