pub struct OrchestratorCoordinator { /* private fields */ }Expand description
Orchestration coordinator holding shared backend references.
Created by crate::app::RustvelloApp or directly via Self::new
for the from_backends() FFI path. All methods are &self — the
coordinator is logically immutable once built.
Implementations§
Source§impl OrchestratorCoordinator
impl OrchestratorCoordinator
Sourcepub async fn route_call(
&self,
new_invocation_id: &InvocationId,
call_dto: &CallDTO,
cc_args: Option<&SerializedArguments>,
registration_cc: ConcurrencyControlType,
index_cc: bool,
runner_id: &RunnerId,
) -> RustvelloResult<RouteCallResult>
pub async fn route_call( &self, new_invocation_id: &InvocationId, call_dto: &CallDTO, cc_args: Option<&SerializedArguments>, registration_cc: ConcurrencyControlType, index_cc: bool, runner_id: &RunnerId, ) -> RustvelloResult<RouteCallResult>
Route a call: check registration CC, create or reuse an invocation, route.
Mirrors pynenc’s BaseOrchestrator.route_call():
- If
registration_cc == Unlimited: always create a new invocation. - Else: query existing REGISTERED invocations with matching CC args.
- No match → create new.
- Match with same
call_id→ reuse (return existing). - Match with different
call_id→ returnReusedDifferentCallso the caller can decide (raise error or reuse).
- For new invocations: register + persist + index CC + route.
Sourcepub async fn reroute_invocations(
&self,
invocation_ids: &[InvocationId],
runner_id: &RunnerId,
) -> RustvelloResult<()>
pub async fn reroute_invocations( &self, invocation_ids: &[InvocationId], runner_id: &RunnerId, ) -> RustvelloResult<()>
Reroute a set of invocations: transition to Rerouted, then re-enqueue.
Mirrors pynenc’s BaseOrchestrator.reroute_invocations():
For each invocation: set status REROUTED → route through broker.
Invalid status transitions are silently skipped (race-safe).
Sourcepub async fn trigger_loop_iteration(
&self,
runner_id: &RunnerId,
) -> RustvelloResult<Vec<InvocationId>>
pub async fn trigger_loop_iteration( &self, runner_id: &RunnerId, ) -> RustvelloResult<Vec<InvocationId>>
Execute one trigger evaluation loop iteration.
Mirrors pynenc’s BaseTrigger.trigger_loop_iteration():
- Evaluate cron conditions (time-based).
- Process valid conditions → match triggers → fire.
- For each fired trigger: register a new invocation + route.
Returns the list of invocation IDs created by triggers.
Sourcepub async fn check_atomic_services(
&self,
runner_id: &RunnerId,
service_interval_minutes: f64,
spread_margin_minutes: f64,
runner_timeout_seconds: f64,
) -> RustvelloResult<Option<Vec<InvocationId>>>
pub async fn check_atomic_services( &self, runner_id: &RunnerId, service_interval_minutes: f64, spread_margin_minutes: f64, runner_timeout_seconds: f64, ) -> RustvelloResult<Option<Vec<InvocationId>>>
Execute one atomic service check: coordination + trigger loop + recording.
Mirrors pynenc’s BaseRunner._check_atomic_services() flow:
- Register heartbeat for this runner (with
can_run_atomic_service=true). - Get active runners eligible for atomic services.
- Check distributed coordination algorithm (time-slot allocation).
- If authorized: run
trigger_loop_iteration, record execution. - Return
Noneif not authorized,Some(created_ids)if ran.
Source§impl OrchestratorCoordinator
impl OrchestratorCoordinator
Sourcepub async fn get_invocations_to_run(
&self,
max_num_invocations: usize,
runner_id: &RunnerId,
config_for_task: &dyn Fn(&TaskId) -> Option<TaskConfig>,
) -> RustvelloResult<Vec<InvocationId>>
pub async fn get_invocations_to_run( &self, max_num_invocations: usize, runner_id: &RunnerId, config_for_task: &dyn Fn(&TaskId) -> Option<TaskConfig>, ) -> RustvelloResult<Vec<InvocationId>>
Retrieve invocations ready to run, handling blocking priority and CC.
- Prioritise blocking invocations (those with waiters)
- Fill remaining slots from broker queue
- For each candidate: check CC, set PENDING or reject/reroute
- Reroute CC-denied invocations at the end
config_for_task resolves the effective task config for CC decisions.
Returns None when the task is unknown (CC is skipped).
Source§impl OrchestratorCoordinator
impl OrchestratorCoordinator
Sourcepub fn new(
orchestrator: Arc<dyn Orchestrator>,
state_backend: Arc<dyn StateBackend>,
broker: Arc<dyn Broker>,
client_data_store: Arc<ClientDataStoreManager>,
trigger_manager: Option<TriggerManager>,
auto_purge_hours: f64,
) -> Self
pub fn new( orchestrator: Arc<dyn Orchestrator>, state_backend: Arc<dyn StateBackend>, broker: Arc<dyn Broker>, client_data_store: Arc<ClientDataStoreManager>, trigger_manager: Option<TriggerManager>, auto_purge_hours: f64, ) -> Self
Create a new coordinator from shared backend references.
Sourcepub async fn set_invocation_status(
&self,
invocation_id: &InvocationId,
status: InvocationStatus,
runner_id: &RunnerId,
) -> RustvelloResult<InvocationStatusRecord>
pub async fn set_invocation_status( &self, invocation_id: &InvocationId, status: InvocationStatus, runner_id: &RunnerId, ) -> RustvelloResult<InvocationStatusRecord>
Atomic status transition with all side-effects, auto-resolving trigger context.
Looks up task_id and arguments from the state backend for trigger
reporting. Prefer Self::set_invocation_status_with_context when
the caller already has this data.
Sourcepub async fn set_invocation_status_with_context(
&self,
invocation_id: &InvocationId,
status: InvocationStatus,
runner_id: &RunnerId,
task_id: &TaskId,
arguments: BTreeMap<String, String>,
) -> RustvelloResult<InvocationStatusRecord>
pub async fn set_invocation_status_with_context( &self, invocation_id: &InvocationId, status: InvocationStatus, runner_id: &RunnerId, task_id: &TaskId, arguments: BTreeMap<String, String>, ) -> RustvelloResult<InvocationStatusRecord>
Atomic status transition with all side-effects and explicit trigger context.
- Atomic status transition (validates state machine)
- If terminal: release waiters + schedule auto-purge
- Record history in state backend
- Notify trigger system (if configured)
Sourcepub async fn register_invocations(
&self,
invocations: &[(InvocationDTO, CallDTO)],
runner_id: &RunnerId,
) -> RustvelloResult<()>
pub async fn register_invocations( &self, invocations: &[(InvocationDTO, CallDTO)], runner_id: &RunnerId, ) -> RustvelloResult<()>
Register invocations with all side-effects.
- Upsert each invocation + call in state backend
- Register with orchestrator (sets Registered status)
- Record history for each
- Notify trigger system (if configured)
- Route all through broker
Sourcepub async fn set_invocation_result(
&self,
invocation_id: &InvocationId,
result: &str,
runner_id: &RunnerId,
) -> RustvelloResult<()>
pub async fn set_invocation_result( &self, invocation_id: &InvocationId, result: &str, runner_id: &RunnerId, ) -> RustvelloResult<()>
Store result and transition to Success, auto-resolving trigger context.
Sourcepub async fn set_invocation_result_with_context(
&self,
invocation_id: &InvocationId,
result: &str,
runner_id: &RunnerId,
task_id: &TaskId,
arguments: BTreeMap<String, String>,
) -> RustvelloResult<()>
pub async fn set_invocation_result_with_context( &self, invocation_id: &InvocationId, result: &str, runner_id: &RunnerId, task_id: &TaskId, arguments: BTreeMap<String, String>, ) -> RustvelloResult<()>
Store a successful result and transition to Success with explicit context.
- Store result in state backend
- Set status to Success (includes release_waiters, auto_purge, history, trigger)
- Notify trigger system of result (if configured)
Sourcepub async fn set_invocation_exception(
&self,
invocation_id: &InvocationId,
error_type: &str,
error_message: &str,
runner_id: &RunnerId,
) -> RustvelloResult<()>
pub async fn set_invocation_exception( &self, invocation_id: &InvocationId, error_type: &str, error_message: &str, runner_id: &RunnerId, ) -> RustvelloResult<()>
Store exception and transition to Failed, auto-resolving trigger context.
Sourcepub async fn set_invocation_exception_with_context(
&self,
invocation_id: &InvocationId,
error_type: &str,
error_message: &str,
runner_id: &RunnerId,
task_id: &TaskId,
arguments: BTreeMap<String, String>,
) -> RustvelloResult<()>
pub async fn set_invocation_exception_with_context( &self, invocation_id: &InvocationId, error_type: &str, error_message: &str, runner_id: &RunnerId, task_id: &TaskId, arguments: BTreeMap<String, String>, ) -> RustvelloResult<()>
Store an exception and transition to Failed with explicit context.
- Store error in state backend
- Set status to Failed (includes release_waiters, auto_purge, history, trigger)
- Notify trigger system of failure (if configured)
Sourcepub async fn set_invocation_retry(
&self,
invocation_id: &InvocationId,
runner_id: &RunnerId,
) -> RustvelloResult<()>
pub async fn set_invocation_retry( &self, invocation_id: &InvocationId, runner_id: &RunnerId, ) -> RustvelloResult<()>
Set an invocation for retry, auto-resolving trigger context.
Sourcepub async fn set_invocation_retry_with_context(
&self,
invocation_id: &InvocationId,
runner_id: &RunnerId,
task_id: &TaskId,
arguments: BTreeMap<String, String>,
) -> RustvelloResult<()>
pub async fn set_invocation_retry_with_context( &self, invocation_id: &InvocationId, runner_id: &RunnerId, task_id: &TaskId, arguments: BTreeMap<String, String>, ) -> RustvelloResult<()>
Set an invocation for retry with explicit context.
- Set status to Retry (via
set_invocation_status_with_context) - Increment retry counter
- Re-route through broker
Sourcepub async fn get_trigger_context(
&self,
invocation_id: &InvocationId,
) -> (TaskId, BTreeMap<String, String>)
pub async fn get_trigger_context( &self, invocation_id: &InvocationId, ) -> (TaskId, BTreeMap<String, String>)
Look up task_id and arguments for trigger context from state backend.
Auto Trait Implementations§
impl Freeze for OrchestratorCoordinator
impl !RefUnwindSafe for OrchestratorCoordinator
impl Send for OrchestratorCoordinator
impl Sync for OrchestratorCoordinator
impl Unpin for OrchestratorCoordinator
impl UnsafeUnpin for OrchestratorCoordinator
impl !UnwindSafe for OrchestratorCoordinator
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.