Skip to content
You are viewing the corvid 0.3.0 release snapshot — frozen at the 0.3.0 engine release.Current documentation

Change events

# use corvid::{Db};
# let db = Db::open_in_memory()?;
let id = db.subscribe(|ev| {
println!("{:?} {} {:?}", ev.kind, ev.collection, ev.key);
});
// ... writes fire the callback ...
db.unsubscribe(id);
# Ok::<(), corvid::Error>(())

In-process subscriptions piggyback on the write path — there is no separate event log. Every event carries:

pub struct ChangeEvent {
pub kind: ChangeKind, // Insert | Delete
pub collection: String,
pub key: Vec<u8>,
}
pub struct SubscriptionId(/* opaque */);
  • Synchronous, post-commit, in mutation order. Callbacks run on the writing thread after the transaction commits — when your callback returns, the event is delivered.
  • Multiple subscribers all receive identical event vectors, in order.
  • Cross-collection tagging: each event names its own collection.
  • Callbacks should be fast and non-blocking; a slow callback stalls the writer. Keep a lock-free hand-off if you process asynchronously.
  • unsubscribe reports whether the subscription existed; ids are distinct.
PathEvents
insert (new key)one Insert
insert (overwrite)one Insert (the new value)
insert_batchone Insert per applied key, in batch order
insert_autoone Insert keyed by the generated key
update returning Someone Insert
update returning None (delete)one Delete
update on missing key creatingone Insert
patch creatingone Insert
patch mergingone Insert
compare_and_set applied (write)one Insert
compare_and_set applied (delete)one Delete
compare_and_set compare failednone
delete / delete_batch / delete_whereone Delete per existing key, in order
delete of absent key (incl. edge cascade)none
link (new or duplicate)one Insert keyed by the from endpoint — including links to missing endpoints
unlinknone
TTL purgenone (silent cascade)
stranded TTL purgenone

The “duplicate link re-emits insert” and “TTL purge is silent” rows are the surprising ones — both are pinned by the conformance suite.

Cache invalidation, derived-state maintenance, audit trails within the process, live UIs. For cross-process notification, run the MCP sidecar or front the engine with your own service — the engine has no networking, by design, and the C ABI excludes subscriptions in v1 (reentrancy across languages; see ABI exclusions).

Next: administration.