jobqueue

package
v0.0.0-...-69b46a9 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackoffBase = 5 * time.Second
	BackoffMax  = 5 * time.Minute
	JitterRatio = 0.25
)

Variables

This section is empty.

Functions

func Encode

func Encode(msg Message) ([]byte, error)

Encode serializes a job message.

func RetryDelay

func RetryDelay(attempt int) time.Duration

RetryDelay returns exponential backoff with jitter for the given attempt index.

Types

type Message

type Message struct {
	ID         string                 `json:"id"`
	Type       string                 `json:"type"`
	Payload    map[string]interface{} `json:"payload"`
	Status     jobs.Status            `json:"status"`
	Attempts   int                    `json:"attempts"`
	MaxRetries int                    `json:"max_retries"`
	RunAt      time.Time              `json:"run_at"`
	CreatedAt  time.Time              `json:"created_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
	LastError  string                 `json:"last_error,omitempty"`
}

Message is the JSON envelope stored in broker-backed job queues.

func Decode

func Decode(data []byte) (Message, error)

Decode deserializes a job message.

func FromJob

func FromJob(job jobs.Job) Message

FromJob converts a domain job into a broker message.

func (Message) ToJob

func (m Message) ToJob() jobs.Job

ToJob converts a broker message into a domain job.

Jump to

Keyboard shortcuts

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