Skip to main content

Engine

Struct Engine 

Source
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

Source

pub fn open(store: Store, config: EngineConfig, clock: Clock) -> Result<Engine>

Open the engine and recover every non-terminal execution from history.

Source

pub fn now(&self) -> u64

Source

pub fn register_definition(&mut self, ir: WorkflowIr) -> Result<bool>

Source

pub fn definitions(&self) -> Vec<Arc<WorkflowIr>>

Source

pub fn definition( &self, name: &str, version: Option<&str>, ) -> Option<Arc<WorkflowIr>>

Source

pub fn start( &mut self, workflow: &str, version: Option<&str>, input: Value, execution_id: Option<String>, ) -> Result<StartResult>

Source

pub fn cancel(&mut self, id: &str, reason: &str) -> Result<ExecutionState>

Source

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.

Source

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.

Source

pub fn execution(&self, id: &str) -> Result<ExecutionState>

Source

pub fn history(&self, id: &str) -> Result<Vec<HistoryEvent>>

Source

pub fn list_executions( &self, status: Option<&str>, workflow: Option<&str>, limit: u32, ) -> Result<Vec<ExecutionSummary>>

Source

pub fn active_count(&self) -> usize

Source

pub fn tick(&mut self) -> Result<Vec<TaskAssignment>>

Periodic work: timers, retries, deadlines, worker liveness, built-ins.

Source

pub fn register_worker(&mut self, req: RegisterWorker) -> Result<Registration>

Source

pub fn heartbeat(&mut self, session_id: &str) -> Result<HeartbeatAck>

Source

pub fn unregister_worker(&mut self, session_id: &str) -> Result<()>

Source

pub fn workers(&self) -> Result<Vec<WorkerInfo>>

Source

pub fn poll(&mut self, session_id: &str) -> Result<Option<TaskAssignment>>

Hand the oldest matching queued task to a worker, if any.

Source

pub fn complete(&mut self, token: &str, output: Value) -> Result<ResultAck>

Record a successful task result.

Source

pub fn fail(&mut self, token: &str, error: TaskError) -> Result<ResultAck>

Record a failed attempt.

Source

pub fn store_stats(&self) -> Result<Vec<(String, u64)>>

Source

pub fn enable_telemetry(&mut self, config: TelemetryConfig)

Export OpenTelemetry traces of executions (see crate::telemetry).

Source

pub fn session_worker(&self, session_id: &str) -> Option<&str>

The worker id that owns a session, if the session exists.

Source

pub fn token_worker(&self, token: &str) -> Option<&str>

The worker id a task token was issued to, if the token is known.

Source

pub fn session_count(&self) -> usize

Source

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

Source

pub fn shared_context(&self) -> Option<Arc<Ctx>>

The shared-mode context, when this engine runs in shared mode.

Source

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).

Source

pub fn token_worker_lookup(&self, token: &str) -> Option<String>

Engine::token_worker that also finds tokens issued by other servers (shared mode).

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<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more