Skip to main content

Module subscription

Module subscription 

Source
Expand description

Post-commit subscription API.

[GraphDb] exposes three subscription entry-points:

  • [GraphDb::subscribe_rule] — edge-fire / retract events for one named rule.
  • [GraphDb::subscribe_all_rules] — edge events for every rule.
  • [GraphDb::subscribe_writes] — node and property mutations.

All three return a Subscription handle. Dropping it unregisters the subscriber on the next commit (via Weak upgrade failure in the distribution loop).

§Ordering invariant

Events are pushed inside log_then_apply_with after the WAL fsync and the in-memory apply have both completed. A subscriber that queries the db immediately after receiving an event therefore observes the state that produced it.

§Bounded queue / Lagged

Each subscription has a fixed-capacity queue (default DEFAULT_SUB_CAPACITY). When the queue is full, events are dropped and a missed count is incremented. The next Subscription::try_recv / Subscription::recv_timeout call that finds an empty queue and a non-zero miss count returns [DbEvent::Lagged { missed }] before continuing with queued events.

§v1 scope

Rule-edge events and write-mutation events only. Query subscriptions ([GraphDb::subscribe_query]) perform a full re-run per commit; differential evaluation is v0.3 wait-list.

Structs§

Subscription
A live subscription handle returned by [GraphDb::subscribe_rule] etc.

Enums§

DbEvent
A post-commit event delivered to subscribers.

Constants§

DEFAULT_SUB_CAPACITY
Default per-subscriber queue capacity.