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;
// Provided methods
fn resolve_grpc_endpoint<'life0, 'life1, 'async_trait>(
&'life0 self,
_service: &'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_target<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 ResolveTarget,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ResolveError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn invalidate(&self, _target: &ResolveTarget) { ... }
}Expand description
Resolves a logical gear name or gRPC service 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, and drop the
memoized answer in invalidate.
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).
Provided Methods§
Sourcefn resolve_grpc_endpoint<'life0, 'life1, 'async_trait>(
&'life0 self,
_service: &'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_grpc_endpoint<'life0, 'life1, 'async_trait>(
&'life0 self,
_service: &'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 a gRPC service (package.Service) to the base URI of a
channel serving it. The default resolves nothing, so a resolver that
predates gRPC consumers keeps them unresolved rather than misrouted.
§Errors
As resolve_endpoint.
Sourcefn resolve_target<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 ResolveTarget,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ResolveError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn resolve_target<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 ResolveTarget,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ResolveError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn invalidate(&self, _target: &ResolveTarget)
fn invalidate(&self, _target: &ResolveTarget)
Forget any memoized answer for target: its endpoint just failed. The
default does nothing (a resolver that does not memoize).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".