pub struct SourceEngine<S> { /* private fields */ }Expand description
One-in-flight source engine with at-least-once replay semantics.
Implementations§
Source§impl<S> SourceEngine<S>where
S: ChainDataSource,
impl<S> SourceEngine<S>where
S: ChainDataSource,
Sourcepub fn new(
source: S,
desired_state: ApplyDesiredState,
committed_next_block: u64,
activation_block: u64,
reorg_depth: usize,
) -> Self
pub fn new( source: S, desired_state: ApplyDesiredState, committed_next_block: u64, activation_block: u64, reorg_depth: usize, ) -> Self
Create an engine at an acknowledged block cursor.
Sourcepub fn restore(
source: S,
desired_state: ApplyDesiredState,
resume: SourceResume,
reorg_depth: usize,
) -> Result<Self, SourceEngineError>
pub fn restore( source: S, desired_state: ApplyDesiredState, resume: SourceResume, reorg_depth: usize, ) -> Result<Self, SourceEngineError>
Restore an engine from a mutually consistent cursor, canonical suffix, and provider checkpoint.
§Errors
Returns SourceEngineError when retained canonical history,
provider checkpoint, scan cursor, activation metadata, or coverage head
are malformed or mutually inconsistent.
Sourcepub fn with_max_delivery_bytes(
self,
max_delivery_bytes: usize,
) -> Result<Self, SourceEngineError>
pub fn with_max_delivery_bytes( self, max_delivery_bytes: usize, ) -> Result<Self, SourceEngineError>
Override the encoded delivery budget, primarily for stricter deployments and tests.
§Errors
Returns SourceEngineError::InvalidDeliverySizeLimit when the limit
is zero or exceeds MAX_DELIVERY_SIZE_BYTES.
Sourcepub fn with_response_limits(self, response_limits: SourceResponseLimits) -> Self
pub fn with_response_limits(self, response_limits: SourceResponseLimits) -> Self
Override the hard local decoded-response admission policy.
Sourcepub async fn next_batch(
&mut self,
to_block_excl: u64,
) -> Result<Option<Delivery>, SourceEngineError>
pub async fn next_batch( &mut self, to_block_excl: u64, ) -> Result<Option<Delivery>, SourceEngineError>
Fetch the next page up to an exclusive target, replaying an unacknowledged page without another provider request.
§Errors
Returns SourceEngineError for query/source failure, invalid or
oversized provider data, unresolvable continuity/reorg state, sequence
exhaustion, or an owner-only fork protocol v1 cannot represent.
Sourcepub fn acknowledge(
&mut self,
delivery_token: &[u8],
) -> Result<(), SourceEngineError>
pub fn acknowledge( &mut self, delivery_token: &[u8], ) -> Result<(), SourceEngineError>
Commit the only in-flight delivery token and advance the durable cursor.
§Errors
Returns SourceEngineError::NoPendingDelivery when nothing is in
flight, SourceEngineError::DeliveryTokenMismatch for the wrong
token, or SourceEngineError::MissingCursor for an invalid pending
delivery.
Sourcepub fn committed_next_block(&self) -> u64
pub fn committed_next_block(&self) -> u64
Exclusive block cursor durably acknowledged by the consumer.
Sourcepub fn activation_cursor(&self) -> Result<Cursor, SourceEngineError>
pub fn activation_cursor(&self) -> Result<Cursor, SourceEngineError>
Cursor persisted on the desired-state activation barrier before the first provider page is requested.
§Errors
Returns SourceEngineError when retained canonical/provider
checkpoint metadata cannot be encoded safely.
Sourcepub fn committed_sequence(&self) -> u64
pub fn committed_sequence(&self) -> u64
Last batch sequence durably acknowledged by the consumer.
Sourcepub fn acknowledge_external_control(
&mut self,
sequence: u64,
) -> Result<(), SourceEngineError>
pub fn acknowledge_external_control( &mut self, sequence: u64, ) -> Result<(), SourceEngineError>
Advance sequence across a service-generated control that does not touch this source’s provider cursor.
§Errors
Returns SourceEngineError::PendingDelivery while a source delivery
is in flight, or SourceEngineError::SequenceRegression if sequence
moves behind committed authority.
Sourcepub fn synchronize_committed_cursor(
&mut self,
resume: SourceResume,
) -> Result<(), SourceEngineError>
pub fn synchronize_committed_cursor( &mut self, resume: SourceResume, ) -> Result<(), SourceEngineError>
Synchronize an engine rebuilt from an older acknowledged cursor after a separately persisted outbox delivery is committed.
§Errors
Returns SourceEngineError when a delivery is pending, sequence
authority regresses, or the replacement cursor/checkpoint/history/
coverage state is malformed or inconsistent. Validation completes
before engine state is replaced.
Sourcepub fn activation_block(&self) -> u64
pub fn activation_block(&self) -> u64
First block routed to all live owners for the active revision.
Auto Trait Implementations§
impl<S> Freeze for SourceEngine<S>where
S: Freeze,
impl<S> RefUnwindSafe for SourceEngine<S>where
S: RefUnwindSafe,
impl<S> Send for SourceEngine<S>where
S: Send,
impl<S> Sync for SourceEngine<S>where
S: Sync,
impl<S> Unpin for SourceEngine<S>where
S: Unpin,
impl<S> UnsafeUnpin for SourceEngine<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for SourceEngine<S>where
S: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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> 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 moreSource§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>
T in a tonic::Request