Documentation
¶
Overview ¶
Package store defines the aggregate persistence interface.
Each subsystem (job, workflow, cron, dlq, event, cluster) defines its own store interface. The composite Store composes them all. A single backend need only implement Store to satisfy every subsystem's persistence contract.
The composite interface:
type Store interface {
job.Store
workflow.Store
cron.Store
dlq.Store
event.Store
cluster.Store
Migrate(ctx context.Context) error
Ping(ctx context.Context) error
Close() error
}
Available Backends ¶
- store/memory — in-memory store for development and testing
- store/postgres — PostgreSQL backend using pgx/v5
- store/bun — Bun ORM backend
- store/sqlite — SQLite backend
- store/redis — Redis backend
Usage ¶
import "github.com/xraph/dispatch/store/postgres"
s, err := postgres.New(ctx, "postgres://user:pass@localhost/dispatch")
if err != nil {
log.Fatal(err)
}
defer s.Close()
d, err := dispatch.New(dispatch.WithStore(s))
Migrations ¶
Call Migrate once at startup to create or update the schema:
if err := s.Migrate(ctx); err != nil {
log.Fatal(err)
}
Package store defines the aggregate persistence interface. Each subsystem (job, workflow, cron, dlq, event, cluster) defines its own store interface. The composite Store composes them all. Backends: Postgres, Bun, SQLite, Redis, and Memory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store interface {
job.Store
job.Lister
workflow.Store
workflow.PageLister
cron.Store
dlq.Store
dlq.PageLister
event.Store
cluster.Store
artifact.Store
artifact.PageLister
// Migrate runs all schema migrations.
Migrate(ctx context.Context) error
// Ping checks database connectivity.
Ping(ctx context.Context) error
// Close closes the store connection.
Close() error
}
Store is the aggregate persistence interface. Each subsystem store is a composable interface — same pattern as ControlPlane. A single backend (postgres, bun, sqlite, etc.) implements all of them.
type WakeNotifier ¶
type WakeNotifier interface {
// StartWakeListener subscribes to the backend's wake signal and calls
// wake for every notification until stop is invoked. Implementations
// must survive connection loss by re-subscribing internally.
StartWakeListener(ctx context.Context, wake func()) (stop func(), err error)
}
WakeNotifier is an optional store capability: backends that can push new-work signals (e.g. Postgres LISTEN/NOTIFY) implement it so worker pools on other instances wake immediately instead of waiting out their idle poll backoff. Polling remains the correctness mechanism — a missed wake only costs poll latency.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package memory implements an in-memory store for unit testing.
|
Package memory implements an in-memory store for unit testing. |
|
Package mongo implements store.Store using the grove ORM with MongoDB driver.
|
Package mongo implements store.Store using the grove ORM with MongoDB driver. |
|
Package postgres implements store.Store using the grove ORM with PostgreSQL dialect.
|
Package postgres implements store.Store using the grove ORM with PostgreSQL dialect. |
|
Package redis implements store.Store using Grove KV backed by Redis.
|
Package redis implements store.Store using Grove KV backed by Redis. |
|
Package sqlite implements store.Store using the Grove ORM with SQLite.
|
Package sqlite implements store.Store using the Grove ORM with SQLite. |
|
Package storetest provides conformance suites that every Dispatch store backend must pass.
|
Package storetest provides conformance suites that every Dispatch store backend must pass. |