Skip to main content

Discovery

Trait Discovery 

Source
pub trait Discovery: Send + Sync {
    // Required methods
    fn instance_id(&self) -> u64;
    fn register<'life0, 'async_trait>(
        &'life0 self,
        spec: DiscoverySpec,
    ) -> Pin<Box<dyn Future<Output = Result<DiscoveryInstance>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn unregister<'life0, 'async_trait>(
        &'life0 self,
        instance: DiscoveryInstance,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
        query: DiscoveryQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<DiscoveryInstance>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_and_watch<'life0, 'async_trait>(
        &'life0 self,
        query: DiscoveryQuery,
        cancel_token: Option<CancellationToken>,
    ) -> Pin<Box<dyn Future<Output = Result<DiscoveryStream>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn shutdown(&self) { ... }
}
Expand description

Discovery trait for service discovery across different backends

Required Methods§

Source

fn instance_id(&self) -> u64

Returns a unique identifier for this worker (e.g lease id if using etcd or generated id for memory store) Discovery objects created by this worker will be associated with this id.

Source

fn register<'life0, 'async_trait>( &'life0 self, spec: DiscoverySpec, ) -> Pin<Box<dyn Future<Output = Result<DiscoveryInstance>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Registers an object in the discovery plane with the instance id

Source

fn unregister<'life0, 'async_trait>( &'life0 self, instance: DiscoveryInstance, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Unregisters an instance from the discovery plane

Source

fn list<'life0, 'async_trait>( &'life0 self, query: DiscoveryQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<DiscoveryInstance>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a list of currently registered instances for the given discovery query This is a one-time snapshot without watching for changes

Source

fn list_and_watch<'life0, 'async_trait>( &'life0 self, query: DiscoveryQuery, cancel_token: Option<CancellationToken>, ) -> Pin<Box<dyn Future<Output = Result<DiscoveryStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a stream of discovery events (Added/Removed) for the given discovery query The optional cancellation token can be used to stop the watch stream

Provided Methods§

Source

fn shutdown(&self)

Clean up resources held by this discovery backend. For KV store backends, this deletes owned registrations immediately rather than waiting for TTL expiry. Default is a no-op for backends that don’t need cleanup.

Implementors§