tabletconn

package
v2.0.0-beta.1+incompat... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2016 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Refer to tabletserver/tablet_error.go for a more detailed explanation on
	// what these errors mean from the VtTablet perspective.
	ERR_NORMAL = iota
	ERR_RETRY
	ERR_FATAL
	ERR_TX_POOL_FULL
	ERR_NOT_IN_TX
)
View Source
const (
	ConnClosed = OperationalError("vttablet: Connection Closed")
	Cancelled  = OperationalError("vttablet: Context Cancelled")
)

Variables

View Source
var (
	// TabletProtocol is exported for unit tests
	TabletProtocol = flag.String("tablet_protocol", "grpc", "how to talk to the vttablets")
)

Functions

func RegisterDialer

func RegisterDialer(name string, dialer TabletDialer)

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

func TabletErrorFromGRPC

func TabletErrorFromGRPC(err error) error

TabletErrorFromGRPC returns a ServerError or a OperationalError from the gRPC error.

Types

type ErrFunc

type ErrFunc func() error

type OperationalError

type OperationalError string

OperationalError represents an error due to a failure to communicate with vttablet.

func (OperationalError) Error

func (e OperationalError) Error() string

type ServerError

type ServerError struct {
	Code int
	Err  string
	// ServerCode is the error code that we got from the server.
	ServerCode vtrpcpb.ErrorCode
}

ServerError represents an error that was returned from a vttablet server.

func (*ServerError) Error

func (e *ServerError) Error() string

func (*ServerError) VtErrorCode

func (e *ServerError) VtErrorCode() vtrpcpb.ErrorCode

VtErrorCode returns the underlying Vitess error code

type TabletConn

type TabletConn interface {
	// Execute executes a non-streaming query on vttablet.
	Execute(ctx context.Context, query string, bindVars map[string]interface{}, transactionId int64) (*sqltypes.Result, error)

	// ExecuteBatch executes a group of queries.
	ExecuteBatch(ctx context.Context, queries []querytypes.BoundQuery, asTransaction bool, transactionId int64) ([]sqltypes.Result, error)

	// StreamExecute executes a streaming query on vttablet. It returns a channel, ErrFunc and error.
	// If error is non-nil, it means that the StreamExecute failed to send the request. Otherwise,
	// 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.
	StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, transactionId int64) (<-chan *sqltypes.Result, ErrFunc, error)

	// Transaction support
	Begin(ctx context.Context) (transactionId int64, err error)
	Commit(ctx context.Context, transactionId int64) error
	Rollback(ctx context.Context, transactionId int64) error

	// Close must be called for releasing resources.
	Close()

	// SetTarget can be called to change the target used for
	// subsequent calls. Can only be called if tabletType was not
	// set to UNKNOWN in TabletDialer.
	SetTarget(keyspace, shard string, tabletType topodatapb.TabletType) error

	// GetEndPoint returns the end point info.
	EndPoint() *topodatapb.EndPoint

	// SplitQuery splits a query into equally sized smaller queries by
	// appending primary key range clauses to the original query
	SplitQuery(ctx context.Context, query querytypes.BoundQuery, splitColumn string, splitCount int64) ([]querytypes.QuerySplit, error)

	// StreamHealth streams StreamHealthResponse to the client
	StreamHealth(ctx context.Context) (<-chan *querypb.StreamHealthResponse, ErrFunc, error)
}

TabletConn defines the interface for a vttablet client. It should not be concurrently used across goroutines.

type TabletDialer

type TabletDialer func(ctx context.Context, endPoint *topodatapb.EndPoint, keyspace, shard string, tabletType topodatapb.TabletType, timeout time.Duration) (TabletConn, error)

TabletDialer represents a function that will return a TabletConn object that can communicate with a tablet.

We support two modes of operation: 1 - using GetSessionId (right after dialing) to get a sessionId. 2 - using Target with each call (and never calling GetSessionId). If tabletType is set to UNKNOWN, we'll use mode 1. Mode 1 is being deprecated.

func GetDialer

func GetDialer() TabletDialer

GetDialer returns the dialer to use, described by the command line flag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL