pub struct NatsBus { /* private fields */ }Expand description
NATS JetStream bus.
Implementations§
Trait Implementations§
Source§impl EventBus for NatsBus
impl EventBus for NatsBus
Source§fn find_event_by_uid(
&self,
topic: &str,
key: &str,
event_uid: &str,
) -> Result<Option<PublishAck>, BusError>
fn find_event_by_uid( &self, topic: &str, key: &str, event_uid: &str, ) -> Result<Option<PublishAck>, BusError>
JetStream-aware UID lookup. The default trait implementation
treats an empty fetch as proof of absence, but a NATS batch
with a 500 ms expires can legitimately deliver zero messages
before expiry on a loaded server even when matching messages
exist — and a false “absent” makes crash-recovery maintenance
re-produce an already-committed event (a duplicate in the audit
stream once outside the JetStream dedup window). Use the
consumer’s server-computed num_pending instead: zero pending
on a freshly-created filtered consumer proves absence; an empty
batch with pending remaining is a timing artifact and retries
bounded, then fails the pass (callers retry later — the cold
intent is durable).
Source§fn set_control_key(&self, key: [u8; 32]) -> Result<(), BusError>
fn set_control_key(&self, key: [u8; 32]) -> Result<(), BusError>
Configure the signer-derived key used for authenticated local controls.
Source§fn publish(
&self,
topic: &str,
key: &str,
value: &Value,
) -> Result<PublishAck, BusError>
fn publish( &self, topic: &str, key: &str, value: &Value, ) -> Result<PublishAck, BusError>
Publish
value onto topic, partitioned by key. Returns the ack.Source§fn publish_idempotent(
&self,
topic: &str,
key: &str,
value: &Value,
event_uid: &str,
) -> Result<PublishAck, BusError>
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 fetch(
&self,
topic: &str,
partition: u32,
offset: u64,
max: usize,
) -> Result<Vec<StoredEvent>, BusError>
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).Auto Trait Implementations§
impl !Freeze for NatsBus
impl !RefUnwindSafe for NatsBus
impl Send for NatsBus
impl Sync for NatsBus
impl Unpin for NatsBus
impl UnsafeUnpin for NatsBus
impl !UnwindSafe for NatsBus
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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