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

package vtgate

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

Package vtgate provides query routing rpc services for vttablets.

Index

Package Files

api.go executor.go executor_stats.go logstats.go plugin_mysql_server.go querylog.go querylogz.go queryz.go resolver.go safe_session.go scatter_conn.go tx_conn.go vcursor_impl.go vschema_manager.go vschema_stats.go vtgate.go

Constants

const (
    ExecutorTemplate = "" /* 2715 byte string literal not displayed */

)
const (
    VSchemaTemplate = "" /* 751 byte string literal not displayed */

)

Variables

var (
    // QueryLogHandler is the debug UI path for exposing query logs
    QueryLogHandler = "/debug/querylog"

    // QueryLogzHandler is the debug UI path for exposing query logs
    QueryLogzHandler = "/debug/querylogz"

    // QueryzHandler is the debug UI path for exposing query plan stats
    QueryzHandler = "/debug/queryz"

    // QueryLogger enables streaming logging of queries
    QueryLogger = streamlog.New("VTGate", 10)
)
var RegisterVTGates []RegisterVTGate

RegisterVTGates stores register funcs for VTGate server.

func RegisterPluginInitializer Uses

func RegisterPluginInitializer(initializer func())

RegisterPluginInitializer lets plugins register themselves to be init'ed at servenv.OnRun-time

func StrsEquals Uses

func StrsEquals(a, b []string) bool

StrsEquals compares contents of two string slices.

type Executor Uses

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

Executor is the engine that executes queries by utilizing the abilities of the underlying vttablets.

func NewExecutor Uses

func NewExecutor(ctx context.Context, serv srvtopo.Server, cell, statsName string, resolver *Resolver, normalize bool, streamSize int, queryPlanCacheSize int64) *Executor

NewExecutor creates a new Executor.

func (*Executor) Execute Uses

func (e *Executor) Execute(ctx context.Context, method string, safeSession *SafeSession, sql string, bindVars map[string]*querypb.BindVariable) (result *sqltypes.Result, err error)

Execute executes a non-streaming query.

func (*Executor) IsKeyspaceRangeBasedSharded Uses

func (e *Executor) IsKeyspaceRangeBasedSharded(keyspace string) bool

IsKeyspaceRangeBasedSharded returns true if the keyspace in the vschema is marked as sharded.

func (*Executor) MessageAck Uses

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

MessageAck acks messages. FIXME(alainjobart) the keyspace field here is not used for routing, but just for finding the table in the VSchema. If we don't find the table in the VSchema, we could just assume it's sharded (which would work for unsharded as well) and route it to the provided keyspace.

func (*Executor) MessageStream Uses

func (e *Executor) 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 (*Executor) ParseDestinationTarget Uses

func (e *Executor) ParseDestinationTarget(targetString string) (string, topodatapb.TabletType, key.Destination, error)

ParseDestinationTarget parses destination target string and sets default keyspace if possible.

func (*Executor) Plans Uses

func (e *Executor) Plans() *cache.LRUCache

Plans returns the LRU plan cache

func (*Executor) SaveVSchema Uses

func (e *Executor) SaveVSchema(vschema *vindexes.VSchema, stats *VSchemaStats)

SaveVSchema updates the vschema and stats

func (*Executor) ServeHTTP Uses

func (e *Executor) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServeHTTP shows the current plans in the query cache.

func (*Executor) StreamExecute Uses

func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession *SafeSession, sql string, bindVars map[string]*querypb.BindVariable, target querypb.Target, callback func(*sqltypes.Result) error) (err error)

StreamExecute executes a streaming query.

func (*Executor) VSchema Uses

func (e *Executor) VSchema() *vindexes.VSchema

VSchema returns the VSchema.

func (*Executor) VSchemaStats Uses

func (e *Executor) VSchemaStats() *VSchemaStats

VSchemaStats returns the loaded vschema stats.

type LogStats Uses

