pub struct InProcessBroker { /* private fields */ }Expand description
Synchronous, in-memory implementation of EventBroker.
The broker stores a bounded retention buffer per event type and maintains a bounded delivery queue per subscription. Subscribers poll for events using a broker-issued subscription id and a cursor.
Implementations§
Source§impl InProcessBroker
impl InProcessBroker
Sourcepub fn new(catalog: Arc<EventCatalog>) -> Result<Self, EventError>
pub fn new(catalog: Arc<EventCatalog>) -> Result<Self, EventError>
Create a new broker backed by the given catalog.
§Errors
Returns EventError::InvalidRetentionWindow when the provided configuration is invalid.
Sourcepub fn with_clock(
catalog: Arc<EventCatalog>,
config: BrokerConfig,
clock: Arc<dyn BrokerClock>,
) -> Result<Self, EventError>
pub fn with_clock( catalog: Arc<EventCatalog>, config: BrokerConfig, clock: Arc<dyn BrokerClock>, ) -> Result<Self, EventError>
Create a broker with explicit configuration and clock.
§Errors
Returns EventError::InvalidRetentionWindow when the provided configuration is invalid.
Trait Implementations§
Source§impl Debug for InProcessBroker
impl Debug for InProcessBroker
Source§impl EventBroker for InProcessBroker
impl EventBroker for InProcessBroker
Source§fn publish(&self, event: TraverseEvent) -> Result<(), EventError>
fn publish(&self, event: TraverseEvent) -> Result<(), EventError>
Publish event to all registered subscribers.
§Errors
EventError::UnregisteredEventTypeif the event type is not in the catalog.EventError::LifecycleViolationif the catalog entry isDraftorDeprecated.
Source§fn publish_with_cursor(
&self,
event: TraverseEvent,
cursor: &str,
) -> Result<(), EventError>
fn publish_with_cursor( &self, event: TraverseEvent, cursor: &str, ) -> Result<(), EventError>
Publish event, adopting cursor as this broker’s own cursor for it
instead of self-assigning the next per-type sequence value. Used by
DurableBroker so live-delivery
cursors stay numerically consistent with the durable journal’s cursor
space (spec 066 FR-007): a cursor obtained during live polling
remains valid when a later poll falls back to durable replay.
§Errors
Returns EventError::InvalidCursor when cursor is not a base-10
unsigned integer, plus the same errors as Self::publish.
Source§fn subscribe(
&self,
event_type: &str,
from_cursor: &str,
) -> Result<Subscription, EventError>
fn subscribe( &self, event_type: &str, from_cursor: &str, ) -> Result<Subscription, EventError>
Create a subscription for event_type starting from from_cursor.
The event type must already be registered in the catalog.
§Errors
Returns EventError::UnregisteredEventType if the event type is not catalogued.
Source§fn poll(
&self,
subscription_id: &str,
max_events: usize,
) -> Result<SubscriptionPoll, EventError>
fn poll( &self, subscription_id: &str, max_events: usize, ) -> Result<SubscriptionPoll, EventError>
Poll a subscription for up to max_events.
§Errors
Source§fn cancel(&self, subscription_id: &str) -> Result<(), EventError>
fn cancel(&self, subscription_id: &str) -> Result<(), EventError>
Cancel a subscription.
§Errors
Returns EventError::SubscriptionNotFound if the subscription id is unknown.
Source§fn subscribe_for_subject(
&self,
event_type: &str,
from_cursor: &str,
subject_id: Option<&str>,
) -> Result<Subscription, EventError>
fn subscribe_for_subject( &self, event_type: &str, from_cursor: &str, subject_id: Option<&str>, ) -> Result<Subscription, EventError>
Source§fn seed_restart_floor(&self, floor: u64)
fn seed_restart_floor(&self, floor: u64)
DurableBroker::open
calls this once at construction, seeded from the durable journal’s
latest cursor, so a freshly constructed in-memory broker correctly
defers stale-looking cursors to durable replay after a restart
instead of accepting them outright. The default implementation is a
no-op.Auto Trait Implementations§
impl !Freeze for InProcessBroker
impl !RefUnwindSafe for InProcessBroker
impl !UnwindSafe for InProcessBroker
impl Send for InProcessBroker
impl Sync for InProcessBroker
impl Unpin for InProcessBroker
impl UnsafeUnpin for InProcessBroker
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more