Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterDialer(name string, dialer DialerFunc)
- type DialerFunc
- type ErrFunc
- type Impl
- type VTGateConn
- func (conn *VTGateConn) Begin(ctx context.Context) (*VTGateTx, error)
- func (conn *VTGateConn) Begin2(ctx context.Context) (*VTGateTx, error)
- func (conn *VTGateConn) Close()
- func (conn *VTGateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, ...) (*sqltypes.Result, error)
- func (conn *VTGateConn) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, ...) ([]sqltypes.Result, error)
- func (conn *VTGateConn) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, ...) ([]sqltypes.Result, error)
- func (conn *VTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, ...) (*sqltypes.Result, error)
- func (conn *VTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, ...) (*sqltypes.Result, error)
- func (conn *VTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, ...) (*sqltypes.Result, error)
- func (conn *VTGateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, ...) (*sqltypes.Result, error)
- func (conn *VTGateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)
- func (conn *VTGateConn) SplitQuery(ctx context.Context, keyspace string, query string, ...) ([]*vtgatepb.SplitQueryResponse_Part, error)
- func (conn *VTGateConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- func (conn *VTGateConn) StreamExecute2(ctx context.Context, query string, bindVars map[string]interface{}, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- func (conn *VTGateConn) StreamExecuteKeyRanges(ctx context.Context, query string, keyspace string, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- func (conn *VTGateConn) StreamExecuteKeyRanges2(ctx context.Context, query string, keyspace string, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- func (conn *VTGateConn) StreamExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- func (conn *VTGateConn) StreamExecuteKeyspaceIds2(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- func (conn *VTGateConn) StreamExecuteShards(ctx context.Context, query string, keyspace string, shards []string, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- func (conn *VTGateConn) StreamExecuteShards2(ctx context.Context, query string, keyspace string, shards []string, ...) (<-chan *sqltypes.Result, ErrFunc, error)
- type VTGateTx
- func (tx *VTGateTx) Commit(ctx context.Context) error
- func (tx *VTGateTx) Commit2(ctx context.Context) error
- func (tx *VTGateTx) Execute(ctx context.Context, query string, bindVars map[string]interface{}, ...) (*sqltypes.Result, error)
- func (tx *VTGateTx) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, ...) ([]sqltypes.Result, error)
- func (tx *VTGateTx) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, ...) ([]sqltypes.Result, error)
- func (tx *VTGateTx) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, ...) (*sqltypes.Result, error)
- func (tx *VTGateTx) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, ...) (*sqltypes.Result, error)
- func (tx *VTGateTx) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, ...) (*sqltypes.Result, error)
- func (tx *VTGateTx) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, ...) (*sqltypes.Result, error)
- func (tx *VTGateTx) Rollback(ctx context.Context) error
- func (tx *VTGateTx) Rollback2(ctx context.Context) error
Constants ¶
const (
// GoRPCProtocol is a vtgate protocol based on go rpc
GoRPCProtocol = "gorpc"
)
Variables ¶
var ( // VtgateProtocol defines the RPC implementation used for connecting to vtgate. VtgateProtocol = flag.String("vtgate_protocol", GoRPCProtocol, "how to talk to vtgate") )
Functions ¶
func RegisterDialer ¶
func RegisterDialer(name string, dialer DialerFunc)
RegisterDialer is meant to be used by Dialer implementations to self register.
Types ¶
type DialerFunc ¶
DialerFunc represents a function that will return a VTGateConn object that can communicate with a VTGate.
type Impl ¶
type Impl interface { // Execute executes a non-streaming query on vtgate. Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) // ExecuteShards executes a non-streaming query for multiple shards on vtgate. ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) // ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids. ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) // ExecuteKeyRanges executes a non-streaming query on a key range. ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) // ExecuteEntityIds executes a non-streaming query for multiple entities. ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) // ExecuteBatchShards executes a set of non-streaming queries for multiple shards. ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool, session interface{}) ([]sqltypes.Result, interface{}, error) // ExecuteBatchKeyspaceIds executes a set of non-streaming queries for multiple keyspace ids. ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, asTransaction bool, session interface{}) ([]sqltypes.Result, interface{}, error) // StreamExecute executes a streaming query on vtgate. StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // StreamExecute2 executes a streaming query on vtgate. StreamExecute2(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // StreamExecuteShards executes a streaming query on vtgate, on a set of shards. StreamExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // StreamExecuteShards2 executes a streaming query on vtgate, on a set of shards. StreamExecuteShards2(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // StreamExecuteKeyRanges executes a streaming query on vtgate, on a set of keyranges. StreamExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // StreamExecuteKeyRanges2 executes a streaming query on vtgate, on a set of keyranges. StreamExecuteKeyRanges2(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // StreamExecuteKeyspaceIds executes a streaming query on vtgate, for the given keyspaceIds. StreamExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // StreamExecuteKeyspaceIds2 executes a streaming query on vtgate, for the given keyspaceIds. StreamExecuteKeyspaceIds2(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error) // Begin starts a transaction and returns a VTGateTX. Begin(ctx context.Context) (interface{}, error) // Commit commits the current transaction. Commit(ctx context.Context, session interface{}) error // Rollback rolls back the current transaction. Rollback(ctx context.Context, session interface{}) error // Begin starts a transaction and returns a VTGateTX. Begin2(ctx context.Context) (interface{}, error) // Commit commits the current transaction. Commit2(ctx context.Context, session interface{}) error // Rollback rolls back the current transaction. Rollback2(ctx context.Context, session interface{}) error // SplitQuery splits a query into equally sized smaller queries by // appending primary key range clauses to the original query. SplitQuery(ctx context.Context, keyspace string, query string, bindVars map[string]interface{}, splitColumn string, splitCount int64) ([]*vtgatepb.SplitQueryResponse_Part, error) // GetSrvKeyspace returns a topo.SrvKeyspace. GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error) // Close must be called for releasing resources. Close() }
Impl defines the interface for a vtgate client protocol implementation. It can be used concurrently across goroutines.
type VTGateConn ¶
type VTGateConn struct {
// contains filtered or unexported fields
}
VTGateConn is the client API object to talk to vtgate. It is constructed using the Dial method. It can be used concurrently across goroutines.
func DialProtocol ¶
func DialProtocol(ctx context.Context, protocol string, address string, timeout time.Duration) (*VTGateConn, error)
DialProtocol dials a specific protocol, and returns the *VTGateConn
func (*VTGateConn) Begin ¶
func (conn *VTGateConn) Begin(ctx context.Context) (*VTGateTx, error)
Begin starts a transaction and returns a VTGateTX.
func (*VTGateConn) Begin2 ¶
func (conn *VTGateConn) Begin2(ctx context.Context) (*VTGateTx, error)
Begin2 starts a transaction and returns a VTGateTX.
func (*VTGateConn) Close ¶
func (conn *VTGateConn) Close()
Close must be called for releasing resources.
func (*VTGateConn) Execute ¶
func (conn *VTGateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
Execute executes a non-streaming query on vtgate. This is using v3 API.
func (*VTGateConn) ExecuteBatchKeyspaceIds ¶
func (conn *VTGateConn) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, asTransaction bool) ([]sqltypes.Result, error)
ExecuteBatchKeyspaceIds executes a set of non-streaming queries for multiple keyspace ids. If "asTransaction" is true, vtgate will automatically create a transaction (per shard) that encloses all the batch queries.
func (*VTGateConn) ExecuteBatchShards ¶
func (conn *VTGateConn) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool) ([]sqltypes.Result, error)
ExecuteBatchShards executes a set of non-streaming queries for multiple shards. If "asTransaction" is true, vtgate will automatically create a transaction (per shard) that encloses all the batch queries.
func (*VTGateConn) ExecuteEntityIds ¶
func (conn *VTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteEntityIds executes a non-streaming query for multiple entities.
func (*VTGateConn) ExecuteKeyRanges ¶
func (conn *VTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteKeyRanges executes a non-streaming query on a key range.
func (*VTGateConn) ExecuteKeyspaceIds ¶
func (conn *VTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids.
func (*VTGateConn) ExecuteShards ¶
func (conn *VTGateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteShards executes a non-streaming query for multiple shards on vtgate.
func (*VTGateConn) GetSrvKeyspace ¶
func (conn *VTGateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)
GetSrvKeyspace returns a topo.SrvKeyspace object.
func (*VTGateConn) SplitQuery ¶
func (conn *VTGateConn) SplitQuery(ctx context.Context, keyspace string, query string, bindVars map[string]interface{}, splitColumn string, splitCount int64) ([]*vtgatepb.SplitQueryResponse_Part, error)
SplitQuery splits a query into equally sized smaller queries by appending primary key range clauses to the original query
func (*VTGateConn) StreamExecute ¶
func (conn *VTGateConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecute executes a streaming query on vtgate. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
func (*VTGateConn) StreamExecute2 ¶
func (conn *VTGateConn) StreamExecute2(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecute2 executes a streaming query on vtgate. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
func (*VTGateConn) StreamExecuteKeyRanges ¶
func (conn *VTGateConn) StreamExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecuteKeyRanges executes a streaming query on vtgate, on a set of keyranges. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
func (*VTGateConn) StreamExecuteKeyRanges2 ¶
func (conn *VTGateConn) StreamExecuteKeyRanges2(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecuteKeyRanges2 executes a streaming query on vtgate, on a set of keyranges. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
func (*VTGateConn) StreamExecuteKeyspaceIds ¶
func (conn *VTGateConn) StreamExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecuteKeyspaceIds executes a streaming query on vtgate, for the given keyspaceIds. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
func (*VTGateConn) StreamExecuteKeyspaceIds2 ¶
func (conn *VTGateConn) StreamExecuteKeyspaceIds2(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecuteKeyspaceIds2 executes a streaming query on vtgate, for the given keyspaceIds. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
func (*VTGateConn) StreamExecuteShards ¶
func (conn *VTGateConn) StreamExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecuteShards executes a streaming query on vtgate, on a set of shards. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
func (*VTGateConn) StreamExecuteShards2 ¶
func (conn *VTGateConn) StreamExecuteShards2(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (<-chan *sqltypes.Result, ErrFunc, error)
StreamExecuteShards2 executes a streaming query on vtgate, on a set of shards. It returns a channel, an ErrFunc, and error. First check the error. Then you can pull values from the channel till it's closed. Following this, you can call ErrFunc to see if the stream ended normally or due to a failure.
type VTGateTx ¶
type VTGateTx struct {
// contains filtered or unexported fields
}
VTGateTx defines an ongoing transaction. It should not be concurrently used across goroutines.
func (*VTGateTx) Execute ¶
func (tx *VTGateTx) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
Execute executes a query on vtgate within the current transaction.
func (*VTGateTx) ExecuteBatchKeyspaceIds ¶
func (tx *VTGateTx) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType) ([]sqltypes.Result, error)
ExecuteBatchKeyspaceIds executes a set of non-streaming queries for multiple keyspace ids.
func (*VTGateTx) ExecuteBatchShards ¶
func (tx *VTGateTx) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType) ([]sqltypes.Result, error)
ExecuteBatchShards executes a set of non-streaming queries for multiple shards.
func (*VTGateTx) ExecuteEntityIds ¶
func (tx *VTGateTx) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteEntityIds executes a non-streaming query for multiple entities.
func (*VTGateTx) ExecuteKeyRanges ¶
func (tx *VTGateTx) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteKeyRanges executes a non-streaming query on a key range.
func (*VTGateTx) ExecuteKeyspaceIds ¶
func (tx *VTGateTx) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids.
func (*VTGateTx) ExecuteShards ¶
func (tx *VTGateTx) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error)
ExecuteShards executes a query for multiple shards on vtgate within the current transaction.