Trait event_store_core::backend::Backend
source · pub trait Backend {
// Required methods
fn backend_name() -> &'static str;
fn create_stream(
&mut self,
stream: Stream,
correlation_id: Uuid
) -> Pin<Box<dyn Future<Output = Result<Stream, StorageError>> + Send>>;
fn delete_stream(
&mut self,
stream: &Stream,
correlation_id: Uuid
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send>>;
fn append_to_stream(
&mut self,
stream_uuid: &str,
events: &[UnsavedEvent],
correlation_id: Uuid
) -> Pin<Box<dyn Future<Output = Result<Vec<Uuid>, StorageError>> + Send>>;
fn read_stream(
&self,
stream_uuid: String,
version: usize,
limit: usize,
correlation_id: Uuid
) -> Pin<Box<dyn Future<Output = Result<Vec<RecordedEvent>, StorageError>> + Send>>;
fn read_stream_info(
&mut self,
stream_uuid: String,
correlation_id: Uuid
) -> Pin<Box<dyn Future<Output = Result<Stream, StorageError>> + Send>>;
fn stream_forward(
&self,
stream_uuid: String,
batch_size: usize,
correlation_id: Uuid
) -> Pin<Box<dyn Stream<Item = Result<Vec<RecordedEvent>, StorageError>> + Send>>;
}
Required Methods§
fn backend_name() -> &'static str
sourcefn create_stream(
&mut self,
stream: Stream,
correlation_id: Uuid
) -> Pin<Box<dyn Future<Output = Result<Stream, StorageError>> + Send>>
fn create_stream( &mut self, stream: Stream, correlation_id: Uuid ) -> Pin<Box<dyn Future<Output = Result<Stream, StorageError>> + Send>>
Create a new stream with an identifier
Errors
The stream creation can fail for multiple reasons:
- pure storage failure (unable to create the stream on the backend)
- The stream already exists
sourcefn delete_stream(
&mut self,
stream: &Stream,
correlation_id: Uuid
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send>>
fn delete_stream( &mut self, stream: &Stream, correlation_id: Uuid ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send>>
Delete a stream from the Backend
Do we need to provide a hard/soft deletion?
Errors
The stream deletion can fail for multiple reasons:
- pure storage failure (unable to delete the stream on the backend)
- The stream doesn’t exists