feat: add the in-process fjall broker #5

Merged
aleksei merged 8 commits from feat/sqlite-broker-adapter into main 2026-10-20 21:42:58 +00:00
Owner

Adds eve_broker_inproc with InProcBrokerUnit and InProcBrokerProvisorUnit.

The transport is an in-process bus (tokio channels): request/response, ephemeral messages and queue groups. Persistence uses a fjall database with three keyspaces:

  • streams — persistent entity markers
  • events — append-only log keyed by [stream][seq]
  • consumers — durable offsets

Other details:

  • events are postcard records; the global sequence and dedup set live in memory and are rebuilt from events on bootstrap
  • one group-commit writer, up to 1000 appends per fjall batch, PersistMode::SyncData
  • a watch epoch wakes consumers even when a publish lands between reads
  • serve/wipe maintain the stream, event and consumer keyspaces
  • SQLite stays only as the projection database (eve_db_sqlite)

Benchmark (entity delete by filter, same machine, prior NATS+Mongo run):

Size in-process fjall + SQLite db NATS + MongoDB
1 ~0.7 ms ~1.4 ms
10,000 ~0.11 s ~0.31 s

Tests:

  • cargo test -p eve_broker_inproc -p eve_db_sqlite
  • cargo test -p eve_e2e --test sqlite --test broker_inproc --test inproc
  • cargo clippy -p eve_broker_inproc -p eve_db_sqlite -p eve_e2e --tests --benches -- -D warnings
Adds `eve_broker_inproc` with `InProcBrokerUnit` and `InProcBrokerProvisorUnit`. The transport is an in-process bus (tokio channels): request/response, ephemeral messages and queue groups. Persistence uses a fjall database with three keyspaces: - `streams` — persistent entity markers - `events` — append-only log keyed by `[stream][seq]` - `consumers` — durable offsets Other details: - events are `postcard` records; the global sequence and dedup set live in memory and are rebuilt from `events` on bootstrap - one group-commit writer, up to 1000 appends per fjall batch, `PersistMode::SyncData` - a watch epoch wakes consumers even when a publish lands between reads - `serve`/`wipe` maintain the stream, event and consumer keyspaces - SQLite stays only as the projection database (`eve_db_sqlite`) Benchmark (`entity delete by filter`, same machine, prior NATS+Mongo run): | Size | in-process fjall + SQLite db | NATS + MongoDB | |---|---:|---:| | 1 | ~0.7 ms | ~1.4 ms | | 10,000 | ~0.11 s | ~0.31 s | Tests: - `cargo test -p eve_broker_inproc -p eve_db_sqlite` - `cargo test -p eve_e2e --test sqlite --test broker_inproc --test inproc` - `cargo clippy -p eve_broker_inproc -p eve_db_sqlite -p eve_e2e --tests --benches -- -D warnings`
Author
Owner

Added the entity_sqlite DELETE_BY_FILTER benchmark and the write-path batching it exposed.

Local comparison on this machine (criterion, 10 samples, temporary SQLite files vs NATS+MongoDB containers):

  • 1 instance: SQLite ~1.0 ms vs NATS+Mongo ~1.4 ms
  • 10,000 instances: SQLite ~0.38–0.42 s vs NATS+Mongo ~0.29–0.32 s

The local path is faster for a small batch; at 10k it is close but still slightly slower. The remaining cost is the durable per-message journal row with its indexes, not the in-process bus. Group commit, cached stream checks and batched deletes brought the 10k case down from ~1.5 s to ~0.4 s. A segment log or a dedup index replacement is the next step if local must clearly win at that batch size.

Added the `entity_sqlite` DELETE_BY_FILTER benchmark and the write-path batching it exposed. Local comparison on this machine (criterion, 10 samples, temporary SQLite files vs NATS+MongoDB containers): - 1 instance: SQLite ~1.0 ms vs NATS+Mongo ~1.4 ms - 10,000 instances: SQLite ~0.38–0.42 s vs NATS+Mongo ~0.29–0.32 s The local path is faster for a small batch; at 10k it is close but still slightly slower. The remaining cost is the durable per-message journal row with its indexes, not the in-process bus. Group commit, cached stream checks and batched deletes brought the 10k case down from ~1.5 s to ~0.4 s. A segment log or a dedup index replacement is the next step if local must clearly win at that batch size.
Author
Owner

Switched SQLite append deduplication to an in-memory set.

  • the unique (stream, message_id) index is dropped; the set is rebuilt from event on bootstrap
  • the writer checks the set (plus ids already accepted in the same batch) before inserting
  • serve/wipe update or clear the set
  • tests cover sequential duplicate, duplicate in one batch and duplicate after reopen
  • trade-off: memory grows with the retained journal, which is already unbounded until retention is added
Switched SQLite append deduplication to an in-memory set. - the unique `(stream, message_id)` index is dropped; the set is rebuilt from `event` on bootstrap - the writer checks the set (plus ids already accepted in the same batch) before inserting - `serve`/`wipe` update or clear the set - tests cover sequential duplicate, duplicate in one batch and duplicate after reopen - trade-off: memory grows with the retained journal, which is already unbounded until retention is added
aleksei changed title from feat: add the SQLite broker adapter to feat: add the fjall local broker 2026-10-20 16:22:24 +00:00
aleksei changed title from feat: add the fjall local broker to feat: add the in-process fjall broker 2026-10-20 19:49:33 +00:00
aleksei deleted branch feat/sqlite-broker-adapter 2026-10-20 21:42:58 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zoo/eve!5
No description provided.