forked from aws-samples/serverless-rust-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
31 lines (26 loc) · 715 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! # Domain logic for the service
pub mod domain;
pub mod entrypoints;
mod error;
pub mod event_bus;
mod model;
pub mod store;
pub mod utils;
pub use error::Error;
use event_bus::EventBus;
pub use model::{Event, Product, ProductRange};
/// Event Service
///
/// This service takes events and publishes them to the event bus.
pub struct EventService {
event_bus: Box<dyn EventBus<E = Event> + Send + Sync>,
}
impl EventService {
pub fn new(event_bus: Box<dyn EventBus<E = Event> + Send + Sync>) -> Self {
Self { event_bus }
}
// Send a batch of events
pub async fn send_events(&self, events: &[Event]) -> Result<(), Error> {
self.event_bus.send_events(events).await
}
}