Trait eventsourced::EvtLog

source ·
pub trait EvtLog: Clone + 'static + Send {
    type Id: Debug;
    type Error: StdError + Send + Sync + 'static;

    const MAX_SEQ_NO: NonZeroU64 = NonZeroU64::MAX;

    // Required methods
    fn persist<E, ToBytes, ToBytesError>(
        &mut self,
        evt: &E,
        type_name: &str,
        id: &Self::Id,
        last_seq_no: Option<NonZeroU64>,
        to_bytes: &ToBytes
    ) -> impl Future<Output = Result<NonZeroU64, Self::Error>> + Send
       where E: Debug + Sync,
             ToBytes: Fn(&E) -> Result<Bytes, ToBytesError> + Sync,
             ToBytesError: StdError + Send + Sync + 'static;
    fn last_seq_no(
        &self,
        type_name: &str,
        id: &Self::Id
    ) -> impl Future<Output = Result<Option<NonZeroU64>, Self::Error>> + Send;
    fn evts_by_id<E, FromBytes, FromBytesError>(
        &self,
        type_name: &str,
        id: &Self::Id,
        after_seq_no: Option<NonZeroU64>,
        from_bytes: FromBytes
    ) -> impl Future<Output = Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>> + Send
       where E: Send,
             FromBytes: Fn(Bytes) -> Result<E, FromBytesError> + Copy + Send + Sync + 'static,
             FromBytesError: StdError + Send + Sync + 'static;
    fn evts_by_type<E, FromBytes, FromBytesError>(
        &self,
        type_name: &str,
        after_seq_no: Option<NonZeroU64>,
        from_bytes: FromBytes
    ) -> impl Future<Output = Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>> + Send
       where E: Send,
             FromBytes: Fn(Bytes) -> Result<E, FromBytesError> + Copy + Send + Sync + 'static,
             FromBytesError: StdError + Send + Sync + 'static;
}
Expand description

Persistence for events.

Required Associated Types§

source

type Id: Debug

source

type Error: StdError + Send + Sync + 'static

Provided Associated Constants§

source

const MAX_SEQ_NO: NonZeroU64 = NonZeroU64::MAX

The maximum value for sequence numbers. Defaults to NonZeroU64::MAX unless overriden by an implementation.

Required Methods§

source

fn persist<E, ToBytes, ToBytesError>( &mut self, evt: &E, type_name: &str, id: &Self::Id, last_seq_no: Option<NonZeroU64>, to_bytes: &ToBytes ) -> impl Future<Output = Result<NonZeroU64, Self::Error>> + Send
where E: Debug + Sync, ToBytes: Fn(&E) -> Result<Bytes, ToBytesError> + Sync, ToBytesError: StdError + Send + Sync + 'static,

Persist the given event and optional tag for the given entity type and ID and return the sequence number for the persisted event. The given last sequence number is used for optimistic locking, i.e. it must match the current last sequence number of the event log.

source

fn last_seq_no( &self, type_name: &str, id: &Self::Id ) -> impl Future<Output = Result<Option<NonZeroU64>, Self::Error>> + Send

Get the last sequence number for the given entity type and ID.

source

fn evts_by_id<E, FromBytes, FromBytesError>( &self, type_name: &str, id: &Self::Id, after_seq_no: Option<NonZeroU64>, from_bytes: FromBytes ) -> impl Future<Output = Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>> + Send
where E: Send, FromBytes: Fn(Bytes) -> Result<E, FromBytesError> + Copy + Send + Sync + 'static, FromBytesError: StdError + Send + Sync + 'static,

Get the events for the given entity ID starting after the given sequence number.

source

fn evts_by_type<E, FromBytes, FromBytesError>( &self, type_name: &str, after_seq_no: Option<NonZeroU64>, from_bytes: FromBytes ) -> impl Future<Output = Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>> + Send
where E: Send, FromBytes: Fn(Bytes) -> Result<E, FromBytesError> + Copy + Send + Sync + 'static, FromBytesError: StdError + Send + Sync + 'static,

Get the events for the given entity type starting after the given sequence number.

Object Safety§

This trait is not object safe.

Implementors§