pub struct BroadcastConfig {
pub max_subscribers_per_channel: usize,
pub max_channels: usize,
pub heartbeat_interval: Duration,
pub client_timeout: Duration,
pub allow_client_events: bool,
}Expand description
Configuration for the broadcaster.
Fields§
§max_subscribers_per_channel: usizeMaximum subscribers per channel (0 = unlimited).
max_channels: usizeMaximum channels (0 = unlimited).
heartbeat_interval: DurationHeartbeat interval for WebSocket connections.
client_timeout: DurationClient timeout (disconnect if no activity).
allow_client_events: boolWhether to allow client-to-client messages (whisper).
Implementations§
Source§impl BroadcastConfig
impl BroadcastConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create configuration from environment variables.
Reads the following environment variables:
BROADCAST_MAX_SUBSCRIBERS: Max subscribers per channel (default: unlimited)BROADCAST_MAX_CHANNELS: Max total channels (default: unlimited)BROADCAST_HEARTBEAT_INTERVAL: Heartbeat interval in seconds (default: 30)BROADCAST_CLIENT_TIMEOUT: Client timeout in seconds (default: 60)BROADCAST_ALLOW_CLIENT_EVENTS: Allow whisper messages (default: true)
§Example
ⓘ
use ferro_broadcast::BroadcastConfig;
let config = BroadcastConfig::from_env();
let broadcaster = Broadcaster::with_config(config);Sourcepub fn max_subscribers_per_channel(self, max: usize) -> Self
pub fn max_subscribers_per_channel(self, max: usize) -> Self
Set maximum subscribers per channel.
Sourcepub fn max_channels(self, max: usize) -> Self
pub fn max_channels(self, max: usize) -> Self
Set maximum channels.
Sourcepub fn heartbeat_interval(self, interval: Duration) -> Self
pub fn heartbeat_interval(self, interval: Duration) -> Self
Set heartbeat interval.
Sourcepub fn client_timeout(self, timeout: Duration) -> Self
pub fn client_timeout(self, timeout: Duration) -> Self
Set client timeout.
Sourcepub fn allow_client_events(self, allow: bool) -> Self
pub fn allow_client_events(self, allow: bool) -> Self
Set whether client events (whisper) are allowed.
Trait Implementations§
Source§impl Clone for BroadcastConfig
impl Clone for BroadcastConfig
Source§fn clone(&self) -> BroadcastConfig
fn clone(&self) -> BroadcastConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BroadcastConfig
impl Debug for BroadcastConfig
Auto Trait Implementations§
impl Freeze for BroadcastConfig
impl RefUnwindSafe for BroadcastConfig
impl Send for BroadcastConfig
impl Sync for BroadcastConfig
impl Unpin for BroadcastConfig
impl UnsafeUnpin for BroadcastConfig
impl UnwindSafe for BroadcastConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more