1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! An offset store keeps track of the last offset used in relation to
//! an entity, including its entity type. It can be used in various places,
//! for example, when consuming event envelopes from a remote projection, where
//! they be emitted by the consumer out of order. This entity can track such situations.

use akka_persistence_rs::{Offset, PersistenceId};
use tokio::sync::oneshot;

/// A last offset can comprise of the same offset type value for a number
/// of persistence identifiers.
pub type LastOffset = (Vec<PersistenceId>, Offset);

pub enum Command {
    GetLastOffset {
        reply_to: oneshot::Sender<Option<LastOffset>>,
    },
    GetOffset {
        persistence_id: PersistenceId,
        reply_to: oneshot::Sender<Option<Offset>>,
    },
    SaveOffset {
        persistence_id: PersistenceId,
        offset: Offset,
    },
}