pub struct BrokerState {
pub log_path: Option<PathBuf>,
pub learnings: Option<SharedLearnings>,
/* private fields */
}Expand description
Shared broker state.
Wraps BrokerStateInner in an RwLock for concurrent read access.
The sequence counter is a standalone AtomicU64 outside the lock so
that sequence numbers can be allocated without coupling to the write
lock.
Fields§
§log_path: Option<PathBuf>Optional path for periodic log flush to disk.
learnings: Option<SharedLearnings>Optional learnings aggregator. Populated when supervisor + learnings mode is active; the publish path forwards every observed message.
Implementations§
Source§impl BrokerState
impl BrokerState
Sourcepub fn attach_learnings(&mut self, aggregator: SharedLearnings)
pub fn attach_learnings(&mut self, aggregator: SharedLearnings)
Attaches a learnings aggregator. Replaces any previously attached
instance. Must be called before start_broker so the publish path
observes every message from the first one.
Sourcepub fn read(&self) -> RwLockReadGuard<'_, BrokerStateInner>
pub fn read(&self) -> RwLockReadGuard<'_, BrokerStateInner>
Acquires a read lock on the inner state.
§Panics
Panics if the lock is poisoned (a thread panicked while holding it).
Sourcepub fn write(&self) -> RwLockWriteGuard<'_, BrokerStateInner>
pub fn write(&self) -> RwLockWriteGuard<'_, BrokerStateInner>
Acquires a write lock on the inner state.
§Panics
Panics if the lock is poisoned (a thread panicked while holding it).
Sourcepub fn uptime_seconds(&self) -> u64
pub fn uptime_seconds(&self) -> u64
Returns the number of seconds since the broker was started.
Used by the HTTP /status handler to report uptime.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BrokerState
impl RefUnwindSafe for BrokerState
impl Send for BrokerState
impl Sync for BrokerState
impl Unpin for BrokerState
impl UnsafeUnpin for BrokerState
impl UnwindSafe for BrokerState
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> 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