Skip to main content

Context

Struct Context 

Source
pub struct Context {
    pub runtime: Arc<Runtime>,
    pub executor: Arc<Executor>,
    pub proc: Arc<Process>,
    /* private fields */
}

Fields§

§runtime: Arc<Runtime>§executor: Arc<Executor>§proc: Arc<Process>

Implementations§

Source§

impl Context

Source

pub fn new(proc: &Arc<Process>, task: &Arc<Task>) -> Self

Source

pub fn scope<T, F: Fn() -> T>(ctx: &Context, f: F) -> T

Source

pub fn try_with_current<T, F: FnOnce(&Context) -> T>(f: F) -> Result<T>

Access the active scheduler context without cloning it.

Source

pub fn with<T, F: Fn(&Context) -> T>(f: F) -> T

Source

pub fn current() -> Result<Context>

Source

pub fn set_task(&self, task: &Arc<Task>)

Source

pub fn task(&self) -> Arc<Task>

Source

pub fn workdir(&self) -> Option<PathBuf>

The directory this process’s filesystem access is confined to (<acl workdir root>/<pid>), or None when the engine’s ACL config declares no workdir root. Packages that touch the filesystem (shell, and any custom one) read it here and refuse to leave it; a workflow script reads the same directory as $env.WORK_DIR (see [crate::utils::consts::ENV_WORK_DIR]).

Source

pub fn cancellation_token(&self) -> CancellationToken

A token that fires once this act should stop the work it started: the engine is shutting down, or the task was overridden while it ran (an abort/cancel/skip/remove/next action, or an error — see Task::set_state).

A package that starts something outside the engine — a child process, an HTTP request, a subscription — selects on it and gives that work up when it fires, so a cancelled act does not hold its scheduler lane until its own deadline. It is a “stop now” signal, not a bound on how long an act may run: that is the act’s own timeout.

let cancel = ctx.cancellation_token();
tokio::select! {
    response = some_request() => Ok(response),
    _ = cancel.cancelled() => Err(ActError::Runtime("cancelled".to_string())),
}
Source

pub async fn prepare(&self) -> Result<()>

Source

pub async fn resolve_sealed(&self) -> Result<()>

Source

pub fn set_action(&self, action: &Action) -> Result<()>

Source

pub fn vars(&self) -> Vars

Source

pub fn set_env<T>(&self, name: &str, value: T)
where T: Serialize + Clone,

Source

pub fn get_env<T>(&self, name: &str) -> Option<T>
where T: for<'de> Deserialize<'de> + Clone,

Source

pub fn set_var<T>(&self, name: &str, value: T)
where T: Serialize + Clone,

Source

pub fn get_var<T>(&self, name: &str) -> Option<T>
where T: for<'de> Deserialize<'de> + Clone,

Source

pub fn eval<T: DeserializeOwned + Serialize>(&self, expr: &str) -> Result<T>

Source

pub fn sched_task(&self, node: &Arc<Node>, prev: Arc<Task>) -> Result<()>

Source

pub fn sched_task_with_vars( &self, node: &Arc<Node>, vars: Vars, parent: Arc<Task>, ) -> Result<()>

Source

pub fn schedule_once(&self, node: &Arc<Node>, prev: Arc<Task>) -> Result<()>

Schedule node with prev as its predecessor, reusing the task instance that was already created for the same (node, prev) slot when it is still in flight. A crash mid-next (or its recovery replay) can re-run the propagation after the node was already scheduled; re-creating the task would duplicate it. Instances that were persisted but never started (state None) are re-enqueued; terminal instances (completed, skipped, …) are left alone so legitimate re-execution (redo, timeout re-evaluation) still creates fresh tasks.

Source

pub fn dispatch_act(&self, act: &Act, vars: Vars) -> Result<()>

Source

pub fn build_acts(&self, acts: &[Act], is_sequence: bool) -> Result<()>

Source

pub fn redo_task(&self, task: &Arc<Task>) -> Result<()>

redo the task and dispatch directly

Source

pub async fn back_task( &self, task: &Arc<Task>, paths: &Vec<Arc<Task>>, ) -> Result<()>

Source

pub async fn abort_task(&self, task: &Arc<Task>) -> Result<()>

Source

pub async fn undo_task(&self, task: &Arc<Task>) -> Result<()>

undo task the undo task is a step task, set the task as completed and set the children acts as cancelled

Source

pub async fn emit_error(&self) -> Result<()>

Source

pub async fn emit_task(&self, task: &Arc<Task>) -> Result<()>

Source

pub async fn emit_message(&self, msg: &Act) -> Result<()>

Source

pub async fn push_next(&self) -> Result<()>

Enqueue the task’s next propagation through the durable outbox: the task state is flushed and a Pending outbox record is written before the in-memory queue dispatch.

Trait Implementations§

Source§

impl Clone for Context

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Context

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ParallelSend for T
where T: Send,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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