pub struct TopologySnapshot {
pub peer_addr: SocketAddr,
pub location: f64,
pub contracts: HashMap<ContractInstanceId, ContractSubscription>,
pub active_subscription_keys: HashSet<ContractInstanceId>,
pub timestamp_nanos: u64,
pub connection_count: usize,
}Expand description
A snapshot of a peer’s complete subscription topology.
Fields§
§peer_addr: SocketAddrThe peer’s socket address
location: f64The peer’s ring location (for proximity analysis)
contracts: HashMap<ContractInstanceId, ContractSubscription>Subscriptions per contract
active_subscription_keys: HashSet<ContractInstanceId>Keys present in this peer’s HostingManager::active_subscriptions map.
Unlike the contracts map (which is merged with the hosting cache and
may hide active-subscription presence behind is_hosting=true), this
field is a direct projection of active_subscriptions with no merge.
Tests that need to detect whether a peer installed a subscription
lease — as opposed to merely caching the contract — should read this.
timestamp_nanos: u64Timestamp when this snapshot was taken (for staleness detection)
connection_count: usizeThe peer’s current established ring-connection count at snapshot time.
Stamped by the snapshot registration sites (which hold the live
ConnectionManager), not by generate_topology_snapshot (which runs on
the HostingManager and has no connection view). 0 when unstamped.
Used as a join/peer_ready progress signal — unlike snapshot presence
(gated only on get_own_addr(), which is the bind address and set
early), a non-zero connection count means the peer has completed at least
one handshake and can originate operations. See
SimNetwork::wait_for_join_convergence_before_ops.
Implementations§
Source§impl TopologySnapshot
impl TopologySnapshot
Sourcepub fn new(peer_addr: SocketAddr, location: f64) -> Self
pub fn new(peer_addr: SocketAddr, location: f64) -> Self
Create a new empty topology snapshot for a peer.
Sourcepub fn set_contract(
&mut self,
contract_id: ContractInstanceId,
subscription: ContractSubscription,
)
pub fn set_contract( &mut self, contract_id: ContractInstanceId, subscription: ContractSubscription, )
Add or update a contract subscription.
Sourcepub fn get_contract(
&self,
contract_id: &ContractInstanceId,
) -> Option<&ContractSubscription>
pub fn get_contract( &self, contract_id: &ContractInstanceId, ) -> Option<&ContractSubscription>
Get the subscription for a contract.
Sourcepub fn has_upstream(&self, contract_id: &ContractInstanceId) -> bool
pub fn has_upstream(&self, contract_id: &ContractInstanceId) -> bool
Check if this peer has an upstream for a contract.
Sourcepub fn is_hosting(&self, contract_id: &ContractInstanceId) -> bool
pub fn is_hosting(&self, contract_id: &ContractInstanceId) -> bool
Check if this peer is hosting a contract.
Trait Implementations§
Source§impl Clone for TopologySnapshot
impl Clone for TopologySnapshot
Source§fn clone(&self) -> TopologySnapshot
fn clone(&self) -> TopologySnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TopologySnapshot
impl RefUnwindSafe for TopologySnapshot
impl Send for TopologySnapshot
impl Sync for TopologySnapshot
impl Unpin for TopologySnapshot
impl UnsafeUnpin for TopologySnapshot
impl UnwindSafe for TopologySnapshot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more