pub struct SessionCommandHandler<R, P, F = InMemoryFrameStore>{ /* private fields */ }Expand description
Handler for session management commands.
Holds an optional DictionaryStore (defaulting to NoopDictionaryStore)
so that frame-generating commands can feed accepted frame payloads into the
per-session training corpus. Without this wiring the
GET /pjs/sessions/{id}/dictionary endpoint would be unreachable end-to-end.
Also holds a FrameStoreGat (defaulting to InMemoryFrameStore) so
frames produced by GenerateFramesCommand / BatchGenerateFramesCommand
remain queryable through GET /pjs/sessions/{id}/streams/{id}/frames.
Implementations§
Source§impl<R, P> SessionCommandHandler<R, P, InMemoryFrameStore>where
R: StreamRepositoryGat + 'static,
P: EventPublisherGat + 'static,
impl<R, P> SessionCommandHandler<R, P, InMemoryFrameStore>where
R: StreamRepositoryGat + 'static,
P: EventPublisherGat + 'static,
Sourcepub fn new(repository: Arc<R>, event_publisher: Arc<P>) -> Self
pub fn new(repository: Arc<R>, event_publisher: Arc<P>) -> Self
Create a handler with the no-op DictionaryStore and a fresh
InMemoryFrameStore.
The dictionary endpoint will return 404 Not Found until the handler is
constructed with SessionCommandHandler::with_stores and a concrete
DictionaryStore such as
crate::infrastructure::repositories::InMemoryDictionaryStore.
Sourcepub fn with_dictionary_store(
repository: Arc<R>,
event_publisher: Arc<P>,
dictionary_store: Arc<dyn DictionaryStore>,
) -> Self
pub fn with_dictionary_store( repository: Arc<R>, event_publisher: Arc<P>, dictionary_store: Arc<dyn DictionaryStore>, ) -> Self
Create a handler with a custom DictionaryStore and a fresh
InMemoryFrameStore.
Source§impl<R, P, F> SessionCommandHandler<R, P, F>
impl<R, P, F> SessionCommandHandler<R, P, F>
Sourcepub fn with_stores(
repository: Arc<R>,
event_publisher: Arc<P>,
dictionary_store: Arc<dyn DictionaryStore>,
frame_store: Arc<F>,
) -> Self
pub fn with_stores( repository: Arc<R>, event_publisher: Arc<P>, dictionary_store: Arc<dyn DictionaryStore>, frame_store: Arc<F>, ) -> Self
Create a handler that feeds accepted frames into both the dictionary
training corpus and the FrameStoreGat used by the frames query
endpoint.
Trait Implementations§
Source§impl<R, P, F> CommandHandlerGat<BatchGenerateFramesCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
impl<R, P, F> CommandHandlerGat<BatchGenerateFramesCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
Source§type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<BatchGenerateFramesCommand>>::Response, ApplicationError>> + Send + 'a
where
Self: 'a
type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<BatchGenerateFramesCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a
Source§fn handle(&self, command: BatchGenerateFramesCommand) -> Self::HandleFuture<'_>
fn handle(&self, command: BatchGenerateFramesCommand) -> Self::HandleFuture<'_>
Source§impl<R, P, F> CommandHandlerGat<CloseSessionCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
impl<R, P, F> CommandHandlerGat<CloseSessionCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
Source§type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CloseSessionCommand>>::Response, ApplicationError>> + Send + 'a
where
Self: 'a
type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CloseSessionCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a
Source§fn handle(&self, command: CloseSessionCommand) -> Self::HandleFuture<'_>
fn handle(&self, command: CloseSessionCommand) -> Self::HandleFuture<'_>
Source§impl<R, P, F> CommandHandlerGat<CompleteStreamCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
impl<R, P, F> CommandHandlerGat<CompleteStreamCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
Source§type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CompleteStreamCommand>>::Response, ApplicationError>> + Send + 'a
where
Self: 'a
type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CompleteStreamCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a
Source§fn handle(&self, command: CompleteStreamCommand) -> Self::HandleFuture<'_>
fn handle(&self, command: CompleteStreamCommand) -> Self::HandleFuture<'_>
Source§impl<R, P, F> CommandHandlerGat<CreateSessionCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
impl<R, P, F> CommandHandlerGat<CreateSessionCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
Source§type Response = Id<SessionMarker>
type Response = Id<SessionMarker>
Source§type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CreateSessionCommand>>::Response, ApplicationError>> + Send + 'a
where
Self: 'a
type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CreateSessionCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a
Source§fn handle(&self, command: CreateSessionCommand) -> Self::HandleFuture<'_>
fn handle(&self, command: CreateSessionCommand) -> Self::HandleFuture<'_>
Source§impl<R, P, F> CommandHandlerGat<CreateStreamCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
impl<R, P, F> CommandHandlerGat<CreateStreamCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
Source§type Response = Id<StreamMarker>
type Response = Id<StreamMarker>
Source§type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CreateStreamCommand>>::Response, ApplicationError>> + Send + 'a
where
Self: 'a
type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CreateStreamCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a
Source§fn handle(&self, command: CreateStreamCommand) -> Self::HandleFuture<'_>
fn handle(&self, command: CreateStreamCommand) -> Self::HandleFuture<'_>
Source§impl<R, P, F> CommandHandlerGat<GenerateFramesCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
impl<R, P, F> CommandHandlerGat<GenerateFramesCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
Source§type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<GenerateFramesCommand>>::Response, ApplicationError>> + Send + 'a
where
Self: 'a
type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<GenerateFramesCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a
Source§fn handle(&self, command: GenerateFramesCommand) -> Self::HandleFuture<'_>
fn handle(&self, command: GenerateFramesCommand) -> Self::HandleFuture<'_>
Source§impl<R, P, F> CommandHandlerGat<StartStreamCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
impl<R, P, F> CommandHandlerGat<StartStreamCommand> for SessionCommandHandler<R, P, F>where
R: StreamRepositoryGat + Send + Sync,
P: EventPublisherGat + Send + Sync,
F: FrameStoreGat + Send + Sync,
Source§type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<StartStreamCommand>>::Response, ApplicationError>> + Send + 'a
where
Self: 'a
type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<StartStreamCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a
Source§fn handle(&self, command: StartStreamCommand) -> Self::HandleFuture<'_>
fn handle(&self, command: StartStreamCommand) -> Self::HandleFuture<'_>
Source§impl<R, P, F> Debug for SessionCommandHandler<R, P, F>
impl<R, P, F> Debug for SessionCommandHandler<R, P, F>
Auto Trait Implementations§
impl<R, P, F = InMemoryFrameStore> !RefUnwindSafe for SessionCommandHandler<R, P, F>
impl<R, P, F = InMemoryFrameStore> !UnwindSafe for SessionCommandHandler<R, P, F>
impl<R, P, F> Freeze for SessionCommandHandler<R, P, F>
impl<R, P, F> Send for SessionCommandHandler<R, P, F>
impl<R, P, F> Sync for SessionCommandHandler<R, P, F>
impl<R, P, F> Unpin for SessionCommandHandler<R, P, F>
impl<R, P, F> UnsafeUnpin for SessionCommandHandler<R, P, F>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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