pub struct NetworkManager { /* private fields */ }Expand description
Network connection manager
Implementations§
Source§impl NetworkManager
impl NetworkManager
Sourcepub fn new(node_id: OxirsNodeId, config: NetworkConfig) -> Self
pub fn new(node_id: OxirsNodeId, config: NetworkConfig) -> Self
Create a new network manager
Sourcepub async fn with_tls(
node_id: OxirsNodeId,
config: NetworkConfig,
) -> Result<Self>
pub async fn with_tls( node_id: OxirsNodeId, config: NetworkConfig, ) -> Result<Self>
Create a new network manager with TLS support
Sourcepub async fn register_peer(&self, node_id: OxirsNodeId, address: SocketAddr)
pub async fn register_peer(&self, node_id: OxirsNodeId, address: SocketAddr)
Register (or update) the network address of a peer node so that address-less send paths can resolve a real endpoint.
Sourcepub async fn send_rpc(
&self,
peer_id: OxirsNodeId,
peer_address: SocketAddr,
message: RpcMessage,
) -> Result<RpcMessage>
pub async fn send_rpc( &self, peer_id: OxirsNodeId, peer_address: SocketAddr, message: RpcMessage, ) -> Result<RpcMessage>
Send RPC message to a peer
Sourcepub async fn send_message(
&self,
node_id: OxirsNodeId,
message: RpcMessage,
) -> Result<()>
pub async fn send_message( &self, node_id: OxirsNodeId, message: RpcMessage, ) -> Result<()>
Send a message to node_id using a previously registered address (or a
live connection’s address). Returns an explicit error when no address is
known — the message is never silently dropped or fabricated as delivered.
Sourcepub async fn send_request_vote(
&self,
peer_id: OxirsNodeId,
peer_address: SocketAddr,
term: u64,
last_log_index: u64,
last_log_term: u64,
) -> Result<(u64, bool)>
pub async fn send_request_vote( &self, peer_id: OxirsNodeId, peer_address: SocketAddr, term: u64, last_log_index: u64, last_log_term: u64, ) -> Result<(u64, bool)>
Send request vote RPC
Sourcepub async fn send_append_entries(
&self,
peer_id: OxirsNodeId,
peer_address: SocketAddr,
term: u64,
prev_log_index: u64,
prev_log_term: u64,
entries: Vec<LogEntry>,
leader_commit: u64,
) -> Result<(u64, bool, u64)>
pub async fn send_append_entries( &self, peer_id: OxirsNodeId, peer_address: SocketAddr, term: u64, prev_log_index: u64, prev_log_term: u64, entries: Vec<LogEntry>, leader_commit: u64, ) -> Result<(u64, bool, u64)>
Send append entries RPC
Sourcepub async fn send_heartbeat(
&self,
term: u64,
peers: &[(OxirsNodeId, SocketAddr)],
)
pub async fn send_heartbeat( &self, term: u64, peers: &[(OxirsNodeId, SocketAddr)], )
Send heartbeat to all peers
Sourcepub async fn handle_inbound(&self, message: RpcMessage) -> Result<RpcMessage>
pub async fn handle_inbound(&self, message: RpcMessage) -> Result<RpcMessage>
Produce the response for an inbound RpcMessage received on the
accept loop. Answers latency-sensitive protocol messages directly (a
Heartbeat gets a real HeartbeatResponse, which is what makes peer
health probes work), returns conservative defaults for consensus
messages a bare network layer cannot decide, and fails loud for
operations that require a wired-up handler (shard/migration) instead of
fabricating a success. This is the single source of truth for inbound
handling; NetworkService::handle_message delegates here.
Sourcepub async fn get_stats(&self) -> NetworkStats
pub async fn get_stats(&self) -> NetworkStats
Get connection statistics
Sourcepub async fn send_secure_rpc(
&self,
peer_id: OxirsNodeId,
peer_address: SocketAddr,
message: RpcMessage,
) -> Result<RpcMessage>
pub async fn send_secure_rpc( &self, peer_id: OxirsNodeId, peer_address: SocketAddr, message: RpcMessage, ) -> Result<RpcMessage>
Send encrypted RPC message to a peer using TLS
Sourcepub async fn get_message_stats(&self) -> MessageStats
pub async fn get_message_stats(&self) -> MessageStats
Get message statistics
Sourcepub async fn reset_stats(&self)
pub async fn reset_stats(&self)
Reset message statistics
Sourcepub async fn get_tls_status(&self) -> Result<TlsStatus>
pub async fn get_tls_status(&self) -> Result<TlsStatus>
Check TLS certificate status
Trait Implementations§
Source§impl Clone for NetworkManager
impl Clone for NetworkManager
Auto Trait Implementations§
impl !Freeze for NetworkManager
impl !RefUnwindSafe for NetworkManager
impl !UnwindSafe for NetworkManager
impl Send for NetworkManager
impl Sync for NetworkManager
impl Unpin for NetworkManager
impl UnsafeUnpin for NetworkManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreimpl<T> MaybeDebug for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.