type LogStats struct {
    Ctx           context.Context
    Method        string
    Target        *querypb.Target
    StmtType      string
    SQL           string
    BindVariables map[string]*querypb.BindVariable
    StartTime     time.Time
    EndTime       time.Time
    ShardQueries  uint32
    RowsAffected  uint64
    PlanTime      time.Duration
    ExecuteTime   time.Duration
    CommitTime    time.Duration
    Error         error
}

LogStats records the stats for a single vtgate query

func NewLogStats Uses

func NewLogStats(ctx context.Context, methodName, sql string, bindVars map[string]*querypb.BindVariable) *LogStats

NewLogStats constructs a new LogStats with supplied Method and ctx field values, and the StartTime field set to the present time.

func (*LogStats) Context Uses

func (stats *LogStats) Context() context.Context

Context returns the context used by LogStats.

func (*LogStats) ContextHTML Uses

func (stats *LogStats) ContextHTML() template.HTML

ContextHTML returns the HTML version of the context that was used, or "". This is a method on LogStats instead of a field so that it doesn't need to be passed by value everywhere.

func (*LogStats) EffectiveCaller Uses

func (stats *LogStats) EffectiveCaller() string

EffectiveCaller returns the effective caller stored in LogStats.Ctx

func (*LogStats) ErrorStr Uses

func (stats *LogStats) ErrorStr() string

ErrorStr returns the error string or ""

func (*LogStats) EventTime Uses

func (stats *LogStats) EventTime() time.Time

EventTime returns the time the event was created.

func (*LogStats) ImmediateCaller Uses

func (stats *LogStats) ImmediateCaller() string

ImmediateCaller returns the immediate caller stored in LogStats.Ctx

func (*LogStats) Logf Uses

func (stats *LogStats) Logf(w io.Writer, params url.Values) error

Logf formats the log record to the given writer, either as tab-separated list of logged fields or as JSON.

func (*LogStats) RemoteAddrUsername Uses

func (stats *LogStats) RemoteAddrUsername() (string, string)

RemoteAddrUsername returns some parts of CallInfo if set

func (*LogStats) Send Uses

func (stats *LogStats) Send()

Send finalizes a record and sends it

func (*LogStats) TotalTime Uses

func (stats *LogStats) TotalTime() time.Duration

TotalTime returns how long this query has been running

type RegisterVTGate Uses

type RegisterVTGate func(vtgateservice.VTGateService)

RegisterVTGate defines the type of registration mechanism.

type Resolver Uses

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. It is implemented using a srvtopo.Resolver.

func NewResolver Uses

func NewResolver(resolver *srvtopo.Resolver, serv srvtopo.Server, cell string, sc *ScatterConn) *Resolver

NewResolver creates a new Resolver.

func (*Resolver) Execute Uses

func (res *Resolver) Execute(
    ctx context.Context,
    sql string,
    bindVars map[string]*querypb.BindVariable,
    keyspace string,
    tabletType topodatapb.TabletType,
    destination key.Destination,
    session *vtgatepb.Session,
    notInTransaction bool,
    options *querypb.ExecuteOptions,
    logStats *LogStats,
) (*sqltypes.Result, error)

Execute executes a non-streaming query based on provided destination. It retries query if new keyspace/shards are re-resolved after a retryable error.

func (*Resolver) ExecuteBatch Uses

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) ExecuteEntityIds Uses

func (res *Resolver) ExecuteEntityIds(
    ctx context.Context,
    sql string,
    bindVariables map[string]*querypb.BindVariable,
    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) GetGatewayCacheStatus Uses

func (res *Resolver) GetGatewayCacheStatus() gateway.TabletCacheStatusList

GetGatewayCacheStatus returns a displayable version of the Gateway cache.

func (*Resolver) MessageAckKeyspaceIds Uses

func (res *Resolver) MessageAckKeyspaceIds(ctx context.Context, keyspace, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error)

MessageAckKeyspaceIds routes message acks based on the associated keyspace ids.

