use std::hash::Hash;
use std::net::IpAddr;
use std::time::Duration;
use ipnet::IpNet;
use tracing::{info, instrument};
use crate::bounds::{Key, Value};
use super::ReplicatedMap;
impl<K: Key + Hash, V: Value> ReplicatedMap<K, V> {
pub async fn start_reconciliation(&self) {
let mut buf = Vec::new();
self.engine.start_reconciliation(&mut buf).await;
}
pub fn forget_peer(&self, peer: IpAddr) {
self.engine.decommission_peer(peer);
}
#[cfg(any(test, feature = "internal-testing"))]
pub fn members_snapshot(&self) -> std::collections::HashSet<std::net::IpAddr> {
self.engine.members_snapshot()
}
#[cfg(any(test, feature = "internal-testing"))]
pub fn peers_map_len(&self) -> usize {
self.engine.peers_map_len()
}
#[cfg(any(test, feature = "internal-testing"))]
pub fn replay_filter_len(&self) -> usize {
self.engine.replay_filter_len()
}
#[cfg(any(test, feature = "internal-testing"))]
pub fn tombstone_acks_len(&self) -> usize {
self.engine.tombstone_acks_len()
}
#[cfg(any(test, feature = "internal-testing"))]
pub fn bulk_dumps_in_flight_count(&self) -> usize {
self.engine.bulk_dumps_in_flight_count()
}
pub fn set_nets(&self, nets: &[IpNet]) {
self.engine.set_nets(nets);
}
#[must_use]
pub fn add_net(&self, net: IpNet) -> bool {
self.engine.add_net(net)
}
#[must_use]
pub fn remove_net(&self, net: IpNet) -> bool {
self.engine.remove_net(net)
}
pub fn nets(&self) -> Vec<IpNet> {
self.engine.nets()
}
pub fn local_net(&self) -> IpNet {
self.engine.local_net()
}
pub fn set_remote_interval(&self, interval: u32) {
self.engine.set_remote_interval(interval);
}
pub fn set_remote_fanout(&self, fanout: usize) {
self.engine.set_remote_fanout(fanout);
}
pub fn set_reconcile_interval(&self, interval: Duration) {
self.engine.set_reconcile_interval(interval);
}
#[instrument(name = "reconcile.store", skip_all)]
pub async fn run(self) {
info!("reconcile store starting");
let tombstones = self.clone();
let snapshots = self.clone();
let discovery = self.clone();
tokio::join!(
self.engine.run(),
tombstones.clear_expired_tombstones(),
snapshots.snapshot_periodically(),
discovery.discover_periodically(),
);
}
}