feat(core): implement event outbox persistence
Add domain_events migration and SeaORM entity. Modify EventBus::publish to persist events before broadcasting (best-effort: DB failure logs warning but still broadcasts in-memory). Update all 19 publish call sites across 4 crates to pass db reference. Add outbox relay background task that polls pending events every 5s and re-broadcasts them, ensuring no events are lost on server restart.
This commit is contained in:
@@ -130,7 +130,7 @@ impl MessageService {
|
||||
"recipient_id": req.recipient_id,
|
||||
"title": req.title,
|
||||
}),
|
||||
));
|
||||
), db).await;
|
||||
|
||||
audit_service::record(
|
||||
AuditLog::new(tenant_id, Some(sender_id), "message.send", "message")
|
||||
@@ -198,7 +198,7 @@ impl MessageService {
|
||||
"message_id": id,
|
||||
"recipient_id": recipient_id,
|
||||
}),
|
||||
));
|
||||
), db).await;
|
||||
|
||||
audit_service::record(
|
||||
AuditLog::new(tenant_id, Some(system_user), "message.send_system", "message")
|
||||
|
||||
Reference in New Issue
Block a user