Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

start_at

start_at opens the subscription at a position you name on every startup, ahead of the stored checkpoints.

It is a clause of the attribute, start_at(KinesisPosition::horizon()), or .start_at(position) among the mount-site settings. The position lands on the shards the subscription opens with, ahead of their first read, whatever their checkpoints say. A reader that starts later in the run, after a failure or a takeover, resumes from its shard's checkpoint. A child shard of a split or a merge with no checkpoint of its own opens at its oldest record, so no record of a resharded key is skipped. A sequence position on a shard this instance does not read is refused, and the service stops at startup. It suits a read model rebuilt from the retained stream on each boot.

Example​

The audit projection is rebuilt from the oldest retained entry on every startup, although it checkpointed every entry it read before.

/// Rebuilds the audit projection from the oldest retained entry on every startup.
#[subscriber(
KinesisStream::new("ledger.audit"),
start_at(KinesisPosition::horizon())
)]
async fn project(entry: &AuditEntry) -> HandlerOutcome {
tracing::info!(entry.id, "entry projected");
HandlerOutcome::ack()
}