Skip to main content

Bridge

Struct Bridge 

Source
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

Source

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.

Source

pub fn set_dispatcher( &mut self, dispatcher: DispatcherRef, ) -> Option<DispatcherRef>

Sets the dispatcher reference, returning the previously stored one

Source

pub fn stop(self) -> Result<(), NetworkBridgeError>

Stops the bridge gracefully

Source

pub fn kill(self) -> Result<(), NetworkBridgeError>

Kills the Network

Source

pub fn local_addr(&self) -> &Option<SocketAddr>

Returns the local address if already bound

Source

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

Source

pub fn ack_closed(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>

Acknowledges a closed channel, required to ensure FIFO ordering under connection loss

Source

pub fn close_channel(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>

Requests that the NetworkThread should be closed

Source

pub fn block_socket(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>

Requests the NetworkThread to block the socket addr

Source

pub fn block_ip(&self, ip_addr: IpAddr) -> Result<(), NetworkBridgeError>

Requests the NetworkThread to block the ip address ip_addr

Source

pub fn block_ip_net(&self, ip_net: IpNet) -> Result<(), NetworkBridgeError>

Requests the NetworkThread to block the ip subnet ip_net

Source

pub fn allow_socket(&self, addr: SocketAddr) -> Result<(), NetworkBridgeError>

Requests the NetworkThread to unblock the socket addr

Source

pub fn allow_ip(&self, ip_addr: IpAddr) -> Result<(), NetworkBridgeError>

Requests the NetworkThread to unblock the ip address ip_addr

Source

pub fn allow_ip_net(&self, ip_net: IpNet) -> Result<(), NetworkBridgeError>

Requests the NetworkThread to unblock the ip subnet ip_net

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<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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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

Source§

impl<T> Erased for T