Struct brane_tsk::caches::DomainRegistryCache
source · pub struct DomainRegistryCache { /* private fields */ }
Expand description
A cache for storing the local registry address of a particular domain.
Implementations§
source§impl DomainRegistryCache
impl DomainRegistryCache
sourcepub fn new(api_address: impl Into<Address>) -> Self
pub fn new(api_address: impl Into<Address>) -> Self
Constructor for the DomainRegistryCache that uses the default timeout.
See DEFAULT_DOMAIN_REGISTRY_CACHE_TIMEOUT
to find what the current default is.
§Arguments
api_address
: The address of a remote centralizedbrane-api
registry that knows an up-to-date mapping of locations to local registries.
§Returns
A new DomainRegistryCache instance.
sourcepub fn with_timeout(
timeout: impl AsPrimitive<u64>,
api_address: impl Into<Address>,
) -> Self
pub fn with_timeout( timeout: impl AsPrimitive<u64>, api_address: impl Into<Address>, ) -> Self
Constructor for the DomainRegistryCache.
§Arguments
timeout
: A timeout (in seconds) that determines after how long entries in the cache become stale.api_address
: The address of a remote centralizedbrane-api
registry that knows an up-to-date mapping of locations to local registries.
§Returns
A new DomainRegistryCache instance.
sourcepub async fn get<'s>(
&'s self,
location: &Location,
) -> Result<Address, DomainRegistryCacheError>
pub async fn get<'s>( &'s self, location: &Location, ) -> Result<Address, DomainRegistryCacheError>
Resolves a given location identifier to an address.
If we know the mapping already (and it isn’t stale), then the in-memory cached address is returned.
Else, a query is made to the API address that is given in this type’s constructor.
§Arguments
location
: TheLocation
ID to search for.
§Returns
A reference to the address of the location.
§Errors
This function may error if we had to retrieve the address from the remote registry but failed.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DomainRegistryCache
impl !RefUnwindSafe for DomainRegistryCache
impl Send for DomainRegistryCache
impl Sync for DomainRegistryCache
impl Unpin for DomainRegistryCache
impl UnwindSafe for DomainRegistryCache
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request