func (*Resolver) MessageStream Uses

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) StreamExecute Uses

func (res *Resolver) StreamExecute(
    ctx context.Context,
    sql string,
    bindVars map[string]*querypb.BindVariable,
    keyspace string,
    tabletType topodatapb.TabletType,
    destination key.Destination,
    options *querypb.ExecuteOptions,
    callback func(*sqltypes.Result) error,
) error

StreamExecute 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. Note we guarantee the callback will not be called concurrently by mutiple go routines.

func (*Resolver) UpdateStream Uses

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

type SafeSession struct {
    *vtgatepb.Session
    // contains filtered or unexported fields
}

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

func NewAutocommitSession(sessn *vtgatepb.Session) *SafeSession

NewAutocommitSession returns a SafeSession based on the original session, but with autocommit enabled.

func NewSafeSession Uses

func NewSafeSession(sessn *vtgatepb.Session) *SafeSession

NewSafeSession returns a new SafeSession based on the Session

func (*SafeSession) Append Uses

func (session *SafeSession) Append(shardSession *vtgatepb.Session_ShardSession, txMode vtgatepb.TransactionMode) error

Append adds a new ShardSession

func (*SafeSession) AutocommitApproval Uses

func (session *SafeSession) AutocommitApproval() bool

AutocommitApproval returns true if we can perform a single round-trip autocommit. If so, the caller is responsible for committing their transaction.

func (*SafeSession) ClearWarnings Uses

func (session *SafeSession) ClearWarnings()

ClearWarnings removes all the warnings from the session

func (*SafeSession) Find Uses

func (session *SafeSession) Find(keyspace, shard string, tabletType topodatapb.TabletType) int64

Find returns the transactionId, if any, for a session

func (*SafeSession) InTransaction Uses

func (session *SafeSession) InTransaction() bool

InTransaction returns true if we are in a transaction

func (*SafeSession) MustRollback Uses

func (session *SafeSession) MustRollback() bool

MustRollback returns true if the transaction must be rolled back.

func (*SafeSession) RecordWarning Uses

func (session *SafeSession) RecordWarning(warning *querypb.QueryWarning)

RecordWarning stores the given warning in the session

func (*SafeSession) Reset Uses

func (session *SafeSession) Reset()

Reset clears the session

func (*SafeSession) SetAutocommittable Uses

func (session *SafeSession) SetAutocommittable(flag bool)

SetAutocommittable sets the state to autocommitable if true. Otherwise, it's notAutocommitable.

func (*SafeSession) SetCommitOrder Uses

func (session *SafeSession) SetCommitOrder(co vtgatepb.CommitOrder)

SetCommitOrder sets the commit order.

func (*SafeSession) SetRollback Uses

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 Uses

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

ScatterConn is used for executing queries across multiple shard level connections.

func NewScatterConn Uses

func NewScatterConn(statsName string, txConn *TxConn, gw gateway.Gateway, hc discovery.HealthCheck) *ScatterConn

NewScatterConn creates a new ScatterConn.

func (*ScatterConn) Close Uses

func (stc *ScatterConn) Close() error

Close closes the underlying Gateway.

func (*ScatterConn) Execute Uses

