pub trait EndpointResolver: Send + Sync {
// Required method
fn resolve_endpoint<'life0, 'life1, 'async_trait>(
&'life0 self,
gear: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ResolveError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
}Expand description
Re-export so the #[toolkit::consumes]-generated wire fn can name the
resolver type as toolkit::discovery::EndpointResolver without the consuming
gear crate needing a direct toolkit-contract dependency.
Resolves a logical gear name to a live base endpoint URI.
Kept as a minimal trait here so toolkit-contract does not depend on the
service-directory SDK. The host layer (toolkit) provides an adapter over
its DirectoryClient; tests can implement it directly.
Return contract:
Ok(Some(uri))— a live instance was resolved.Ok(None)— the lookup succeeded but no live instance is registered (provider not ready yet, or every instance evicted).Err(ResolveError)— the directory backend itself failed to answer.
Both Ok(None) and Err(..) surface to the caller as a retryable
TransportError::Unresolved; the distinction exists for logging/metrics.
DirectoryResolvingClient calls this on every request so provider
churn is observed immediately. Implementations whose lookup is expensive
(e.g. an out-of-process gRPC directory) SHOULD memoize internally (short
TTL) rather than performing a network round-trip per call.
Required Methods§
Sourcefn resolve_endpoint<'life0, 'life1, 'async_trait>(
&'life0 self,
gear: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ResolveError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn resolve_endpoint<'life0, 'life1, 'async_trait>(
&'life0 self,
gear: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ResolveError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Resolve gear to a base endpoint URI (e.g. http://billing:8080).
§Errors
Returns ResolveError only when the directory backend could not be
queried; a successful query with no live instance is Ok(None).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".