pub struct FileBackedBus { /* private fields */ }Expand description
File-backed event bus: wraps InMemoryBus with append-only JSONL persistence.
Every published event is serialized to a JSONL log file before being
broadcast to live subscribers. Use FileBackedBus::replay to read
back all persisted events (e.g. after a restart).
Implementations§
Source§impl FileBackedBus
impl FileBackedBus
Sourcepub async fn open(path: impl AsRef<Path>, capacity: usize) -> Result<Self>
pub async fn open(path: impl AsRef<Path>, capacity: usize) -> Result<Self>
Open (or create) a JSONL event log at path with the given broadcast capacity.
Trait Implementations§
Source§impl EventBus for FileBackedBus
impl EventBus for FileBackedBus
Source§fn publish<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn publish<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Publish an event to all subscribers.
Source§fn subscribe(&self) -> Box<dyn EventSubscriber>
fn subscribe(&self) -> Box<dyn EventSubscriber>
Create a new subscriber that receives all future events.
Source§fn subscriber_count(&self) -> usize
fn subscriber_count(&self) -> usize
Number of active subscribers.
Source§fn replay_since<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
topic: Option<&'life1 str>,
since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn replay_since<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
topic: Option<&'life1 str>,
since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Replay events since a given event ID (exclusive). Returns events in order.
If
since_id is None, replays all events. If the bus does not support
persistence, returns an empty vec.Source§fn gc_older_than<'life0, 'async_trait>(
&'life0 self,
_max_age: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn gc_older_than<'life0, 'async_trait>(
&'life0 self,
_max_age: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete events older than the given age. Returns count of deleted events.
No-op for buses that don’t support persistence.
Auto Trait Implementations§
impl !Freeze for FileBackedBus
impl !RefUnwindSafe for FileBackedBus
impl Send for FileBackedBus
impl Sync for FileBackedBus
impl Unpin for FileBackedBus
impl UnsafeUnpin for FileBackedBus
impl UnwindSafe for FileBackedBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more