Skip to main content

Module events

Module events 

Source
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§

EventBus
Broadcast-based event bus for the framework
EventEnvelope
Envelope wrapping a framework event with metadata

Enums§

EntityEvent
Events related to entity mutations (create, update, delete)
FrameworkEvent
Top-level framework event that wraps entity and link events
LinkEvent
Events related to link mutations (create, delete)