pub struct SessionManager { /* private fields */ }Expand description
Manages session IDs for ordered event processing.
The session manager provides different strategies for grouping related events to ensure they are processed in order. This is critical for maintaining consistency when handling sequences of related events.
§Examples
use github_bot_sdk::events::{SessionManager, SessionIdStrategy};
let manager = SessionManager::new(SessionIdStrategy::Entity);
// Use with event processing...Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(strategy: SessionIdStrategy) -> Self
pub fn new(strategy: SessionIdStrategy) -> Self
Create a new session manager with the given strategy.
Sourcepub fn generate_session_id(&self, envelope: &EventEnvelope) -> Option<String>
pub fn generate_session_id(&self, envelope: &EventEnvelope) -> Option<String>
Generate a session ID for an event envelope.
Returns None if the strategy is SessionIdStrategy::None or if
the event doesn’t support session-based ordering.
Sourcepub fn extract_ordering_key(&self, envelope: &EventEnvelope) -> Option<String>
pub fn extract_ordering_key(&self, envelope: &EventEnvelope) -> Option<String>
Extract an ordering key from an event envelope.
The ordering key is used by queue systems to ensure events with the same key are processed in order.
Sourcepub fn entity_session_strategy() -> SessionIdStrategy
pub fn entity_session_strategy() -> SessionIdStrategy
Get an entity-based session strategy.
Creates session IDs in the format: {entity_type}-{repo}-{entity_id}
For example: “pr-owner/repo-123” or “issue-owner/repo-456”
Sourcepub fn repository_session_strategy() -> SessionIdStrategy
pub fn repository_session_strategy() -> SessionIdStrategy
Get a repository-based session strategy.
All events for a repository share the same session ID.
Format: repo-{owner}/{name}