pub trait ServiceDiscovery: Send {
    // Required method
    fn pull_instances<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<HashSet<GroupcachePeer>, Box<dyn Error + Send + Sync + 'static>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn interval(&self) -> Duration { ... }
}
Expand description

This trait abstracts away boilerplate associated with pull-based service discovery.

groupcache periodically runs ServiceDiscovery::pull_instances and compares pulled instances with the ones it already knew about from previous invocations of ServiceDiscovery::pull_instances.

groupcache connects with new peers and disconnects with missing peers via [Groupcache::set_peers].

Required Methods§

source

fn pull_instances<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<HashSet<GroupcachePeer>, Box<dyn Error + Send + Sync + 'static>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Pulls groupcache instances from a source-of-truth system (kubernetes API server, consul etc).

Based on this function groupcache is able to update its routing table, so that it can correctly route to healthy instances and stop hitting unhealthy nodes.

Returning Error from this function will be logged by groupcache but routing table will not be updated.

Provided Methods§

source

fn interval(&self) -> Duration

Specifies duration between consecutive executions of ServiceDiscovery::pull_instances.

Implementors§