feat(events): add dunite-events leaf crate (event bus + SSE adapter) #40
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/DEV-528-events-crate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Adds the
dunite-eventsleaf crate (DEV-528, under BUNYIP-340) - the in-process event bus + SSE framing extracted from bunyip, generic over the consumer's event type.bus: theSseEventtrait (name()+target_user()) andEventBus<E: SseEvent>- per-user + global tokio broadcast channels with lazy per-user channel reaping. Framework-neutral (tokio only).sse: the actix adapter.sse_response(bus, user_id)opens the merged (per-user + global)text/event-streamwith a 25s keepalive and aresyncframe on aLaggedreceiver;encode_event/encode_resyncdo the framing.The concrete event enum stays in the consumer (bunyip's
BunyipEvent) and implementsSseEvent. menkent hand-ported the same bus +/v1/eventsstream (MKT-16); this is the convergence target.Deps
Adds
tokio-stream(featuressync, forBroadcastStream) to the workspace.actix-web/tokio/futures-util/serde/serde_json/uuidwere already present. Leaf crate (no dunite-core dep).Validation
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test -p dunite-eventsgreen in the pinned rust-builder image. Tests: per-user / global routing, cross-user isolation, no-subscriber noop (bus); event / resync frame shape (sse).Consumer follow-up (bunyip, after merge)
event_bus.rs: keepBunyipEvent+ add itsimpl SseEvent; re-exportEventBusfrom the crate.web::Data<Arc<EventBus>>becomesEventBus<BunyipEvent>.handlers/events.rs: the handler becomes a thindunite_events::sse::sse_response(&bus, user_id).Leaf crate, so bunyip's
dunite-corerev does not move.#DEV-528