pub struct BusCaptureAdapter { /* private fields */ }Expand description
Captures bus traffic and forwards encoded entries to the EventStoreWriter.
One adapter instance owns one writer; the kernel constructs the adapter after spawning
the writer, then registers it with the bus dispatch wrappers. The adapter is Send + Sync so it can be shared between bus subscribers, but in practice the message bus is
single-threaded and the adapter lives on the engine thread.
Implementations§
Source§impl BusCaptureAdapter
impl BusCaptureAdapter
Sourcepub fn new(
writer: Arc<EventStoreWriter>,
registry: Arc<EncoderRegistry>,
halt: HaltCallback,
) -> Self
pub fn new( writer: Arc<EventStoreWriter>, registry: Arc<EncoderRegistry>, halt: HaltCallback, ) -> Self
Constructs a new adapter over writer, registry, and halt.
halt is the adapter-level fail-stop callback. The writer carries its own halt
callback for backend and backpressure failures; the adapter callback fires on any
submit error so SubmitError::Closed (which can originate outside the writer’s
own halt path, e.g. an external close) still reaches the kernel.
Sourcepub fn with_submit_counter(self, submit_counter: Arc<AtomicU64>) -> Self
pub fn with_submit_counter(self, submit_counter: Arc<AtomicU64>) -> Self
Shares an entry-submit counter with the data-marker capture path.
Sourcepub fn registry(&self) -> &EncoderRegistry
pub fn registry(&self) -> &EncoderRegistry
Returns the encoder allow-list this adapter consults.
Sourcepub fn high_watermark(&self) -> u64
pub fn high_watermark(&self) -> u64
Returns the wrapped writer’s current durable high-watermark.
Sourcepub fn capture<T: 'static>(
&self,
topic: Topic,
message: &T,
headers: Headers,
ts_init: UnixNanos,
) -> Result<bool, CaptureError>
pub fn capture<T: 'static>( &self, topic: Topic, message: &T, headers: Headers, ts_init: UnixNanos, ) -> Result<bool, CaptureError>
Captures a state-affecting bus message.
Looks up the encoder for T, builds an EntryDraft, and forwards it to the
writer. Returns Ok(false) when the type has no registered encoder so the adapter
can be wired into bus dispatch paths that carry a mix of state-affecting and
non-state-affecting messages without surfacing per-message errors, and when the
message’s registered identity was already captured on another dispatch hop (the
same order event reaches the tap via the portfolio endpoint send and the strategy
topic publish; the log records it once).
topic is the bus topic the message was dispatched on, headers are the
dispatch-time correlation headers (defaulting to Headers::empty until header
propagation lands across all message types), and ts_init is the domain
timestamp from AtomicTime (typically the message’s own ts_init field).
§Errors
Returns:
CaptureError::Haltedwhen a prior capture already observed a writer failure and the adapter has fail-stopped.CaptureError::Encodewhen the registered encoder rejects the message.CaptureError::Submitwhen the writer rejects the submit; the adapter halt callback fires before this error returns.
Sourcepub fn capture_any(
&self,
topic: Topic,
message: &dyn Any,
headers: Headers,
ts_init: UnixNanos,
) -> Result<bool, CaptureError>
pub fn capture_any( &self, topic: Topic, message: &dyn Any, headers: Headers, ts_init: UnixNanos, ) -> Result<bool, CaptureError>
Type-erased counterpart to Self::capture.
Bus dispatch hands messages to the tap as &dyn Any because the static type is
not in scope at the registration site. This method dispatches on the concrete
type behind the trait object and follows the same fail-stop semantics as
Self::capture.
§Errors
See Self::capture.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BusCaptureAdapter
impl !RefUnwindSafe for BusCaptureAdapter
impl !UnwindSafe for BusCaptureAdapter
impl Send for BusCaptureAdapter
impl Sync for BusCaptureAdapter
impl Unpin for BusCaptureAdapter
impl UnsafeUnpin for BusCaptureAdapter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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>
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