Documentation ¶
Index ¶
- Variables
- func DebugVars() map[string]interface{}
- func FetchInt(vars map[string]interface{}, tags string) int
- func FetchVal(vars map[string]interface{}, tags string) interface{}
- func NewServer(config tabletserver.Config, connParams sqldb.ConnParams, enableRowcache bool) (*tabletserver.TabletServer, error)
- func QueryStats() map[string]QueryStat
- func StartDefaultServer(connParams sqldb.ConnParams) error
- func StopDefaultServer()
- type QueryCatcher
- type QueryClient
- func (client *QueryClient) Begin() error
- func (client *QueryClient) Commit() error
- func (client *QueryClient) Execute(query string, bindvars map[string]interface{}) (*mproto.QueryResult, error)
- func (client *QueryClient) ExecuteBatch(queries []proto.BoundQuery, asTransaction bool) (*proto.QueryResultList, error)
- func (client *QueryClient) Rollback() error
- func (client *QueryClient) StreamExecute(query string, bindvars map[string]interface{}, ...) error
- type QueryStat
- type TxCatcher
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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) 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) 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 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) 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.