pub struct NetworkConfig { /* private fields */ }Expand description
Configuration builder for the network dispatcher
§Example
This example binds to local host on a free port chosen by the operating system.
use kompact::prelude::*;
use kompact_net::NetworkConfig;
let mut conf = KompactConfig::default();
conf.system_components(DeadletterBox::new, NetworkConfig::default().build());
let system = conf.build().wait().expect("system");Implementations§
Source§impl NetworkConfig
impl NetworkConfig
Sourcepub fn new(addr: SocketAddr) -> Self
pub fn new(addr: SocketAddr) -> Self
Create a new config with addr and protocol TCP
NetworkDispatcher and NetworkThread will use the default BufferConfig
Sourcepub fn with_buffer_config(addr: SocketAddr, buffer_config: BufferConfig) -> Self
pub fn with_buffer_config(addr: SocketAddr, buffer_config: BufferConfig) -> Self
Create a new config with addr and protocol TCP
Note: Only the NetworkThread and NetworkDispatcher will use the BufferConfig, not Actors
Sourcepub fn with_custom_allocator(
addr: SocketAddr,
buffer_config: BufferConfig,
custom_allocator: Arc<dyn ChunkAllocator>,
) -> Self
pub fn with_custom_allocator( addr: SocketAddr, buffer_config: BufferConfig, custom_allocator: Arc<dyn ChunkAllocator>, ) -> Self
Create a new config with addr and protocol TCP
Note: Only the NetworkThread and NetworkDispatcher will use the BufferConfig, not Actors
Sourcepub fn with_socket(self, addr: SocketAddr) -> Self
pub fn with_socket(self, addr: SocketAddr) -> Self
Replace the current socket address with addr.
Sourcepub fn build(self) -> impl Fn(KPromise<()>) -> NetworkDispatcher
pub fn build(self) -> impl Fn(KPromise<()>) -> NetworkDispatcher
Complete the configuration and provide a function that produces a network dispatcher
Returns the appropriate function type for use with system_components.
Sourcepub fn get_buffer_config(&self) -> &BufferConfig
pub fn get_buffer_config(&self) -> &BufferConfig
Returns a pointer to the configurations BufferConfig.
Sourcepub fn set_buffer_config(&mut self, buffer_config: BufferConfig)
pub fn set_buffer_config(&mut self, buffer_config: BufferConfig)
Sets the configurations BufferConfig to buffer_config
Sourcepub fn get_custom_allocator(&self) -> &Option<Arc<dyn ChunkAllocator>>
pub fn get_custom_allocator(&self) -> &Option<Arc<dyn ChunkAllocator>>
Returns a pointer to the CustomAllocator option so that it can be cloned by the caller.
Sourcepub fn get_tcp_nodelay(&self) -> bool
pub fn get_tcp_nodelay(&self) -> bool
Reads the tcp_nodelay parameter of the NetworkConfig.
Sourcepub fn set_tcp_nodelay(&mut self, nodelay: bool)
pub fn set_tcp_nodelay(&mut self, nodelay: bool)
If set to true the Nagle algorithm will be turned off for all Tcp Network-channels.
Decreases network-latency at the cost of reduced throughput and increased congestion.
Default value is false, i.e. the Nagle algorithm is turned on by default.
Sourcepub fn set_max_connection_retry_attempts(&mut self, count: u8)
pub fn set_max_connection_retry_attempts(&mut self, count: u8)
Configures how many attempts at re-establishing a connection will be made before giving up and discarding the enqueued outgoing messages.
Default value is 10 times.
Sourcepub fn get_max_connection_retry_attempts(&self) -> u8
pub fn get_max_connection_retry_attempts(&self) -> u8
Returns the number of times the system will retry before giving up on a connection.
Sourcepub fn set_connection_retry_interval(&mut self, milliseconds: u64)
pub fn set_connection_retry_interval(&mut self, milliseconds: u64)
Configures how long to wait (in ms) between attempts at establishing a connection.
Default value is 5000 ms.
Sourcepub fn get_connection_retry_interval(&self) -> u64
pub fn get_connection_retry_interval(&self) -> u64
How long (in ms) the system will wait between attempts at re-establishing connection.
Sourcepub fn set_boot_timeout(&mut self, milliseconds: u64)
pub fn set_boot_timeout(&mut self, milliseconds: u64)
Configures how long the system will wait (in ms) for the network layer to set-up
Default value is 5000 ms.
Sourcepub fn get_boot_timeout(&self) -> u64
pub fn get_boot_timeout(&self) -> u64
How long (in ms) the system will wait (in ms) for the network layer to set-up
Sourcepub fn set_soft_connection_limit(&mut self, limit: u32)
pub fn set_soft_connection_limit(&mut self, limit: u32)
Configures how many concurrent Network-connections may be active at any point in time
When the limit is exceeded the system will gracefully close the least recently used channel.
Default value is 1000 Connections.
Sourcepub fn get_soft_connection_limit(&self) -> u32
pub fn get_soft_connection_limit(&self) -> u32
How many Active Network-connections the system will allow before it starts closing least recently used
Sourcepub fn set_hard_connection_limit(&mut self, limit: u32)
pub fn set_hard_connection_limit(&mut self, limit: u32)
Configures how many concurrent Network-connections the system may have at any point.
When the limit is exceeded the system will reject all incoming and outgoing requests for new connections.
Default value is 1100 Connections.
Sourcepub fn get_hard_connection_limit(&self) -> u32
pub fn get_hard_connection_limit(&self) -> u32
How many Network-connections the system will allow before it starts closing least recently used
Trait Implementations§
Source§impl Clone for NetworkConfig
impl Clone for NetworkConfig
Source§fn clone(&self) -> NetworkConfig
fn clone(&self) -> NetworkConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more