Expand description
The provider contract: a discovery mechanism is a source of observations and nothing more. A provider watches one transport (a multicast group, a broadcast port, a rendezvous endpoint set), hands every datagram it hears to the manager as raw bytes, and answers for its own health. It parses nothing, verifies nothing, trusts nothing and holds no peers — the manager owns the one verification path and the one registry, which is what makes adding a provider a registration rather than a rewrite.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::provider::Beacon;
// The beacon signs this node's advertisements with one rising sequence, so every
// transmitting provider shares the replay window.
let identity = NodeIdentity::ephemeral().unwrap();
let beacon = Beacon::new(Arc::new(identity), vec!["127.0.0.1:8741".into()],
vec!["http".into()], vec![], "docs");
let first = beacon.next_envelope();
let second = beacon.next_envelope();
assert!(second.adv.seq > first.adv.seq, "the sequence only rises");Structs§
- Beacon
- What this node says about itself: the signer plus the advertised facts, with one monotonically increasing sequence shared by every transmitting provider — a reader deduplicates by (instance, seq) regardless of which transport delivered first.
- Counters
- The counters a provider’s threads share with its status.
- Observation
- One raw observation: where it came from, and the bytes as heard. Parsing and verification happen once, in the manager, for every provider alike.
- Observation
Sender - The providers’ half of the bounded queue to the manager: a send that would wait is a drop,
counted in the counter the manager reports as
overflow. - Provider
Context - What a provider gets to work with: the channel to the manager, the shared stop flag, and the beacon it announces.
- Provider
Status - One provider’s status: state, why, and its counters.
Enums§
- Mesh
Provider State - The provider’s health, as every surface reports it.
Constants§
- OBSERVATION_
QUEUE - How many observations wait for the manager at most. A flood beyond it is dropped at the provider and counted, so a segment shouting datagrams costs this process a bounded queue and one counter, never memory without end (I2133).
Traits§
- Mesh
Provider - A discovery mechanism. Implementing this — and handing an instance to the manager — is the whole registration: no consumer, surface or registry learns provider names.
Functions§
- jitter_
ms - A deterministic small jitter in
0..boundmilliseconds, from OS entropy; zero when entropy is unavailable — jitter is a nicety, never a dependency.