worker

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

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWorkerClient

func NewWorkerClient(pool *pgxpool.Pool, retention Retention) *workerClient

Types

type IEnqueuer

type IEnqueuer interface {
	Enqueue(ctx context.Context, args jobArgs) error
	// EnqueueAt queues the job to run no earlier than at (a time not in the future runs it now).
	EnqueueAt(ctx context.Context, args jobArgs, at time.Time) error
	// EnqueueUniqueAt is EnqueueAt that skips the job while an equal one (by the fields tagged `river:"unique"`,
	// else all args) is still queued or running. River requires running among the unique states, so a job that
	// queues its own successor must differ from itself in a unique field (e.g. an attempt counter).
	EnqueueUniqueAt(ctx context.Context, args jobArgs, at time.Time) error
}

IEnqueuer is the interface for enqueuing jobs into the River queue. It is used by the use-case layer to enqueue jobs without depending on the River implementation.

func NewEnqueuer

func NewEnqueuer() IEnqueuer

NewEnqueuer returns a no-op IEnqueuer suitable for unit tests where the enqueue code path is never exercised (ProcessNotification never enqueues).

type IEnqueuerFactory

type IEnqueuerFactory interface {
	NewEnqueuer() IEnqueuer
}

type Retention

type Retention struct {
	// Completed is how long a job that succeeded stays.
	Completed time.Duration
	// Failed is how long a cancelled or discarded job stays.
	Failed time.Duration
}

Retention is how long River keeps finished jobs. The arguments of a job carry what the job needs (an address, a name, a link), so a finished job is not kept longer than its failure can be looked at; zero keeps River's own default.

type TransactionalEnqueuer

type TransactionalEnqueuer interface {
	EnqueueTx(context.Context, pgx.Tx, river.JobArgs) error
}

TransactionalEnqueuer joins persisted delivery payloads and their River job in one commit.

Jump to

Keyboard shortcuts

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