Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
twiq: Add use_case::worker_repository mod
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod command; | ||
pub mod user_repository; | ||
pub mod worker_repository; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use async_trait::async_trait; | ||
use event_store_core::event_id::EventId; | ||
|
||
#[derive(Debug, Eq, PartialEq, thiserror::Error)] | ||
pub enum Error { | ||
#[error("unknown {0}")] | ||
Unknown(String), | ||
} | ||
|
||
pub type Result<T, E = Error> = std::result::Result<T, E>; | ||
|
||
#[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
pub enum WorkerName { | ||
CreateUserRequest, | ||
} | ||
|
||
#[async_trait] | ||
pub trait WorkerRepository { | ||
async fn find_last_event_id(worker_name: WorkerName) -> Result<Option<EventId>>; | ||
async fn store_last_event_id( | ||
worker_name: WorkerName, | ||
before: Option<EventId>, | ||
after: EventId, | ||
) -> Result<()>; | ||
} | ||
|
||
pub trait HasWorkerRepository { | ||
type WorkerRepository: WorkerRepository + Send + Sync; | ||
|
||
fn worker_repository(&self) -> &Self::WorkerRepository; | ||
} |