pub trait EventStore: Send + Sync {
// Required methods
fn append<'life0, 'async_trait>(
&'life0 self,
ev: PersistedEvent,
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn append_batch<'life0, 'async_trait>(
&'life0 self,
evs: Vec<PersistedEvent>,
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn load_since<'life0, 'life1, 'async_trait>(
&'life0 self,
doc_id: &'life1 str,
from_lsn: i64,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<PersistedEvent>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn latest_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
doc_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Snapshot>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn write_snapshot<'life0, 'async_trait>(
&'life0 self,
snap: Snapshot,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn compact<'life0, 'life1, 'async_trait>(
&'life0 self,
doc_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
具体后端必须实现的最小持久化接口。
Required Methods§
Sourcefn append<'life0, 'async_trait>(
&'life0 self,
ev: PersistedEvent,
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append<'life0, 'async_trait>(
&'life0 self,
ev: PersistedEvent,
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
追加单条事件。返回分配的 lsn。
Sourcefn append_batch<'life0, 'async_trait>(
&'life0 self,
evs: Vec<PersistedEvent>,
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append_batch<'life0, 'async_trait>(
&'life0 self,
evs: Vec<PersistedEvent>,
) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
在单事务内批量追加事件。返回最后一条的 lsn。
Sourcefn load_since<'life0, 'life1, 'async_trait>(
&'life0 self,
doc_id: &'life1 str,
from_lsn: i64,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<PersistedEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_since<'life0, 'life1, 'async_trait>(
&'life0 self,
doc_id: &'life1 str,
from_lsn: i64,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<PersistedEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
读取指定文档分片自 from_lsn 之后的增量事件,上限为 limit 条。
Sourcefn latest_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
doc_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn latest_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
doc_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取指定文档分片的最新快照(如果存在)。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".