pub struct InMemoryConnectionProvider { /* private fields */ }Expand description
A connection provider that uses in-memory channels instead of TCP sockets. This implementation uses synchronous data structures with wakers to notify callers expecting to connect or receive a message for example.
This provider can be shared between several StageGraph implementations representing different Amaru nodes communicating together.
Trait Implementations§
Source§impl Clone for InMemoryConnectionProvider
impl Clone for InMemoryConnectionProvider
Source§fn clone(&self) -> InMemoryConnectionProvider
fn clone(&self) -> InMemoryConnectionProvider
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConnectionProvider for InMemoryConnectionProvider
impl ConnectionProvider for InMemoryConnectionProvider
Source§fn listen(&self, addr: SocketAddr) -> BoxFuture<'static, Result<SocketAddr>>
fn listen(&self, addr: SocketAddr) -> BoxFuture<'static, Result<SocketAddr>>
Create a new listener for the given address. If a listener already exists for this address, it is removed to allow supervised restarts.
Source§fn accept(
&self,
listener_addr: SocketAddr,
) -> BoxFuture<'static, Result<(Peer, ConnectionId)>>
fn accept( &self, listener_addr: SocketAddr, ) -> BoxFuture<'static, Result<(Peer, ConnectionId)>>
Accept an incoming connection for the specified listener. Returns the peer and connection ID. If no peer is currently trying to connect, this waits until a connection is available and wakes the caller.
Source§fn connect(
&self,
addr: Vec<SocketAddr>,
_timeout: Duration,
) -> BoxFuture<'static, Result<ConnectionId>>
fn connect( &self, addr: Vec<SocketAddr>, _timeout: Duration, ) -> BoxFuture<'static, Result<ConnectionId>>
Connect to one of the given addresses. If a listener for the target address is already registered, the connection is established immediately.
This creates 2 connection endpoints with shared read / write queues.
Source§fn connect_addrs(
&self,
addr: ToSocketAddrs,
timeout: Duration,
) -> BoxFuture<'static, Result<ConnectionId>>
fn connect_addrs( &self, addr: ToSocketAddrs, timeout: Duration, ) -> BoxFuture<'static, Result<ConnectionId>>
Connect to a given peer, at a list of SocketAddr.
Source§fn send(
&self,
conn: ConnectionId,
data: NonEmptyBytes,
) -> BoxFuture<'static, Result<()>>
fn send( &self, conn: ConnectionId, data: NonEmptyBytes, ) -> BoxFuture<'static, Result<()>>
Send a message to the connection peer:
- Add bytes to the connection write_queue (this is the read_queue of the peer on its connection)
- Wake the peer so that it can read the data.
Source§fn recv(
&self,
conn: ConnectionId,
bytes: NonZeroUsize,
) -> BoxFuture<'static, Result<NonEmptyBytes>>
fn recv( &self, conn: ConnectionId, bytes: NonZeroUsize, ) -> BoxFuture<'static, Result<NonEmptyBytes>>
Receive a new message by reading from the message queue when a new message has arrived
Source§fn close(&self, conn: ConnectionId) -> BoxFuture<'static, Result<()>>
fn close(&self, conn: ConnectionId) -> BoxFuture<'static, Result<()>>
Close a connection, given its connection id. This removes the corresponding endpoint from the endpoints map and also removes the peer’s endpoint so that both sides get notified of the closure. Closing an already-closed connection is a no-op (idempotent).
Source§impl Default for InMemoryConnectionProvider
impl Default for InMemoryConnectionProvider
Source§fn default() -> InMemoryConnectionProvider
fn default() -> InMemoryConnectionProvider
Auto Trait Implementations§
impl Freeze for InMemoryConnectionProvider
impl !RefUnwindSafe for InMemoryConnectionProvider
impl Send for InMemoryConnectionProvider
impl Sync for InMemoryConnectionProvider
impl Unpin for InMemoryConnectionProvider
impl UnsafeUnpin for InMemoryConnectionProvider
impl !UnwindSafe for InMemoryConnectionProvider
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request