pub struct ConnectionConfig {
pub url: String,
pub auth: AuthRequest,
pub connect_timeout: Duration,
pub read_timeout: Duration,
pub tls: TlsConfig,
pub message_buffer: usize,
pub event_buffer: usize,
pub client_id: Option<String>,
}Expand description
Configuration for WebSocket connection.
Debug is implemented manually so embedded credentials cannot leak.
The auth field is rendered as <redacted> and any query-string
parameter on url whose name case-insensitively matches a known
secret key (token, key, apikey, api_key, secret, password)
has its value replaced with ***.
Fields§
§url: StringWebSocket endpoint URL
auth: AuthRequestAuthentication credentials
connect_timeout: DurationConnection timeout (default: 30 seconds)
read_timeout: DurationRead timeout for messages (default: 30 seconds)
tls: TlsConfigOptional TLS customization (custom CA / accept invalid certs). Default means “use the OS trust store” — identical to pre-3.0.1 behaviour.
message_buffer: usizeCapacity of the inbound message channel that backs messages() and
message_stream(). Defaults to DEFAULT_MESSAGE_BUFFER. Use
ConnectionConfigBuilder::message_buffer to override.
event_buffer: usizeCapacity of the lifecycle event channel that backs events() and
state_events(). Defaults to DEFAULT_EVENT_BUFFER. Use
ConnectionConfigBuilder::event_buffer to override.
client_id: Option<String>Optional caller-supplied identifier used as a metric label on the
metrics feature. Defaults to None. Low-cardinality only —
suitable for deployment / instance / service identifiers, never for
per-request UUIDs (Prometheus storage explodes on high-cardinality
labels). Values longer than CLIENT_ID_MAX_LEN are truncated by
the builder.
Implementations§
Source§impl ConnectionConfig
impl ConnectionConfig
Sourcepub fn new(url: impl Into<String>, auth: AuthRequest) -> ConnectionConfig
pub fn new(url: impl Into<String>, auth: AuthRequest) -> ConnectionConfig
Create a new connection configuration
Sourcepub fn builder(
url: impl Into<String>,
auth: AuthRequest,
) -> ConnectionConfigBuilder
pub fn builder( url: impl Into<String>, auth: AuthRequest, ) -> ConnectionConfigBuilder
Create a builder for fluent configuration
Sourcepub fn client_id(&self) -> Option<&str>
pub fn client_id(&self) -> Option<&str>
Caller-supplied identifier used as a metric label, or None if
unset. See ConnectionConfigBuilder::client_id.
Sourcepub fn fugle_stock(auth: AuthRequest) -> ConnectionConfig
pub fn fugle_stock(auth: AuthRequest) -> ConnectionConfig
Create configuration for Fugle stock WebSocket endpoint
§Example
use marketdata_core::websocket::ConnectionConfig;
use marketdata_core::AuthRequest;
let config = ConnectionConfig::fugle_stock(
AuthRequest::with_api_key("my-api-key")
);
assert_eq!(config.url, "wss://api.fugle.tw/marketdata/v1.0/stock/streaming");Sourcepub fn fugle_futopt(auth: AuthRequest) -> ConnectionConfig
pub fn fugle_futopt(auth: AuthRequest) -> ConnectionConfig
Create configuration for Fugle futures/options WebSocket endpoint
§Example
use marketdata_core::websocket::ConnectionConfig;
use marketdata_core::AuthRequest;
let config = ConnectionConfig::fugle_futopt(
AuthRequest::with_api_key("my-api-key")
);
assert_eq!(config.url, "wss://api.fugle.tw/marketdata/v1.0/futopt/streaming");Trait Implementations§
Source§impl Clone for ConnectionConfig
impl Clone for ConnectionConfig
Source§fn clone(&self) -> ConnectionConfig
fn clone(&self) -> ConnectionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more