Documentation
¶
Overview ¶
Package background defines the background.Job and background.Queue interfaces plus an in-memory, non-durable stub Queue for the MVP.
Background job durability is explicitly post-MVP (PRD §44.3). The interface is defined now so Application authors can code against a stable contract.
See TAD §9.1 for the full specification. Implemented in Phase 2.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnqueueOpts ¶
type EnqueueOpts struct {
// RunAt specifies when the job should execute. Zero value means run
// immediately.
RunAt time.Time
// MaxRetries is the maximum number of retry attempts on failure.
MaxRetries int
}
EnqueueOpts controls scheduling and retry behaviour.
type Job ¶
type Job interface {
// Name returns the unique string identifier for this job type.
Name() string
// Handle processes the job payload. Returns an error if processing fails.
Handle(ctx context.Context, payload []byte) error
}
Job is the interface that a background task must implement. See TAD §9.1 and PRD §44.3 (background jobs are post-MVP).
type Queue ¶
type Queue interface {
// Enqueue schedules a job for execution.
Enqueue(ctx context.Context, job string, payload []byte, opts EnqueueOpts) error
// RegisterHandler registers the handler for a named job type.
RegisterHandler(job string, j Job)
}
Queue accepts job registrations and enqueue calls. The MVP implementation is a non-durable in-memory stub — it executes jobs synchronously in a goroutine and does not persist them across restarts. See TAD §9.1.
func NewInMemoryQueue ¶
func NewInMemoryQueue() Queue
NewInMemoryQueue creates a non-durable in-memory Queue stub.