ServerConfig
2025年9月7日大约 1 分钟hyperlanewebrusttypeserver-config
提示
hyperlane
框架的 ServerConfig
相关类型定义如下
/// A type alias for a `Result<ServerConfig, serde_json::Error>`.
///
/// This is used for operations that can fail during `ServerConfig` deserialization.
pub type ServerConfigResult = Result<ServerConfig, serde_json::Error>;
/// A type alias for `RwLockReadGuard<'a, ServerConfigInner>`.
///
/// This provides read-only access to the `ServerConfigInner` wrapped in a `RwLock`.
pub(crate) type RwLockReadGuardServerConfigInner<'a> = RwLockReadGuard<'a, ServerConfigInner>;
/// A type alias for `RwLockWriteGuard<'a, ServerConfigInner>`.
///
/// This provides mutable access to the `ServerConfigInner` wrapped in a `RwLock`.
pub(crate) type RwLockWriteGuardServerConfigInner<'a> = RwLockWriteGuard<'a, ServerConfigInner>;
/// Represents the inner, mutable server configuration.
///
/// This structure holds all the settings for the HTTP and WebSocket server,
/// including network parameters and buffer sizes. It is not intended to be used directly
/// by end-users, but rather through the `ServerConfig` wrapper.
#[derive(Clone, Data, CustomDebug, DisplayDebug, PartialEq, Eq, Deserialize, Serialize)]
pub(crate) struct ServerConfigInner {
/// The host address the server will bind to.
#[get(pub(crate))]
#[get_mut(pub(super))]
#[set(pub(super))]
pub(super) host: String,
/// The port number the server will listen on.
#[get(pub(crate))]
#[get_mut(pub(super))]
#[set(pub(super))]
pub(super) port: usize,
/// The buffer size for WebSocket connections.
#[get(pub(crate))]
#[get_mut(pub(super))]
#[set(pub(super))]
pub(super) ws_buffer: usize,
/// The buffer size for HTTP connections.
#[get(pub(crate))]
#[get_mut(pub(super))]
#[set(pub(super))]
pub(super) http_buffer: usize,
/// The `TCP_NODELAY` option for sockets.
#[get(pub(crate))]
#[get_mut(pub(super))]
#[set(pub(super))]
pub(super) nodelay: OptionBool,
/// The `SO_LINGER` option for sockets.
#[get(pub(crate))]
#[get_mut(pub(super))]
#[set(pub(super))]
pub(super) linger: OptionDuration,
/// The `IP_TTL` option for sockets.
#[get(pub(crate))]
#[get_mut(pub(super))]
#[set(pub(super))]
pub(super) ttl: OptionU32,
}
/// Represents the thread-safe, shareable server configuration.
///
/// This structure wraps `ServerConfigInner` in an `Arc<RwLock<ServerConfigInner>>`
/// to allow for safe concurrent access and modification of the server settings.
#[derive(Clone, Getter, CustomDebug, DisplayDebug)]
pub struct ServerConfig(#[get(pub(super))] pub(super) ArcRwLockServerConfigInner);