fakes

package
v2.0.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2016 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSecondsBehindMaster is the default MySQL replication lag which is
	// reported in all faked stream health responses.
	DefaultSecondsBehindMaster uint32 = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorQueryService

type ErrorQueryService struct {
}

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

It is used as base for other, more specialised QueryService fakes e.g. StreamHealthQueryService.

func (*ErrorQueryService) Begin

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

Begin is part of QueryService interface

func (*ErrorQueryService) Commit

func (e *ErrorQueryService) Commit(ctx context.Context, target *querypb.Target, 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{}, 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, asTransaction bool, transactionID int64) ([]sqltypes.Result, error)

ExecuteBatch 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, 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) ([]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,
) ([]querytypes.QuerySplit, error)

SplitQueryV2 is part of QueryService interface

func (*ErrorQueryService) StreamExecute

func (e *ErrorQueryService) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, 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 StreamHealthQueryService

type StreamHealthQueryService struct {
	ErrorQueryService
	// contains filtered or unexported fields
}

StreamHealthQueryService is a QueryService implementation which allows to send custom StreamHealthResponse messages by adding them to a channel. Note that it only works with one connected client because messages going into "healthResponses" are not duplicated to all clients.

If you want to override other QueryService methods, embed this struct as anonymous field in your own QueryService fake.

func NewStreamHealthQueryService

func NewStreamHealthQueryService(target querypb.Target) *StreamHealthQueryService

NewStreamHealthQueryService creates a new fake query service for the target.

func (*StreamHealthQueryService) AddDefaultHealthResponse

func (q *StreamHealthQueryService) AddDefaultHealthResponse()

AddDefaultHealthResponse adds a faked health response to the buffer channel. The response will have default values typical for a healthy tablet.

func (*StreamHealthQueryService) AddHealthResponseWithQPS

func (q *StreamHealthQueryService) AddHealthResponseWithQPS(qps float64)

AddHealthResponseWithQPS adds a faked health response to the buffer channel. Only "qps" is different in this message.

func (*StreamHealthQueryService) StreamHealthRegister

func (q *StreamHealthQueryService) StreamHealthRegister(c chan<- *querypb.StreamHealthResponse) (int, error)

StreamHealthRegister implements the QueryService interface. It sends all queued and future healthResponses to the connected client e.g. the healthcheck module.

func (*StreamHealthQueryService) UpdateType

func (q *StreamHealthQueryService) UpdateType(tabletType topodatapb.TabletType)

UpdateType changes the type of the query service. Only newly sent health messages will use the new type.

Jump to

Keyboard shortcuts

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