use super::*;
#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
pub struct SseEvent {
#[get(type(clone))]
pub(crate) id: Option<String>,
#[get(type(clone))]
pub(crate) event: Option<String>,
pub(crate) data: String,
#[get(type(copy))]
pub(crate) retry: Option<u64>,
#[get(type(clone))]
pub(crate) comment: Option<String>,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct SseConfig {
#[get(type(copy))]
pub(crate) heartbeat_ms: u64,
#[get(type(copy))]
pub(crate) retry_ms: u64,
#[get(type(copy))]
pub(crate) replay_capacity: usize,
#[get(type(copy))]
pub(crate) channel_capacity: usize,
#[get(type(copy))]
pub(crate) max_topics: usize,
}
#[derive(Clone, Copy, Default)]
pub(crate) struct FxHasher {
pub(crate) state: u64,
}
#[repr(align(64))]
pub(crate) struct SseShard {
pub(crate) map: RwLock<SseShardMap>,
}
pub(crate) struct SharedSseEvent {
pub(crate) event: SseEvent,
pub(crate) encoded: OnceLock<Box<[u8]>>,
}
pub(crate) struct TopicState {
pub(crate) subscribers: AtomicUsize,
pub(crate) sender: Sender<Arc<SharedSseEvent>>,
pub(crate) replay: Mutex<SseReplayQueue>,
}
pub(crate) struct SseHubInner {
pub(crate) config: SseConfig,
pub(crate) next_seq: AtomicU64,
pub(crate) active_topics: AtomicUsize,
pub(crate) shards: Box<[SseShard; SSE_SHARD_COUNT]>,
}
#[derive(Clone)]
pub struct SseHub {
pub(crate) inner: Arc<SseHubInner>,
}
pub struct SseSubscription {
pub(crate) topic: String,
pub(crate) state: Arc<TopicState>,
pub(crate) hub: Arc<SseHubInner>,
pub(crate) replayed: VecDeque<Arc<SharedSseEvent>>,
pub(crate) receiver: Receiver<Arc<SharedSseEvent>>,
}
pub struct SseStream;
#[derive(Clone)]
pub struct SsePlugin {
pub(crate) config: SseConfig,
pub(crate) hub: SseHub,
}