framework

package
v2.0.0-alpha4+incompat... Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BaseConfig is the base config of the default server.
	BaseConfig tabletserver.Config
	// Target is the target info for the default server.
	Target query.Target
	// DefaultServer is the default server.
	DefaultServer *tabletserver.TabletServer
	// ServerAddress is the http URL for the default server.
	ServerAddress string
)

Functions

func DebugVars

func DebugVars() map[string]interface{}

DebugVars parses /debug/vars and returns a map. The function returns an empty map on error.

func FetchInt

func FetchInt(vars map[string]interface{}, tags string) int

FetchInt fetches the specified slash-separated tag and returns the value as an int. It returns 0 on error, or if not found.

func FetchVal

func FetchVal(vars map[string]interface{}, tags string) interface{}

FetchVal fetches the specified slash-separated tag and returns the value as an interface. It returns nil on error, or if not found.

func NewServer

func NewServer(config tabletserver.Config, connParams sqldb.ConnParams, enableRowcache bool) (*tabletserver.TabletServer, error)

NewServer starts a new unregistered TabletServer. You have to end it with StopService once testing is done.

func QueryStats

func QueryStats() map[string]QueryStat

QueryStats parses /debug/query_stats and returns a map of the query stats keyed by the query.

func StartDefaultServer

func StartDefaultServer(connParams sqldb.ConnParams) error

StartDefaultServer starts the default server and initializes all the global variables. This function should only be called once at the beginning of the test.

func StopDefaultServer

func StopDefaultServer()

StopDefaultServer must be called once all the tests are done.

Types

type QueryCatcher

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

QueryCatcher allows you to capture and fetch queries that are being executed by TabletServer.

func NewQueryCatcher

func NewQueryCatcher() QueryCatcher

NewQueryCatcher sets up the capture and retuns a QueryCatcher. You must call Close when done.

func (*QueryCatcher) Close

func (qc *QueryCatcher) Close()

Close closes the QueryCatcher.

func (*QueryCatcher) Next

func (qc *QueryCatcher) Next() (*tabletserver.LogStats, error)

Next fetches the next captured query. If the wait is longer than one second, it returns an error.

type QueryClient

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

QueryClient provides a convenient wrapper for TabletServer's query service. It's not thread safe, but you can create multiple clients that point to the same server.

func NewClient

func NewClient(ctx context.Context, server *tabletserver.TabletServer) *QueryClient

NewClient creates a new client for the specified server.

func NewDefaultClient

func NewDefaultClient() *QueryClient

NewDefaultClient creates a new client for the default server.

func (*QueryClient) Begin

func (client *QueryClient) Begin() error

Begin begins a transaction.

func (*QueryClient) Commit

func (client *QueryClient) Commit() error

Commit commits the current transaction.

func (*QueryClient) Execute

func (client *QueryClient) Execute(query string, bindvars map[string]interface{}) (*mproto.QueryResult, error)

Execute executes a query.

func (*QueryClient) ExecuteBatch

func (client *QueryClient) ExecuteBatch(queries []proto.BoundQuery, asTransaction bool) (*proto.QueryResultList, error)

ExecuteBatch executes a batch of queries.

func (*QueryClient) Rollback

func (client *QueryClient) Rollback() error

Rollback rolls back the current transaction.

func (*QueryClient) StreamExecute

func (client *QueryClient) StreamExecute(query string, bindvars map[string]interface{}, sendReply func(*mproto.QueryResult) error) error

StreamExecute executes a query & streams the results.

type QueryStat

type QueryStat struct {
	Query, Table, Plan                     string
	QueryCount, Time, RowCount, ErrorCount int
}

QueryStat contains the stats for one query.

type TxCatcher

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

TxCatcher allows you to capture and fetch transactions that are being executed by TabletServer.

func NewTxCatcher

func NewTxCatcher() TxCatcher

NewTxCatcher sets up the capture and returns a new TxCatcher. You must call Close when done.

func (*TxCatcher) Close

func (tc *TxCatcher) Close()

Close closes the TxCatcher.

func (*TxCatcher) Next

func (tc *TxCatcher) Next() (*tabletserver.TxConnection, error)

Next fetches the next captured transaction. If the wait is longer than one second, it returns an error.

Jump to

Keyboard shortcuts

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