vitess: github.com/youtube/vitess/go/vt/vtgate/vtgateconn Index | Files

package vtgateconn

import "github.com/youtube/vitess/go/vt/vtgate/vtgateconn"

Index

Package Files

vtgateconn.go

Constants

const (
    // AtomicityMulti is the default level. It allows distributed transactions
    // with best effort commits. Partial commits are possible.
    AtomicityMulti = Atomicity(iota)
    // AtomicitySingle prevents a transaction from crossing the boundary of
    // a single database.
    AtomicitySingle
    // Atomicity2PC allows distributed transactions, and performs 2PC commits.
    Atomicity2PC
)

Variables

var (
    // VtgateProtocol defines the RPC implementation used for connecting to vtgate.
    VtgateProtocol = flag.String("vtgate_protocol", "grpc", "how to talk to vtgate")
)

func RegisterDialer Uses

func RegisterDialer(name string, dialer DialerFunc)

RegisterDialer is meant to be used by Dialer implementations to self register.

func WithAtomicity Uses

func WithAtomicity(ctx context.Context, level Atomicity) context.Context

WithAtomicity returns a context with the atomicity level set.

type Atomicity Uses

type Atomicity int

Atomicity specifies atomicity level of a transaction.

func AtomicityFromContext Uses

func AtomicityFromContext(ctx context.Context) Atomicity

AtomicityFromContext returns the atomicity of the context.

type DialerFunc Uses

type DialerFunc func(ctx context.Context, address string, timeout time.Duration) (Impl, error)

DialerFunc represents a function that will return an Impl object that can communicate with a VTGate.

type Impl Uses

