pub struct Engine {
pub config: EngineConfig,
pub metrics: Metrics,
pub changed: Arc<Notify>,
/* private fields */
}Fields§
§config: EngineConfig§metrics: Metrics§changed: Arc<Notify>Implementations§
Source§impl Engine
impl Engine
Sourcepub fn open(store: Store, config: EngineConfig, clock: Clock) -> Result<Engine>
pub fn open(store: Store, config: EngineConfig, clock: Clock) -> Result<Engine>
Open the engine and recover every non-terminal execution from history.
pub fn now(&self) -> u64
pub fn register_definition(&mut self, ir: WorkflowIr) -> Result<bool>
pub fn definitions(&self) -> Vec<Arc<WorkflowIr>>
pub fn definition( &self, name: &str, version: Option<&str>, ) -> Option<Arc<WorkflowIr>>
pub fn start( &mut self, workflow: &str, version: Option<&str>, input: Value, execution_id: Option<String>, ) -> Result<StartResult>
Sourcepub fn start_scheduled(
&mut self,
workflow: &str,
version: Option<&str>,
input: Value,
execution_id: String,
schedule_id: &str,
) -> Result<StartResult>
pub fn start_scheduled( &mut self, workflow: &str, version: Option<&str>, input: Value, execution_id: String, schedule_id: &str, ) -> Result<StartResult>
Engine::start for a schedule: the execution records schedule_id.
pub fn cancel(&mut self, id: &str, reason: &str) -> Result<ExecutionState>
Sourcepub fn signal(&mut self, id: &str, name: &str, payload: Value) -> Result<u64>
pub fn signal(&mut self, id: &str, name: &str, payload: Value) -> Result<u64>
Send a typed signal to a running execution. The payload is validated
against the workflow’s signal declaration (defaults applied) and
buffered until an await step takes it. Returns the history sequence
number of the recorded signal.
Sourcepub fn query(&self, id: &str, name: &str) -> Result<Value>
pub fn query(&self, id: &str, name: &str) -> Result<Value>
Evaluate a declared query against the current state of an execution.
Steps that have not completed read as null.
pub fn execution(&self, id: &str) -> Result<ExecutionState>
pub fn history(&self, id: &str) -> Result<Vec<HistoryEvent>>
Sourcepub fn run_history(&self, id: &str, run: u32) -> Result<Vec<HistoryEvent>>
pub fn run_history(&self, id: &str, run: u32) -> Result<Vec<HistoryEvent>>
The history of one run of an execution (continue-as-new): the current run’s, or an earlier run’s from the archive.
pub fn list_executions( &self, status: Option<&str>, workflow: Option<&str>, limit: u32, ) -> Result<Vec<ExecutionSummary>>
pub fn active_count(&self) -> usize
Sourcepub fn tick(&mut self) -> Result<Vec<TaskAssignment>>
pub fn tick(&mut self) -> Result<Vec<TaskAssignment>>
Periodic work: timers, retries, deadlines, worker liveness, built-ins.
pub fn register_worker(&mut self, req: RegisterWorker) -> Result<Registration>
pub fn heartbeat(&mut self, session_id: &str) -> Result<HeartbeatAck>
pub fn unregister_worker(&mut self, session_id: &str) -> Result<()>
pub fn workers(&self) -> Result<Vec<WorkerInfo>>
Sourcepub fn poll(&mut self, session_id: &str) -> Result<Option<TaskAssignment>>
pub fn poll(&mut self, session_id: &str) -> Result<Option<TaskAssignment>>
Hand the oldest matching queued task to a worker, if any.
Sourcepub fn complete(&mut self, token: &str, output: Value) -> Result<ResultAck>
pub fn complete(&mut self, token: &str, output: Value) -> Result<ResultAck>
Record a successful task result.
Sourcepub fn fail(&mut self, token: &str, error: TaskError) -> Result<ResultAck>
pub fn fail(&mut self, token: &str, error: TaskError) -> Result<ResultAck>
Record a failed attempt.
pub fn store_stats(&self) -> Result<Vec<(String, u64)>>
Sourcepub fn enable_telemetry(&mut self, config: TelemetryConfig)
pub fn enable_telemetry(&mut self, config: TelemetryConfig)
Export OpenTelemetry traces of executions (see crate::telemetry).
Sourcepub fn session_worker(&self, session_id: &str) -> Option<&str>
pub fn session_worker(&self, session_id: &str) -> Option<&str>
The worker id that owns a session, if the session exists.
Sourcepub fn token_worker(&self, token: &str) -> Option<&str>
pub fn token_worker(&self, token: &str) -> Option<&str>
The worker id a task token was issued to, if the token is known.
pub fn session_count(&self) -> usize
Sourcepub fn refresh_definitions(&mut self) -> Result<usize>
pub fn refresh_definitions(&mut self) -> Result<usize>
Load definitions registered in the store since this engine opened (another server registered them). Used by cluster standbys, whose engine only reads. Returns how many were new.
Source§impl Engine
impl Engine
The shared-mode context, when this engine runs in shared mode.
Sourcepub fn session_worker_lookup(&mut self, session_id: &str) -> Option<String>
pub fn session_worker_lookup(&mut self, session_id: &str) -> Option<String>
Engine::session_worker that also finds sessions opened on other
servers (shared mode).
Sourcepub fn token_worker_lookup(&self, token: &str) -> Option<String>
pub fn token_worker_lookup(&self, token: &str) -> Option<String>
Engine::token_worker that also finds tokens issued by other
servers (shared mode).
Source§impl Engine
impl Engine
Sourcepub fn create_schedule(&mut self, req: CreateSchedule) -> Result<Value>
pub fn create_schedule(&mut self, req: CreateSchedule) -> Result<Value>
Create a schedule. Its first occurrence is the first one after now.
pub fn schedule_row(&self, id: &str) -> Result<ScheduleRow>
pub fn get_schedule(&self, id: &str) -> Result<Value>
Sourcepub fn schedule_workflow(&self, id: &str) -> Result<String>
pub fn schedule_workflow(&self, id: &str) -> Result<String>
The workflow a schedule starts (for authorization).
pub fn list_schedules(&self) -> Result<Vec<Value>>
Sourcepub fn update_schedule(&mut self, id: &str, patch: Value) -> Result<Value>
pub fn update_schedule(&mut self, id: &str, patch: Value) -> Result<Value>
Change a schedule: patch holds the fields to change (null clears
an optional one; paused pauses or resumes). The next occurrence is
recomputed from now, so occurrences missed while paused are skipped.
pub fn set_schedule_paused(&mut self, id: &str, paused: bool) -> Result<Value>
pub fn delete_schedule(&mut self, id: &str) -> Result<()>
Sourcepub fn trigger_schedule(&mut self, id: &str) -> Result<Triggered>
pub fn trigger_schedule(&mut self, id: &str) -> Result<Triggered>
Fire a schedule now, outside its timing (the overlap policy applies).
The execution id is <schedule-id>:manual:<now>.
Sourcepub fn fire_schedules(&mut self) -> Result<usize>
pub fn fire_schedules(&mut self) -> Result<usize>
Fire every due occurrence (called from Engine::tick). Looks the
store up at most every POLL_MS, unless a schedule changed here.
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl !Sync for Engine
impl !UnwindSafe for Engine
impl Forget for Engine
impl Move for Engine
impl Send for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request