pub struct Bridge { /* private fields */ }Expand description
Bridge to Network Threads. Routes outbound messages to the correct network thread. Single threaded for now.
Implementations§
Source§impl Bridge
impl Bridge
Sourcepub fn new(
lookup: Arc<ArcSwap<ActorStore>>,
network_thread_log: KompactLogger,
bridge_log: KompactLogger,
addr: SocketAddr,
dispatcher_ref: DispatcherRef,
network_config: &NetworkConfig,
) -> (Self, SocketAddr)
pub fn new( lookup: Arc<ArcSwap<ActorStore>>, network_thread_log: KompactLogger, bridge_log: KompactLogger, addr: SocketAddr, dispatcher_ref: DispatcherRef, network_config: &NetworkConfig, ) -> (Self, SocketAddr)
Creates a new bridge
§Returns
A tuple consisting of the new Bridge object and the network event receiver. The receiver will allow responding to [NetworkEvent]s for external state management.
Sourcepub fn set_dispatcher(
&mut self,
dispatcher: DispatcherRef,
) -> Option<DispatcherRef>
pub fn set_dispatcher( &mut self, dispatcher: DispatcherRef, ) -> Option<DispatcherRef>
Sets the dispatcher reference, returning the previously stored one
Sourcepub fn stop(self) -> Result<(), NetworkBridgeError>
pub fn stop(self) -> Result<(), NetworkBridgeError>
Stops the bridge gracefully
Sourcepub fn kill(self) -> Result<(), NetworkBridgeError>
pub fn kill(self) -> Result<(), NetworkBridgeError>
Kills the Network
Sourcepub fn local_addr(&self) -> &Option<SocketAddr>
pub fn local_addr(&self) -> &Option<SocketAddr>
Returns the local address if already bound
Sourcepub fn connect(
&self,
proto: Transport,
addr: SocketAddr,
) -> Result<(), NetworkBridgeError>
pub fn connect( &self, proto: Transport, addr: SocketAddr, ) -> Result<(), NetworkBridgeError>
Attempts to establish a TCP connection to the provided addr.
§Side effects
When the connection is successul:
- a ConnectionState::Connected is dispatched on the network bridge event queue
- NetworkThread will listen for incoming messages and write outgoing messages on the channel
§Errors
If the provided protocol is not supported
Sourcepub fn ack_closed(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
pub fn ack_closed(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
Acknowledges a closed channel, required to ensure FIFO ordering under connection loss
Sourcepub fn close_channel(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
pub fn close_channel(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
Requests that the NetworkThread should be closed
Sourcepub fn block_socket(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
pub fn block_socket(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
Requests the NetworkThread to block the socket addr
Sourcepub fn block_ip(&self, ip_addr: IpAddr) -> Result<(), NetworkBridgeError>
pub fn block_ip(&self, ip_addr: IpAddr) -> Result<(), NetworkBridgeError>
Requests the NetworkThread to block the ip address ip_addr
Sourcepub fn block_ip_net(&self, ip_net: IpNet) -> Result<(), NetworkBridgeError>
pub fn block_ip_net(&self, ip_net: IpNet) -> Result<(), NetworkBridgeError>
Requests the NetworkThread to block the ip subnet ip_net
Sourcepub fn allow_socket(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
pub fn allow_socket(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>
Requests the NetworkThread to unblock the socket addr
Sourcepub fn allow_ip(&self, ip_addr: IpAddr) -> Result<(), NetworkBridgeError>
pub fn allow_ip(&self, ip_addr: IpAddr) -> Result<(), NetworkBridgeError>
Requests the NetworkThread to unblock the ip address ip_addr
Sourcepub fn allow_ip_net(&self, ip_net: IpNet) -> Result<(), NetworkBridgeError>
pub fn allow_ip_net(&self, ip_net: IpNet) -> Result<(), NetworkBridgeError>
Requests the NetworkThread to unblock the ip subnet ip_net