vtgateconn

package
v0.0.0-...-bc668d9 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2015 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDialer

func RegisterDialer(name string, dialer DialerFunc)

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

Types

type DialerFunc

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

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

func GetDialer

func GetDialer() DialerFunc

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

type ErrFunc

type ErrFunc func() error

ErrFunc is used to check for streaming errors.

type OperationalError

type OperationalError string

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

func (OperationalError) Error

func (e OperationalError) Error() string

type ServerError

type ServerError struct {
	Code int
	Err  string
}

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

func (*ServerError) Error

func (e *ServerError) Error() string

type VTGateConn

type VTGateConn interface {
	// Execute executes a non-streaming query on vtgate.
	Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topo.TabletType) (*mproto.QueryResult, error)

	// ExecuteBatch executes a group of queries.
	ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, tabletType topo.TabletType) (*tproto.QueryResultList, error)

	// StreamExecute executes a streaming query on vtgate. 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{}, tabletType topo.TabletType) (<-chan *mproto.QueryResult, ErrFunc)

	// Transaction support
	Begin(ctx context.Context) error
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error

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

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

VTGateConn defines the interface for a vtgate client. It should not be concurrently used across goroutines.

Jump to

Keyboard shortcuts

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