models

package
v0.0.0-...-453881e Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2018 License: MIT Imports: 5 Imported by: 8

Documentation

Index

Constants

View Source
const StatusExpired = JobStatus("expired")

StatusExpired indicates the job was dequeued after its ExpiresAt date.

View Source
const StatusFailed = JobStatus("failed")

StatusFailed indicates the job completed, but an error occurred.

View Source
const StatusInProgress = JobStatus("in-progress")

StatusInProgress indicates a QueuedJob has been dequeued, and is being worked on.

View Source
const StatusQueued = JobStatus("queued")

StatusQueued indicates a QueuedJob is scheduled to be run at some point in the future.

View Source
const StatusSucceeded = JobStatus("succeeded")

StatusSucceeded indicates a job has been completed successfully and then archived.

View Source
const StrategyAtLeastOnce = DeliveryStrategy("at_least_once")

StrategyAtLeastOnce should be used for jobs that can be retried in the event of failure.

View Source
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.

func (DeliveryStrategy) Value

func (d DeliveryStrategy) Value() (driver.Value, error)

Value implements the driver.Valuer 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

func (*JobStatus) Scan

func (j *JobStatus) Scan(src interface{}) error

Scan implements the Scanner interface.

func (JobStatus) Value

func (j JobStatus) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

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.

Jump to

Keyboard shortcuts

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