pub struct ContextOrchestrator { /* private fields */ }Expand description
Orchestrates multiple ContextRuntimes across OS threads.
Routes incoming events to the correct context based on event type and stream assignments.
Implementations§
Source§impl ContextOrchestrator
impl ContextOrchestrator
Sourcepub fn build(
context_map: &ContextMap,
program: &Program,
output_tx: Sender<Event>,
channel_capacity: usize,
) -> Result<Self, String>
pub fn build( context_map: &ContextMap, program: &Program, output_tx: Sender<Event>, channel_capacity: usize, ) -> Result<Self, String>
Build the orchestrator from engine state.
For each declared context:
- Creates a bounded mpsc channel
- Creates an Engine with only the streams assigned to that context
- Spawns an OS thread with optional CPU affinity
- Inside the thread: creates a single-threaded Tokio runtime and runs the ContextRuntime event loop
Sourcepub fn build_with_checkpoint(
context_map: &ContextMap,
program: &Program,
output_tx: Sender<Event>,
channel_capacity: usize,
checkpoint_config: Option<(CheckpointConfig, Arc<dyn StateStore>)>,
recovery_checkpoint: Option<&Checkpoint>,
) -> Result<Self, String>
pub fn build_with_checkpoint( context_map: &ContextMap, program: &Program, output_tx: Sender<Event>, channel_capacity: usize, checkpoint_config: Option<(CheckpointConfig, Arc<dyn StateStore>)>, recovery_checkpoint: Option<&Checkpoint>, ) -> Result<Self, String>
Build the orchestrator with optional checkpoint configuration and recovery state.
Sourcepub async fn process(&self, event: SharedEvent) -> Result<(), String>
pub async fn process(&self, event: SharedEvent) -> Result<(), String>
Route an incoming event to the correct context (async, waits on backpressure).
Sourcepub fn try_process(&self, event: SharedEvent) -> Result<(), DispatchError>
pub fn try_process(&self, event: SharedEvent) -> Result<(), DispatchError>
Non-blocking dispatch — returns ChannelFull instead of waiting.
Sourcepub fn process_batch(&self, events: Vec<SharedEvent>) -> Vec<DispatchError>
pub fn process_batch(&self, events: Vec<SharedEvent>) -> Vec<DispatchError>
Batch dispatch — non-blocking, returns errors for events that could not be sent.
Sourcepub fn router(&self) -> EventTypeRouter
pub fn router(&self) -> EventTypeRouter
Get a cloneable router handle for direct multi-producer dispatch.
Sourcepub fn shutdown(self)
pub fn shutdown(self)
Shut down all context threads.
Sends shutdown signal, drops senders, and waits for threads to finish.
Sourcepub fn trigger_checkpoint(&mut self)
pub fn trigger_checkpoint(&mut self)
Trigger a checkpoint across all contexts.
Sends a CheckpointBarrier to every context. Each context will snapshot
its engine state and send a CheckpointAck back. Call try_complete_checkpoint()
afterwards to drain acks and persist.
Sourcepub fn try_complete_checkpoint(&mut self) -> Result<bool, StoreError>
pub fn try_complete_checkpoint(&mut self) -> Result<bool, StoreError>
Try to complete a pending checkpoint by draining acknowledgments.
Returns true if a checkpoint was fully completed and persisted.
Sourcepub fn should_checkpoint(&self) -> bool
pub fn should_checkpoint(&self) -> bool
Check if a periodic checkpoint should be triggered (based on configured interval).
Sourcepub fn checkpoint_tick(&mut self) -> Result<bool, StoreError>
pub fn checkpoint_tick(&mut self) -> Result<bool, StoreError>
Run one checkpoint cycle: trigger if due, then try to complete.
Call this periodically from the main event loop (e.g., every second or on a timer).
Sourcepub fn context_names(&self) -> Vec<&str>
pub fn context_names(&self) -> Vec<&str>
Get the names of all running contexts
Sourcepub const fn ingress_routing(&self) -> &FxHashMap<String, String>
pub const fn ingress_routing(&self) -> &FxHashMap<String, String>
Get the ingress routing table (for testing/debugging)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextOrchestrator
impl !RefUnwindSafe for ContextOrchestrator
impl Send for ContextOrchestrator
impl Sync for ContextOrchestrator
impl Unpin for ContextOrchestrator
impl UnsafeUnpin for ContextOrchestrator
impl !UnwindSafe for ContextOrchestrator
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