go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/vttablet/queryservice Index | Files | Directories

package queryservice

import "gopkg.in/src-d/go-vitess.v1/vt/vttablet/queryservice"

Package queryservice contains the interface for the service definition of the Query Service.

Index

Package Files

queryservice.go wrapped.go

func ExecuteWithStreamer Uses

func ExecuteWithStreamer(ctx context.Context, conn QueryService, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) sqltypes.ResultStream

ExecuteWithStreamer performs a StreamExecute, but returns a *sqltypes.ResultStream to iterate on. This function should only be used for legacy code. New usage should directly use StreamExecute.

func ExecuteWithTransactionalStreamer Uses

func ExecuteWithTransactionalStreamer(ctx context.Context, conn QueryService, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) sqltypes.ResultStream

ExecuteWithTransactionalStreamer does the same thing as ExecuteWithStreamer, but inside a transaction

type QueryService Uses

type QueryService interface {

    // Begin returns the transaction id to use for further operations
    Begin(ctx context.Context, target *querypb.Target, options *querypb.ExecuteOptions) (int64, error)

    // Commit commits the current transaction
    Commit(ctx context.Context, target *querypb.Target, transactionID int64) error

    // Rollback aborts the current transaction
    Rollback(ctx context.Context, target *querypb.Target, transactionID int64) error

    // Prepare prepares the specified transaction.
    Prepare(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)

    // CommitPrepared commits the prepared transaction.
    CommitPrepared(ctx context.Context, target *querypb.Target, dtid string) (err error)

    // RollbackPrepared rolls back the prepared transaction.
    RollbackPrepared(ctx context.Context, target *querypb.Target, dtid string, originalID int64) (err error)

    // CreateTransaction creates the metadata for a 2PC transaction.
    CreateTransaction(ctx context.Context, target *querypb.Target, dtid string, participants []*querypb.Target) (err error)

    // StartCommit atomically commits the transaction along with the
    // decision to commit the associated 2pc transaction.
    StartCommit(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)

    // SetRollback transitions the 2pc transaction to the Rollback state.
    // If a transaction id is provided, that transaction is also rolled back.
    SetRollback(ctx context.Context, target *querypb.Target, dtid string, transactionID int64) (err error)

    // ConcludeTransaction deletes the 2pc transaction metadata
    // essentially resolving it.
    ConcludeTransaction(ctx context.Context, target *querypb.Target, dtid string) (err error)

    // ReadTransaction returns the metadata for the sepcified dtid.
    ReadTransaction(ctx context.Context, target *querypb.Target, dtid string) (metadata *querypb.TransactionMetadata, err error)

    // Query execution
    Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
    StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
    ExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, transactionID int64, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)

    // Combo methods, they also return the transactionID from the
    // Begin part. If err != nil, the transactionID may still be
    // non-zero, and needs to be propagated back (like for a DB
    // Integrity Error)
    BeginExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (*sqltypes.Result, int64, error)
    BeginExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, options *querypb.ExecuteOptions) ([]sqltypes.Result, int64, error)

    // Messaging methods.
    MessageStream(ctx context.Context, target *querypb.Target, name string, callback func(*sqltypes.Result) error) error
    MessageAck(ctx context.Context, target *querypb.Target, name string, ids []*querypb.Value) (count int64, err error)

    // SplitQuery is a MapReduce helper function
    // This version of SplitQuery supports multiple algorithms and multiple split columns.
    // See the documentation of SplitQueryRequest in 'proto/vtgate.proto' for more information.
    SplitQuery(ctx context.Context, target *querypb.Target, query *querypb.BoundQuery, splitColumns []string, splitCount int64, numRowsPerQueryPart int64, algorithm querypb.SplitQueryRequest_Algorithm) ([]*querypb.QuerySplit, error)

    // UpdateStream streams updates from the provided position or timestamp.
    UpdateStream(ctx context.Context, target *querypb.Target, position string, timestamp int64, callback func(*querypb.StreamEvent) error) error

    // VStream streams VReplication events based on the specified filter.
    VStream(ctx context.Context, target *querypb.Target, startPos string, filter *binlogdatapb.Filter, send func([]*binlogdatapb.VEvent) error) error

    // VStreamRows streams rows of a table from the specified starting point.
    VStreamRows(ctx context.Context, target *querypb.Target, query string, lastpk *querypb.QueryResult, send func(*binlogdatapb.VStreamRowsResponse) error) error

    // StreamHealth streams health status.
    StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error

    // HandlePanic will be called if any of the functions panic.
    HandlePanic(err *error)

    // Close must be called for releasing resources.
    Close(ctx context.Context) error
}

QueryService is the interface implemented by the tablet's query service. All streaming methods accept a callback function that will be called for each response. If the callback returns an error, that error is returned back by the function, except in the case of io.EOF in which case the stream will be terminated with no error. Streams can also be terminated by canceling the context. This API is common for both server and client implementations. All functions must be safe to be called concurrently.

func Wrap Uses

func Wrap(impl QueryService, wrapper WrapperFunc) QueryService

Wrap returns a wrapped version of the original QueryService implementation. This lets you avoid repeating boiler-plate code by consolidating it in the wrapper function. A good example of this is go/vt/vtgate/gateway/discoverygateway.go. For every method invocation, the wrapper function is called, which can in turn call the provided inner function that will use the input parameters to call the implementation. In order to load balance across multiple implementations, you can set impl to be nil and provide the connection as input to the action function. In the case of StreamHealth or Close, there is no target and it will be nil. If necessary, the wrapper can validate the nil against the method name. The wrapper is also responsible for calling HandlePanic where necessary.

type WrapperFunc Uses

type WrapperFunc func(ctx context.Context, target *querypb.Target, conn QueryService, name string, inTransaction bool, inner func(context.Context, *querypb.Target, QueryService) (canRetry bool, err error)) error

WrapperFunc defines the signature for the wrapper function used by Wrap. Parameter ordering is as follows: original parameters, connection, method name, additional parameters and inner func. The inner function returns err and canRetry. If canRetry is true, the error is specific to the current vttablet and can be retried elsewhere. The flag will be false if there was no error.

Directories

PathSynopsis
fakes

Package queryservice imports 7 packages (graph) and is imported by 24 packages. Updated 2019-06-13. Refresh now. Tools for package owners.