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,
}
pub(crate) struct TopicState {
pub(crate) sender: Sender<SseEvent>,
pub(crate) replay: VecDeque<(u64, SseEvent)>,
}
pub(crate) struct SseHubInner {
pub(crate) config: SseConfig,
pub(crate) next_seq: AtomicU64,
pub(crate) topics: Mutex<HashMap<String, TopicState>>,
}
#[derive(Clone)]
pub struct SseHub {
pub(crate) inner: Arc<SseHubInner>,
}
pub struct SseSubscription {
pub(crate) topic: String,
pub(crate) hub: Arc<SseHubInner>,
pub(crate) replayed: VecDeque<SseEvent>,
pub(crate) receiver: Receiver<SseEvent>,
}
pub struct SseStream;
#[derive(Clone)]
pub struct SsePlugin {
pub(crate) config: SseConfig,
pub(crate) hub: SseHub,
}