Behaviour for persisting job state across VM restarts.
Forks can implement this behaviour to swap the storage backend
(e.g. PostgreSQL, Redis, S3, etc.). The default Core.JobStore.Memory
provides zero-durability in-memory IDs for prototyping.
All callbacks are invoked synchronously by Core.Workers.JobQueue.
Each callback receives the opaque state returned by init/1 as its
first argument, allowing multiple queues to use independent storage
backends (e.g. separate SQLite files).
Summary
Callbacks
Remove old completed / failed jobs. opts contains :max_age_days.
Fetch a single job by id.
Initialise the store (create tables, indexes, etc.). Returns opaque state.
Persist a new job. Must return the job with an assigned :id.
List jobs, optionally filtered by status.
Partially update a job by id. changes is a keyword list of fields.
Types
Callbacks
Remove old completed / failed jobs. opts contains :max_age_days.
@callback get_job(state(), pos_integer()) :: {:ok, Core.Workers.Job.t()} | {:error, :not_found}
Fetch a single job by id.
Initialise the store (create tables, indexes, etc.). Returns opaque state.
@callback insert_job(state(), Core.Workers.Job.t()) :: {:ok, Core.Workers.Job.t()} | {:error, term()}
Persist a new job. Must return the job with an assigned :id.
@callback list_jobs(state(), Keyword.t()) :: [Core.Workers.Job.t()]
List jobs, optionally filtered by status.
@callback update_job(state(), pos_integer(), changes :: Keyword.t()) :: :ok | {:error, term()}
Partially update a job by id. changes is a keyword list of fields.