fakes

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultReplicationLagSeconds is the default MySQL replication lag which is
	// reported in all faked stream health responses.
	DefaultReplicationLagSeconds 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) (bool, error)) 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) AddHealthResponseWithReplicationLag added in v0.12.0

func (q *StreamHealthQueryService) AddHealthResponseWithReplicationLag(replicationLag uint32)

AddHealthResponseWithReplicationLag adds a faked health response to the buffer channel. Only "replication_lag_seconds" 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, reservedID 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