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;
}Expand description
Discovery trait for service discovery across different backends
Required Methods§
Sourcefn instance_id(&self) -> u64
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.
Sourcefn 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 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
Sourcefn 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 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
Sourcefn 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<'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
Sourcefn 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,
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