queryservice

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

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

Go to latest
Published: Apr 15, 2016 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package queryservice contains the interface for the service definition of the Query Service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallCorrectSplitQuery

func CallCorrectSplitQuery(
	queryService QueryService,
	useSplitQueryV2 bool,
	ctx context.Context,
	target *querypb.Target,
	sql string,
	bindVariables map[string]interface{},
	splitColumns []string,
	splitCount int64,
	numRowsPerQueryPart int64,
	algorithm querypb.SplitQueryRequest_Algorithm,
	sessionID int64) ([]querytypes.QuerySplit, error)

CallCorrectSplitQuery calls the correct SplitQuery. This trivial logic is encapsulated in a function here so it can be easily tested. TODO(erez): Remove once the migration to SplitQueryV2 is done.

Types

type ErrorQueryService

type ErrorQueryService struct {
	GetSessionIdError error
}

ErrorQueryService is an implementation of QueryService that returns a configurable error for some of its methods.

func (*ErrorQueryService) Begin

func (e *ErrorQueryService) Begin(ctx context.Context, target *querypb.Target, sessionID int64) (int64, error)

Begin is part of QueryService interface

func (*ErrorQueryService) Commit

func (e *ErrorQueryService) Commit(ctx context.Context, target *querypb.Target, sessionID, transactionID int64) error

Commit is part of QueryService interface

func (*ErrorQueryService) Execute

func (e *ErrorQueryService) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, sessionID, transactionID int64) (*sqltypes.Result, error)

Execute is part of QueryService interface

func (*ErrorQueryService) ExecuteBatch

func (e *ErrorQueryService) ExecuteBatch(ctx context.Context, target *querypb.Target, queries []querytypes.BoundQuery, sessionID int64, asTransaction bool, transactionID int64) ([]sqltypes.Result, error)

ExecuteBatch is part of QueryService interface

func (*ErrorQueryService) GetSessionId

func (e *ErrorQueryService) GetSessionId(keyspace, shard string) (int64, error)

GetSessionId is part of QueryService interface

func (*ErrorQueryService) HandlePanic

func (e *ErrorQueryService) HandlePanic(*error)

HandlePanic is part of QueryService interface

func (*ErrorQueryService) Rollback

func (e *ErrorQueryService) Rollback(ctx context.Context, target *querypb.Target, sessionID, transactionID int64) error

Rollback is part of QueryService interface

func (*ErrorQueryService) SplitQuery

func (e *ErrorQueryService) SplitQuery(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, splitColumn string, splitCount int64, sessionID int64) ([]querytypes.QuerySplit, error)

SplitQuery is part of QueryService interface TODO(erez): Remove once the migration to SplitQuery V2 is done.

func (*ErrorQueryService) SplitQueryV2

func (e *ErrorQueryService) SplitQueryV2(
	ctx context.Context,
	target *querypb.Target,
	sql string,
	bindVariables map[string]interface{},
	splitColumns []string,
	splitCount int64,
	numRowsPerQueryPart int64,
	algorithm querypb.SplitQueryRequest_Algorithm,
	sessionID int64) ([]querytypes.QuerySplit, error)

SplitQuery is part of QueryService interface

func (*ErrorQueryService) StreamExecute

func (e *ErrorQueryService) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, sessionID int64, sendReply func(*sqltypes.Result) error) error

StreamExecute is part of QueryService interface

func (*ErrorQueryService) StreamHealthRegister

func (e *ErrorQueryService) StreamHealthRegister(chan<- *querypb.StreamHealthResponse) (int, error)

StreamHealthRegister is part of QueryService interface

func (*ErrorQueryService) StreamHealthUnregister

func (e *ErrorQueryService) StreamHealthUnregister(int) error

StreamHealthUnregister is part of QueryService interface

type QueryService

type QueryService interface {
	// GetSessionId establishes a session to guarantee the current
	// query service state doesn't change.
	// This is begin deprecated, replaced by the Target structure.
	GetSessionId(keyspace, shard string) (int64, error)

	// Begin returns the transaction id to use for further operations
	Begin(ctx context.Context, target *querypb.Target, sessionID int64) (int64, error)

	// Commit commits the current transaction
	Commit(ctx context.Context, target *querypb.Target, sessionID, transactionID int64) error

	// Rollback aborts the current transaction
	Rollback(ctx context.Context, target *querypb.Target, sessionID, transactionID int64) error

	Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, sessionID, transactionID int64) (*sqltypes.Result, error)
	StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, sessionID int64, sendReply func(*sqltypes.Result) error) error
	ExecuteBatch(ctx context.Context, target *querypb.Target, queries []querytypes.BoundQuery, sessionID int64, asTransaction bool, transactionID int64) ([]sqltypes.Result, error)

	// SplitQuery is a map reduce helper function
	// TODO(erez): Remove this and rename the following func to SplitQuery
	// once we migrate to SplitQuery V2.
	SplitQuery(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, splitColumn string, splitCount int64, sessionID int64) ([]querytypes.QuerySplit, error)

	// SplitQueryV2 is a MapReduce helper function.
	// This is version of SplitQuery supports multiple algorithms and multiple split columns.
	// See the documentation of SplitQueryRequest in 'proto/vtgate.proto' for more information.
	SplitQueryV2(
		ctx context.Context,
		target *querypb.Target,
		sql string,
		bindVariables map[string]interface{},
		splitColumns []string,
		splitCount int64,
		numRowsPerQueryPart int64,
		algorithm querypb.SplitQueryRequest_Algorithm,
		sessionID int64) ([]querytypes.QuerySplit, error)

	// StreamHealthRegister registers a listener for StreamHealth
	StreamHealthRegister(chan<- *querypb.StreamHealthResponse) (int, error)

	// StreamHealthUnregister unregisters a listener for StreamHealth
	StreamHealthUnregister(int) error

	// Helper for RPC panic handling: call this in a defer statement
	// at the beginning of each RPC handling method.
	HandlePanic(*error)
}

QueryService is the interface implemented by the tablet's query service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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