feat: centralize NATS message broker implementation in infra and abstract its usage in API and worker

This commit is contained in:
2026-01-02 01:22:18 +01:00
parent 064d2ae748
commit 328f2f2fb2
14 changed files with 158 additions and 110 deletions

View File

@@ -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"] }

View File

@@ -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>>>;
}