pub struct ContextOutboundInterceptor { /* private fields */ }Expand description
Outbound interceptor that captures the current dcontext and attaches it to outgoing actor messages as headers.
- Local targets: attaches a
ContextSnapshotHeaderonly — no serialization is performed, preserving local-only context values. - Remote targets: serializes context to bytes and attaches a
ContextHeaderfor wire transport.
§Error Handling
Controlled by ErrorPolicy:
LogAndContinue(default) — log and send the message without context.Reject— reject the message.
§Usage
ⓘ
use dcontext_dactor::{ContextOutboundInterceptor, ErrorPolicy};
// Default: log and continue on errors
runtime.add_outbound_interceptor(Box::new(ContextOutboundInterceptor::default()));
// Strict: reject messages if context serialization fails
runtime.add_outbound_interceptor(Box::new(
ContextOutboundInterceptor::new(ErrorPolicy::Reject),
));Implementations§
Source§impl ContextOutboundInterceptor
impl ContextOutboundInterceptor
Sourcepub fn new(error_policy: ErrorPolicy) -> Self
pub fn new(error_policy: ErrorPolicy) -> Self
Create with a specific error policy.
Trait Implementations§
Source§impl Default for ContextOutboundInterceptor
impl Default for ContextOutboundInterceptor
Source§impl OutboundInterceptor for ContextOutboundInterceptor
impl OutboundInterceptor for ContextOutboundInterceptor
Source§fn on_send(
&self,
ctx: &OutboundContext<'_>,
_runtime_headers: &RuntimeHeaders,
headers: &mut Headers,
_message: &dyn Any,
) -> Disposition
fn on_send( &self, ctx: &OutboundContext<'_>, _runtime_headers: &RuntimeHeaders, headers: &mut Headers, _message: &dyn Any, ) -> Disposition
Called before the message is sent. Can modify headers, delay, reject,
or retry. The message body is provided as
&dyn Any for inspection.Source§fn on_reply(
&self,
_ctx: &OutboundContext<'_>,
_runtime_headers: &RuntimeHeaders,
_headers: &Headers,
_outcome: &Outcome<'_>,
)
fn on_reply( &self, _ctx: &OutboundContext<'_>, _runtime_headers: &RuntimeHeaders, _headers: &Headers, _outcome: &Outcome<'_>, )
Called when an ask() reply is received back on the sender side.
The reply is type-erased — downcast if you know the type. Read more
Source§fn on_expand_item(
&self,
ctx: &OutboundContext<'_>,
headers: &Headers,
seq: u64,
item: &(dyn Any + 'static),
) -> Disposition
fn on_expand_item( &self, ctx: &OutboundContext<'_>, headers: &Headers, seq: u64, item: &(dyn Any + 'static), ) -> Disposition
Called for each item flowing through a stream or feed on the sender side. Read more
Auto Trait Implementations§
impl Freeze for ContextOutboundInterceptor
impl RefUnwindSafe for ContextOutboundInterceptor
impl Send for ContextOutboundInterceptor
impl Sync for ContextOutboundInterceptor
impl Unpin for ContextOutboundInterceptor
impl UnsafeUnpin for ContextOutboundInterceptor
impl UnwindSafe for ContextOutboundInterceptor
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