feat: centralize NATS message broker implementation in infra and abstract its usage in API and worker
This commit is contained in:
@@ -12,6 +12,7 @@ serde_json = "1.0.146"
|
||||
thiserror = "2.0.17"
|
||||
tracing = "0.1"
|
||||
uuid = { version = "1.19.0", features = ["v4", "serde"] }
|
||||
futures-core = "0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1", features = ["rt", "macros"] }
|
||||
|
||||
@@ -42,4 +42,10 @@ pub trait LinkRepository: Send + Sync {
|
||||
pub trait MessageBroker: Send + Sync {
|
||||
/// Publish an event when a note is created or updated.
|
||||
async fn publish_note_updated(&self, note: &Note) -> DomainResult<()>;
|
||||
|
||||
/// Subscribe to note update events.
|
||||
/// Returns a stream of notes that have been updated.
|
||||
async fn subscribe_note_updates(
|
||||
&self,
|
||||
) -> DomainResult<std::pin::Pin<Box<dyn futures_core::Stream<Item = Note> + Send>>>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user