commit_hook is invoked right before the calling for commit which sorts out and processes outboxes and internally processable events.
(&mut self)
| 70 | /// commit_hook is invoked right before the calling for commit |
| 71 | /// which sorts out and processes outboxes and internally processable events. |
| 72 | pub async fn _commit_hook(&mut self) -> ApplicationResult<()> { |
| 73 | let event_sender = &mut self.context.write().await.sender; |
| 74 | let mut outboxes = vec![]; |
| 75 | |
| 76 | for e in self.repository.get_events() { |
| 77 | if e.externally_notifiable() { |
| 78 | outboxes.push(e.outbox()); |
| 79 | }; |
| 80 | if e.internally_notifiable() { |
| 81 | event_sender |
| 82 | .send(e.message_clone()) |
| 83 | .await |
| 84 | .expect("Event Collecting failed!") |
| 85 | } |
| 86 | } |
| 87 | Outbox::add(self.executor(), outboxes).await |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | //TODO Using UOW, transaction handling |
no test coverage detected