behest_runtime/event_publisher.rs
1//! External event publishing boundary for runtime events.
2
3use async_trait::async_trait;
4use thiserror::Error;
5
6use crate::event::AgentEvent;
7
8/// Errors produced by runtime event publishers.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum EventPublishError {
12 /// Publishing a single event to the broker failed.
13 #[error("runtime event publish failed: {message}")]
14 PublishFailed {
15 /// Human-readable failure description.
16 message: String,
17 },
18}
19
20/// Publishes agent events to an external message broker.
21#[async_trait]
22pub trait EventPublisher: Send + Sync {
23 /// Publishes an agent event.
24 ///
25 /// # Errors
26 ///
27 /// Returns [`EventPublishError`] when the event cannot be delivered.
28 async fn publish(&self, event: AgentEvent) -> Result<(), EventPublishError>;
29}