func (stc *ScatterConn) Execute(
    ctx context.Context,
    query string,
    bindVars map[string]*querypb.BindVariable,
    rss []*srvtopo.ResolvedShard,
    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 Uses

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 Uses

func (stc *ScatterConn) ExecuteEntityIds(
    ctx context.Context,
    rss []*srvtopo.ResolvedShard,
    sqls []string,
    bindVars []map[string]*querypb.BindVariable,
    tabletType topodatapb.TabletType,
    session *SafeSession,
    notInTransaction bool,
    options *querypb.ExecuteOptions,
) (*sqltypes.Result, error)

ExecuteEntityIds executes queries that are shard specific.

func (*ScatterConn) ExecuteMultiShard Uses

func (stc *ScatterConn) ExecuteMultiShard(
    ctx context.Context,
    rss []*srvtopo.ResolvedShard,
    queries []*querypb.BoundQuery,
    tabletType topodatapb.TabletType,
    session *SafeSession,
    notInTransaction bool,
    autocommit bool,
) (qr *sqltypes.Result, errs []error)

ExecuteMultiShard is like Execute, but each shard gets its own Sql Queries and BindVariables.

It always returns a non-nil query result and an array of shard errors which may be nil so that callers can optionally process a partially-successful operation.

func (*ScatterConn) GetGatewayCacheStatus Uses

func (stc *ScatterConn) GetGatewayCacheStatus() gateway.TabletCacheStatusList

GetGatewayCacheStatus returns a displayable version of the Gateway cache.

func (*ScatterConn) MessageAck Uses

func (stc *ScatterConn) MessageAck(ctx context.Context, rss []*srvtopo.ResolvedShard, values [][]*querypb.Value, name string) (int64, error)

MessageAck acks messages across multiple shards.

func (*ScatterConn) MessageStream Uses

func (stc *ScatterConn) MessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, name string, callback func(*sqltypes.Result) error) error

MessageStream streams messages from the specified shards. Note we guarantee the callback will not be called concurrently by mutiple go routines, through processOneStreamingResult.

func (*ScatterConn) SplitQuery Uses

func (stc *ScatterConn) SplitQuery(
    ctx context.Context,
    sql string,
    bindVariables map[string]*querypb.BindVariable,
    splitColumns []string,
    perShardSplitCount int64,
    numRowsPerQueryPart int64,
    algorithm querypb.SplitQueryRequest_Algorithm,
    rss []*srvtopo.ResolvedShard,
    querySplitToQueryPartFunc func(
        querySplit *querypb.QuerySplit, rs *srvtopo.ResolvedShard) (*vtgatepb.SplitQueryResponse_Part, error)) ([]*vtgatepb.SplitQueryResponse_Part, error)

SplitQuery scatters a SplitQuery request to the shards whose names are given in 'shards'. For every set of *querypb.QuerySplit's received from a shard, it applies the given 'querySplitToPartFunc' function to convert each *querypb.QuerySplit into a 'SplitQueryResponse_Part' message. Finally, it aggregates the obtained SplitQueryResponse_Parts across all shards and returns the resulting slice.

func (*ScatterConn) StreamExecute Uses

