pub struct TimestampOracle<T> {
state: TimestampOracleState<T>,
advance_to: Option<T>,
next: Box<dyn Fn() -> T>,
}
Expand description
A type that provides write and read timestamps, reads observe exactly their preceding writes..
Specifically, all read timestamps will be greater or equal to all previously reported write timestamps, and strictly less than all subsequently emitted write timestamps.
Fields
state: TimestampOracleState<T>
advance_to: Option<T>
next: Box<dyn Fn() -> T>
Implementations
sourceimpl<T: CoordTimestamp> TimestampOracle<T>
impl<T: CoordTimestamp> TimestampOracle<T>
sourcepub fn new<F>(initially: T, next: F) -> Self where
F: Fn() -> T + 'static,
pub fn new<F>(initially: T, next: F) -> Self where
F: Fn() -> T + 'static,
Create a new timeline, starting at the indicated time. next
generates
new timestamps when invoked. The timestamps have no requirements, and can
retreat from previous invocations.
sourcepub fn peek_ts(&self) -> T
pub fn peek_ts(&self) -> T
Peek the current value of the timestamp.
No operations should be assigned to the timestamp returned by this function. The
timestamp returned should only be used to compare the progress of the TimestampOracle
against some external source of time.
Subsequent values of self.read_ts()
and self.write_ts()
will be greater or equal to
this timestamp.
NOTE: This can be removed once DDL is included in group commits.
sourcepub fn write_ts(&mut self) -> T
pub fn write_ts(&mut self) -> T
Acquire a new timestamp for writing.
This timestamp will be strictly greater than all prior values of
self.read_ts()
, and less than or equal to all subsequent values of
self.read_ts()
.
sourcepub fn read_ts(&mut self) -> T
pub fn read_ts(&mut self) -> T
Acquire a new timestamp for reading.
This timestamp will be greater or equal to all prior values of self.write_ts()
,
and strictly less than all subsequent values of self.write_ts()
.
sourcepub fn fast_forward(&mut self, lower_bound: T)
pub fn fast_forward(&mut self, lower_bound: T)
Electively advance the tracked times.
If lower_bound
is strictly greater than the current time (of either state), the
resulting state will be Writing(lower_bound)
.
sourcepub fn should_advance_to(&mut self) -> Option<T>
pub fn should_advance_to(&mut self) -> Option<T>
Whether and to what the next value of `self.write_ts() has advanced since this method was last called.
This method may produce the same value multiple times, and should not be used as a test for whether a write-to-read transition has occurred, so much as an advisory signal that write capabilities can advance.
Auto Trait Implementations
impl<T> !RefUnwindSafe for TimestampOracle<T>
impl<T> !Send for TimestampOracle<T>
impl<T> !Sync for TimestampOracle<T>
impl<T> Unpin for TimestampOracle<T> where
T: Unpin,
impl<T> !UnwindSafe for TimestampOracle<T>
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> FutureExt for T
impl<T> FutureExt for T
sourcefn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
sourcefn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<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>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
sourceimpl<P, R> ProtoType<R> for P where
R: RustType<P>,
impl<P, R> ProtoType<R> for P where
R: RustType<P>,
sourcefn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
See RustType::from_proto
.
sourcefn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
See RustType::into_proto
.
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