messager

package
v0.18.6 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MessageStats tracks stats for messages.
	MessageStats = stats.NewGaugesWithMultiLabels(
		"Messages",
		"Stats for messages",
		[]string{"TableName", "Metric"})
)

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the engine for handling messages.

func NewEngine

func NewEngine(tsv TabletService, se *schema.Engine, vs VStreamer) *Engine

NewEngine creates a new Engine.

func (*Engine) Close

func (me *Engine) Close()

Close closes the Engine service.

func (*Engine) GetGenerator added in v0.12.1

func (me *Engine) GetGenerator(name string) (QueryGenerator, error)

func (*Engine) Open

func (me *Engine) Open()

Open starts the Engine service.

func (*Engine) Subscribe

func (me *Engine) Subscribe(ctx context.Context, name string, send func(*sqltypes.Result) error) (done <-chan struct{}, err error)

Subscribe subscribes to messages from the requested table. The function returns a done channel that will be closed when the subscription ends, which can be initiated by the send function returning io.EOF. The engine can also end a subscription which is usually triggered by Close. It's the responsibility of the send function to promptly return if the done channel is closed. Otherwise, the engine's Close function will hang indefinitely.

type MessageRow

type MessageRow struct {
	Priority  int64
	TimeNext  int64
	Epoch     int64
	TimeAcked int64
	Row       []sqltypes.Value
	// contains filtered or unexported fields
}

MessageRow represents a message row. The first column in Row is always the "id".

func BuildMessageRow

func BuildMessageRow(row []sqltypes.Value) (*MessageRow, error)

BuildMessageRow builds a MessageRow from a db row.

type QueryGenerator added in v0.12.1

type QueryGenerator interface {
	GenerateAckQuery(ids []string) (string, map[string]*querypb.BindVariable)
	GeneratePostponeQuery(ids []string) (string, map[string]*querypb.BindVariable)
	GeneratePurgeQuery(timeCutoff int64) (string, map[string]*querypb.BindVariable)
}

type TabletService

type TabletService interface {
	tabletenv.Env
	PostponeMessages(ctx context.Context, target *querypb.Target, querygen QueryGenerator, ids []string) (count int64, err error)
	PurgeMessages(ctx context.Context, target *querypb.Target, querygen QueryGenerator, timeCutoff int64) (count int64, err error)
}

TabletService defines the functions of TabletServer that the messager needs for callback.

type VStreamer

type VStreamer interface {
	Stream(ctx context.Context, startPos string, tablePKs []*binlogdatapb.TableLastPK, filter *binlogdatapb.Filter, throttlerApp throttlerapp.Name, send func([]*binlogdatapb.VEvent) error) error
	StreamResults(ctx context.Context, query string, send func(*binlogdatapb.VStreamResultsResponse) error) error
}

VStreamer defines the functions of VStreamer that the messager needs.

Jump to

Keyboard shortcuts

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