Skip to main content

rns_net/
event.rs

1//! Event types for the driver loop — concrete sync instantiation.
2
3pub use crate::common::event::{
4    BackboneInterfaceEntry, BackbonePeerHookEvent, BackbonePeerStateEntry, BlackholeInfo,
5    DrainStatus, HolePunchPolicy, HookInfo, InterfaceStatsResponse, LifecycleState, LinkInfoEntry,
6    LocalDestinationEntry, NextHopResponse, PathTableEntry, ProviderBridgeConsumerStats,
7    ProviderBridgeStats, QueryRequest, QueryResponse, RateTableEntry, ResourceInfoEntry,
8    RuntimeConfigApplyMode, RuntimeConfigEntry, RuntimeConfigError, RuntimeConfigErrorCode,
9    RuntimeConfigSource, RuntimeConfigValue, SingleInterfaceStat,
10};
11
12/// Concrete Event type using boxed sync Writer.
13pub type Event = crate::common::event::Event<Box<dyn crate::interface::Writer>>;
14
15pub const DEFAULT_EVENT_QUEUE_CAPACITY: usize = 8192;
16
17pub type EventSender = std::sync::mpsc::SyncSender<Event>;
18pub type EventReceiver = std::sync::mpsc::Receiver<Event>;
19
20pub fn channel() -> (EventSender, EventReceiver) {
21    channel_with_capacity(DEFAULT_EVENT_QUEUE_CAPACITY)
22}
23
24pub fn channel_with_capacity(capacity: usize) -> (EventSender, EventReceiver) {
25    std::sync::mpsc::sync_channel(capacity.max(1))
26}