feat: with tx on all

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-10-03 23:08:12 +02:00
parent e774529b04
commit bc28451f8d
18 changed files with 256 additions and 28 deletions

View File

@@ -54,6 +54,9 @@ pub enum PersistenceError {
#[error("failed to publish item {0}")]
UpdatePublished(anyhow::Error),
#[error("database query failed {0}")]
AnyErr(anyhow::Error),
}
#[derive(Error, Debug)]

View File

@@ -3,10 +3,14 @@ use std::fmt::Display;
use async_trait::async_trait;
use errors::{DeserializeError, PersistenceError, SerializeError};
pub trait Tx: Send + Sync {}
pub type DynTx = Box<dyn Tx>;
#[async_trait]
pub trait Persistence {
async fn insert(&self, event_info: &EventInfo, content: Vec<u8>) -> anyhow::Result<()>;
async fn next(&self) -> Option<String>;
async fn next(&self) -> Result<Option<(String, DynTx)>, PersistenceError>;
async fn get(&self, event_id: &str) -> Result<Option<(EventInfo, Vec<u8>)>, PersistenceError>;
async fn update_published(&self, event_id: &str) -> Result<(), PersistenceError>;
}