class SQLite
SQLite-backed task store with async pub/sub and webhook delivery.
This is the enlightened replacement for the in-memory TaskStore. Follows the gospel:
- async-job's schema patterns (indexed by state, updated_at DESC)
- async-job's duck-typed delegate protocol (#call, #start, #stop)
- Async::Queue-based pub/sub (fiber-safe, no threads)
- Async::HTTP::Internet for webhook delivery (no Net::HTTP)
The store composes three concerns:
- SQLite — persistent CRUD for tasks, push configs
- PubSub — in-process streaming subscriptions
- Webhooks — push notification delivery
SQLite is safe for fiber-based concurrency within a single process because Ruby fibers are cooperatively scheduled — only one fiber runs at a time, so no concurrent writes can collide.
Definitions
def initialize(path: ":memory:")
Implementation
def initialize(path: ":memory:")
@db = ::SQLite3::Database.new(path)
@db.results_as_hash = true
@db.execute("PRAGMA journal_mode = WAL")
@db.execute("PRAGMA synchronous = NORMAL")
@db.execute("PRAGMA foreign_keys = ON")
@pub_sub = PubSub.new
@webhooks = Webhooks.new
create_tables
end