Skip to main content

Crate wabot_addon_async_sqlite

Crate wabot_addon_async_sqlite 

Source
Expand description

SQLite JobRepository + CronJobRepository.

The durable counterpart to wabot-addon-async-in-memory for a single node. Both are SqliteJsonbStore wrappers: the entity lives in a data JSON column and the queries read it with data->>'$."field"', so the SQL reads side by side with the Postgres addon’s.

ⓘ
let db = SqliteDatabase::open(SqliteConfig::at("/var/lib/app/app.db"))?;
register_job_repository(&c, Arc::new(SqliteJobRepository::new(db.clone())));
register_cron_job_repository(&c, Arc::new(SqliteCronJobRepository::new(db)));
register_async_runtime(&c);   // InProcessLocker is the right one on one node

§Why this exists when there is an in-memory one

Because jobs that vanish on restart are only acceptable for tests. A deployment job — build this image, start this container, renew this certificate — that disappears because the process was upgraded leaves the system half-changed with nothing recording that it was. In-memory is right for a unit test and wrong for anything that survives a reboot.

§Field names are camelCase

scheduledAt, not scheduled_at. That is the wabot-ts wire format, and the document is the same shape in both stacks — a rule worth keeping even where, as here, no TypeScript will ever read these rows: it is what lets one entity definition serve both.

Structs§

SqliteCronJobRepository
SqliteJobRepository

Constants§

CRON_JOBS_TABLE
JOBS_TABLE
Default table names. Match the Postgres addon’s, so an application that moves between backends addresses the same tables.