Core.JobStore.SQLite (ServCore v0.3.0)

Copy Markdown View Source

SQLite-backed job store with WAL mode enabled.

Jobs are persisted synchronously. On VM restart, :queued and :running jobs are reloaded. :running jobs are reset to :queued so workers can reclaim them.

This is a stateful adapter: init/1 returns the database path as opaque state, and every subsequent callback receives that state as its first argument. This allows multiple JobQueue processes to each use their own SQLite file without sharing global configuration.

Configuration

{Core.Workers.JobQueue,
  store: Core.JobStore.SQLite,
  store_opts: [database: "priv/jobs.db"]}

Requires {:exqlite, "~> 0.29"} in your mix.exs deps.

Options

  • :database – path to the SQLite file (default: "jobs.db")

Connection model

Each operation opens and closes its own connection. This is simple but limits throughput (roughly ~1,000 ops/sec on a typical SSD). Because Core.Workers.JobQueue is a single GenServer, calls are serialized, so the risk of a last_insert_rowid() race between concurrent inserts is low. For higher throughput implement a connection-pool adapter.