Struct reactive_messaging::prelude::ConstConfig
source · pub struct ConstConfig {
pub msg_size_hint: u32,
pub sender_buffer: u32,
pub receiver_buffer: u32,
pub graceful_close_timeout_millis: u16,
pub retrying_strategy: RetryingStrategies,
pub socket_options: SocketOptions,
pub channel: Channels,
pub executor_instruments: Instruments,
}Expand description
Implements something that could be called the “Zero-Cost Const Configuration Pattern”, that produces a usize
whose goal is to be the only const parameter of a generic struct (avoiding the alternative of bloating it with several const params).
When using the const “query functions” defined here in ifs, the compiler will have the opportunity to cancel out any unreachable code (zero-cost abstraction).
Some commonly used combinations may be pre-defined in some enum variants, but you may always build unmapped possibilities through [Self::custom()].
Usage examples:
see bellowFields§
§msg_size_hint: u32Pre-allocates the sender/receiver buffers to this value (power of 2).
Setting it wisely may economize some realloc calls
sender_buffer: u32How many messages (per peer) may be enqueued for output (power of 2) before operations start to fail
receiver_buffer: u32How many messages (per peer) may be enqueued for processing (power of 2) before operations start to fail
graceful_close_timeout_millis: u16How many milliseconds to wait before giving up waiting for a socket to close.
Set this taking SocketOptions::linger_millis into account
retrying_strategy: RetryingStrategiesSpecifies what to do when operations fail (full buffers / connection droppings)
socket_options: SocketOptionsMesses with the low level (system) socket options
channel: ChannelsAllows changing the backing queue for the sender/receiver buffers
executor_instruments: InstrumentsAllows changing the Stream executor options in regard to logging & collected/reported metrics
Implementations§
source§impl ConstConfig
impl ConstConfig
sourcepub const fn default() -> ConstConfig
pub const fn default() -> ConstConfig
Contains sane & performant defaults.
Usage example:
const CONFIG: ConstConfig = ConstConfig {
receiver_buffer: 1024,
..ConstConfig::default()
};sourcepub const fn into(self) -> u64
pub const fn into(self) -> u64
For use when instantiating a generic struct that uses the “Const Config Pattern”
– when chosing a pre-defined configuration.
See also [Self::custom()].
Example:
see bellowsourcepub const fn from(config: u64) -> Self
pub const fn from(config: u64) -> Self
Builds Self from the generic const CONFIGS: usize parameter used in structs
by the “Const Config Pattern”
pub const fn extract_receiver_buffer(config: u64) -> u32
pub const fn extract_executor_instruments(config: u64) -> usize
pub const fn extract_msg_size_hint(config: u64) -> u32
pub const fn extract_graceful_close_timeout(config: u64) -> Duration
pub const fn extract_retrying_strategy(config: u64) -> RetryingStrategies
pub const fn extract_socket_options(config: u64) -> SocketOptions
Trait Implementations§
source§impl Debug for ConstConfig
impl Debug for ConstConfig
source§impl PartialEq for ConstConfig
impl PartialEq for ConstConfig
source§fn eq(&self, other: &ConstConfig) -> bool
fn eq(&self, other: &ConstConfig) -> bool
self and other values to be equal, and is used
by ==.