pub struct FakeAdapter { /* private fields */ }Expand description
In-memory PartnerAdapter for tests: records sent messages,
plays a scripted incoming queue, and can fail sends on demand.
Clone shares state; keep a clone (or a FakeRecorder) to
inspect sends after moving the adapter into a PartnerRouter.
Implementations§
Source§impl FakeAdapter
impl FakeAdapter
Sourcepub fn scripted(queue: Vec<IncomingMessage>) -> Self
pub fn scripted(queue: Vec<IncomingMessage>) -> Self
A fake that plays the given messages, in order, on receive; once the queue drains, further receives time out.
Sourcepub fn failing_send(reason: impl Into<String>) -> Self
pub fn failing_send(reason: impl Into<String>) -> Self
A fake whose every send fails at the transport.
Sourcepub fn failing_receive(reason: impl Into<String>) -> Self
pub fn failing_receive(reason: impl Into<String>) -> Self
A fake whose every receive fails at the transport, so a mid-scenario receive transport failure is expressible.
Sourcepub fn recorder(&self) -> FakeRecorder
pub fn recorder(&self) -> FakeRecorder
A handle onto this fake’s recorded sends.
Trait Implementations§
Source§impl Clone for FakeAdapter
impl Clone for FakeAdapter
Source§fn clone(&self) -> FakeAdapter
fn clone(&self) -> FakeAdapter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl PartnerAdapter for FakeAdapter
impl PartnerAdapter for FakeAdapter
Source§fn send<'a>(
&'a self,
lane_key: &'a str,
_target_uri: &'a str,
msg: OutgoingMessage,
) -> BoxFuture<'a, Result<Option<Exchange>, TransportError>>
fn send<'a>( &'a self, lane_key: &'a str, _target_uri: &'a str, msg: OutgoingMessage, ) -> BoxFuture<'a, Result<Option<Exchange>, TransportError>>
Send a message to the target URI, parking any roundtrip under
the lane key, and return the synchronous reply when the
adapter produces one: the context-stimulus
direct: send
returns the routed exchange (Ok(Some(..))) so an
expectReply assertion can read it (rc-qvz6); partner and
fake adapters answer Ok(None). Adapters without a client
role keep the default (a transport failure naming the gap);
the http partner is one such adapter — the router’s own client
lane performs every http client-role send.Source§fn receive<'a>(
&'a self,
_lane_key: &'a str,
source_uri: &'a str,
deadline: Duration,
) -> BoxFuture<'a, Result<IncomingMessage, ReceiveError>>
fn receive<'a>( &'a self, _lane_key: &'a str, source_uri: &'a str, deadline: Duration, ) -> BoxFuture<'a, Result<IncomingMessage, ReceiveError>>
Receive a message from the source URI before the deadline
passes. Implementations must respect the deadline; they never
hang past it.
The host:port authority this adapter’s listener bound, when it
owns one (the http partner);
None otherwise. The router uses
it to resolve declared and dynamic endpoint references to real
wire addresses.Source§fn set_secret_query_keys(&self, keys: &[String])
fn set_secret_query_keys(&self, keys: &[String])
Stores the query keys classified secret (ADR-0051 positive
secret rule) for the adapter’s diagnostic redaction; the
router fans the set out from the booted context’s component
metadata. Default noop: adapters without wire-path
diagnostics render nothing to redact.
Auto Trait Implementations§
impl !RefUnwindSafe for FakeAdapter
impl !UnwindSafe for FakeAdapter
impl Freeze for FakeAdapter
impl Send for FakeAdapter
impl Sync for FakeAdapter
impl Unpin for FakeAdapter
impl UnsafeUnpin for FakeAdapter
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request