Expand description
Internal event system for real-time notifications
The EventBus is the core of the real-time system. It uses tokio::sync::broadcast
to decouple mutations (REST, GraphQL handlers) from notifications (WebSocket, SSE).
§Architecture
REST Handler ──┐
├──▶ EventBus::publish() ──▶ broadcast channel ──▶ WebSocket subscribers
GraphQL Handler┘ ──▶ SSE subscribers§Usage
ⓘ
let event_bus = EventBus::new(1024);
// Subscribe to events
let mut rx = event_bus.subscribe();
// Publish an event (non-blocking, fire-and-forget)
event_bus.publish(FrameworkEvent::Entity(EntityEvent::Created {
entity_type: "order".to_string(),
entity_id: Uuid::new_v4(),
data: json!({"name": "Order #1"}),
}));
// Receive events
if let Ok(event) = rx.recv().await {
println!("Received: {:?}", event);
}Structs§
- Event
Bus - Broadcast-based event bus for the framework
- Event
Envelope - Envelope wrapping a framework event with metadata
Enums§
- Entity
Event - Events related to entity mutations (create, update, delete)
- Framework
Event - Top-level framework event that wraps entity and link events
- Link
Event - Events related to link mutations (create, delete)