pub trait LogTracker<Op>:
Sized
+ Send
+ Sync {
// Required methods
fn init<'life0, 'life1, 'async_trait>(
db: &'life0 dyn Db,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Self, DbError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn track_one(
&self,
peer_id: &Uuid,
entry_idx: u64,
timestamp: Timestamp,
server_user_id: Option<Uuid>,
op: &Op,
batch: &mut dyn DbBatch,
) -> Result<(), LogTrackerError>;
fn track_expunged(
&self,
peer_id: &Uuid,
entry_idx: u64,
hash: &Hash,
batch: &mut dyn DbBatch,
) -> Result<(), LogTrackerError>;
fn all_cursors<'life0, 'life1, 'async_trait>(
&'life0 self,
db: &'life1 dyn Db,
) -> Pin<Box<dyn Future<Output = Result<PeerCursors, DbError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Records each log entry as the processor ingests it.
The processor calls init once at startup, then
track_one for every ingested entry (or
track_expunged for an expunged marker),
inside the batch that applies that entry. What gets recorded, and how, is up
to the implementation — see LogIndexTracker for the built-in op-log.
§Duplicate rejection
An implementation may or may not reject a repeated (peer_id, entry_idx).
If it does — e.g. by making (peer_id, entry_idx) a unique key, so a
repeat fails the batch and rolls the whole apply back — then the reducer it
is paired with need not be idempotent. If it does not, the reducer must be.
Nothing yet enforces that pairing at the type level (a future marker on the
reducer could); today it is a contract the wiring must honor.
Required Methods§
Sourcefn init<'life0, 'life1, 'async_trait>(
db: &'life0 dyn Db,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Self, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn init<'life0, 'life1, 'async_trait>(
db: &'life0 dyn Db,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Self, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initialize this tracker’s backing state, namespaced by prefix, and
return an instance bound to it.
Sourcefn track_one(
&self,
peer_id: &Uuid,
entry_idx: u64,
timestamp: Timestamp,
server_user_id: Option<Uuid>,
op: &Op,
batch: &mut dyn DbBatch,
) -> Result<(), LogTrackerError>
fn track_one( &self, peer_id: &Uuid, entry_idx: u64, timestamp: Timestamp, server_user_id: Option<Uuid>, op: &Op, batch: &mut dyn DbBatch, ) -> Result<(), LogTrackerError>
Record entry, identified by (peer_id, entry_idx), by enqueuing its
writes into batch so they commit together with the rest of the entry’s
application. Must not commit on its own.
Sourcefn track_expunged(
&self,
peer_id: &Uuid,
entry_idx: u64,
hash: &Hash,
batch: &mut dyn DbBatch,
) -> Result<(), LogTrackerError>
fn track_expunged( &self, peer_id: &Uuid, entry_idx: u64, hash: &Hash, batch: &mut dyn DbBatch, ) -> Result<(), LogTrackerError>
Record the expunged marker at (peer_id, entry_idx), naming the hash
of the entry that was expunged, by enqueuing into batch. This occupies
the stream index so the peer’s cursor advances past the gap without a
real entry ever being applied there. Must not commit on its own.
Sourcefn all_cursors<'life0, 'life1, 'async_trait>(
&'life0 self,
db: &'life1 dyn Db,
) -> Pin<Box<dyn Future<Output = Result<PeerCursors, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn all_cursors<'life0, 'life1, 'async_trait>(
&'life0 self,
db: &'life1 dyn Db,
) -> Pin<Box<dyn Future<Output = Result<PeerCursors, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Every peer’s cursor as a version vector; seeds a processor’s in-memory cursor view at open.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".