Skip to main content

OutgoingWebsocketManager

Struct OutgoingWebsocketManager 

Source
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

Source

pub fn new(config: Config, urls: Vec<String>) -> Self

Creates a new manager for the given URLs.

§Arguments
  • config - Node configuration (uses allow_public_space for connections)
  • urls - WebSocket URLs to connect to (e.g. ["wss://relay.example.com/ws"])
Source

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.

Source

pub fn urls(&self) -> &[String]

Returns the configured target URLs. Useful for tests that want to know how many connections to expect.

Trait Implementations§

Source§

impl Actor for OutgoingWebsocketManager

Source§

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,

Called once before the actor starts processing messages. Read more
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,

Handle an incoming message. Read more
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,

Called once after the actor’s message loop exits. Read more
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,

Handle a batch of messages drained from the mailbox. Read more
Source§

fn try_clone_storage(&self) -> Option<Box<dyn Actor>>

Attempts to produce a clone of this actor for storage read/write splitting. Read more
Source§

impl Clone for OutgoingWebsocketManager

Source§

fn clone(&self) -> OutgoingWebsocketManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V