pub struct StreamSession { /* private fields */ }Expand description
StreamSession aggregate root - manages multiple prioritized streams
Implementations§
Source§impl StreamSession
impl StreamSession
Sourcepub fn new(config: SessionConfig) -> Self
pub fn new(config: SessionConfig) -> Self
Create new session
Sourcepub fn state(&self) -> &SessionState
pub fn state(&self) -> &SessionState
Get current state
Sourcepub fn config(&self) -> &SessionConfig
pub fn config(&self) -> &SessionConfig
Get configuration
Sourcepub fn stats(&self) -> &SessionStats
pub fn stats(&self) -> &SessionStats
Get statistics
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
Get creation timestamp
Sourcepub fn updated_at(&self) -> DateTime<Utc>
pub fn updated_at(&self) -> DateTime<Utc>
Get last update timestamp
Sourcepub fn expires_at(&self) -> DateTime<Utc>
pub fn expires_at(&self) -> DateTime<Utc>
Get expiration timestamp
Sourcepub fn completed_at(&self) -> Option<DateTime<Utc>>
pub fn completed_at(&self) -> Option<DateTime<Utc>>
Get completion timestamp
Sourcepub fn client_info(&self) -> Option<&str>
pub fn client_info(&self) -> Option<&str>
Get client info metadata
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if session is expired
Sourcepub fn get_stream(&self, stream_id: StreamId) -> Option<&Stream>
pub fn get_stream(&self, stream_id: StreamId) -> Option<&Stream>
Get stream by ID
Sourcepub fn update_stream_config(
&mut self,
stream_id: StreamId,
config: StreamConfig,
) -> DomainResult<()>
pub fn update_stream_config( &mut self, stream_id: StreamId, config: StreamConfig, ) -> DomainResult<()>
Update configuration of a child stream through the aggregate root.
Child mutations must flow through the aggregate so the session-level
timestamp is bumped and a DomainEvent::StreamConfigUpdated event is
raised. Application code MUST NOT reach into Stream directly to
mutate config — the previous get_stream_mut accessor that allowed
this was a DDD violation (see issue #259).
Sourcepub fn create_stream_patch_frames(
&mut self,
stream_id: StreamId,
priority_threshold: Priority,
max_frames: usize,
) -> DomainResult<Vec<Frame>>
pub fn create_stream_patch_frames( &mut self, stream_id: StreamId, priority_threshold: Priority, max_frames: usize, ) -> DomainResult<Vec<Frame>>
Generate patch frames for a child stream through the aggregate root.
Wraps Stream::create_patch_frames so that session-level statistics
(stats.total_frames) and the updated_at timestamp stay consistent
with the child mutation, and a DomainEvent::FramesBatched event is
raised when frames are produced.
Sourcepub fn activate(&mut self) -> DomainResult<()>
pub fn activate(&mut self) -> DomainResult<()>
Activate session
Sourcepub fn create_stream(&mut self, source_data: JsonData) -> DomainResult<StreamId>
pub fn create_stream(&mut self, source_data: JsonData) -> DomainResult<StreamId>
Create new stream in this session
Sourcepub fn start_stream(&mut self, stream_id: StreamId) -> DomainResult<()>
pub fn start_stream(&mut self, stream_id: StreamId) -> DomainResult<()>
Start streaming for a specific stream
Sourcepub fn complete_stream(&mut self, stream_id: StreamId) -> DomainResult<()>
pub fn complete_stream(&mut self, stream_id: StreamId) -> DomainResult<()>
Complete a specific stream
Sourcepub fn fail_stream(
&mut self,
stream_id: StreamId,
error: String,
) -> DomainResult<()>
pub fn fail_stream( &mut self, stream_id: StreamId, error: String, ) -> DomainResult<()>
Fail a specific stream
Sourcepub fn create_priority_frames(
&mut self,
batch_size: usize,
) -> DomainResult<Vec<Frame>>
pub fn create_priority_frames( &mut self, batch_size: usize, ) -> DomainResult<Vec<Frame>>
Create frames for all active streams based on priority
Sourcepub fn close(&mut self) -> DomainResult<()>
pub fn close(&mut self) -> DomainResult<()>
Close session gracefully
Sourcepub fn force_close_expired(&mut self) -> DomainResult<bool>
pub fn force_close_expired(&mut self) -> DomainResult<bool>
Force close expired session with proper cleanup
Sourcepub fn extend_timeout(&mut self, additional_seconds: u64) -> DomainResult<()>
pub fn extend_timeout(&mut self, additional_seconds: u64) -> DomainResult<()>
Extend session timeout (if allowed)
Sourcepub fn set_client_info(
&mut self,
client_info: String,
user_agent: Option<String>,
ip_address: Option<String>,
)
pub fn set_client_info( &mut self, client_info: String, user_agent: Option<String>, ip_address: Option<String>, )
Set client information
Sourcepub fn pending_events(&self) -> &VecDeque<DomainEvent>
pub fn pending_events(&self) -> &VecDeque<DomainEvent>
Get pending domain events
Sourcepub fn take_events(&mut self) -> VecDeque<DomainEvent>
pub fn take_events(&mut self) -> VecDeque<DomainEvent>
Take all pending events (clears the queue)
Sourcepub fn health_check(&self) -> SessionHealth
pub fn health_check(&self) -> SessionHealth
Check session health
Trait Implementations§
Source§impl Clone for StreamSession
impl Clone for StreamSession
Source§fn clone(&self) -> StreamSession
fn clone(&self) -> StreamSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamSession
impl Debug for StreamSession
Source§impl<'de> Deserialize<'de> for StreamSession
impl<'de> Deserialize<'de> for StreamSession
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for StreamSession
impl RefUnwindSafe for StreamSession
impl Send for StreamSession
impl Sync for StreamSession
impl Unpin for StreamSession
impl UnsafeUnpin for StreamSession
impl UnwindSafe for StreamSession
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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