pub struct VenueClock { /* private fields */ }Expand description
The earliest a venue’s clock can read at a given moment, from the times it stamped on events this host received.
Each observe gives a stamp and the Instant its event arrived. The event
was stamped before it arrived, so at that instant the venue’s clock read the stamp or later:
the delay in between only makes the stamp earlier. The clock keeps the one sample that bounds
the venue’s time the tightest, allowing for drift since it was taken, and counts on from it on
tokio’s clock. An old event delivered late, such as a fill a venue replays when a stream
resubscribes, gives a loose bound and so never displaces a better one.
§Caller obligations
- Observe only times the venue itself stamped. A time filled in from this host’s clock, for
an event that arrived without one, is not the venue’s: if this host’s clock is ahead, it
reads as a venue clock that is ahead too, and every bound taken from it is late. A
Tradesays which it is in itstime_source. - Pass the instant the event arrived, read from
Instant::now. That is tokio’s clock, so a test runtime with a paused clock controls it.
§Known limitations
- A stamp the venue sends from ahead of its own clock, such as one read in the wrong time
zone, is kept: it bounds the venue’s time later than it is until a later sample bounds it
later still. Compare the result with this host’s clock (see
host_lead) to see such a stamp. - A venue clock that steps back is followed only as fast as the drift allowance lets the old sample go, about 0.36 s an hour.
- Before the first sample there is no bound:
earliest_atisNone. - The monotonic clock is not free of the host’s time keeping. On some platforms, such as Linux, it does not advance while the host is suspended, which makes the bound earlier than it could be: safe for a read’s start, but no help for its end. NTP can also slew it, up to 500 ppm or more while it corrects an offset, beyond the drift allowance. A slew that speeds it up corrects a wall clock that is behind, so a caller that also bounds a read’s start by the wall clock, taking the earlier of the two, stays covered.
Implementations§
Source§impl VenueClock
impl VenueClock
Sourcepub fn observe(&mut self, stamp: DateTime<Utc>, received: Instant)
pub fn observe(&mut self, stamp: DateTime<Utc>, received: Instant)
Records stamp, a time the venue stamped on an event that arrived at received.
Kept when it bounds the venue’s time at received later than the sample held, and
otherwise dropped.
Sourcepub fn earliest_at(&self, at: Instant) -> Option<DateTime<Utc>>
pub fn earliest_at(&self, at: Instant) -> Option<DateTime<Utc>>
The earliest the venue’s clock can read at at, or None before any sample.
Counts from the sample on tokio’s clock, less the drift allowance, so the venue’s clock
reads this or later at at. at may be before the sample.
Sourcepub fn host_lead(
&self,
host_time: DateTime<Utc>,
at: Instant,
) -> Option<TimeDelta>
pub fn host_lead( &self, host_time: DateTime<Utc>, at: Instant, ) -> Option<TimeDelta>
The most this host’s clock can lead the venue’s, given it read host_time at at, or
None before any sample. Negative when this host’s clock is behind the venue’s.
An upper bound: it is the true lead plus the delay of the sample held and the drift allowed for since. A large negative value says the venue’s clock is ahead, or that a stamp was (see the type’s known limitations).
Sourcepub fn span_start(&self, moment: HostMoment) -> Option<DateTime<Utc>>
pub fn span_start(&self, moment: HostMoment) -> Option<DateTime<Utc>>
Where a read of what the venue stamped from moment on starts: the earliest the venue’s
clock can read at moment, or this host’s time then if that is earlier, as on a host clock
behind the venue’s. None before any sample, when the caller has to allow for the
difference between the clocks itself.
A host clock ahead of the venue’s does not make the start late, and one behind it costs a
read that starts that much earlier. Less a caller’s own margin, for the delay between an
event and its arrival, this is where a read of what was missed after moment begins.
Sourcepub fn span_end(&self, since: HostMoment, now: HostMoment) -> DateTime<Utc>
pub fn span_end(&self, since: HostMoment, now: HostMoment) -> DateTime<Utc>
Where a read that has to reach now ends, for a span that began at since: the latest of
this host’s time at now, the earliest the venue’s clock can read then, and since’s host
time counted on to now on tokio’s clock. Before any sample the venue’s time is left out.
So neither a host clock behind the venue’s nor one stepped back since since ends the read
early. The venue’s clock can still read later than this, as an estimate is a lower bound:
add a margin for that.
Trait Implementations§
Source§impl Clone for VenueClock
impl Clone for VenueClock
impl Copy for VenueClock
Source§impl Debug for VenueClock
impl Debug for VenueClock
Source§impl Default for VenueClock
impl Default for VenueClock
impl Eq for VenueClock
Source§impl PartialEq for VenueClock
impl PartialEq for VenueClock
impl StructuralPartialEq for VenueClock
Auto Trait Implementations§
impl Freeze for VenueClock
impl RefUnwindSafe for VenueClock
impl Send for VenueClock
impl Sync for VenueClock
impl Unpin for VenueClock
impl UnsafeUnpin for VenueClock
impl UnwindSafe for VenueClock
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonSchemaMaybe for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.