Expand description
Event Stream - Real-time Event Push System
This module provides a publish-subscribe event system for real-time event pushing,
similar to Docker’s docker events and docker logs -f functionality.
§Features
- Publish-subscribe pattern with multiple publishers and subscribers
- Event filtering by type and resource ID
- Event history with optional replay
- Backpressure handling for slow consumers
§Example
use ipckit::{EventBus, Event, EventFilter};
let bus = EventBus::new(Default::default());
let publisher = bus.publisher();
// Subscribe to task events
let mut subscriber = bus.subscribe(
EventFilter::new().event_type("task.*")
);
// Publish an event
publisher.publish(Event::new("task.started", serde_json::json!({"task_id": "123"})));
// Receive the event
if let Some(event) = subscriber.try_recv() {
println!("Received: {:?}", event);
}Modules§
- event_
types - Standard event type constants.
Structs§
- Event
- An event that can be published and subscribed to.
- Event
Bus - The main event bus for publish-subscribe communication.
- Event
BusConfig - Configuration for the event bus.
- Event
Filter - Event filter for subscribing to specific events.
- Event
Publisher - Event publisher for sending events to the bus.
- Event
Subscriber - Event subscriber for receiving events from the bus.
Enums§
- Slow
Consumer Policy - Policy for handling slow consumers.
Type Aliases§
- EventId
- A unique event identifier.