fakes

package
v2.1.0-alpha.1+incompa... Latest Latest
Warning

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

Go to latest
Published: Nov 8, 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) BeginExecute

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

BeginExecute is part of QueryService interface

func (*ErrorQueryService) BeginExecuteBatch

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

BeginExecuteBatch 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) CommitPrepared

func (e *ErrorQueryService) CommitPrepared(ctx context.Context, target *querypb.Target, dtid string) (err error)

CommitPrepared is part of QueryService interface

func (*ErrorQueryService) CreateTransaction

func (e *ErrorQueryService) CreateTransaction(ctx context.Context, target *querypb.Target, dtid string, participants []*querypb.Target) (err error)

CreateTransaction 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, options *querypb.ExecuteOptions) (*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, options *querypb.ExecuteOptions) ([]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) Prepare

func (e *ErrorQueryService) Prepare(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)

Prepare is part of QueryService interface

func (*ErrorQueryService) ReadTransaction

func (e *ErrorQueryService) ReadTransaction(ctx context.Context, target *querypb.Target, dtid string) (metadata *querypb.TransactionMetadata, err error)

ReadTransaction is part of QueryService interface

func (*ErrorQueryService) ResolveTransaction

func (e *ErrorQueryService) ResolveTransaction(ctx context.Context, target *querypb.Target, dtid string) (err error)

ResolveTransaction 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) RollbackPrepared

func (e *ErrorQueryService) RollbackPrepared(ctx context.Context, target *querypb.Target, dtid string, originalID int64) (err error)

RollbackPrepared is part of QueryService interface

func (*ErrorQueryService) SetRollback

func (e *ErrorQueryService) SetRollback(ctx context.Context, target *querypb.Target, dtid string, transactionID int64) (err error)

SetRollback is part of QueryService interface

func (*ErrorQueryService) SplitQuery

func (e *ErrorQueryService) SplitQuery(
	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)

SplitQuery is part of QueryService interface

func (*ErrorQueryService) StartCommit

func (e *ErrorQueryService) StartCommit(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)

StartCommit is part of QueryService interface

func (*ErrorQueryService) StreamExecute

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

func (*ErrorQueryService) UpdateStream

func (e *ErrorQueryService) UpdateStream(ctx context.Context, target *querypb.Target, position string, timestamp int64, sendReply func(*querypb.StreamEvent) error) error

UpdateStream 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) AddHealthResponseWithNotServing

func (q *StreamHealthQueryService) AddHealthResponseWithNotServing()

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

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) AddHealthResponseWithSecondsBehindMaster

func (q *StreamHealthQueryService) AddHealthResponseWithSecondsBehindMaster(replicationLag uint32)

AddHealthResponseWithSecondsBehindMaster adds a faked health response to the buffer channel. Only "seconds_behind_master" 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