Documentation ¶
Overview ¶
Package vtgate provides query routing rpc services for vttablets.
Package vtgate provides query routing rpc services for vttablets.
Index ¶
- Variables
- func Init(serv SrvTopoServer, schema *planbuilder.Schema, cell string, ...)
- func StrsEquals(a, b []string) bool
- type AddressList
- type Balancer
- type EndPointsCacheStatus
- type EndPointsCacheStatusList
- type GetEndPointsFunc
- type Planner
- type RegisterVTGate
- type ResilientSrvTopoServer
- func (server *ResilientSrvTopoServer) CacheStatus() *ResilientSrvTopoServerCacheStatus
- func (server *ResilientSrvTopoServer) GetEndPoints(context context.Context, cell, keyspace, shard string, ...) (result *topo.EndPoints, err error)
- func (server *ResilientSrvTopoServer) GetSrvKeyspace(context context.Context, cell, keyspace string) (*topo.SrvKeyspace, error)
- func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(context context.Context, cell string) ([]string, error)
- func (server *ResilientSrvTopoServer) GetSrvShard(context context.Context, cell, keyspace, shard string) (*topo.SrvShard, error)
- type ResilientSrvTopoServerCacheStatus
- type Resolver
- func (res *Resolver) Commit(ctx context.Context, inSession *proto.Session) error
- func (res *Resolver) Execute(ctx context.Context, sql string, bindVars map[string]interface{}, ...) (*mproto.QueryResult, error)
- func (res *Resolver) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, keyspace string, ...) (*tproto.QueryResultList, error)
- func (res *Resolver) ExecuteBatchKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdBatchQuery) (*tproto.QueryResultList, error)
- func (res *Resolver) ExecuteEntityIds(ctx context.Context, query *proto.EntityIdsQuery) (*mproto.QueryResult, error)
- func (res *Resolver) ExecuteKeyRanges(ctx context.Context, query *proto.KeyRangeQuery) (*mproto.QueryResult, error)
- func (res *Resolver) ExecuteKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdQuery) (*mproto.QueryResult, error)
- func (res *Resolver) InitializeConnections(ctx context.Context) error
- func (res *Resolver) Rollback(ctx context.Context, inSession *proto.Session) error
- func (res *Resolver) StreamExecute(ctx context.Context, sql string, bindVars map[string]interface{}, ...) error
- func (res *Resolver) StreamExecuteKeyRanges(ctx context.Context, query *proto.KeyRangeQuery, ...) error
- func (res *Resolver) StreamExecuteKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdQuery, ...) error
- type Router
- type SafeSession
- type ScatterConn
- func (stc *ScatterConn) Close() error
- func (stc *ScatterConn) Commit(context context.Context, session *SafeSession) (err error)
- func (stc *ScatterConn) Execute(context context.Context, query string, bindVars map[string]interface{}, ...) (*mproto.QueryResult, error)
- func (stc *ScatterConn) ExecuteBatch(context context.Context, queries []tproto.BoundQuery, keyspace string, ...) (qrs *tproto.QueryResultList, err error)
- func (stc *ScatterConn) ExecuteEntityIds(context context.Context, shards []string, sqls map[string]string, ...) (*mproto.QueryResult, error)
- func (stc *ScatterConn) ExecuteMulti(context context.Context, query string, keyspace string, ...) (*mproto.QueryResult, error)
- func (stc *ScatterConn) InitializeConnections(ctx context.Context) error
- func (stc *ScatterConn) Rollback(context context.Context, session *SafeSession) (err error)
- func (stc *ScatterConn) SplitQuery(ctx context.Context, query tproto.BoundQuery, splitCount int, ...) ([]proto.SplitQueryPart, error)
- func (stc *ScatterConn) StreamExecute(context context.Context, query string, bindVars map[string]interface{}, ...) error
- func (stc *ScatterConn) StreamExecuteMulti(context context.Context, query string, keyspace string, ...) error
- type ShardConn
- func (sdc *ShardConn) Begin(ctx context.Context) (transactionID int64, err error)
- func (sdc *ShardConn) Close()
- func (sdc *ShardConn) Commit(ctx context.Context, transactionID int64) (err error)
- func (sdc *ShardConn) Dial(ctx context.Context) error
- func (sdc *ShardConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, ...) (qr *mproto.QueryResult, err error)
- func (sdc *ShardConn) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, transactionID int64) (qrs *tproto.QueryResultList, err error)
- func (sdc *ShardConn) Rollback(ctx context.Context, transactionID int64) (err error)
- func (sdc *ShardConn) SplitQuery(ctx context.Context, query tproto.BoundQuery, splitCount int) (queries []tproto.QuerySplit, err error)
- func (sdc *ShardConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, ...) (<-chan *mproto.QueryResult, tabletconn.ErrFunc)
- func (sdc *ShardConn) WrapError(in error, endPoint topo.EndPoint, inTransaction bool) (wrapped error)
- type ShardConnError
- type SrvKeyspaceCacheStatus
- type SrvKeyspaceCacheStatusList
- type SrvKeyspaceNamesCacheStatus
- type SrvKeyspaceNamesCacheStatusList
- type SrvShardCacheStatus
- type SrvShardCacheStatusList
- type SrvTopoServer
- type VTGate
- func (vtg *VTGate) Begin(ctx context.Context, outSession *proto.Session) (err error)
- func (vtg *VTGate) Commit(ctx context.Context, inSession *proto.Session) (err error)
- func (vtg *VTGate) Execute(ctx context.Context, query *proto.Query, reply *proto.QueryResult) (err error)
- func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdBatchQuery, ...) (err error)
- func (vtg *VTGate) ExecuteBatchShard(ctx context.Context, batchQuery *proto.BatchQueryShard, ...) (err error)
- func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, query *proto.EntityIdsQuery, reply *proto.QueryResult) (err error)
- func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, query *proto.KeyRangeQuery, reply *proto.QueryResult) (err error)
- func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdQuery, reply *proto.QueryResult) (err error)
- func (vtg *VTGate) ExecuteShard(ctx context.Context, query *proto.QueryShard, reply *proto.QueryResult) (err error)
- func (vtg *VTGate) InitializeConnections(ctx context.Context) (err error)
- func (vtg *VTGate) Rollback(ctx context.Context, inSession *proto.Session) (err error)
- func (vtg *VTGate) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest, ...) (err error)
- func (vtg *VTGate) StreamExecute(ctx context.Context, query *proto.Query, ...) (err error)
- func (vtg *VTGate) StreamExecuteKeyRanges(ctx context.Context, query *proto.KeyRangeQuery, ...) (err error)
- func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdQuery, ...) (err error)
- func (vtg *VTGate) StreamExecuteShard(ctx context.Context, query *proto.QueryShard, ...) (err error)
Constants ¶
This section is empty.
Variables ¶
var RegisterVTGates []RegisterVTGate
RegisterVTGates stores register funcs for VTGate server.
Functions ¶
func Init ¶
func Init(serv SrvTopoServer, schema *planbuilder.Schema, cell string, retryDelay time.Duration, retryCount int, connTimeout time.Duration, maxInFlight int)
Init initializes VTGate server.
func StrsEquals ¶
StrsEquals compares contents of two string slices.
Types ¶
type AddressList ¶
type AddressList []*addressStatus
func (AddressList) Len ¶
func (al AddressList) Len() int
func (AddressList) Less ¶
func (al AddressList) Less(i, j int) bool
func (AddressList) Swap ¶
func (al AddressList) Swap(i, j int)
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
Balancer is a simple round-robin load balancer. It allows you to temporarily mark down nodes that are non-functional.
func NewBalancer ¶
func NewBalancer(getEndPoints GetEndPointsFunc, retryDelay time.Duration) *Balancer
NewBalancer creates a Balancer. getAddresses is the function it will use to refresh the list of addresses if one of the nodes has been marked down. The list of addresses is shuffled. retryDelay specifies the minimum time a node will be marked down before it will be cleared for a retry.
func (*Balancer) Get ¶
Get returns a single endpoint that was not recently marked down. If it finds an address that was down for longer than retryDelay, it refreshes the list of addresses and returns the next available node. If all addresses are marked down, it waits and retries. If a refresh fails, it returns an error.
type EndPointsCacheStatus ¶
type EndPointsCacheStatus struct { Cell string Keyspace string Shard string TabletType topo.TabletType Value *topo.EndPoints OriginalValue *topo.EndPoints LastError error LastErrorContext context.Context }
EndPointsCacheStatus is the current value for an EndPoints object
func (*EndPointsCacheStatus) StatusAsHTML ¶
func (st *EndPointsCacheStatus) StatusAsHTML() template.HTML
StatusAsHTML returns an HTML version of our status. It works best if there is data in the cache.
type EndPointsCacheStatusList ¶
type EndPointsCacheStatusList []*EndPointsCacheStatus
EndPointsCacheStatusList is used for sorting
func (EndPointsCacheStatusList) Len ¶
func (epcsl EndPointsCacheStatusList) Len() int
Len is part of sort.Interface
func (EndPointsCacheStatusList) Less ¶
func (epcsl EndPointsCacheStatusList) Less(i, j int) bool
Less is part of sort.Interface
func (EndPointsCacheStatusList) Swap ¶
func (epcsl EndPointsCacheStatusList) Swap(i, j int)
Swap is part of sort.Interface
type GetEndPointsFunc ¶
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
func NewPlanner ¶
func NewPlanner(schema *planbuilder.Schema, cacheSize int) *Planner
type RegisterVTGate ¶
type RegisterVTGate func(*VTGate)
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 SrvTopoServer.
func (*ResilientSrvTopoServer) CacheStatus ¶
func (server *ResilientSrvTopoServer) CacheStatus() *ResilientSrvTopoServerCacheStatus
CacheStatus returns a displayable version of the cache
func (*ResilientSrvTopoServer) GetEndPoints ¶
func (server *ResilientSrvTopoServer) GetEndPoints(context context.Context, cell, keyspace, shard string, tabletType topo.TabletType) (result *topo.EndPoints, err error)
GetEndPoints return all endpoints for the given cell, keyspace, shard, and tablet type.
func (*ResilientSrvTopoServer) GetSrvKeyspace ¶
func (server *ResilientSrvTopoServer) GetSrvKeyspace(context context.Context, cell, keyspace string) (*topo.SrvKeyspace, error)
GetSrvKeyspace returns SrvKeyspace object for the given cell and keyspace.
func (*ResilientSrvTopoServer) GetSrvKeyspaceNames ¶
func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(context context.Context, cell string) ([]string, error)
GetSrvKeyspaceNames returns all keyspace names for the given cell.
func (*ResilientSrvTopoServer) GetSrvShard ¶
func (server *ResilientSrvTopoServer) GetSrvShard(context context.Context, cell, keyspace, shard string) (*topo.SrvShard, error)
GetSrvShard returns SrvShard object for the given cell, keyspace, and shard.
type ResilientSrvTopoServerCacheStatus ¶
type ResilientSrvTopoServerCacheStatus struct { SrvKeyspaceNames SrvKeyspaceNamesCacheStatusList SrvKeyspaces SrvKeyspaceCacheStatusList SrvShards SrvShardCacheStatusList EndPoints EndPointsCacheStatusList }
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 SrvTopoServer, statsName, cell string, retryDelay time.Duration, retryCount int, connTimeout time.Duration) *Resolver
NewResolver creates a new Resolver. All input parameters are passed through for creating ScatterConn.
func (*Resolver) Execute ¶
func (res *Resolver) Execute( ctx context.Context, sql string, bindVars map[string]interface{}, keyspace string, tabletType topo.TabletType, session *proto.Session, mapToShards func(string) (string, []string, error), ) (*mproto.QueryResult, 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, queries []tproto.BoundQuery, keyspace string, tabletType topo.TabletType, session *proto.Session, mapToShards func(string) (string, []string, error), ) (*tproto.QueryResultList, 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, query *proto.KeyspaceIdBatchQuery) (*tproto.QueryResultList, 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, query *proto.EntityIdsQuery, ) (*mproto.QueryResult, 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, query *proto.KeyRangeQuery) (*mproto.QueryResult, 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, query *proto.KeyspaceIdQuery) (*mproto.QueryResult, 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) InitializeConnections ¶
InitializeConnections pre-initializes VTGate by connecting to vttablets of all keyspace/shard/type. It is not necessary to call this function before serving queries, but it would reduce connection overhead when serving.
func (*Resolver) StreamExecute ¶
func (res *Resolver) StreamExecute( ctx context.Context, sql string, bindVars map[string]interface{}, keyspace string, tabletType topo.TabletType, session *proto.Session, mapToShards func(string) (string, []string, error), sendReply func(*mproto.QueryResult) error, ) error
StreamExecuteShard executes a streaming query on shards resolved by given func. 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.
func (*Resolver) StreamExecuteKeyRanges ¶
func (res *Resolver) StreamExecuteKeyRanges(ctx context.Context, query *proto.KeyRangeQuery, sendReply func(*mproto.QueryResult) 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, query *proto.KeyspaceIdQuery, sendReply func(*mproto.QueryResult) 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.
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(serv SrvTopoServer, cell string, schema *planbuilder.Schema, statsName string, scatterConn *ScatterConn) *Router
NewRouter creates a new Router.
type SafeSession ¶
func NewSafeSession ¶
func NewSafeSession(sessn *proto.Session) *SafeSession
func (*SafeSession) Append ¶
func (session *SafeSession) Append(shardSession *proto.ShardSession)
func (*SafeSession) Find ¶
func (session *SafeSession) Find(keyspace, shard string, tabletType topo.TabletType) int64
func (*SafeSession) InTransaction ¶
func (session *SafeSession) InTransaction() bool
func (*SafeSession) Reset ¶
func (session *SafeSession) Reset()
type ScatterConn ¶
type ScatterConn struct {
// contains filtered or unexported fields
}
ScatterConn is used for executing queries across multiple ShardConn connections.
func NewScatterConn ¶
func NewScatterConn(serv SrvTopoServer, statsName, cell string, retryDelay time.Duration, retryCount int, connTimeout time.Duration) *ScatterConn
NewScatterConn creates a new ScatterConn. All input parameters are passed through for creating the appropriate ShardConn.
func (*ScatterConn) Close ¶
func (stc *ScatterConn) Close() error
Close closes the underlying ShardConn connections.
func (*ScatterConn) Commit ¶
func (stc *ScatterConn) Commit(context context.Context, session *SafeSession) (err error)
Commit commits the current transaction. There are no retries on this operation.
func (*ScatterConn) Execute ¶
func (stc *ScatterConn) Execute( context context.Context, query string, bindVars map[string]interface{}, keyspace string, shards []string, tabletType topo.TabletType, session *SafeSession, ) (*mproto.QueryResult, error)
Execute executes a non-streaming query on the specified shards.
func (*ScatterConn) ExecuteBatch ¶
func (stc *ScatterConn) ExecuteBatch( context context.Context, queries []tproto.BoundQuery, keyspace string, shards []string, tabletType topo.TabletType, session *SafeSession, ) (qrs *tproto.QueryResultList, err error)
ExecuteBatch executes a batch of non-streaming queries on the specified shards.
func (*ScatterConn) ExecuteEntityIds ¶
func (stc *ScatterConn) ExecuteEntityIds( context context.Context, shards []string, sqls map[string]string, bindVars map[string]map[string]interface{}, keyspace string, tabletType topo.TabletType, session *SafeSession, ) (*mproto.QueryResult, error)
ExecuteEntityIds executes queries that are shard specific.
func (*ScatterConn) ExecuteMulti ¶
func (stc *ScatterConn) ExecuteMulti( context context.Context, query string, keyspace string, shardVars map[string]map[string]interface{}, tabletType topo.TabletType, session *SafeSession, ) (*mproto.QueryResult, error)
ExecuteMulti is like Execute, but each shard gets its own bindVars. If len(shards) is not equal to len(bindVars), the function panics.
func (*ScatterConn) InitializeConnections ¶
func (stc *ScatterConn) InitializeConnections(ctx context.Context) error
InitializeConnections pre-initializes all ShardConn which create underlying connections. It also populates topology cache by accessing it. It is not necessary to call this function before serving queries, but it would reduce connection overhead when serving.
func (*ScatterConn) Rollback ¶
func (stc *ScatterConn) Rollback(context context.Context, session *SafeSession) (err error)
Rollback rolls back the current transaction. There are no retries on this operation.
func (*ScatterConn) SplitQuery ¶
func (stc *ScatterConn) SplitQuery(ctx context.Context, query tproto.BoundQuery, splitCount int, keyRangeByShard map[string]kproto.KeyRange, keyspace string) ([]proto.SplitQueryPart, error)
SplitQuery scatters a SplitQuery request to all shards. For a set of splits received from a shard, it construct a KeyRange queries by appending that shard's keyrange to the splits. Aggregates all splits across all shards in no specific order and returns.
func (*ScatterConn) StreamExecute ¶
func (stc *ScatterConn) StreamExecute( context context.Context, query string, bindVars map[string]interface{}, keyspace string, shards []string, tabletType topo.TabletType, session *SafeSession, sendReply func(reply *mproto.QueryResult) error, ) error
StreamExecute executes a streaming query on vttablet. The retry rules are the same.
func (*ScatterConn) StreamExecuteMulti ¶
func (stc *ScatterConn) StreamExecuteMulti( context context.Context, query string, keyspace string, shardVars map[string]map[string]interface{}, tabletType topo.TabletType, session *SafeSession, sendReply func(reply *mproto.QueryResult) 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.
type ShardConn ¶
type ShardConn struct {
// contains filtered or unexported fields
}
ShardConn represents a load balanced connection to a group of vttablets that belong to the same shard. ShardConn can be concurrently used across goroutines. Such requests are interleaved on the same underlying connection.
func NewShardConn ¶
func NewShardConn(ctx context.Context, serv SrvTopoServer, cell, keyspace, shard string, tabletType topo.TabletType, retryDelay time.Duration, retryCount int, connTimeout time.Duration) *ShardConn
NewShardConn creates a new ShardConn. It creates a Balancer using serv, cell, keyspace, tabletType and retryDelay. retryCount is the max number of retries before a ShardConn returns an error on an operation.
func (*ShardConn) Close ¶
func (sdc *ShardConn) Close()
Close closes the underlying TabletConn. ShardConn can be reused after this because it opens connections on demand.
func (*ShardConn) Commit ¶
Commit commits the current transaction. The retry rules are the same as Execute.
func (*ShardConn) Dial ¶
Dial creates tablet connection and connects to the vttablet. It is not necessary to call this function before serving queries, but it would reduce connection overhead when serving the first query.
func (*ShardConn) Execute ¶
func (sdc *ShardConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, transactionID int64) (qr *mproto.QueryResult, err error)
Execute executes a non-streaming query on vttablet. If there are connection errors, it retries retryCount times before failing. It does not retry if the connection is in the middle of a transaction.
func (*ShardConn) ExecuteBatch ¶
func (sdc *ShardConn) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, transactionID int64) (qrs *tproto.QueryResultList, err error)
ExecuteBatch executes a group of queries. The retry rules are the same as Execute.
func (*ShardConn) Rollback ¶
Rollback rolls back the current transaction. The retry rules are the same as Execute.
func (*ShardConn) SplitQuery ¶
func (sdc *ShardConn) SplitQuery(ctx context.Context, query tproto.BoundQuery, splitCount int) (queries []tproto.QuerySplit, err error)
func (*ShardConn) StreamExecute ¶
func (sdc *ShardConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, transactionID int64) (<-chan *mproto.QueryResult, tabletconn.ErrFunc)
StreamExecute executes a streaming query on vttablet. The retry rules are the same as Execute.
func (*ShardConn) WrapError ¶
func (sdc *ShardConn) WrapError(in error, endPoint topo.EndPoint, inTransaction bool) (wrapped error)
WrapError returns ShardConnError which preserves the original error code if possible, adds the connection context and adds a bit to determine whether the keyspace/shard needs to be re-resolved for a potential sharding event.
type ShardConnError ¶
func (*ShardConnError) Error ¶
func (e *ShardConnError) Error() string
type SrvKeyspaceCacheStatus ¶
type SrvKeyspaceCacheStatus struct { Cell string Keyspace string Value *topo.SrvKeyspace LastError error LastErrorContext 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 LastErrorContext 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 SrvShardCacheStatus ¶
type SrvShardCacheStatus struct { Cell string Keyspace string Shard string Value *topo.SrvShard LastError error LastErrorContext context.Context }
SrvShardCacheStatus is the current value for a SrvShard object
func (*SrvShardCacheStatus) StatusAsHTML ¶
func (st *SrvShardCacheStatus) StatusAsHTML() template.HTML
StatusAsHTML returns an HTML version of our status. It works best if there is data in the cache.
type SrvShardCacheStatusList ¶
type SrvShardCacheStatusList []*SrvShardCacheStatus
SrvShardCacheStatusList is used for sorting
func (SrvShardCacheStatusList) Len ¶
func (sscsl SrvShardCacheStatusList) Len() int
Len is part of sort.Interface
func (SrvShardCacheStatusList) Less ¶
func (sscsl SrvShardCacheStatusList) Less(i, j int) bool
Less is part of sort.Interface
func (SrvShardCacheStatusList) Swap ¶
func (sscsl SrvShardCacheStatusList) Swap(i, j int)
Swap is part of sort.Interface
type SrvTopoServer ¶
type SrvTopoServer interface { GetSrvKeyspaceNames(context context.Context, cell string) ([]string, error) GetSrvKeyspace(context context.Context, cell, keyspace string) (*topo.SrvKeyspace, error) GetSrvShard(context context.Context, cell, keyspace, shard string) (*topo.SrvShard, error) GetEndPoints(context context.Context, cell, keyspace, shard string, tabletType topo.TabletType) (*topo.EndPoints, error) }
SrvTopoServer is a subset of topo.Server that only contains the serving graph read-only calls used by clients to resolve serving addresses.
type VTGate ¶
type VTGate struct {
// contains filtered or unexported fields
}
VTGate is the rpc interface to vtgate. Only one instance can be created.
func (*VTGate) Execute ¶
func (vtg *VTGate) Execute(ctx context.Context, query *proto.Query, reply *proto.QueryResult) (err error)
Execute executes a non-streaming query by routing based on the values in the query.
func (*VTGate) ExecuteBatchKeyspaceIds ¶
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) (err error)
ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids.
func (*VTGate) ExecuteBatchShard ¶
func (vtg *VTGate) ExecuteBatchShard(ctx context.Context, batchQuery *proto.BatchQueryShard, reply *proto.QueryResultList) (err error)
ExecuteBatchShard executes a group of queries on the specified shards.
func (*VTGate) ExecuteEntityIds ¶
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, query *proto.EntityIdsQuery, reply *proto.QueryResult) (err error)
ExecuteEntityIds excutes a non-streaming query based on given KeyspaceId map.
func (*VTGate) ExecuteKeyRanges ¶
func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, query *proto.KeyRangeQuery, reply *proto.QueryResult) (err error)
ExecuteKeyRanges executes a non-streaming query based on the specified keyranges.
func (*VTGate) ExecuteKeyspaceIds ¶
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdQuery, reply *proto.QueryResult) (err error)
ExecuteKeyspaceIds executes a non-streaming query based on the specified keyspace ids.
func (*VTGate) ExecuteShard ¶
func (vtg *VTGate) ExecuteShard(ctx context.Context, query *proto.QueryShard, reply *proto.QueryResult) (err error)
ExecuteShard executes a non-streaming query on the specified shards.
func (*VTGate) InitializeConnections ¶
InitializeConnections pre-initializes VTGate by connecting to vttablets of all keyspace/shard/type. It is not necessary to call this function before serving queries, but it would reduce connection overhead when serving.
func (*VTGate) SplitQuery ¶
func (vtg *VTGate) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest, reply *proto.SplitQueryResult) (err error)
SplitQuery splits a query into sub queries by appending keyranges and primary key range clauses. Rows corresponding to the sub queries are guaranteed to be non-overlapping and will add up to the rows of original query. Number of sub queries will be a multiple of N that is greater than or equal to SplitQueryRequest.SplitCount, where N is the number of shards.
func (*VTGate) StreamExecute ¶
func (vtg *VTGate) StreamExecute(ctx context.Context, query *proto.Query, sendReply func(*proto.QueryResult) error) (err 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, query *proto.KeyRangeQuery, sendReply func(*proto.QueryResult) error) (err 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, query *proto.KeyspaceIdQuery, sendReply func(*proto.QueryResult) error) (err 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) StreamExecuteShard ¶
func (vtg *VTGate) StreamExecuteShard(ctx context.Context, query *proto.QueryShard, sendReply func(*proto.QueryResult) error) (err error)
StreamExecuteShard executes a streaming query on the specified shards.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package gorpcvtgateconn provides go rpc connectivity for VTGate.
|
Package gorpcvtgateconn provides go rpc connectivity for VTGate. |
Package gorpcvtgateservice provides to go rpc glue for vtgate
|
Package gorpcvtgateservice provides to go rpc glue for vtgate |