internal

package
v0.0.0-...-8ff35f7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStaleReminder = errors.New("the reminder is stale already")

ErrStaleReminder is returned by ProcessReminderPostTxn.

Functions

func ProcessReminderPostTxn

func ProcessReminderPostTxn(ctx context.Context, s Submitter, db db.DB, r *reminder.Reminder) error

ProcessReminderPostTxn is called right after the transaction that saves the reminder.

If the reminder is fresh enough, it means the sweeper hasn't picked it up yet and we can submit the task right now. This is the "happy" path. If the reminder is sufficiently old, or if SubmitFromReminder fails, we'll let the sweeper try to submit the task. It is the "sweep" path.

Returns ErrStaleReminder if the reminder is stale and should be handled by the sweeper.

func Submit

func Submit(ctx context.Context, s Submitter, payload *reminder.Payload, path TxnPath) error

Submit submits the prepared request through the given submitter.

Recognizes AlreadyExists as success. Annotates retriable errors with transient.Tag.

func SubmitBatch

func SubmitBatch(ctx context.Context, sub Submitter, db db.DB, batch []*reminder.Reminder) (int, error)

SubmitBatch process a batch of reminders by submitting corresponding tasks and deleting reminders.

Reminders batch will be modified to fetch Reminders' payloads. RAM usage is equivalent to O(total payload size of each Reminder in batch).

Logs errors inside. Returns the total number of successfully processed reminders.

func SubmitFromReminder

func SubmitFromReminder(ctx context.Context, s Submitter, db db.DB, r *reminder.Reminder, t TxnPath) error

SubmitFromReminder submits the request and deletes the reminder on success or a fatal error.

Mutates `r` by deserializing the payload, if necessary.

Types

type Submitter

type Submitter interface {
	// Submit submits a task, returning a gRPC status.
	Submit(ctx context.Context, payload *reminder.Payload) error
}

Submitter is used by the dispatcher and the sweeper to submit tasks.

type TxnPath

type TxnPath string

TxnPath indicates a code path a task can take.

const (
	TxnPathNone  TxnPath = "none"  // not a transactional task
	TxnPathHappy TxnPath = "happy" // the reminder was processed right after txn landed
	TxnPathSweep TxnPath = "sweep" // the reminder was processed during a sweep
)

Directories

Path Synopsis
Package db defines common database interface.
Package db defines common database interface.
Package lessor defines common lessor interface.
Package lessor defines common lessor interface.
Package loopbacktest is an integration test for TQ loopback dispatcher.
Package loopbacktest is an integration test for TQ loopback dispatcher.
Package metrics contains definition of metrics exposed by server/tq.
Package metrics contains definition of metrics exposed by server/tq.
Package partition encapsulates partitioning and querying large keyspace which can't be expressed even as uint64.
Package partition encapsulates partitioning and querying large keyspace which can't be expressed even as uint64.
Package reminder holds Reminder to avoid circular dependencies.
Package reminder holds Reminder to avoid circular dependencies.
Package testutil provides fakes for testing TQ guts.
Package testutil provides fakes for testing TQ guts.
Package workset contains a synchronized work queue implementation used by inproc sweeper.
Package workset contains a synchronized work queue implementation used by inproc sweeper.

Jump to

Keyboard shortcuts

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