Documentation ¶
Overview ¶
Package vtgate provides query routing rpc services for vttablets.
Package vtgate provides query routing rpc services for vttablets.
Index ¶
- Constants
- Variables
- func RegisterPluginInitializer(initializer func())
- func StrsEquals(a, b []string) bool
- type Planner
- func (plr *Planner) GetPlan(sql, keyspace string, bindvars map[string]interface{}) (*engine.Plan, error)
- func (plr *Planner) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (plr *Planner) VSchema() *vindexes.VSchema
- func (plr *Planner) VSchemaStats() *VSchemaStats
- func (plr *Planner) WatchSrvVSchema(ctx context.Context, cell string)
- type RegisterVTGate
- type ResilientSrvTopoServer
- func (server *ResilientSrvTopoServer) CacheStatus() *ResilientSrvTopoServerCacheStatus
- func (server *ResilientSrvTopoServer) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error)
- func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error)
- func (server *ResilientSrvTopoServer) WatchSrvVSchema(ctx context.Context, cell string) (*topo.WatchSrvVSchemaData, <-chan *topo.WatchSrvVSchemaData, topo.CancelFunc)
- type ResilientSrvTopoServerCacheStatus
- type Resolver
- func (res *Resolver) Execute(ctx context.Context, sql string, bindVars map[string]interface{}, ...) (*sqltypes.Result, error)
- func (res *Resolver) ExecuteBatch(ctx context.Context, tabletType topodatapb.TabletType, asTransaction bool, ...) ([]sqltypes.Result, error)
- func (res *Resolver) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, ...) ([]sqltypes.Result, error)
- func (res *Resolver) ExecuteEntityIds(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (*sqltypes.Result, error)
- func (res *Resolver) ExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (*sqltypes.Result, error)
- func (res *Resolver) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (*sqltypes.Result, error)
- func (res *Resolver) GetGatewayCacheStatus() gateway.TabletCacheStatusList
- func (res *Resolver) MessageStream(ctx context.Context, keyspace string, shard string, ...) error
- func (res *Resolver) StreamExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) error
- func (res *Resolver) StreamExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) error
- func (res *Resolver) UpdateStream(ctx context.Context, keyspace string, shard string, ...) error
- type Router
- func (rtr *Router) Execute(ctx context.Context, sql string, bindVars map[string]interface{}, ...) (*sqltypes.Result, error)
- func (rtr *Router) IsKeyspaceRangeBasedSharded(keyspace string) bool
- func (rtr *Router) MessageAck(ctx context.Context, keyspace, name string, ids []*querypb.Value) (int64, error)
- func (rtr *Router) StreamExecute(ctx context.Context, sql string, bindVars map[string]interface{}, ...) error
- type SafeSession
- func (session *SafeSession) Append(shardSession *vtgatepb.Session_ShardSession) error
- func (session *SafeSession) Find(keyspace, shard string, tabletType topodatapb.TabletType) int64
- func (session *SafeSession) InTransaction() bool
- func (session *SafeSession) MustRollback() bool
- func (session *SafeSession) Reset()
- func (session *SafeSession) SetRollback()
- type ScatterConn
- func (stc *ScatterConn) Close() error
- func (stc *ScatterConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, ...) (*sqltypes.Result, error)
- func (stc *ScatterConn) ExecuteBatch(ctx context.Context, batchRequest *scatterBatchRequest, ...) (qrs []sqltypes.Result, err error)
- func (stc *ScatterConn) ExecuteEntityIds(ctx context.Context, shards []string, sqls map[string]string, ...) (*sqltypes.Result, error)
- func (stc *ScatterConn) ExecuteMultiShard(ctx context.Context, keyspace string, ...) (*sqltypes.Result, error)
- func (stc *ScatterConn) GetGatewayCacheStatus() gateway.TabletCacheStatusList
- func (stc *ScatterConn) MessageAck(ctx context.Context, keyspace string, shardIDs map[string][]*querypb.Value, ...) (int64, error)
- func (stc *ScatterConn) MessageStream(ctx context.Context, keyspace string, shards []string, name string, ...) error
- func (stc *ScatterConn) SplitQuery(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) ([]*vtgatepb.SplitQueryResponse_Part, error)
- func (stc *ScatterConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, ...) error
- func (stc *ScatterConn) StreamExecuteMulti(ctx context.Context, query string, keyspace string, ...) error
- func (stc *ScatterConn) UpdateStream(ctx context.Context, target *querypb.Target, timestamp int64, position string, ...) error
- type SrvKeyspaceCacheStatus
- type SrvKeyspaceCacheStatusList
- type SrvKeyspaceNamesCacheStatus
- type SrvKeyspaceNamesCacheStatusList
- type TxConn
- type VSchemaKeyspaceStats
- type VSchemaKeyspaceStatsList
- type VSchemaStats
- type VTGate
- func (vtg *VTGate) Begin(ctx context.Context, singledb bool) (*vtgatepb.Session, error)
- func (vtg *VTGate) Commit(ctx context.Context, twopc bool, session *vtgatepb.Session) error
- func (vtg *VTGate) Execute(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error)
- func (vtg *VTGate) ExecuteBatch(ctx context.Context, sqlList []string, ...) (*vtgatepb.Session, []sqltypes.QueryResponse, error)
- func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, ...) ([]sqltypes.Result, error)
- func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, ...) ([]sqltypes.Result, error)
- func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) ExecuteShards(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) GetGatewayCacheStatus() gateway.TabletCacheStatusList
- func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)
- func (vtg *VTGate) HandlePanic(err *error)
- func (vtg *VTGate) IsHealthy() error
- func (vtg *VTGate) MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error)
- func (vtg *VTGate) MessageStream(ctx context.Context, keyspace string, shard string, ...) error
- func (vtg *VTGate) ResolveTransaction(ctx context.Context, dtid string) error
- func (vtg *VTGate) Rollback(ctx context.Context, session *vtgatepb.Session) error
- func (vtg *VTGate) SplitQuery(ctx context.Context, keyspace string, sql string, ...) ([]*vtgatepb.SplitQueryResponse_Part, error)
- func (vtg *VTGate) StreamExecute(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) error
- func (vtg *VTGate) StreamExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) error
- func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) error
- func (vtg *VTGate) StreamExecuteShards(ctx context.Context, sql string, bindVariables map[string]interface{}, ...) error
- func (vtg *VTGate) UpdateStream(ctx context.Context, keyspace string, shard string, ...) error
- func (vtg *VTGate) VSchemaStats() *VSchemaStats
Constants ¶
const ( TxSingle = iota TxMulti TxTwoPC )
Transaction modes. The value specifies what's allowed.
const ( // TopoTemplate is the HTML to use to display the // ResilientSrvTopoServerCacheStatus object TopoTemplate = `` /* 1064-byte string literal not displayed */ )
const ( // VSchemaTemplate is the HTML template to display VSchemaStats. VSchemaTemplate = `` /* 671-byte string literal not displayed */ )
Variables ¶
var RegisterVTGates []RegisterVTGate
RegisterVTGates stores register funcs for VTGate server.
Functions ¶
func RegisterPluginInitializer ¶
func RegisterPluginInitializer(initializer func())
RegisterPluginInitializer lets plugins register themselves to be init'ed at servenv.OnRun-time
func StrsEquals ¶
StrsEquals compares contents of two string slices.
Types ¶
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
Planner is used to compute the plan. It contains the vschema, and has a cache of previous computed plans.
func NewPlanner ¶
func NewPlanner(ctx context.Context, serv topo.SrvTopoServer, cell string, cacheSize int, normalize bool) *Planner
NewPlanner creates a new planner for VTGate. It will watch the vschema in the topology until the ctx is closed.
func (*Planner) GetPlan ¶
func (plr *Planner) GetPlan(sql, keyspace string, bindvars map[string]interface{}) (*engine.Plan, error)
GetPlan computes the plan for the given query. If one is in the cache, it reuses it.
func (*Planner) ServeHTTP ¶
func (plr *Planner) ServeHTTP(response http.ResponseWriter, request *http.Request)
ServeHTTP shows the current plans in the query cache.
func (*Planner) VSchemaStats ¶
func (plr *Planner) VSchemaStats() *VSchemaStats
VSchemaStats returns the loaded vschema stats.
func (*Planner) WatchSrvVSchema ¶
WatchSrvVSchema watches the SrvVSchema from the topo. The function does not return an error. It instead logs warnings on failure. The SrvVSchema object is roll-up of all the Keyspace information, so when a keyspace is added or removed, it will be properly updated.
This function will wait until the first value has either been processed or triggered an error before returning.
type RegisterVTGate ¶
type RegisterVTGate func(vtgateservice.VTGateService)
RegisterVTGate defines the type of registration mechanism.
type ResilientSrvTopoServer ¶
type ResilientSrvTopoServer struct {
// contains filtered or unexported fields
}
ResilientSrvTopoServer is an implementation of SrvTopoServer based on a topo.Server that uses a cache for two purposes: - limit the QPS to the underlying topo.Server - return the last known value of the data if there is an error
func NewResilientSrvTopoServer ¶
func NewResilientSrvTopoServer(base topo.Server, counterPrefix string) *ResilientSrvTopoServer
NewResilientSrvTopoServer creates a new ResilientSrvTopoServer based on the provided topo.Server.
func (*ResilientSrvTopoServer) CacheStatus ¶
func (server *ResilientSrvTopoServer) CacheStatus() *ResilientSrvTopoServerCacheStatus
CacheStatus returns a displayable version of the cache
func (*ResilientSrvTopoServer) GetSrvKeyspace ¶
func (server *ResilientSrvTopoServer) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error)
GetSrvKeyspace returns SrvKeyspace object for the given cell and keyspace.
func (*ResilientSrvTopoServer) GetSrvKeyspaceNames ¶
func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error)
GetSrvKeyspaceNames returns all keyspace names for the given cell.
func (*ResilientSrvTopoServer) WatchSrvVSchema ¶
func (server *ResilientSrvTopoServer) WatchSrvVSchema(ctx context.Context, cell string) (*topo.WatchSrvVSchemaData, <-chan *topo.WatchSrvVSchemaData, topo.CancelFunc)
WatchSrvVSchema is part of the SrvTopoServer API
type ResilientSrvTopoServerCacheStatus ¶
type ResilientSrvTopoServerCacheStatus struct { SrvKeyspaceNames SrvKeyspaceNamesCacheStatusList SrvKeyspaces SrvKeyspaceCacheStatusList }
ResilientSrvTopoServerCacheStatus has the full status of the cache
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is the layer to resolve KeyspaceIds and KeyRanges to shards. It will try to re-resolve shards if ScatterConn returns retryable error, which may imply horizontal or vertical resharding happened.
func NewResolver ¶
func NewResolver(serv topo.SrvTopoServer, cell string, sc *ScatterConn) *Resolver
NewResolver creates a new Resolver.
func (*Resolver) Execute ¶
func (res *Resolver) Execute( ctx context.Context, sql string, bindVars map[string]interface{}, keyspace string, tabletType topodatapb.TabletType, session *vtgatepb.Session, mapToShards func(string) (string, []string, error), notInTransaction bool, options *querypb.ExecuteOptions, ) (*sqltypes.Result, error)
Execute executes a non-streaming query based on shards resolved by given func. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) ExecuteBatch ¶
func (res *Resolver) ExecuteBatch( ctx context.Context, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions, buildBatchRequest func() (*scatterBatchRequest, error), ) ([]sqltypes.Result, error)
ExecuteBatch executes a group of queries based on shards resolved by given func. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) ExecuteBatchKeyspaceIds ¶
func (res *Resolver) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)
ExecuteBatchKeyspaceIds executes a group of queries based on KeyspaceIds. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) ExecuteEntityIds ¶
func (res *Resolver) ExecuteEntityIds( ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions, ) (*sqltypes.Result, error)
ExecuteEntityIds executes a non-streaming query based on given KeyspaceId map. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) ExecuteKeyRanges ¶
func (res *Resolver) ExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyRanges []*topodatapb.KeyRange, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteKeyRanges executes a non-streaming query based on KeyRanges. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) ExecuteKeyspaceIds ¶
func (res *Resolver) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyspaceIds [][]byte, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteKeyspaceIds executes a non-streaming query based on KeyspaceIds. It retries query if new keyspace/shards are re-resolved after a retryable error. This throws an error if a dml spans multiple keyspace_ids. Resharding depends on being able to uniquely route a write.
func (*Resolver) GetGatewayCacheStatus ¶
func (res *Resolver) GetGatewayCacheStatus() gateway.TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*Resolver) MessageStream ¶
func (res *Resolver) MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error
MessageStream streams messages.
func (*Resolver) StreamExecuteKeyRanges ¶
func (res *Resolver) StreamExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyRanges []*topodatapb.KeyRange, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteKeyRanges executes a streaming query on the specified KeyRanges. The KeyRanges are resolved to shards using the serving graph. This function currently temporarily enforces the restriction of executing on one shard since it cannot merge-sort the results to guarantee ordering of response which is needed for checkpointing. The api supports supplying multiple keyranges to make it future proof.
func (*Resolver) StreamExecuteKeyspaceIds ¶
func (res *Resolver) StreamExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyspaceIds [][]byte, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteKeyspaceIds executes a streaming query on the specified KeyspaceIds. The KeyspaceIds are resolved to shards using the serving graph. This function currently temporarily enforces the restriction of executing on one shard since it cannot merge-sort the results to guarantee ordering of response which is needed for checkpointing. The api supports supplying multiple KeyspaceIds to make it future proof.
func (*Resolver) UpdateStream ¶
func (res *Resolver) UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken, callback func(*querypb.StreamEvent, int64) error) error
UpdateStream streams the events. TODO(alainjobart): Implement the multi-shards merge code.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is the layer to route queries to the correct shards based on the values in the query.
func NewRouter ¶
func NewRouter(ctx context.Context, serv topo.SrvTopoServer, cell, statsName string, scatterConn *ScatterConn, normalize bool) *Router
NewRouter creates a new Router.
func (*Router) Execute ¶
func (rtr *Router) Execute(ctx context.Context, sql string, bindVars map[string]interface{}, keyspace string, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
Execute routes a non-streaming query.
func (*Router) IsKeyspaceRangeBasedSharded ¶
IsKeyspaceRangeBasedSharded returns true if the keyspace in the vschema is marked as sharded.
func (*Router) MessageAck ¶
func (rtr *Router) MessageAck(ctx context.Context, keyspace, name string, ids []*querypb.Value) (int64, error)
MessageAck acks messages.
func (*Router) StreamExecute ¶
func (rtr *Router) StreamExecute(ctx context.Context, sql string, bindVars map[string]interface{}, keyspace string, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecute executes a streaming query.
type SafeSession ¶
SafeSession is a mutex-protected version of the Session. It is thread-safe if each thread only accesses one shard. (the use pattern is 'Find', if not found, then 'Append', for a single shard)
func NewSafeSession ¶
func NewSafeSession(sessn *vtgatepb.Session) *SafeSession
NewSafeSession returns a new SafeSession based on the Session
func (*SafeSession) Append ¶
func (session *SafeSession) Append(shardSession *vtgatepb.Session_ShardSession) error
Append adds a new ShardSession
func (*SafeSession) Find ¶
func (session *SafeSession) Find(keyspace, shard string, tabletType topodatapb.TabletType) int64
Find returns the transactionId, if any, for a session
func (*SafeSession) InTransaction ¶
func (session *SafeSession) InTransaction() bool
InTransaction returns true if we are in a transaction
func (*SafeSession) MustRollback ¶
func (session *SafeSession) MustRollback() bool
MustRollback returns true if the transaction must be rolled back.
func (*SafeSession) SetRollback ¶
func (session *SafeSession) SetRollback()
SetRollback sets the flag indicating that the transaction must be rolled back. The call is a no-op if the session is not in a transaction.
type ScatterConn ¶
type ScatterConn struct {
// contains filtered or unexported fields
}
ScatterConn is used for executing queries across multiple shard level connections.
func NewScatterConn ¶
func NewScatterConn(statsName string, txConn *TxConn, gw gateway.Gateway) *ScatterConn
NewScatterConn creates a new ScatterConn.
func (*ScatterConn) Close ¶
func (stc *ScatterConn) Close() error
Close closes the underlying Gateway.
func (*ScatterConn) Execute ¶
func (stc *ScatterConn) Execute( ctx context.Context, query string, bindVars map[string]interface{}, keyspace string, shards []string, tabletType topodatapb.TabletType, session *SafeSession, notInTransaction bool, options *querypb.ExecuteOptions, ) (*sqltypes.Result, error)
Execute executes a non-streaming query on the specified shards.
func (*ScatterConn) ExecuteBatch ¶
func (stc *ScatterConn) ExecuteBatch( ctx context.Context, batchRequest *scatterBatchRequest, tabletType topodatapb.TabletType, asTransaction bool, session *SafeSession, options *querypb.ExecuteOptions) (qrs []sqltypes.Result, err error)
ExecuteBatch executes a batch of non-streaming queries on the specified shards.
func (*ScatterConn) ExecuteEntityIds ¶
func (stc *ScatterConn) ExecuteEntityIds( ctx context.Context, shards []string, sqls map[string]string, bindVars map[string]map[string]interface{}, keyspace string, tabletType topodatapb.TabletType, session *SafeSession, notInTransaction bool, options *querypb.ExecuteOptions, ) (*sqltypes.Result, error)
ExecuteEntityIds executes queries that are shard specific.
func (*ScatterConn) ExecuteMultiShard ¶
func (stc *ScatterConn) ExecuteMultiShard( ctx context.Context, keyspace string, shardQueries map[string]querytypes.BoundQuery, tabletType topodatapb.TabletType, session *SafeSession, notInTransaction bool, options *querypb.ExecuteOptions, ) (*sqltypes.Result, error)
ExecuteMultiShard is like Execute, but each shard gets its own Sql Queries and BindVariables.
func (*ScatterConn) GetGatewayCacheStatus ¶
func (stc *ScatterConn) GetGatewayCacheStatus() gateway.TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*ScatterConn) MessageAck ¶
func (stc *ScatterConn) MessageAck(ctx context.Context, keyspace string, shardIDs map[string][]*querypb.Value, name string) (int64, error)
MessageAck acks messages across multiple shards.
func (*ScatterConn) MessageStream ¶
func (stc *ScatterConn) MessageStream(ctx context.Context, keyspace string, shards []string, name string, callback func(*sqltypes.Result) error) error
MessageStream streams messages from the specified shards.
func (*ScatterConn) SplitQuery ¶
func (stc *ScatterConn) SplitQuery( ctx context.Context, sql string, bindVariables map[string]interface{}, splitColumns []string, perShardSplitCount int64, numRowsPerQueryPart int64, algorithm querypb.SplitQueryRequest_Algorithm, shards []string, querySplitToQueryPartFunc func( querySplit *querytypes.QuerySplit, shard string) (*vtgatepb.SplitQueryResponse_Part, error), keyspace string) ([]*vtgatepb.SplitQueryResponse_Part, error)
SplitQuery scatters a SplitQuery request to the shards whose names are given in 'shards'. For every set of querytypes.QuerySplit's received from a shard, it applies the given 'querySplitToPartFunc' function to convert each querytypes.QuerySplit into a 'SplitQueryResponse_Part' message. Finally, it aggregates the obtained SplitQueryResponse_Parts across all shards and returns the resulting slice.
func (*ScatterConn) StreamExecute ¶
func (stc *ScatterConn) StreamExecute( ctx context.Context, query string, bindVars map[string]interface{}, keyspace string, shards []string, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(reply *sqltypes.Result) error, ) error
StreamExecute executes a streaming query on vttablet. The retry rules are the same.
func (*ScatterConn) StreamExecuteMulti ¶
func (stc *ScatterConn) StreamExecuteMulti( ctx context.Context, query string, keyspace string, shardVars map[string]map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(reply *sqltypes.Result) error, ) error
StreamExecuteMulti is like StreamExecute, but each shard gets its own bindVars. If len(shards) is not equal to len(bindVars), the function panics.
func (*ScatterConn) UpdateStream ¶
func (stc *ScatterConn) UpdateStream(ctx context.Context, target *querypb.Target, timestamp int64, position string, callback func(*querypb.StreamEvent) error) error
UpdateStream just sends the query to the gateway, and sends the results back.
type SrvKeyspaceCacheStatus ¶
type SrvKeyspaceCacheStatus struct { Cell string Keyspace string Value *topodatapb.SrvKeyspace LastError error LastErrorCtx context.Context }
SrvKeyspaceCacheStatus is the current value for a SrvKeyspace object
func (*SrvKeyspaceCacheStatus) StatusAsHTML ¶
func (st *SrvKeyspaceCacheStatus) StatusAsHTML() template.HTML
StatusAsHTML returns an HTML version of our status. It works best if there is data in the cache.
type SrvKeyspaceCacheStatusList ¶
type SrvKeyspaceCacheStatusList []*SrvKeyspaceCacheStatus
SrvKeyspaceCacheStatusList is used for sorting
func (SrvKeyspaceCacheStatusList) Len ¶
func (skcsl SrvKeyspaceCacheStatusList) Len() int
Len is part of sort.Interface
func (SrvKeyspaceCacheStatusList) Less ¶
func (skcsl SrvKeyspaceCacheStatusList) Less(i, j int) bool
Less is part of sort.Interface
func (SrvKeyspaceCacheStatusList) Swap ¶
func (skcsl SrvKeyspaceCacheStatusList) Swap(i, j int)
Swap is part of sort.Interface
type SrvKeyspaceNamesCacheStatus ¶
type SrvKeyspaceNamesCacheStatus struct { Cell string Value []string LastError error LastErrorCtx context.Context }
SrvKeyspaceNamesCacheStatus is the current value for SrvKeyspaceNames
type SrvKeyspaceNamesCacheStatusList ¶
type SrvKeyspaceNamesCacheStatusList []*SrvKeyspaceNamesCacheStatus
SrvKeyspaceNamesCacheStatusList is used for sorting
func (SrvKeyspaceNamesCacheStatusList) Len ¶
func (skncsl SrvKeyspaceNamesCacheStatusList) Len() int
Len is part of sort.Interface
func (SrvKeyspaceNamesCacheStatusList) Less ¶
func (skncsl SrvKeyspaceNamesCacheStatusList) Less(i, j int) bool
Less is part of sort.Interface
func (SrvKeyspaceNamesCacheStatusList) Swap ¶
func (skncsl SrvKeyspaceNamesCacheStatusList) Swap(i, j int)
Swap is part of sort.Interface
type TxConn ¶
type TxConn struct {
// contains filtered or unexported fields
}
TxConn is used for executing transactional requests.
func (*TxConn) Commit ¶
Commit commits the current transaction. If twopc is true, then the 2PC protocol is used to ensure atomicity.
type VSchemaKeyspaceStats ¶
VSchemaKeyspaceStats contains a rollup of the VSchema stats for a keyspace. It is used to display a table with the information in the status page.
type VSchemaKeyspaceStatsList ¶
type VSchemaKeyspaceStatsList []*VSchemaKeyspaceStats
VSchemaKeyspaceStatsList is to sort VSchemaKeyspaceStats by keyspace.
func (VSchemaKeyspaceStatsList) Len ¶
func (l VSchemaKeyspaceStatsList) Len() int
Len is part of sort.Interface
func (VSchemaKeyspaceStatsList) Less ¶
func (l VSchemaKeyspaceStatsList) Less(i, j int) bool
Less is part of sort.Interface
func (VSchemaKeyspaceStatsList) Swap ¶
func (l VSchemaKeyspaceStatsList) Swap(i, j int)
Swap is part of sort.Interface
type VSchemaStats ¶
type VSchemaStats struct { Error string Keyspaces VSchemaKeyspaceStatsList }
VSchemaStats contains a rollup of the VSchema stats.
func NewVSchemaStats ¶
func NewVSchemaStats(vschema *vindexes.VSchema, errorMessage string) *VSchemaStats
NewVSchemaStats returns a new VSchemaStats from a VSchema.
type VTGate ¶
type VTGate struct {
// contains filtered or unexported fields
}
VTGate is the rpc interface to vtgate. Only one instance can be created. It implements vtgateservice.VTGateService
func Init ¶
func Init(ctx context.Context, hc discovery.HealthCheck, topoServer topo.Server, serv topo.SrvTopoServer, cell string, retryCount int, tabletTypesToWait []topodatapb.TabletType) *VTGate
Init initializes VTGate server.
func (*VTGate) Execute ¶
func (vtg *VTGate) Execute(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspaceShard string, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error)
Execute executes a non-streaming query by routing based on the values in the query.
func (*VTGate) ExecuteBatch ¶
func (vtg *VTGate) ExecuteBatch(ctx context.Context, sqlList []string, bindVariablesList []map[string]interface{}, keyspaceShard string, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, []sqltypes.QueryResponse, error)
ExecuteBatch executes a non-streaming queries by routing based on the values in the query.
func (*VTGate) ExecuteBatchKeyspaceIds ¶
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)
ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids.
func (*VTGate) ExecuteBatchShards ¶
func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)
ExecuteBatchShards executes a group of queries on the specified shards.
func (*VTGate) ExecuteEntityIds ¶
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteEntityIds excutes a non-streaming query based on given KeyspaceId map.
func (*VTGate) ExecuteKeyRanges ¶
func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyRanges []*topodatapb.KeyRange, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteKeyRanges executes a non-streaming query based on the specified keyranges.
func (*VTGate) ExecuteKeyspaceIds ¶
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyspaceIds [][]byte, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteKeyspaceIds executes a non-streaming query based on the specified keyspace ids.
func (*VTGate) ExecuteShards ¶
func (vtg *VTGate) ExecuteShards(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, shards []string, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteShards executes a non-streaming query on the specified shards.
func (*VTGate) GetGatewayCacheStatus ¶
func (vtg *VTGate) GetGatewayCacheStatus() gateway.TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*VTGate) GetSrvKeyspace ¶
func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)
GetSrvKeyspace is part of the vtgate service API.
func (*VTGate) HandlePanic ¶
HandlePanic recovers from panics, and logs / increment counters
func (*VTGate) IsHealthy ¶
IsHealthy returns nil if server is healthy. Otherwise, it returns an error indicating the reason.
func (*VTGate) MessageAck ¶
func (vtg *VTGate) MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error)
MessageAck is part of the vtgate service API. This is a V3 level API that's sent to the Router. The table name will be resolved using V3 rules, and the routing will make use of vindexes for sharded keyspaces.
func (*VTGate) MessageStream ¶
func (vtg *VTGate) MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error
MessageStream is part of the vtgate service API. This is a V2 level API that's sent to the Resolver.
func (*VTGate) ResolveTransaction ¶
ResolveTransaction resolves the specified 2PC transaction.
func (*VTGate) SplitQuery ¶
func (vtg *VTGate) SplitQuery( ctx context.Context, keyspace string, sql string, bindVariables map[string]interface{}, splitColumns []string, splitCount int64, numRowsPerQueryPart int64, algorithm querypb.SplitQueryRequest_Algorithm) ([]*vtgatepb.SplitQueryResponse_Part, error)
SplitQuery implements the SplitQuery RPC. This is the new version that supports multiple split-columns and multiple splitting algorithms. See the documentation of SplitQueryRequest in "proto/vtgate.proto" for more information.
func (*VTGate) StreamExecute ¶
func (vtg *VTGate) StreamExecute(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspaceShard string, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecute executes a streaming query by routing based on the values in the query.
func (*VTGate) StreamExecuteKeyRanges ¶
func (vtg *VTGate) StreamExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyRanges []*topodatapb.KeyRange, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteKeyRanges executes a streaming query on the specified KeyRanges. The KeyRanges are resolved to shards using the serving graph. This function currently temporarily enforces the restriction of executing on one shard since it cannot merge-sort the results to guarantee ordering of response which is needed for checkpointing. The api supports supplying multiple keyranges to make it future proof.
func (*VTGate) StreamExecuteKeyspaceIds ¶
func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, keyspaceIds [][]byte, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteKeyspaceIds executes a streaming query on the specified KeyspaceIds. The KeyspaceIds are resolved to shards using the serving graph. This function currently temporarily enforces the restriction of executing on one shard since it cannot merge-sort the results to guarantee ordering of response which is needed for checkpointing. The api supports supplying multiple KeyspaceIds to make it future proof.
func (*VTGate) StreamExecuteShards ¶
func (vtg *VTGate) StreamExecuteShards(ctx context.Context, sql string, bindVariables map[string]interface{}, keyspace string, shards []string, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteShards executes a streaming query on the specified shards.
func (*VTGate) UpdateStream ¶
func (vtg *VTGate) UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken, callback func(*querypb.StreamEvent, int64) error) error
UpdateStream is part of the vtgate service API.
func (*VTGate) VSchemaStats ¶
func (vtg *VTGate) VSchemaStats() *VSchemaStats
VSchemaStats returns the loaded vschema stats.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package buffer provides a buffer for MASTER traffic during failovers.
|
Package buffer provides a buffer for MASTER traffic during failovers. |
Package fakerpcvtgateconn provides a fake implementation of vtgateconn.Impl that doesn't do any RPC, but uses a local map to return results.
|
Package fakerpcvtgateconn provides a fake implementation of vtgateconn.Impl that doesn't do any RPC, but uses a local map to return results. |
Package gateway contains the routing layer of vtgate.
|
Package gateway contains the routing layer of vtgate. |
Package gatewaytest contains a test suite to run against a Gateway object.
|
Package gatewaytest contains a test suite to run against a Gateway object. |
Package grpcvtgateconn provides gRPC connectivity for VTGate.
|
Package grpcvtgateconn provides gRPC connectivity for VTGate. |
Package grpcvtgateservice provides the gRPC glue for vtgate
|
Package grpcvtgateservice provides the gRPC glue for vtgate |
Package l2vtgate provides the core functionnality of a second-layer vtgate to route queries from an original vtgate to a subset of tablets.
|
Package l2vtgate provides the core functionnality of a second-layer vtgate to route queries from an original vtgate to a subset of tablets. |
Package masterbuffer contains experimental logic to buffer master requests in VTGate.
|
Package masterbuffer contains experimental logic to buffer master requests in VTGate. |
Package planbuilder allows you to build execution plans that describe how to fulfill a query that may span multiple keyspaces or shards.
|
Package planbuilder allows you to build execution plans that describe how to fulfill a query that may span multiple keyspaces or shards. |
Package vtgateconntest provides the test methods to make sure a vtgateconn/vtgateservice pair over RPC works correctly.
|
Package vtgateconntest provides the test methods to make sure a vtgateconn/vtgateservice pair over RPC works correctly. |
Package vtgateservice provides to interface definition for the vtgate service
|
Package vtgateservice provides to interface definition for the vtgate service |