type Impl interface {
    // Execute executes a non-streaming query on vtgate.
    Execute(ctx context.Context, query string, bindVars map[string]interface{}, keyspace string, tabletType topodatapb.TabletType, session interface{}, options *querypb.ExecuteOptions) (*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{}, options *querypb.ExecuteOptions) (*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{}, options *querypb.ExecuteOptions) (*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{}, options *querypb.ExecuteOptions) (*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{}, options *querypb.ExecuteOptions) (*sqltypes.Result, interface{}, error)

    // ExecuteBatch executes a non-streaming queries on vtgate.
    ExecuteBatch(ctx context.Context, queryList []string, bindVarsList []map[string]interface{}, keyspace string, tabletType topodatapb.TabletType, asTransaction bool, session interface{}, options *querypb.ExecuteOptions) ([]sqltypes.QueryResponse, 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{}, options *querypb.ExecuteOptions) ([]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{}, options *querypb.ExecuteOptions) ([]sqltypes.Result, interface{}, error)

    // StreamExecute executes a streaming query on vtgate.
    StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, keyspace string, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (sqltypes.ResultStream, 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, options *querypb.ExecuteOptions) (sqltypes.ResultStream, 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, options *querypb.ExecuteOptions) (sqltypes.ResultStream, 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, options *querypb.ExecuteOptions) (sqltypes.ResultStream, error)

    // Begin starts a transaction and returns a VTGateTX.
    Begin(ctx context.Context, singledb bool) (interface{}, error)
    // Commit commits the current transaction.
    Commit(ctx context.Context, session interface{}, twopc bool) error
    // Rollback rolls back the current transaction.
    Rollback(ctx context.Context, session interface{}) error
    // ResolveTransaction resolves the specified 2pc transaction.
    ResolveTransaction(ctx context.Context, dtid string) error

    // Messaging functions.
    MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error
    MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error)

    // SplitQuery splits a query into smaller queries. It is mostly used by batch job frameworks
    // such as MapReduce. See the documentation for the vtgate.SplitQueryRequest protocol buffer
    // message in 'proto/vtgate.proto'.
    SplitQuery(
        ctx context.Context,
        keyspace string,
        query string,
        bindVars map[string]interface{},
        splitColumns []string,
        splitCount int64,
        numRowsPerQueryPart int64,
        algorithm querypb.SplitQueryRequest_Algorithm) ([]*vtgatepb.SplitQueryResponse_Part, error)

    // GetSrvKeyspace returns a topo.SrvKeyspace.
    GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)

    // UpdateStream asks for a stream of StreamEvent.
    UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken) (UpdateStreamReader, 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 UpdateStreamReader Uses

type UpdateStreamReader interface {
    // Recv returns the next result on the stream.
    // It will return io.EOF if the stream ended.
    Recv() (*querypb.StreamEvent, int64, error)
}

UpdateStreamReader is returned by UpdateStream.

type VTGateConn Uses

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 Dial Uses

func Dial(ctx context.Context, address string, timeout time.Duration, keyspace string) (*VTGateConn, error)

Dial dials using the command-line specified protocol, and returns the *VTGateConn.

func DialProtocol Uses

func DialProtocol(ctx context.Context, protocol string, address string, timeout time.Duration, keyspace string) (*VTGateConn, error)

DialProtocol dials a specific protocol, and returns the *VTGateConn

func (*VTGateConn) Begin Uses

func (conn *VTGateConn) Begin(ctx context.Context) (*VTGateTx, error)

Begin starts a transaction and returns a VTGateTX.

func (*VTGateConn) Close Uses

func (conn *VTGateConn) Close()

Close must be called for releasing resources.

func (*VTGateConn) Execute Uses

func (conn *VTGateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

Execute executes a non-streaming query on vtgate. This is using v3 API.

func (*VTGateConn) ExecuteBatch Uses

func (conn *VTGateConn) ExecuteBatch(ctx context.Context, queryList []string, bindVarsList []map[string]interface{}, tabletType topodatapb.TabletType, asTransaction bool, options *querypb.ExecuteOptions) ([]sqltypes.QueryResponse, error)

ExecuteBatch executes a non-streaming list of queries on vtgate. This is using v3 API.

func (*VTGateConn) ExecuteBatchKeyspaceIds Uses

func (conn *VTGateConn) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, asTransaction bool, options *querypb.ExecuteOptions) ([]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 Uses

func (conn *VTGateConn) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool, options *querypb.ExecuteOptions) ([]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 Uses

func (conn *VTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteEntityIds executes a non-streaming query for multiple entities.

func (*VTGateConn) ExecuteKeyRanges Uses

func (conn *VTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteKeyRanges executes a non-streaming query on a key range.

func (*VTGateConn) ExecuteKeyspaceIds Uses

func (conn *VTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids.

func (*VTGateConn) ExecuteShards Uses

func (conn *VTGateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteShards executes a non-streaming query for multiple shards on vtgate.

func (*VTGateConn) GetSrvKeyspace Uses

func (conn *VTGateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)

GetSrvKeyspace returns a topo.SrvKeyspace object.

func (*VTGateConn) MessageAck Uses

func (conn *VTGateConn) MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error)

MessageAck acks messages.

func (*VTGateConn) MessageStream Uses

func (conn *VTGateConn) MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error

MessageStream streams messages.

func (*VTGateConn) ResolveTransaction Uses

func (conn *VTGateConn) ResolveTransaction(ctx context.Context, dtid string) error

ResolveTransaction resolves the 2pc transaction.

func (*VTGateConn) SplitQuery Uses

func (conn *VTGateConn) SplitQuery(
    ctx context.Context,
    keyspace string,
    query string,
    bindVars map[string]interface{},
    splitColumns []string,
    splitCount int64,
    numRowsPerQueryPart int64,
    algorithm querypb.SplitQueryRequest_Algorithm,
) ([]*vtgatepb.SplitQueryResponse_Part, error)

SplitQuery splits a query into smaller queries. It is mostly used by batch job frameworks such as MapReduce. See the documentation for the vtgate.SplitQueryRequest protocol buffer message in 'proto/vtgate.proto'.

func (*VTGateConn) StreamExecute Uses

func (conn *VTGateConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (sqltypes.ResultStream, error)

StreamExecute executes a streaming query on vtgate. It returns a ResultStream and an error. First check the error. Then you can pull values from the ResultStream until io.EOF, or another error.

func (*VTGateConn) StreamExecuteKeyRanges Uses

func (conn *VTGateConn) StreamExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (sqltypes.ResultStream, error)

StreamExecuteKeyRanges executes a streaming query on vtgate, on a set of keyranges. It returns a ResultStream and an error. First check the error. Then you can pull values from the ResultStream until io.EOF, or another error.

func (*VTGateConn) StreamExecuteKeyspaceIds Uses

func (conn *VTGateConn) StreamExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (sqltypes.ResultStream, error)

StreamExecuteKeyspaceIds executes a streaming query on vtgate, for the given keyspaceIds. It returns a ResultStream and an error. First check the error. Then you can pull values from the ResultStream until io.EOF, or another error.

func (*VTGateConn) StreamExecuteShards Uses

func (conn *VTGateConn) StreamExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (sqltypes.ResultStream, error)

StreamExecuteShards executes a streaming query on vtgate, on a set of shards. It returns a ResultStream and an error. First check the error. Then you can pull values from the ResultStream until io.EOF, or another error.

func (*VTGateConn) UpdateStream Uses

func (conn *VTGateConn) UpdateStream(ctx context.Context, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken) (UpdateStreamReader, error)

UpdateStream executes a streaming query on vtgate. It returns an UpdateStreamReader and an error. First check the error. Then you can pull values from the UpdateStreamReader until io.EOF, or another error.

type VTGateTx Uses

type VTGateTx struct {
    // contains filtered or unexported fields
}

VTGateTx defines an ongoing transaction. It should not be concurrently used across goroutines.

func (*VTGateTx) Commit Uses

func (tx *VTGateTx) Commit(ctx context.Context) error

Commit commits the current transaction.

func (*VTGateTx) Execute Uses

func (tx *VTGateTx) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

Execute executes a query on vtgate within the current transaction.

func (*VTGateTx) ExecuteBatch Uses

func (tx *VTGateTx) ExecuteBatch(ctx context.Context, query []string, bindVars []map[string]interface{}, tabletType topodatapb.TabletType, asTransaction bool, options *querypb.ExecuteOptions) ([]sqltypes.QueryResponse, error)

ExecuteBatch executes a list of queries on vtgate within the current transaction.

func (*VTGateTx) ExecuteBatchKeyspaceIds Uses

func (tx *VTGateTx) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)

ExecuteBatchKeyspaceIds executes a set of non-streaming queries for multiple keyspace ids.

func (*VTGateTx) ExecuteBatchShards Uses

func (tx *VTGateTx) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)

ExecuteBatchShards executes a set of non-streaming queries for multiple shards.

func (*VTGateTx) ExecuteEntityIds Uses

func (tx *VTGateTx) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteEntityIds executes a non-streaming query for multiple entities.

func (*VTGateTx) ExecuteKeyRanges Uses

func (tx *VTGateTx) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteKeyRanges executes a non-streaming query on a key range.

func (*VTGateTx) ExecuteKeyspaceIds Uses

func (tx *VTGateTx) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids.

func (*VTGateTx) ExecuteShards Uses

func (tx *VTGateTx) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecuteShards executes a query for multiple shards on vtgate within the current transaction.

func (*VTGateTx) Rollback Uses

func (tx *VTGateTx) Rollback(ctx context.Context) error

Rollback rolls back the current transaction.

Package vtgateconn imports 9 packages (graph) and is imported by 9 packages. Updated 2017-02-02. Refresh now. Tools for package owners.