Skip to main content

PartnerAdapter

Trait PartnerAdapter 

Source
pub trait PartnerAdapter: Send + Sync {
    // Required method
    fn receive<'a>(
        &'a self,
        lane_key: &'a str,
        source_uri: &'a str,
        deadline: Duration,
    ) -> BoxFuture<'a, Result<IncomingMessage, ReceiveError>>;

    // Provided methods
    fn send<'a>(
        &'a self,
        lane_key: &'a str,
        target_uri: &'a str,
        msg: OutgoingMessage,
    ) -> BoxFuture<'a, Result<(), TransportError>> { ... }
    fn bound_authority(&self) -> Option<String> { ... }
}
Expand description

The harness-owned far side of the wire for one endpoint family.

Implementations must be Send + Sync; calls return boxed futures so the trait stays object-safe behind Box<dyn PartnerAdapter>.

The two-key contract splits the lane from the wire: lane_key is the registered router key whose lane (queue, parked roundtrip) the call belongs to, target_uri/source_uri is the resolved address the scenario referenced. Adapters that own a listener (the http partner) read their arrival lane by the registered key’s request path; adapters that dial treat the target URI as the wire address.

Required Methods§

Source

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.

Provided Methods§

Source

fn send<'a>( &'a self, lane_key: &'a str, target_uri: &'a str, msg: OutgoingMessage, ) -> BoxFuture<'a, Result<(), TransportError>>

Send a message to the target URI, parking any roundtrip under the lane key. 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 bound_authority(&self) -> Option<String>

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§