jobs

package
v0.0.0-...-d364ca2 Latest Latest
Warning

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

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

Documentation

Overview

Package jobs wraps River with Soro transactions, options, and telemetry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Perform

func Perform[T river.JobArgs](ctx context.Context, args T, handler Handler[T]) error

Perform executes a typed handler synchronously without inserting a River job. It is intended for focused handler tests; queue semantics remain the job client's responsibility.

func Register

func Register[T river.JobArgs](client *Client, handler Handler[T]) error

Types

type Client

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

func New

func New(db *database.DB, observer *observability.Provider, logger *slog.Logger, config Config) (*Client, error)

func (*Client) Enabled

func (client *Client) Enabled() bool

func (*Client) Enqueue

func (client *Client) Enqueue(ctx context.Context, args river.JobArgs, options ...Option) (*Result, error)

func (*Client) EnqueueTx

func (client *Client) EnqueueTx(ctx context.Context, args river.JobArgs, options ...Option) (*Result, error)

func (*Client) Migrate

func (client *Client) Migrate(ctx context.Context) error

func (*Client) Start

func (client *Client) Start(ctx context.Context) error

func (*Client) Stop

func (client *Client) Stop(ctx context.Context) error

type Config

type Config struct {
	WorkersEnabled  bool
	DefaultQueue    string
	Queues          map[string]int
	Schema          string
	ShutdownTimeout time.Duration
}

func (Config) Validate

func (config Config) Validate() error

type Handler

type Handler[T river.JobArgs] func(context.Context, T) error

type Option

type Option func(*insertSettings) error

func Delay

func Delay(duration time.Duration) Option

func MaxAttempts

func MaxAttempts(attempts int) Option

func Priority

func Priority(priority int) Option

func Queue

func Queue(name string) Option

func Unique

func Unique(config UniqueConfig) Option

func UniqueByArgs

func UniqueByArgs() Option

type Result

type Result struct {
	ID        int64
	Duplicate bool
}

type UniqueConfig

type UniqueConfig struct {
	ByArgs   bool
	ByQueue  bool
	ByPeriod time.Duration
}

Jump to

Keyboard shortcuts

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