pub struct OutgoingWebsocketManager { /* private fields */ }Expand description
Manages outbound WebSocket connections to relay servers.
Created with a list of WebSocket URLs. On pre_start, connects to each
URL (with retry) and spawns a WsConn actor per connection. All
outgoing messages are fanned out to all connected clients.
The clients map is shared via Arc<RwLock<...>> so that e2e tests
can hold their own clone of this manager and observe connection
state via Self::connected_count while the actor-driven copy
(moved into crate::Node) performs the actual work.
Implementations§
Source§impl OutgoingWebsocketManager
impl OutgoingWebsocketManager
Sourcepub fn new(config: Config, urls: Vec<String>) -> Self
pub fn new(config: Config, urls: Vec<String>) -> Self
Creates a new manager for the given URLs.
§Arguments
config- Node configuration (usesallow_public_spacefor connections)urls- WebSocket URLs to connect to (e.g.["wss://relay.example.com/ws"])
Sourcepub async fn connected_count(&self) -> usize
pub async fn connected_count(&self) -> usize
Returns the number of remote URLs that have an active WebSocket connection.
This is a readiness signal: it reflects the state of the
clients map, which is populated only after connect_async
succeeds (see pre_start). Once connected_count() == urls.len(),
all configured peer connections have completed the WebSocket
handshake and are ready to send/receive messages.
e2e tests should poll on this instead of blind sleep(N):
while client.connected_count().await < expected {
crate::tokio_time::sleep(Duration::from_millis(50)).await;
}Returns a snapshot under the read lock; the count is monotonic
(only grows as connections succeed). Callers do not need to
handle rollback — the actor never removes entries from clients
during normal operation.
Trait Implementations§
Source§impl Actor for OutgoingWebsocketManager
impl Actor for OutgoingWebsocketManager
Source§fn subscribe_to_everything(&self) -> bool
fn subscribe_to_everything(&self) -> bool
Returns true — this adapter subscribes to all messages (relay behavior).
Source§fn pre_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pre_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: Arc<Message>,
_ctx: &'life1 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: Arc<Message>,
_ctx: &'life1 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn stopping<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stopping<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn handle_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
batch: &'life1 mut Vec<Arc<Message>>,
context: &'life2 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
batch: &'life1 mut Vec<Arc<Message>>,
context: &'life2 ActorContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn is_relay_server(&self) -> bool
fn is_relay_server(&self) -> bool
Source§impl Clone for OutgoingWebsocketManager
impl Clone for OutgoingWebsocketManager
Source§fn clone(&self) -> OutgoingWebsocketManager
fn clone(&self) -> OutgoingWebsocketManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more