Skip to main content

SessionCommandHandler

Struct SessionCommandHandler 

Source
pub struct SessionCommandHandler<R, P, F = InMemoryFrameStore>
where R: StreamRepositoryGat + 'static, P: EventPublisherGat + 'static, F: FrameStoreGat + 'static,
{ /* 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,

Source

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.

Source

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>
where R: StreamRepositoryGat + 'static, P: EventPublisherGat + 'static, F: FrameStoreGat + 'static,

Source

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>

Source§

type Response = Vec<Frame>

The response type for this command
Source§

type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<BatchGenerateFramesCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a

Future type returned by handle method
Source§

fn handle(&self, command: BatchGenerateFramesCommand) -> Self::HandleFuture<'_>

Handle the command and return a future
Source§

impl<R, P, F> CommandHandlerGat<CloseSessionCommand> for SessionCommandHandler<R, P, F>

Source§

type Response = ()

The response type for this command
Source§

type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CloseSessionCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a

Future type returned by handle method
Source§

fn handle(&self, command: CloseSessionCommand) -> Self::HandleFuture<'_>

Handle the command and return a future
Source§

impl<R, P, F> CommandHandlerGat<CompleteStreamCommand> for SessionCommandHandler<R, P, F>

Source§

type Response = ()

The response type for this command
Source§

type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CompleteStreamCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a

Future type returned by handle method
Source§

fn handle(&self, command: CompleteStreamCommand) -> Self::HandleFuture<'_>

Handle the command and return a future
Source§

impl<R, P, F> CommandHandlerGat<CreateSessionCommand> for SessionCommandHandler<R, P, F>

Source§

type Response = Id<SessionMarker>

The response type for this command
Source§

type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CreateSessionCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a

Future type returned by handle method
Source§

fn handle(&self, command: CreateSessionCommand) -> Self::HandleFuture<'_>

Handle the command and return a future
Source§

impl<R, P, F> CommandHandlerGat<CreateStreamCommand> for SessionCommandHandler<R, P, F>

Source§

type Response = Id<StreamMarker>

The response type for this command
Source§

type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<CreateStreamCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a

Future type returned by handle method
Source§

fn handle(&self, command: CreateStreamCommand) -> Self::HandleFuture<'_>

Handle the command and return a future
Source§

impl<R, P, F> CommandHandlerGat<GenerateFramesCommand> for SessionCommandHandler<R, P, F>

Source§

type Response = Vec<Frame>

The response type for this command
Source§

type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<GenerateFramesCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a

Future type returned by handle method
Source§

fn handle(&self, command: GenerateFramesCommand) -> Self::HandleFuture<'_>

Handle the command and return a future
Source§

impl<R, P, F> CommandHandlerGat<StartStreamCommand> for SessionCommandHandler<R, P, F>

Source§

type Response = ()

The response type for this command
Source§

type HandleFuture<'a> = impl Future<Output = Result<<SessionCommandHandler<R, P, F> as CommandHandlerGat<StartStreamCommand>>::Response, ApplicationError>> + Send + 'a where Self: 'a

Future type returned by handle method
Source§

fn handle(&self, command: StartStreamCommand) -> Self::HandleFuture<'_>

Handle the command and return a future
Source§

impl<R, P, F> Debug for SessionCommandHandler<R, P, F>
where R: StreamRepositoryGat + 'static, P: EventPublisherGat + 'static, F: FrameStoreGat + 'static,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more