Skip to main content

EventBus

Trait EventBus 

Source
pub trait EventBus: Send + Sync {
    // Required methods
    fn publish(
        &self,
        topic: &str,
        key: &str,
        value: &Value,
    ) -> Result<PublishAck, BusError>;
    fn fetch(
        &self,
        topic: &str,
        partition: u32,
        offset: u64,
        max: usize,
    ) -> Result<Vec<StoredEvent>, BusError>;
    fn partitions(&self, topic: &str) -> Result<u32, BusError>;
    fn topics(&self) -> Vec<String>;

    // Provided methods
    fn set_control_key(&self, _key: [u8; 32]) -> Result<(), BusError> { ... }
    fn publish_idempotent(
        &self,
        topic: &str,
        key: &str,
        value: &Value,
        _event_uid: &str,
    ) -> Result<PublishAck, BusError> { ... }
    fn find_event_by_uid(
        &self,
        topic: &str,
        key: &str,
        event_uid: &str,
    ) -> Result<Option<PublishAck>, BusError> { ... }
    fn maintenance(&self, _now_ms: u64) -> Result<u64, BusError> { ... }
}
Expand description

Publish/consume abstraction. Synchronous by design: the harness calls it from worker threads (never the hot path), and network backends manage their own I/O runtime internally.

Required Methods§

Source

fn publish( &self, topic: &str, key: &str, value: &Value, ) -> Result<PublishAck, BusError>

Publish value onto topic, partitioned by key. Returns the ack.

Source

fn fetch( &self, topic: &str, partition: u32, offset: u64, max: usize, ) -> Result<Vec<StoredEvent>, BusError>

Read up to max events from topic/partition starting at offset (ordered replay).

Source

fn partitions(&self, topic: &str) -> Result<u32, BusError>

Number of partitions configured for topic.

Source

fn topics(&self) -> Vec<String>

Topics currently provisioned.

Provided Methods§

Source

fn set_control_key(&self, _key: [u8; 32]) -> Result<(), BusError>

Configure the signer-derived key used for authenticated local controls.

Source

fn publish_idempotent( &self, topic: &str, key: &str, value: &Value, _event_uid: &str, ) -> Result<PublishAck, BusError>

Publish a stable event UID. Backends with native or local deduplication override this method; the default preserves compatibility while the UID remains embedded in the event payload for downstream deduplication.

Source

fn find_event_by_uid( &self, topic: &str, key: &str, event_uid: &str, ) -> Result<Option<PublishAck>, BusError>

Locate an already committed event by stable UID during crash recovery.

Source

fn maintenance(&self, _now_ms: u64) -> Result<u64, BusError>

Run backend maintenance such as hot-retention expiry. Managed brokers may return zero when retention is enforced natively.

Implementors§