Documentation
¶
Index ¶
Constants ¶
const StatusExpired = JobStatus("expired")
StatusExpired indicates the job was dequeued after its ExpiresAt date.
const StatusFailed = JobStatus("failed")
StatusFailed indicates the job completed, but an error occurred.
const StatusInProgress = JobStatus("in-progress")
StatusInProgress indicates a QueuedJob has been dequeued, and is being worked on.
const StatusQueued = JobStatus("queued")
StatusQueued indicates a QueuedJob is scheduled to be run at some point in the future.
const StatusSucceeded = JobStatus("succeeded")
StatusSucceeded indicates a job has been completed successfully and then archived.
const StrategyAtLeastOnce = DeliveryStrategy("at_least_once")
StrategyAtLeastOnce should be used for jobs that can be retried in the event of failure.
const StrategyAtMostOnce = DeliveryStrategy("at_most_once")
StrategyAtMostOnce should be used for jobs that should not be retried in the event of failure.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchivedJob ¶
type ArchivedJob struct { ID types.PrefixUUID `json:"id"` Name string `json:"name"` Attempts uint8 `json:"attempts"` Status JobStatus `json:"status"` CreatedAt time.Time `json:"created_at"` Data json.RawMessage `json:"data"` ExpiresAt types.NullTime `json:"expires_at"` }
An ArchivedJob is an in-memory representation of an archived job.
ArchivedJob records are immutable, once they are stored in the database, they are never written, updated, or moved back to the jobs table.
type DeliveryStrategy ¶
type DeliveryStrategy string
DeliveryStrategy describes how a job should be run. If it's safe to run a job more than once (updating a cache), use StrategyAtLeastOnce for your Job. If it's not safe to run a job more than once (sending an email or SMS), use StrategyAtMostOnce.
func (*DeliveryStrategy) Scan ¶
func (d *DeliveryStrategy) Scan(src interface{}) error
Scan implements the Scanner interface.
type Job ¶
type Job struct { Name string `json:"name"` DeliveryStrategy DeliveryStrategy `json:"delivery_strategy"` Attempts uint8 `json:"attempts"` Concurrency uint8 `json:"concurrency"` CreatedAt time.Time `json:"created_at"` }
A Job is an in-memory representation of a record in the jobs table.
Once you create a Job, you can enqueue new jobs using the Job name.
type JobStatus ¶
type JobStatus string
type QueuedJob ¶
type QueuedJob struct { ID types.PrefixUUID `json:"id"` Name string `json:"name"` Attempts uint8 `json:"attempts"` RunAfter time.Time `json:"run_after"` ExpiresAt types.NullTime `json:"expires_at"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Status JobStatus `json:"status"` Data json.RawMessage `json:"data"` }
A QueuedJob is a job to be run at a point in the future.
QueuedJobs can have the status "queued" (to be run at some point), or "in-progress" (a dequeuer is acting on them).
Directories
¶
Path | Synopsis |
---|---|
Logic for interacting with the "archived_jobs" table.
|
Logic for interacting with the "archived_jobs" table. |
Package db contains logic for connecting to the database.
|
Package db contains logic for connecting to the database. |
Logic for interacting with the "jobs" table.
|
Logic for interacting with the "jobs" table. |
Logic for interacting with the "queued_jobs" table.
|
Logic for interacting with the "queued_jobs" table. |