jobs

package
v0.4.1 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: 10 Imported by: 0

Documentation

Overview

Package jobs runs durable SQLite jobs with bounded leases and retry backoff.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backoff

func Backoff(attempt int) time.Duration

Backoff returns exponential retry delay with bounded jitter.

func Permanent

func Permanent(err error) error

Permanent marks an error as non-retryable.

Types

type Handler

type Handler func(context.Context, model.Job) error

Handler processes one claimed job and must be idempotent.

type PermanentError

type PermanentError struct{ Err error }

PermanentError prevents a retry for invalid or unrecoverable work.

func (*PermanentError) Error

func (e *PermanentError) Error() string

func (*PermanentError) Unwrap

func (e *PermanentError) Unwrap() error

type Runner

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

Runner owns a fixed-size worker pool.

func New

func New(repo *repository.Repository, handlers map[string]Handler, workers int, poll, lease time.Duration, logger *slog.Logger) *Runner

New creates a durable worker runner.

func (*Runner) Start

func (r *Runner) Start(ctx context.Context)

Start runs workers until context cancellation and returns immediately.

func (*Runner) Wait

func (r *Runner) Wait()

Wait waits for all worker goroutines after cancellation.

Jump to

Keyboard shortcuts

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