fakes

package
v3.0.0-rc.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2018 License: Apache-2.0 Imports: 7 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

View Source
var ErrorQueryService = queryservice.Wrap(
	nil,
	func(ctx context.Context, target *querypb.Target, conn queryservice.QueryService, name string, inTransaction bool, inner func(context.Context, *querypb.Target, queryservice.QueryService) (error, bool)) error {
		return fmt.Errorf("ErrorQueryService does not implement any method")
	},
)

ErrorQueryService is an object that returns an error for all methods.

Functions

This section is empty.

Types

type StreamHealthQueryService

type StreamHealthQueryService struct {
	queryservice.QueryService
	// 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) Begin

Begin implemented as a no op

func (*StreamHealthQueryService) Execute

func (q *StreamHealthQueryService) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) (*sqltypes.Result, error)

Execute implemented as a no op

func (*StreamHealthQueryService) StreamHealth

func (q *StreamHealthQueryService) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error

StreamHealth 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