func (stc *ScatterConn) StreamExecute(
    ctx context.Context,
    query string,
    bindVars map[string]*querypb.BindVariable,
    rss []*srvtopo.ResolvedShard,
    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. Note we guarantee the callback will not be called concurrently by mutiple go routines, through processOneStreamingResult.

func (*ScatterConn) StreamExecuteMulti Uses

func (stc *ScatterConn) StreamExecuteMulti(
    ctx context.Context,
    query string,
    rss []*srvtopo.ResolvedShard,
    bindVars []map[string]*querypb.BindVariable,
    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. Note we guarantee the callback will not be called concurrently by mutiple go routines, through processOneStreamingResult.

func (*ScatterConn) UpdateStream Uses

func (stc *ScatterConn) UpdateStream(ctx context.Context, rs *srvtopo.ResolvedShard, timestamp int64, position string, callback func(*querypb.StreamEvent) error) error

UpdateStream just sends the query to the ResolvedShard, and sends the results back.

type TxConn Uses

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

TxConn is used for executing transactional requests.

func NewTxConn Uses

func NewTxConn(gw gateway.Gateway, txMode vtgatepb.TransactionMode) *TxConn

NewTxConn builds a new TxConn.

func (*TxConn) Begin Uses

func (txc *TxConn) Begin(ctx context.Context, session *SafeSession) error

Begin begins a new transaction. If one is already in progress, it commmits it and starts a new one.

func (*TxConn) Commit Uses

func (txc *TxConn) Commit(ctx context.Context, session *SafeSession) error

Commit commits the current transaction. The type of commit can be best effort or 2pc depending on the session setting.

func (*TxConn) Resolve Uses

func (txc *TxConn) Resolve(ctx context.Context, dtid string) error

Resolve resolves the specified 2PC transaction.

func (*TxConn) Rollback Uses

func (txc *TxConn) Rollback(ctx context.Context, session *SafeSession) error

Rollback rolls back the current transaction. There are no retries on this operation.

type VSchemaKeyspaceStats Uses

type VSchemaKeyspaceStats struct {
    Keyspace    string
    Sharded     bool
    TableCount  int
    VindexCount int
    Error       string
}

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

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

VSchemaManager is used to watch for updates to the vschema and to implement the DDL commands to add / remove vindexes

func (*VSchemaManager) GetCurrentSrvVschema Uses

func (vm *VSchemaManager) GetCurrentSrvVschema() *vschemapb.SrvVSchema

GetCurrentSrvVschema returns a copy of the latest SrvVschema from the topo watch

func (*VSchemaManager) UpdateVSchema Uses

func (vm *VSchemaManager) UpdateVSchema(ctx context.Context, ksName string, vschema *vschemapb.SrvVSchema) error

UpdateVSchema propagates the updated vschema to the topo. The entry for the given keyspace is updated in the global topo, and the full SrvVSchema is updated in all known cells.

type VSchemaStats Uses

type VSchemaStats struct {
    Error     string
    Keyspaces []*VSchemaKeyspaceStats
}

VSchemaStats contains a rollup of the VSchema stats.

func NewVSchemaStats Uses

func NewVSchemaStats(vschema *vindexes.VSchema, errorMessage string) *VSchemaStats

NewVSchemaStats returns a new VSchemaStats from a VSchema.

type VTGate Uses

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 VTGate exposes multiple generations of interfaces. The V3 interface is the latest one, which is capable of processing queries with no additional hints. V2 functions require the keyspace id or keyrange to be specified. V1 functions require shard info. V0 functions are informational that return topo information. Often, 'V2' or 'legacy' is used to refer to all legacy versions of the API (V2, V1 and V0).

func Init Uses

func Init(ctx context.Context, hc discovery.HealthCheck, serv srvtopo.Server, cell string, retryCount int, tabletTypesToWait []topodatapb.TabletType) *VTGate

Init initializes VTGate server.

func (*VTGate) Begin Uses

func (vtg *VTGate) Begin(ctx context.Context, singledb bool) (*vtgatepb.Session, error)

Begin begins a transaction. This is a legacy function.

func (*VTGate) Commit Uses

func (vtg *VTGate) Commit(ctx context.Context, twopc bool, session *vtgatepb.Session) error

Commit commits a transaction. This is a legacy function.

func (*VTGate) Execute Uses

func (vtg *VTGate) Execute(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error)

Execute executes a non-streaming query. This is a V3 function.

func (*VTGate) ExecuteBatch Uses

func (vtg *VTGate) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVariablesList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error)

ExecuteBatch executes a batch of queries. This is a V3 function.

func (*VTGate) ExecuteBatchKeyspaceIds Uses

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. This is a legacy function.

func (*VTGate) ExecuteBatchShards Uses

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. This is a legacy function.

func (*VTGate) ExecuteEntityIds Uses

func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, 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. This is a legacy function.

func (*VTGate) ExecuteKeyRanges Uses

func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, 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. This is a legacy function.

func (*VTGate) ExecuteKeyspaceIds Uses

func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, 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. This is a legacy function.

func (*VTGate) ExecuteShards Uses

func (vtg *VTGate) ExecuteShards(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, 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. This is a legacy function.

func (*VTGate) Gateway Uses

func (vtg *VTGate) Gateway() gateway.Gateway

Gateway returns the current gateway implementation. Mostly used for tests.

func (*VTGate) GetGatewayCacheStatus Uses

func (vtg *VTGate) GetGatewayCacheStatus() gateway.TabletCacheStatusList

GetGatewayCacheStatus returns a displayable version of the Gateway cache.

func (*VTGate) GetSrvKeyspace Uses

func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)

GetSrvKeyspace is part of the vtgate service API.

func (*VTGate) HandlePanic Uses

func (vtg *VTGate) HandlePanic(err *error)

HandlePanic recovers from panics, and logs / increment counters

func (*VTGate) IsHealthy Uses

func (vtg *VTGate) IsHealthy() error

IsHealthy returns nil if server is healthy. Otherwise, it returns an error indicating the reason.

func (*VTGate) MessageAck Uses

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 executor. The table name will be resolved using V3 rules, and the routing will make use of vindexes for sharded keyspaces. TODO(sougou): Deprecate this in favor of an SQL statement.

func (*VTGate) MessageAckKeyspaceIds Uses

func (vtg *VTGate) MessageAckKeyspaceIds(ctx context.Context, keyspace string, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error)

MessageAckKeyspaceIds is part of the vtgate service API. It routes message acks based on the associated keyspace ids.

func (*VTGate) MessageStream Uses

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. Note we guarantee the callback will not be called concurrently by mutiple go routines.

func (*VTGate) ResolveTransaction Uses

func (vtg *VTGate) ResolveTransaction(ctx context.Context, dtid string) error

ResolveTransaction resolves the specified 2PC transaction.

func (*VTGate) Rollback Uses

func (vtg *VTGate) Rollback(ctx context.Context, session *vtgatepb.Session) error

Rollback rolls back a transaction. This is a legacy function.

func (*VTGate) SplitQuery Uses

func (vtg *VTGate) SplitQuery(
    ctx context.Context,
    keyspace string,
    sql string,
    bindVariables map[string]*querypb.BindVariable,
    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 Uses

func (vtg *VTGate) StreamExecute(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) error

StreamExecute executes a streaming query. This is a V3 function. Note we guarantee the callback will not be called concurrently by mutiple go routines.

func (*VTGate) StreamExecuteKeyRanges Uses

func (vtg *VTGate) StreamExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, 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. This is a legacy function. Note we guarantee the callback will not be called concurrently by mutiple go routines.

func (*VTGate) StreamExecuteKeyspaceIds Uses

func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, 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. This is a legacy function. Note we guarantee the callback will not be called concurrently by mutiple go routines.

func (*VTGate) StreamExecuteShards Uses

func (vtg *VTGate) StreamExecuteShards(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, 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. This is a legacy function. Note we guarantee the callback will not be called concurrently by mutiple go routines.

func (*VTGate) UpdateStream Uses

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. Note we guarantee the callback will not be called concurrently by mutiple go routines, as the current implementation can only target one shard.

func (*VTGate) VSchemaStats Uses

func (vtg *VTGate) VSchemaStats() *VSchemaStats

VSchemaStats returns the loaded vschema stats.

Directories

PathSynopsis
bufferPackage buffer provides a buffer for MASTER traffic during failovers.
engine
fakerpcvtgateconnPackage fakerpcvtgateconn provides a fake implementation of vtgateconn.Impl that doesn't do any RPC, but uses a local map to return results.
gatewayPackage gateway contains the routing layer of vtgate.
gatewaytestPackage gatewaytest contains a test suite to run against a Gateway object.
grpcvtgateconnPackage grpcvtgateconn provides gRPC connectivity for VTGate.
grpcvtgateservicePackage grpcvtgateservice provides the gRPC glue for vtgate
planbuilderPackage planbuilder allows you to build execution plans that describe how to fulfill a query that may span multiple keyspaces or shards.
vindexes
vschemaacl
vtgateconn
vtgateconntestPackage vtgateconntest provides the test methods to make sure a vtgateconn/vtgateservice pair over RPC works correctly.
vtgateservicePackage vtgateservice provides to interface definition for the vtgate service

Package vtgate imports 62 packages (graph) and is imported by 4 packages. Updated 2019-06-13. Refresh now. Tools for package owners.