tabletconn

package
v0.0.0-...-d271c08 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2014 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_NORMAL = iota
	ERR_RETRY
	ERR_FATAL
	ERR_TX_POOL_FULL
	ERR_NOT_IN_TX
)
View Source
const (
	CONN_CLOSED = OperationalError("vttablet: Connection Closed")
)

Variables

This section is empty.

Functions

func RegisterDialer

func RegisterDialer(name string, dialer TabletDialer)

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

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
}

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

func (*ServerError) Error

func (e *ServerError) Error() string

type TabletConn

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

	// ExecuteBatch executes a group of queries.
	ExecuteBatch(context context.Context, queries []tproto.BoundQuery, transactionId int64) (*tproto.QueryResultList, 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(context context.Context, query string, bindVars map[string]interface{}, transactionId int64) (<-chan *mproto.QueryResult, ErrFunc, error)

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

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

	// GetEndPoint returns the end point info.
	EndPoint() topo.EndPoint

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

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

type TabletDialer

type TabletDialer func(context context.Context, endPoint topo.EndPoint, keyspace, shard string, timeout time.Duration) (TabletConn, error)

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

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