#[cfg(feature = "preview")]
use tokio::time::{Duration, Instant};
#[cfg(feature = "preview")]
use tokio_util::time::delay_queue;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(crate) struct SyncPeer {
pub(super) addr: super::Addr,
pub(super) graph_id: super::GraphId,
}
impl SyncPeer {
pub(crate) const fn new(addr: super::Addr, graph_id: super::GraphId) -> Self {
Self { addr, graph_id }
}
pub(crate) fn check_request(&self, message_id: super::GraphId) -> Result<(), super::Error> {
match self.graph_id.as_bytes() == message_id.as_bytes() {
true => Ok(()),
false => Err(super::Error::Transport(
anyhow::anyhow!("The message's GraphId doesn't match the current GraphId!").into(),
)),
}
}
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub(crate) enum SyncResponse {
Ok(Box<[u8]>),
Err(String),
}
#[cfg(feature = "preview")]
#[derive(Debug, Clone)]
pub(crate) struct HelloSubscription {
pub(super) graph_change_debounce: Duration,
pub(super) schedule_delay: Duration,
pub(super) last_notified: Instant,
pub(super) expires_at: Instant,
pub(super) queue_key: delay_queue::Key,
}