Module event_stream

Module event_stream 

Source
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.
EventBus
The main event bus for publish-subscribe communication.
EventBusConfig
Configuration for the event bus.
EventFilter
Event filter for subscribing to specific events.
EventPublisher
Event publisher for sending events to the bus.
EventSubscriber
Event subscriber for receiving events from the bus.

Enums§

SlowConsumerPolicy
Policy for handling slow consumers.

Type Aliases§

EventId
A unique event identifier.