pub struct ClusterServiceRegistry { /* private fields */ }Expand description
Cluster-wide service registry built from advertisements.
Implementations§
Source§impl ClusterServiceRegistry
impl ClusterServiceRegistry
pub fn new() -> Self
Sourcepub fn set_chain_manager(&mut self, cm: Arc<ChainManager>)
pub fn set_chain_manager(&mut self, cm: Arc<ChainManager>)
Attach a chain manager for exochain audit logging.
Sourcepub fn merge(&mut self, advert: ServiceAdvertisement)
pub fn merge(&mut self, advert: ServiceAdvertisement)
Merge a service advertisement (add or update).
Sourcepub fn resolve(&self, name: &str) -> Vec<&ServiceAdvertisement>
pub fn resolve(&self, name: &str) -> Vec<&ServiceAdvertisement>
Resolve a service by name. Returns all nodes hosting it.
Sourcepub fn resolve_preferred(
&self,
name: &str,
preferred_node: &str,
) -> Option<&ServiceAdvertisement>
pub fn resolve_preferred( &self, name: &str, preferred_node: &str, ) -> Option<&ServiceAdvertisement>
Resolve a service, preferring a specific node.
Sourcepub fn service_names(&self) -> Vec<String>
pub fn service_names(&self) -> Vec<String>
List all known service names.
Sourcepub fn remove_node(&mut self, node_id: &str)
pub fn remove_node(&mut self, node_id: &str)
Remove all services from a node.
Sourcepub fn all_advertisements(&self) -> Vec<&ServiceAdvertisement>
pub fn all_advertisements(&self) -> Vec<&ServiceAdvertisement>
Get all advertisements (for gossip).
Sourcepub fn service_count(&self) -> usize
pub fn service_count(&self) -> usize
Number of unique services.
Sourcepub fn total_advertisements(&self) -> usize
pub fn total_advertisements(&self) -> usize
Total number of advertisements (across all replicas).
Sourcepub fn resolve_round_robin(
&self,
name: &str,
counter: &AtomicU64,
) -> Option<&ServiceAdvertisement>
pub fn resolve_round_robin( &self, name: &str, counter: &AtomicU64, ) -> Option<&ServiceAdvertisement>
Resolve a service using round-robin across replicas.
The caller provides a shared atomic counter that is incremented on each call, distributing requests evenly across all nodes hosting the named service.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClusterServiceRegistry
impl RefUnwindSafe for ClusterServiceRegistry
impl Send for ClusterServiceRegistry
impl Sync for ClusterServiceRegistry
impl Unpin for ClusterServiceRegistry
impl UnsafeUnpin for ClusterServiceRegistry
impl UnwindSafe for ClusterServiceRegistry
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
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> ⓘ
Converts
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> ⓘ
Converts
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