pub struct EventService<S, H>where
S: EventStore,
H: EventHandler,{ /* private fields */ }Expand description
Service for managing domain events with DTO conversion Uses compile-time polymorphism for zero-cost abstractions
Implementations§
Source§impl<S, H> EventService<S, H>where
S: EventStore,
H: EventHandler,
impl<S, H> EventService<S, H>where
S: EventStore,
H: EventHandler,
Sourcepub fn new(event_store: Arc<Mutex<S>>, event_handler: H) -> Self
pub fn new(event_store: Arc<Mutex<S>>, event_handler: H) -> Self
Create new event service with event store and handler
Sourcepub async fn publish_event(&self, event: DomainEvent) -> ApplicationResult<()>
pub async fn publish_event(&self, event: DomainEvent) -> ApplicationResult<()>
Publish domain event with zero-cost handling
Sourcepub async fn publish_events(
&self,
events: Vec<DomainEvent>,
) -> ApplicationResult<()>
pub async fn publish_events( &self, events: Vec<DomainEvent>, ) -> ApplicationResult<()>
Publish multiple domain events
Sourcepub fn get_session_events_dto(
&self,
session_id: SessionId,
) -> ApplicationResult<Vec<DomainEventDto>>
pub fn get_session_events_dto( &self, session_id: SessionId, ) -> ApplicationResult<Vec<DomainEventDto>>
Get events for session as DTOs (for API responses)
Sourcepub fn get_stream_events_dto(
&self,
stream_id: StreamId,
) -> ApplicationResult<Vec<DomainEventDto>>
pub fn get_stream_events_dto( &self, stream_id: StreamId, ) -> ApplicationResult<Vec<DomainEventDto>>
Get events for stream as DTOs (for API responses)
Sourcepub fn get_events_since_dto(
&self,
since: DateTime<Utc>,
) -> ApplicationResult<Vec<DomainEventDto>>
pub fn get_events_since_dto( &self, since: DateTime<Utc>, ) -> ApplicationResult<Vec<DomainEventDto>>
Get events since timestamp as DTOs (for API responses)
Sourcepub fn get_session_events(
&self,
session_id: SessionId,
) -> ApplicationResult<Vec<DomainEvent>>
pub fn get_session_events( &self, session_id: SessionId, ) -> ApplicationResult<Vec<DomainEvent>>
Get events for session (domain objects, for internal use)
Sourcepub fn get_stream_events(
&self,
stream_id: StreamId,
) -> ApplicationResult<Vec<DomainEvent>>
pub fn get_stream_events( &self, stream_id: StreamId, ) -> ApplicationResult<Vec<DomainEvent>>
Get events for stream (domain objects, for internal use)
Sourcepub fn replay_from_dtos(
&self,
event_dtos: Vec<DomainEventDto>,
) -> ApplicationResult<Vec<DomainEvent>>
pub fn replay_from_dtos( &self, event_dtos: Vec<DomainEventDto>, ) -> ApplicationResult<Vec<DomainEvent>>
Replay events from DTOs (for event sourcing reconstruction)
Source§impl<S> EventService<S, NoOpEventHandler>where
S: EventStore,
Convenience constructors for common configurations
impl<S> EventService<S, NoOpEventHandler>where
S: EventStore,
Convenience constructors for common configurations
Sourcepub fn with_noop_handler(event_store: Arc<Mutex<S>>) -> Self
pub fn with_noop_handler(event_store: Arc<Mutex<S>>) -> Self
Create event service with no-op handler (maximum performance)
Source§impl<S> EventService<S, LoggingEventHandler>where
S: EventStore,
impl<S> EventService<S, LoggingEventHandler>where
S: EventStore,
Sourcepub fn with_logging_handler(event_store: Arc<Mutex<S>>) -> Self
pub fn with_logging_handler(event_store: Arc<Mutex<S>>) -> Self
Create event service with logging handler (zero-allocation logging)
Source§impl<S, H> EventService<S, H>where
S: EventStore,
H: EventHandler,
Event publishing convenience methods
impl<S, H> EventService<S, H>where
S: EventStore,
H: EventHandler,
Event publishing convenience methods
Sourcepub async fn publish_session_activated(
&self,
session_id: SessionId,
) -> ApplicationResult<()>
pub async fn publish_session_activated( &self, session_id: SessionId, ) -> ApplicationResult<()>
Publish session activated event
Sourcepub async fn publish_session_closed(
&self,
session_id: SessionId,
) -> ApplicationResult<()>
pub async fn publish_session_closed( &self, session_id: SessionId, ) -> ApplicationResult<()>
Publish session closed event
Sourcepub async fn publish_stream_created(
&self,
session_id: SessionId,
stream_id: StreamId,
) -> ApplicationResult<()>
pub async fn publish_stream_created( &self, session_id: SessionId, stream_id: StreamId, ) -> ApplicationResult<()>
Publish stream created event
Sourcepub async fn publish_stream_completed(
&self,
session_id: SessionId,
stream_id: StreamId,
) -> ApplicationResult<()>
pub async fn publish_stream_completed( &self, session_id: SessionId, stream_id: StreamId, ) -> ApplicationResult<()>
Publish stream completed event
Sourcepub async fn publish_stream_failed(
&self,
session_id: SessionId,
stream_id: StreamId,
error: String,
) -> ApplicationResult<()>
pub async fn publish_stream_failed( &self, session_id: SessionId, stream_id: StreamId, error: String, ) -> ApplicationResult<()>
Publish stream failed event
Auto Trait Implementations§
impl<S, H> Freeze for EventService<S, H>where
H: Freeze,
impl<S, H> RefUnwindSafe for EventService<S, H>where
H: RefUnwindSafe,
impl<S, H> Send for EventService<S, H>
impl<S, H> Sync for EventService<S, H>
impl<S, H> Unpin for EventService<S, H>where
H: Unpin,
impl<S, H> UnwindSafe for EventService<S, H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more