lynn_tcp 1.2.5

Lightweight asynchronous TCP framework
Documentation
use std::{
    net::SocketAddr,
    sync::{LazyLock, OnceLock},
};

pub(crate) const DEFAULT_ADDR: LazyLock<SocketAddr> = LazyLock::new(|| {
    let addr = DEFAULT_IPV4.parse::<SocketAddr>().unwrap();
    addr
});
/// The default server address.
pub(crate) const DEFAULT_IPV4: &str = "0.0.0.0:9177";
/// The maximum number of connections allowed by the server.
pub(crate) const DEFAULT_MAX_CONNECTIONS: usize = 1000;
/// The maximum number of threads allowed by the server.
pub(crate) const DEFAULT_MAX_REACTOR_TASKPOOL_SIZE: usize = 512;
/// The default maximum receive data size for a single client in bytes.
pub(crate) const DEFAULT_MAX_RECEIVE_BYTES_SIZE: usize = 1024 * 1;
/// The default system channel size, used to store the maximum number of messages that can be buffered in the system channel.
pub(crate) const DEFAULT_SYSTEM_CHANNEL_SIZE: usize = 64;
/// The default maximum processing permit size for a single client.
/// Assuming the single processing delay is controlled within 100ms, the server allows processing at least 14 requests from a single client within 100ms.
pub(crate) const DEFAULT_PROCESS_PERMIT_SIZE: usize = 14;
/// The interval for heartbeat detection in seconds.
pub(crate) const DEFAULT_CHECK_HEART_INTERVAL: u64 = 5;
/// The timeout time for heartbeat detection in seconds.
pub(crate) const DEFAULT_CHECK_HEART_TIMEOUT_TIME: u64 = 30;
/// The default message header mark, used to identify the start of a message.
pub(crate) const DEFAULT_MESSAGE_HEADER_MARK: u16 = 9177;
/// The default message tail mark, used to identify the end of a message.
pub(crate) const DEFAULT_MESSAGE_TAIL_MARK: u16 = 7719;
/// A OnceLock for the server message header mark, used to store the message header mark for the server.
pub(crate) static SERVER_MESSAGE_HEADER_MARK: OnceLock<u16> = OnceLock::new();
/// A OnceLock for the server message tail mark, used to store the message tail mark for the server.
pub(crate) static SERVER_MESSAGE_TAIL_MARK: OnceLock<u16> = OnceLock::new();
/// The default maximum number of connections allowed per IP address.
pub(crate) const DEFAULT_MAX_CONNECTIONS_PER_IP: usize = 10;
/// The default connection rate limit (connections per second). 0 means no limit.
pub(crate) const DEFAULT_CONNECTION_RATE_LIMIT: u64 = 100;
/// The default TCP_NODELAY setting.
pub(crate) const DEFAULT_TCP_NODELAY: bool = true;
/// The default TCP keep-alive enabled setting.
pub(crate) const DEFAULT_TCP_KEEPALIVE_ENABLED: bool = false;
/// The default TCP keep-alive time in seconds.
pub(crate) const DEFAULT_TCP_KEEPALIVE_TIME_SECS: u64 = 60;
/// The default read timeout in seconds. 0 means no timeout.
pub(crate) const DEFAULT_READ_TIMEOUT_SECS: u64 = 0;
/// The default write timeout in seconds. 0 means no timeout.
pub(crate) const DEFAULT_WRITE_TIMEOUT_SECS: u64 = 0;
/// The default receive buffer size in bytes.
pub(crate) const DEFAULT_RECV_BUFFER_SIZE: usize = 8192;
/// The default send buffer size in bytes.
pub(crate) const DEFAULT_SEND_BUFFER_SIZE: usize = 8192;