pub struct SocketConfig {Show 14 fields
pub url: String,
pub mode: Mode,
pub suffix: Vec<u8>,
pub message_handler: Option<TcpMessageHandler>,
pub heartbeat: Option<(u64, Vec<u8>)>,
pub reconnect_timeout_ms: Option<u64>,
pub reconnect_delay_initial_ms: Option<u64>,
pub reconnect_delay_max_ms: Option<u64>,
pub reconnect_backoff_factor: Option<f64>,
pub reconnect_jitter_ms: Option<u64>,
pub connection_max_retries: Option<u32>,
pub reconnect_max_attempts: Option<u32>,
pub idle_timeout_ms: Option<u64>,
pub certs_dir: Option<String>,
}Expand description
Configuration for TCP socket connection.
Fields§
§url: StringThe URL to connect to.
mode: ModeThe connection mode {Plain, TLS}.
suffix: Vec<u8>The sequence of bytes which separates lines.
message_handler: Option<TcpMessageHandler>The optional function to handle incoming messages.
heartbeat: Option<(u64, Vec<u8>)>The optional heartbeat with period and beat message.
reconnect_timeout_ms: Option<u64>The timeout (milliseconds) for reconnection attempts.
reconnect_delay_initial_ms: Option<u64>The initial reconnection delay (milliseconds) for reconnects.
reconnect_delay_max_ms: Option<u64>The maximum reconnect delay (milliseconds) for exponential backoff.
reconnect_backoff_factor: Option<f64>The exponential backoff factor for reconnection delays.
reconnect_jitter_ms: Option<u64>The maximum jitter (milliseconds) added to reconnection delays.
connection_max_retries: Option<u32>The maximum number of initial connection attempts (default: 5).
reconnect_max_attempts: Option<u32>The maximum number of reconnection attempts before giving up.
None: Unlimited reconnection attempts (default, recommended for production).Some(n): After n failed attempts, transition to CLOSED state.
idle_timeout_ms: Option<u64>The idle timeout (milliseconds) for the read task. When set, the read task will break and trigger reconnection if no data is received within this duration. Useful for detecting silently dead connections where the server stops sending without closing.
certs_dir: Option<String>The path to the certificates directory.
Implementations§
Source§impl SocketConfig
impl SocketConfig
Sourcepub fn builder() -> SocketConfigBuilder
pub fn builder() -> SocketConfigBuilder
Create an instance of SocketConfig using the builder syntax
Source§impl SocketConfig
impl SocketConfig
Sourcepub fn validate(&self) -> NetworkConfigResult<()>
pub fn validate(&self) -> NetworkConfigResult<()>
Checks whether all socket settings are valid.
§Errors
Returns a NetworkConfigError if url is empty, the heartbeat interval or a
reconnection timing field is not positive, reconnect_backoff_factor is not finite and
at least 1.0, or reconnect_delay_initial_ms exceeds reconnect_delay_max_ms.