Struct splinter::registry::RemoteYamlRegistry
source · [−]pub struct RemoteYamlRegistry { /* private fields */ }
Expand description
A remote, read-only registry.
The RemoteYamlRegistry
provides access to a remote registry YAML file over HTTP(S). The remote
registry file must be a YAML sequence of nodes, where each node is valid (see Node
for
validity criteria). Read operations are provided by the RegistryReader
implementation.
The remote YAML file is cached locally by saving it to the filesystem. This ensures that the
registry will remain available even if the remote file becomes unreachable. The on-disk
location of the local cache is determined by the cache_dir
argument of the registry’s
constructor
.
On initialization, the RemoteYamlRegistry
will attempt to immediately fetch and cache the
remote file. If this fails, the registry will log an error message and attempt to fetch/cache
the remote file every time a read query is made on the registry (through one of the
RegistryReader
methods) until the file is successfully cached. Until the registry has a
local cache, it will behave as an empty registry. Once the remote file has been successfully
cached for the first time, the registry will always provide data from the cache.
If an automatic_refresh_period
is provided to the registry’s constructor
, the registry
will attempt to automatically refresh the cache in the background after the given time since
the last automatic refresh attempt has elapsed.
If a forced_refresh_period
is provided to the registry’s constructor
, the registry will
attempt to cache the remote file on each read after the given time since the last successful
cache attempt has elapsed.
If a forced or automatic cache refresh fails for any reason, an error message will be logged and the previously cached registry values will continue to be used. The next time the registry is read, it will try again to refresh the cache.
Implementations
sourceimpl RemoteYamlRegistry
impl RemoteYamlRegistry
sourcepub fn new(
url: &str,
cache_dir: &str,
automatic_refresh_period: Option<Duration>,
forced_refresh_period: Option<Duration>
) -> Result<Self, RegistryError>
pub fn new(
url: &str,
cache_dir: &str,
automatic_refresh_period: Option<Duration>,
forced_refresh_period: Option<Duration>
) -> Result<Self, RegistryError>
Construct a new RemoteYamlRegistry
.
Arguments
url
- URL of the registry’s backing YAML file.cache_dir
- Directory that the local registry cache will be stored in.automatic_refresh_period
- Amount of time between attempts to automatically fetch and cache the remote YAML file in the background. IfNone
, background refreshes will be disabled. The automatic refresh occurs with a tolerance of +/- 1 second.forced_refresh_period
- Amount of time since the last successful cache refresh before attempting to refresh on every read operation. IfNone
, forced refreshes will be disabled.
pub fn take_shutdown_handle(&mut self) -> Option<RemoteYamlShutdownHandle>
Trait Implementations
sourceimpl RegistryReader for RemoteYamlRegistry
impl RegistryReader for RemoteYamlRegistry
sourcefn get_node(&self, identity: &str) -> Result<Option<Node>, RegistryError>
fn get_node(&self, identity: &str) -> Result<Option<Node>, RegistryError>
Returns the node with the given identity, if it exists in the registry. Read more
sourcefn list_nodes<'a, 'b: 'a>(
&'b self,
predicates: &'a [MetadataPredicate]
) -> Result<NodeIter<'a>, RegistryError>
fn list_nodes<'a, 'b: 'a>(
&'b self,
predicates: &'a [MetadataPredicate]
) -> Result<NodeIter<'a>, RegistryError>
Returns an iterator over the nodes in the registry. Read more
sourcefn count_nodes(
&self,
predicates: &[MetadataPredicate]
) -> Result<u32, RegistryError>
fn count_nodes(
&self,
predicates: &[MetadataPredicate]
) -> Result<u32, RegistryError>
Returns the count of nodes in the registry. Read more
Auto Trait Implementations
impl !RefUnwindSafe for RemoteYamlRegistry
impl Send for RemoteYamlRegistry
impl Sync for RemoteYamlRegistry
impl Unpin for RemoteYamlRegistry
impl !UnwindSafe for RemoteYamlRegistry
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<P, N> IntoBytes<P> for N where
P: Message + FromNative<N>,
impl<P, N> IntoBytes<P> for N where
P: Message + FromNative<N>,
fn into_bytes(self) -> Result<Vec<u8, Global>, ProtoConversionError>
sourceimpl<N, P> IntoNative<N> for P where
N: FromProto<P>,
impl<N, P> IntoNative<N> for P where
N: FromProto<P>,
fn into_native(self) -> Result<N, ProtoConversionError>
sourceimpl<N, P> IntoProto<P> for N where
P: FromNative<N>,
impl<N, P> IntoProto<P> for N where
P: FromNative<N>,
fn into_proto(self) -> Result<P, ProtoConversionError>
sourceimpl<T> IntoSql for T
impl<T> IntoSql for T
sourcefn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
Convert self
to an expression for Diesel’s query builder. Read more
sourcefn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
Convert &self
to an expression for Diesel’s query builder. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more