sqlstore

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package sqlstore defines the durable state model and dialect-specific SQL used by the portable SQL job adapter. Backend runtimes own their database clients, while this package keeps queue semantics consistent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaimSelection

func ClaimSelection(dialect Dialect) (string, error)

func ClaimSelectionForQueue

func ClaimSelectionForQueue(dialect Dialect, placeholder string) (string, error)

ClaimSelectionForQueue returns the atomic claim selection restricted to one queue. The backend supplies the placeholder because SQL drivers differ.

func Schema

func Schema(dialect Dialect) ([]string, error)

Types

type Dialect

type Dialect string
const (
	SQLite     Dialect = "sqlite"
	PostgreSQL Dialect = "postgresql"
	MySQL      Dialect = "mysql"
)

type Record

type Record struct {
	ID              string
	Queue           string
	JobName         string
	Payload         string
	PayloadVersion  int
	Priority        int
	RunAt           time.Time
	State           State
	Attempts        int
	MaximumAttempts int
	ClaimedBy       string
	ClaimedAt       *time.Time
	LastError       string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

func NewRecord

func NewRecord(id, jobName, payload string, maximumAttempts int, now time.Time) Record

func (*Record) Acknowledge

func (record *Record) Acknowledge(workerID string) error

func (*Record) Claim

func (record *Record) Claim(workerID string, now time.Time) error

func (*Record) Fail

func (record *Record) Fail(workerID, message string, retryAt, now time.Time) (bool, error)

Fail records an execution failure. It returns true when the job remains retryable and false when it has reached its failed terminal state.

func (*Record) Release

func (record *Record) Release(now time.Time) bool

func (Record) Stale

func (record Record) Stale(cutoff time.Time) bool

type State

type State string
const (
	Ready   State = "ready"
	Running State = "running"
	Failed  State = "failed"
)

Jump to

Keyboard shortcuts

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