Expand description
headgate-testkit — the in-process test double: a complete in-memory Store so
handler code, retry behavior, steps, and runner wiring can be tested with no
database at all (River’s rivertest, asynq’s asynqtest). The Go twin is
go/headgatetest; both keep the same split:
FAITHFUL: the transition table (every ack outcome, fence-gated identity,
LeaseRejected for a superseded holder), attempts vs crash_attempts, quarantine at
the crash limit, job uniqueness uniqueness in both modes, retention policy ephemeral retention-0 delete,
retention and eviction contract retention eviction (quarantined exempt), per-partition round-robin admission,
priority ordering, duty leases.
SIMPLIFIED, capability-honestly (runtime capability boundary): caps() is 0 — no Transactional (so
once/step_once error, as they must without a real transaction), no Inspect
(scheduler/operations/quarantine duties idle), no Notifying (workers poll). Like
the SQL backends it admits state = available only — pair admit with
promote_due (the worker and testing::drain already do). An unconfigured rate
class is UNLIMITED here; configure one with MemStore::set_rate_limit. Time is
the store’s own clock and tests can freeze or step it — no sleeps.
Structs§
- Enqueued
- A description of an enqueue.
kindis required; every other field is an optional matcher, andNonemeans “do not care”. - MemStore
- Mysql
Test Database - One migrated MySQL database.
optscan be cloned into amysql_async::Poolwithout re-parsing or exposing credentials. - Postgres
Test Database - One migrated Postgres schema. Use
configto construct a pool/store; it carries the schema in the startupsearch_path, so every pooled connection sees the same isolated namespace. - Redis
Test Namespace - A process-unique Redis key prefix. Redis’s schema boundary is already an explicit
prefix in both drivers, so tests do not need a scarce numbered logical database and
never call
FLUSHALL/FLUSHDB. - Test
Database Error
Traits§
- Enqueued
Jobs - Whatever a test double can list back. Implemented for
MemStore; a live backend implements it overInspect::list_jobsin the test that needs it.
Functions§
- assert_
enqueue_ backpressure - Shared live-backend proof for bounded enqueue. It deliberately drives contention: 64 producers race for 25 slots, then the helper verifies idempotent replay, atomic batch rejection, capacity release on terminalization, lowering below current depth, and disabling the policy. Every assertion uses the public Store/Inspect ports.
- assert_
enqueued find_enqueued, panicking with that message. The assertion form.- assert_
sticky_ routing - Shared live-backend proof for strict sticky routing. A 5,000-job high-priority backlog pinned to another worker must not fill the bounded candidate draw and hide the caller’s pinned or ordinary work. Rate-limited requeue then proves the route is durable lifecycle state rather than lease metadata.
- find_
enqueued - Find the enqueued jobs matching
want, or an error saying what was there instead.