pub trait Discovery: Send + Sync {
// Required methods
fn instance_id(&self) -> u64;
fn register_internal<'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 methods
fn check_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 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 { ... }
fn update_model_taints<'life0, 'async_trait>(
&'life0 self,
id: ModelCardInstanceId,
taints: HashSet<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn update_model_taints_internal<'life0, 'async_trait>(
&'life0 self,
_id: ModelCardInstanceId,
_taints: HashSet<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn shutdown(&self) { ... }
}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) Endpoint and model objects created by this worker use this ID. Event channels and sources use a publisher-level ID because a worker can own more than one publisher for the same topic.
Sourcefn register_internal<'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_internal<'life0, 'async_trait>(
&'life0 self,
spec: DiscoverySpec,
) -> Pin<Box<dyn Future<Output = Result<DiscoveryInstance>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Backend-specific raw registration implementation.
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 for the given discovery query
The watch is established before this returns. A backend still initializing waits for it, and fails the call if that initialization ends first.
The stream starts with the state at establishment: one Added per matching instance,
then one DiscoveryEvent::Resync holding the same set, empty when nothing matches.
Later changes follow that Resync, which never replays over them.
A backend that falls behind sends the changes it missed, then one Resync of the full
set. A change that started and ended inside the gap is not reported.
Replace any state held from an earlier stream or a Discovery::list call on every
Resync. Instances that left are absent from it, with no Removed event to report them.
The optional cancellation token can be used to stop the watch stream
Provided Methods§
Sourcefn check_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn check_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Probe required discovery connectivity without registering a worker. In-process implementations have no remote dependency. Remote backends override this with a read against their authoritative store.
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 update_model_taints<'life0, 'async_trait>(
&'life0 self,
id: ModelCardInstanceId,
taints: HashSet<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_model_taints<'life0, 'async_trait>(
&'life0 self,
id: ModelCardInstanceId,
taints: HashSet<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Replace the caller-managed taints of this worker’s existing base model card.
Sourcefn update_model_taints_internal<'life0, 'async_trait>(
&'life0 self,
_id: ModelCardInstanceId,
_taints: HashSet<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_model_taints_internal<'life0, 'async_trait>(
&'life0 self,
_id: ModelCardInstanceId,
_taints: HashSet<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Backend-specific authoritative read, taint-only mutation, and persistence.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".