pub struct Relay { /* private fields */ }Implementations§
Source§impl Relay
impl Relay
pub async fn new(state_dir: PathBuf) -> Result<Self>
pub fn router(self) -> Router
Sourcepub fn spawn_pair_sweeper(&self)
pub fn spawn_pair_sweeper(&self)
Spawn a background tokio task that runs evict_expired_pair_slots every
60 seconds. Call once after Relay::new; the handle is leaked deliberately
— process exit reaps it. Safe to skip in tests where you’d rather test
eviction inline.
Sourcepub async fn persist_counters(&self) -> Result<()>
pub async fn persist_counters(&self) -> Result<()>
Snapshot the in-process counters to <state_dir>/counters.json. Called
every 30s by spawn_counter_persister and once during graceful
shutdown so a deploy doesn’t reset the running totals.
Sourcepub async fn append_history(&self) -> Result<()>
pub async fn append_history(&self) -> Result<()>
Append one row to <state_dir>/stats-history.jsonl mirroring the
/stats endpoint at this instant. Used by /stats.html for sparklines.
File grows ~250 B per call → ~720 KB/day. A future prune wave can
roll old entries off once the history exceeds 90 days.
Sourcepub fn spawn_counter_persister(&self)
pub fn spawn_counter_persister(&self)
Spawn a background tokio task that calls persist_counters every 30s
- appends a history row on the same tick. Loss bound: counters can drift back up to 30s on crash, history can drop one row.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Relay
impl !RefUnwindSafe for Relay
impl Send for Relay
impl Sync for Relay
impl Unpin for Relay
impl UnsafeUnpin for Relay
impl !UnwindSafe for Relay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more