use std::sync::{Arc, Mutex}; use esrs::handler::EventHandler; use esrs::store::StoreEvent; use crate::aggregate::{TestAggregate, TestEvent}; #[derive(Clone)] pub struct TestEventHandler { pub total: Arc>, } #[async_trait::async_trait] impl EventHandler for TestEventHandler { async fn handle(&self, event: &StoreEvent) { let mut guard = self.total.lock().unwrap(); *guard += event.payload.add; } }