pub struct Aggregate { /* private fields */ }Expand description
The read-only multi-city view.
Deliberately not generic and deliberately without a transport: the merge order is the part that must be deterministic and testable, and it needs no socket to be either.
Implementations§
Source§impl Aggregate
impl Aggregate
pub fn new() -> Self
Sourcepub fn attach(&mut self, upstream: Upstream)
pub fn attach(&mut self, upstream: Upstream)
Registers an upstream. Re-registering the same label replaces its settings rather than adding a second entry, so a corrected address does not silently leave the old one attached.
pub fn detach(&mut self, label: &CityLabel) -> bool
Sourcepub fn cities(&self) -> impl Iterator<Item = &Upstream>
pub fn cities(&self) -> impl Iterator<Item = &Upstream>
Every attached city, in label order. BTreeMap rather than a hash
map because iteration order reaching an interface must not depend on
hashing.
Sourcepub fn merge(streams: Vec<(CityLabel, Vec<EventRecord>)>) -> Vec<Sighting>
pub fn merge(streams: Vec<(CityLabel, Vec<EventRecord>)>) -> Vec<Sighting>
Interleaves per-city event streams into one readable sequence.
Ordering is (t, city, seq). Sequence numbers are meaningless across
cities - each Ledger numbers its own history - so time leads, and the
label breaks ties. The label is in the key rather than a tiebreak of
last resort because two cities can genuinely stamp the same
millisecond, and the merged view must still be the same twice.