pub struct TransportManager { /* private fields */ }Expand description
OutprocTransportManager - Cross-process transport manager
Responsibilities:
- Manage transport layer for multiple Dests (each Dest maps to one DestTransport)
- Create DestTransport on-demand (lazy initialization)
- Provide unified send/recv interface
- Support custom connection factories
- Prevent duplicate connection creation using Either state machine
§Comparison with InprocTransportManager
- OutprocTransportManager: Cross-process, uses WebRTC/WebSocket
- InprocTransportManager: Intra-process, uses mpsc channels, zero serialization
§State Machine
None → Connecting(Notify) → Connected(Transport)
↓ ↓
(multiple waiters) (ready)Implementations§
Source§impl OutprocTransportManager
impl OutprocTransportManager
Sourcepub fn new(local_id: ActrId, conn_factory: Arc<dyn WireBuilder>) -> Self
pub fn new(local_id: ActrId, conn_factory: Arc<dyn WireBuilder>) -> Self
Create new OutprocTransportManager
§Arguments
local_id: Local Actor IDconn_factory: Wire builder, asynchronously creates Wire handle list based on Dest
Sourcepub async fn is_closing(&self, dest: &Dest) -> bool
pub async fn is_closing(&self, dest: &Dest) -> bool
Check if a destination is currently being closed
Sourcepub async fn get_or_create_transport(
&self,
dest: &Dest,
) -> NetworkResult<Arc<DestTransport>>
pub async fn get_or_create_transport( &self, dest: &Dest, ) -> NetworkResult<Arc<DestTransport>>
Get or create DestTransport for specified Dest
§Arguments
dest: Target destination
§Returns
- DestTransport for this Dest (Arc-shared)
§State Machine
Uses Either to prevent duplicate connections:
- If Connected → return transport
- If Connecting → wait for notify, then retry
- If None → insert Connecting(notify), create connection outside lock
Sourcepub async fn send(
&self,
dest: &Dest,
payload_type: PayloadType,
data: &[u8],
) -> NetworkResult<()>
pub async fn send( &self, dest: &Dest, payload_type: PayloadType, data: &[u8], ) -> NetworkResult<()>
Sourcepub async fn close_transport(&self, dest: &Dest) -> NetworkResult<()>
pub async fn close_transport(&self, dest: &Dest) -> NetworkResult<()>
Close DestTransport for specified Dest
Called by OutprocOutGate when connection events indicate cleanup is needed. This triggers the cleanup chain: OutprocTransportManager → DestTransport → WirePool
§Arguments
dest: Target destination
Sourcepub async fn close_all(&self) -> NetworkResult<()>
pub async fn close_all(&self) -> NetworkResult<()>
Close all DestTransports
Sourcepub async fn dest_count(&self) -> usize
pub async fn dest_count(&self) -> usize
Get count of currently managed Dests
Sourcepub async fn list_dests(&self) -> Vec<Dest>
pub async fn list_dests(&self) -> Vec<Dest>
List all connected Dests
Sourcepub fn spawn_health_checker(&self, interval: Duration) -> JoinHandle<()>
pub fn spawn_health_checker(&self, interval: Duration) -> JoinHandle<()>
Spawn health checker background task with smart reconnect
Periodically checks all DestTransport health status:
- If some connections failed → trigger smart reconnect (reuse working connections)
- If all connections failed → remove entire DestTransport
§Arguments
interval: Health check interval (recommended: 10-30 seconds)
§Returns
- JoinHandle for the background task (can be used to cancel)
§Example
ⓘ
let mgr = Arc::new(OutprocTransportManager::new(local_id, factory));
let health_check_handle = mgr.spawn_health_checker(Duration::from_secs(10));Trait Implementations§
Auto Trait Implementations§
impl Freeze for OutprocTransportManager
impl !RefUnwindSafe for OutprocTransportManager
impl Send for OutprocTransportManager
impl Sync for OutprocTransportManager
impl Unpin for OutprocTransportManager
impl !UnwindSafe for OutprocTransportManager
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
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 more