pub struct RemoteSink { /* private fields */ }Expand description
A fenced door for a remote watch loop’s pushes.
Created by the generated remote_sink() after the source is
installed, it remembers which source that was. apply
installs the document and reloads — unless the source has since been
replaced, in which case it refuses: a watch loop serving yesterday’s
store cannot overwrite today’s, by construction rather than by the old
documentation’s request to please stop the loop first.
Cheap to clone; each wiring of a watch loop should take its own — once, where the loop starts. A sink taken per delivery reads the generation of that moment and fences nothing.
Implementations§
Source§impl RemoteSink
impl RemoteSink
Sourcepub fn status(&self) -> RemoteStatus
pub fn status(&self) -> RemoteStatus
How the fetches from the store behind this sink have gone.
The door a #[dynamic_config] type has to its
RemoteStatus: the slot itself is generated private, and a sink is
the public handle on it — which is also where the question belongs,
since a sink is what a watch loop holds.
Taking a sink only to read this is fine and costs an atomic load:
the generation a sink captures fences
apply and nothing else. A loop that will deliver
documents still takes its own, once, where it starts.
let status = DbConfig::remote_sink().status();
if status.reachable() == Some(false) {
eprintln!("the store has stopped answering");
}With the telemetry feature, Exposition::add_remote renders the
same status as Prometheus text; see
the telemetry module. The example above stays
feature-free on purpose, because this method is not.
Sourcepub fn failed(&self, error: &Error)
pub fn failed(&self, error: &Error)
Reports an attempt to reach the store that came back with nothing.
A watch loop is the half of a store this crate cannot see.
apply records a delivery, so a working watch keeps
RemoteStatus current — but a loop whose stream broke, whose
blocking query is erroring or whose credential was refused delivers
nothing, and would otherwise say nothing: reachable would report the
last delivery rather than the last attempt, and a store that stopped
answering an hour ago would look healthy until something called
refresh.
What it moves is deliberately narrow — the failure streak and the last
failure, and nothing else. fetches, last_fetch and
last_fetch_duration are left alone, so
dynamic_config_remote_last_fetch_seconds keeps ageing while
dynamic_config_remote_up goes to zero, which is the pair an alert
wants. The stored document is untouched: a failed attempt is no reason
to stop serving what the last good one produced.
Fenced on the sink’s generation exactly as apply is,
so a loop still winding down after its source was replaced cannot
charge its failures to the replacement. A stale report is dropped
silently, and there is nothing to handle: a loop must never have to
deal with a failure to report a failure.
The error’s kind and key path are recorded and nothing else — a
store’s address never enters a RemoteStatus, for the reason its
own documentation gives.
Sourcepub fn apply(&self, document: Fetched) -> Result<(), Error>
pub fn apply(&self, document: Fetched) -> Result<(), Error>
Installs a document the watch pushed, and reloads.
Everything a file change would do happens here too — validation, the reload hooks, the cache — because it is the same code path, reached with a document instead of a filesystem event. A failure leaves the previous snapshot serving.
§Errors
If the source has been replaced since this sink was created — checked before the reload and again after it, because a replacement can land while the reload runs — or if the resulting configuration does not load or validate.
Trait Implementations§
Source§impl Clone for RemoteSink
impl Clone for RemoteSink
Source§fn clone(&self) -> RemoteSink
fn clone(&self) -> RemoteSink
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RemoteSink
Auto Trait Implementations§
impl Freeze for RemoteSink
impl RefUnwindSafe for RemoteSink
impl Send for RemoteSink
impl Sync for RemoteSink
impl Unpin for RemoteSink
impl UnsafeUnpin for RemoteSink
impl UnwindSafe for RemoteSink
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);