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
impl Context
pub fn new(proc: &Arc<Process>, task: &Arc<Task>) -> Self
pub fn scope<T, F: Fn() -> T>(ctx: &Context, f: F) -> T
Sourcepub fn try_with_current<T, F: FnOnce(&Context) -> T>(f: F) -> Result<T>
pub fn try_with_current<T, F: FnOnce(&Context) -> T>(f: F) -> Result<T>
Access the active scheduler context without cloning it.
pub fn with<T, F: Fn(&Context) -> T>(f: F) -> T
pub fn current() -> Result<Context>
pub fn set_task(&self, task: &Arc<Task>)
pub fn task(&self) -> Arc<Task> ⓘ
Sourcepub fn workdir(&self) -> Option<PathBuf>
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]).
Sourcepub fn cancellation_token(&self) -> CancellationToken
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())),
}pub async fn prepare(&self) -> Result<()>
pub async fn resolve_sealed(&self) -> Result<()>
pub fn set_action(&self, action: &Action) -> Result<()>
pub fn vars(&self) -> Vars
pub fn set_env<T>(&self, name: &str, value: T)
pub fn get_env<T>(&self, name: &str) -> Option<T>where
T: for<'de> Deserialize<'de> + Clone,
pub fn set_var<T>(&self, name: &str, value: T)
pub fn get_var<T>(&self, name: &str) -> Option<T>where
T: for<'de> Deserialize<'de> + Clone,
pub fn eval<T: DeserializeOwned + Serialize>(&self, expr: &str) -> Result<T>
pub fn sched_task(&self, node: &Arc<Node>, prev: Arc<Task>) -> Result<()>
pub fn sched_task_with_vars( &self, node: &Arc<Node>, vars: Vars, parent: Arc<Task>, ) -> Result<()>
Sourcepub fn schedule_once(&self, node: &Arc<Node>, prev: Arc<Task>) -> Result<()>
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.
pub fn dispatch_act(&self, act: &Act, vars: Vars) -> Result<()>
pub fn build_acts(&self, acts: &[Act], is_sequence: bool) -> Result<()>
pub async fn back_task( &self, task: &Arc<Task>, paths: &Vec<Arc<Task>>, ) -> Result<()>
pub async fn abort_task(&self, task: &Arc<Task>) -> Result<()>
Sourcepub async fn undo_task(&self, task: &Arc<Task>) -> Result<()>
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