pub struct WebRtcGate { /* private fields */ }Expand description
WebRTC Gate - OutboundGate implementation
§Responsibilities
- Implement OutboundGate trait
- Send messages using WebRtcCoordinator
- Serialize/deserialize RpcEnvelope (Protobuf)
- Track pending requests and match responses (by r equest_id)
- Route messages by PayloadType (RPC → Mailbox, DataStream → Registry)
§Design Principles
- Response reuses Request’s request_id (standard RPC semantics)
- Use pending_requests to distinguish: exists = Response, doesn’t exist = Request
- Gateway layer doesn’t deserialize payloads, raw bytes go directly to Mailbox
- IMPORTANT: pending_requests should be shared with OutprocOutGate
Implementations§
Source§impl WebRtcGate
impl WebRtcGate
Sourcepub fn new(
coordinator: Arc<WebRtcCoordinator>,
pending_requests: Arc<RwLock<HashMap<String, (ActrId, Sender<ActorResult<Bytes>>)>>>,
data_stream_registry: Arc<DataStreamRegistry>,
) -> Self
pub fn new( coordinator: Arc<WebRtcCoordinator>, pending_requests: Arc<RwLock<HashMap<String, (ActrId, Sender<ActorResult<Bytes>>)>>>, data_stream_registry: Arc<DataStreamRegistry>, ) -> Self
Create new WebRtcGate with shared pending_requests and DataStreamRegistry
§Arguments
coordinator: WebRtcCoordinator instancepending_requests: Shared pending requests (should be same as OutprocOutGate)data_stream_registry: DataStream registry for fast-path routing
Sourcepub async fn set_local_id(&self, actor_id: ActrId)
pub async fn set_local_id(&self, actor_id: ActrId)
Set local Actor ID
Sourcepub async fn start_receive_loop(
&self,
mailbox: Arc<dyn Mailbox>,
) -> RuntimeResult<()>
pub async fn start_receive_loop( &self, mailbox: Arc<dyn Mailbox>, ) -> RuntimeResult<()>
Start message receive loop (called by ActrSystem/ActrNode)
§Arguments
mailbox: message queue for persisting inbound requests
§Architecture
According to three-loop architecture design (framework-runtime-architecture.zh.md):
- WebRtcGate belongs to outer loop (Transport layer)
- Mailbox belongs to inner loop (state path)
- Message flow: WebRTC → WebRtcGate → Mailbox/DataStreamRegistry → Scheduler → ActrNode
§Message Routing Logic
- Route based on PayloadType:
- RpcReliable/RpcSignal: Deserialize RpcEnvelope, check pending_requests, enqueue to Mailbox
- StreamReliable/StreamLatencyFirst: Deserialize DataStream, dispatch to DataStreamRegistry
Sourcepub async fn send_response(
&self,
target: &ActrId,
response_envelope: RpcEnvelope,
) -> RuntimeResult<()>
pub async fn send_response( &self, target: &ActrId, response_envelope: RpcEnvelope, ) -> RuntimeResult<()>
Send response (called by Mailbox handler loop)
§Arguments
target: response target ActrId (original request sender)response_envelope: response RpcEnvelope (must reuse original request_id)
§Design Principle
- Response reuses Request’s request_id (caller is responsible)
- Receiver matches to pending_requests by request_id and wakes up waiting caller
Auto Trait Implementations§
impl Freeze for WebRtcGate
impl !RefUnwindSafe for WebRtcGate
impl Send for WebRtcGate
impl Sync for WebRtcGate
impl Unpin for WebRtcGate
impl !UnwindSafe for WebRtcGate
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