struct Scheduler<'a> {Show 36 fields
run_id: &'a str,
plan: Plan,
node_of: HashMap<&'a str, &'a FlowNode>,
incoming: HashMap<&'a str, Vec<&'a FlowEdge>>,
outgoing: HashMap<&'a str, Vec<&'a FlowEdge>>,
decided: HashMap<&'a str, bool>,
finished: HashSet<&'a str>,
failed: HashSet<&'a str>,
ready: VecDeque<(&'a str, bool)>,
queued: HashSet<&'a str>,
held: Vec<&'a FlowEdge>,
rounds: HashMap<&'a str, u32>,
loop_started: HashMap<String, Instant>,
spent: f64,
spent_by: HashMap<&'a str, f64>,
history: HashMap<&'a str, VecDeque<Value>>,
scope: ExecutionScope,
response: Option<Value>,
run_cap_usd: Option<f64>,
cancel: Cancel,
cancelled: bool,
in_flight: Vec<(&'a str, bool)>,
running_ro: Vec<(&'a str, bool)>,
waiting: Option<(&'a str, bool)>,
deadlines: BTreeMap<String, i64>,
resume_on: BTreeMap<String, String>,
wait_timeouts: BTreeMap<String, i64>,
chain: Vec<String>,
lookup: Option<Arc<dyn DroneLookup>>,
late_spend: Arc<LateSpend>,
replay: Option<Arc<Replay>>,
recorder: Option<(Recorder, GraphRef)>,
started: Instant,
elapsed_before_ms: u64,
tx: &'a UnboundedSender<RunEvent>,
states: &'a Arc<Mutex<HashMap<String, BlockState>>>,
}Fields§
§run_id: &'a str§plan: Plan§node_of: HashMap<&'a str, &'a FlowNode>§incoming: HashMap<&'a str, Vec<&'a FlowEdge>>The edges into a block, back-edges left out.
outgoing: HashMap<&'a str, Vec<&'a FlowEdge>>§decided: HashMap<&'a str, bool>Edges decided this pass of their loop: true when they carry the run on.
finished: HashSet<&'a str>Blocks that ran or were skipped this pass of their loop.
failed: HashSet<&'a str>The blocks that failed this pass of their loop and whose failure the graph handled.
ready: VecDeque<(&'a str, bool)>§queued: HashSet<&'a str>§held: Vec<&'a FlowEdge>Edges out of a loop that were not taken, decided when nothing can run.
rounds: HashMap<&'a str, u32>How many times each guard has sent the run round its loop.
loop_started: HashMap<String, Instant>§spent: f64§spent_by: HashMap<&'a str, f64>§history: HashMap<&'a str, VecDeque<Value>>§scope: ExecutionScope§response: Option<Value>§run_cap_usd: Option<f64>§cancel: Cancel§cancelled: boolSet when the run ended because cancel did, so that is not taken for a failure.
in_flight: Vec<(&'a str, bool)>The blocks that are running while they have effects, and whether each was forced: the ones a restart must not run again on its own.
running_ro: Vec<(&'a str, bool)>The blocks of the batch that is running and have no effects: a restart runs them again.
waiting: Option<(&'a str, bool)>The Wait block the run is stopped at, and whether it was forced, and what it waits for: a time, as milliseconds since 1970, or the key of an event.
deadlines: BTreeMap<String, i64>§resume_on: BTreeMap<String, String>§wait_timeouts: BTreeMap<String, i64>When the Wait block runs out of its own timeout_seconds.
chain: Vec<String>The drones above this one (a Drone block called it), and where to find a drone to call.
lookup: Option<Arc<dyn DroneLookup>>§late_spend: Arc<LateSpend>What callees spent that nobody was waiting for any more, by child run: counted at the next block.
replay: Option<Arc<Replay>>§recorder: Option<(Recorder, GraphRef)>Writes the run’s checkpoints, with the graph version they say the run is on.
started: Instant§elapsed_before_ms: u64How long the run had already run before this process took it up, when it is resumed.
tx: &'a UnboundedSender<RunEvent>§states: &'a Arc<Mutex<HashMap<String, BlockState>>>Implementations§
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
Sourcepub(super) fn run_call<'s>(
&'s mut self,
node: &'a FlowNode,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 's>>where
'a: 's,
pub(super) fn run_call<'s>(
&'s mut self,
node: &'a FlowNode,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 's>>where
'a: 's,
Call the drone node names and give what it came to. It is boxed, because a
callee can call too: a future that runs a run that can run it cannot say it is
Send without help.
async fn call(&mut self, node: &'a FlowNode) -> Result<Value, String>
Source§impl Scheduler<'_>
impl Scheduler<'_>
Sourcepub(super) async fn settle_late_spend(&mut self)
pub(super) async fn settle_late_spend(&mut self)
Before more work starts: wait for the callees that were stopped when their call was given up on, and count what they spent, so the cap and the next callee’s allowance see it. The spend is also put on the calling block’s state, which is what the ledger sums.
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
Sourcepub(super) fn checkpoint(&mut self, after: Option<&str>) -> Result<(), String>
pub(super) fn checkpoint(&mut self, after: Option<&str>) -> Result<(), String>
Keep the run as it stands as its next checkpoint, after the block that
just finished (none for the first, before any block). A run that cannot
keep a checkpoint goes on, and the next one is a diff from the last kept;
a run that has used up its steps (§3.3: at most 1,000) ends, saying so.
Sourcepub(super) fn checkpoint_required(&mut self, id: &str) -> Result<(), String>
pub(super) fn checkpoint_required(&mut self, id: &str) -> Result<(), String>
The checkpoint a run keeps before it stops at id: without it a restart could not
take the wait up again, so a run that cannot keep it ends.
Sourcepub(super) fn effect_of_node(&self, node: &FlowNode, kind: BlockKind) -> Effect
pub(super) fn effect_of_node(&self, node: &FlowNode, kind: BlockKind) -> Effect
What node does to the world. A block a replay stubs does nothing to it.
Sourcepub(super) fn real_effect_of_node(
&self,
node: &FlowNode,
kind: BlockKind,
) -> Effect
pub(super) fn real_effect_of_node( &self, node: &FlowNode, kind: BlockKind, ) -> Effect
What node does to the world, which a for-each takes from its body.
Sourcepub(super) fn mark_in_flight(
&mut self,
node: &'a FlowNode,
forced: bool,
) -> Result<(), String>
pub(super) fn mark_in_flight( &mut self, node: &'a FlowNode, forced: bool, ) -> Result<(), String>
Before a block with effects starts, keep a checkpoint that says it is running. A restart that finds it as the newest knows the block may have done its work already. When the run cannot keep it, the block does not start: it would be a step no restart could account for.
Sourcepub(super) fn mark_batch_in_flight(
&mut self,
batch: &[(&'a str, bool)],
) -> Result<(), String>
pub(super) fn mark_batch_in_flight( &mut self, batch: &[(&'a str, bool)], ) -> Result<(), String>
mark_in_flight for a batch of blocks that start together: the
ones with effects are listed as running in one checkpoint, kept before any starts, and
the others are listed as ready until they finish.
Sourcefn keep(&mut self, after: Option<&str>, required: bool) -> Result<(), String>
fn keep(&mut self, after: Option<&str>, required: bool) -> Result<(), String>
checkpoint, and with required a checkpoint that
could not be kept ends the run.
Sourcefn snapshot(&self, step: u32) -> Checkpoint
fn snapshot(&self, step: u32) -> Checkpoint
The run as it stands, as checkpoint step.
Sourcepub(super) fn restore(&mut self, c: &Checkpoint) -> Result<(), String>
pub(super) fn restore(&mut self, c: &Checkpoint) -> Result<(), String>
Set this scheduler (new, for the graph the checkpoint was written on) to
where c left the run. A checkpoint that names a block or an edge the graph
does not have was written on another graph, and is refused.
Sourcepub(super) fn restore_state(&mut self, c: &Checkpoint) -> Result<(), String>
pub(super) fn restore_state(&mut self, c: &Checkpoint) -> Result<(), String>
restore but for the run’s own place only: its checkpoints go on as they are,
which a run that starts from c (a replay) does not have yet.
Sourcefn legacy_failed(
&self,
c: &Checkpoint,
finished: &HashSet<&'a str>,
decided: &HashMap<&'a str, bool>,
) -> HashSet<&'a str>
fn legacy_failed( &self, c: &Checkpoint, finished: &HashSet<&'a str>, decided: &HashMap<&'a str, bool>, ) -> HashSet<&'a str>
The blocks that failed in this pass, for a checkpoint written before the set was kept. A block that
finished with a handled failure said so as its output (failed: true and the error), but a block that
failed in one pass of a loop and was skipped in the next keeps that output too. So the output counts
only for a block that ran this pass: a root, or one an edge into it was taken for, or a Join that a
branch (found the same way) failed into.
Sourcepub(super) async fn show_restored(&self)
pub(super) async fn show_restored(&self)
Show what the restored blocks did, as the run’s own block states, so what a person sees of a resumed run is not blank where blocks already ran.
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
pub(super) async fn run_foreach( &mut self, node: &'a FlowNode, ) -> Result<Value, String>
Sourcefn item_limit(
&self,
cfg: &ForEachConfig,
id: &str,
(index, total): (usize, usize),
(started, spent_before): (Instant, f64),
) -> Option<String>
fn item_limit( &self, cfg: &ForEachConfig, id: &str, (index, total): (usize, usize), (started, spent_before): (Instant, f64), ) -> Option<String>
Why the next item must not run, in plain words, or None.
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
pub(super) fn run_join(&self, node: &'a FlowNode) -> Result<Value, String>
Sourcefn branches_of(&self, id: &str) -> Branches
fn branches_of(&self, id: &str) -> Branches
How each branch into the join id ended, by the block it came from.
Sourcepub(super) fn join_bits(&self, id: &str) -> (bool, bool)
pub(super) fn join_bits(&self, id: &str) -> (bool, bool)
What a join’s output is made of: tainted when a branch that arrived was, and when one failed (what it said is outside text), derived when one was.
Sourcepub(super) fn join_has_failed_branch(&self, id: &str) -> bool
pub(super) fn join_has_failed_branch(&self, id: &str) -> bool
Whether id is a Join that a branch failed into: it runs then even when no branch arrived,
so the failures are said and not hidden by a join that was skipped.
Sourcepub(super) fn handles_failure(&self, id: &str) -> bool
pub(super) fn handles_failure(&self, id: &str) -> bool
Whether a failure of block id is the graph’s to handle: it has an error edge,
or every way out of it is into a Join that leaves failed branches out.
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
Sourcepub(super) fn next_batch(&self) -> Vec<(&'a str, bool)>
pub(super) fn next_batch(&self) -> Vec<(&'a str, bool)>
The blocks at the front of the ready list that can run together, in order: none when the first cannot, one when only it can.
Sourcepub(super) async fn step_batch(
&mut self,
batch: Vec<(&'a str, bool)>,
) -> Result<(), String>
pub(super) async fn step_batch( &mut self, batch: Vec<(&'a str, bool)>, ) -> Result<(), String>
Run batch, which next_batch gave, together. Every block’s
outcome is taken up even when one fails; the first failure the graph does not handle
is the run’s.
Source§impl Scheduler<'_>
impl Scheduler<'_>
Sourcepub(super) fn stub_of(
&self,
node: &FlowNode,
kind: BlockKind,
) -> Option<Result<Value, String>>
pub(super) fn stub_of( &self, node: &FlowNode, kind: BlockKind, ) -> Option<Result<Value, String>>
What node says instead of running, when this run replays an earlier one and the block
would do something to the world (it sends, files, starts, writes or calls a drone that may).
A block that only reads runs as it always does, and so does every block of a run that
was asked to do it for real.
Sourcepub(super) fn keep_stub_bits(&mut self, id: &str)
pub(super) fn keep_stub_bits(&mut self, id: &str)
A stubbed block’s output is as tainted as it was in the run replayed.
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
Sourcepub(super) async fn run_wait(
&mut self,
node: &'a FlowNode,
) -> Result<Value, String>
pub(super) async fn run_wait( &mut self, node: &'a FlowNode, ) -> Result<Value, String>
Wait as node says, keeping the checkpoint first, and give what the wait
came to: when it ended and whether it was late, or the event’s payload.
Sourcepub(super) async fn run_approval(
&mut self,
node: &'a FlowNode,
) -> Result<Value, String>
pub(super) async fn run_approval( &mut self, node: &'a FlowNode, ) -> Result<Value, String>
An Approval block: wait for the person’s answer on a key that stays inside AgentMux, showing card.
A yes is the block’s output; a no and silence fail it.
async fn wait_for( &mut self, node: &'a FlowNode, wait: Wait, approval: Option<(Card, u64)>, ) -> Result<Value, String>
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
fn new( run_id: &'a str, graph: &'a DroneGraph, plan: Plan, scope: ExecutionScope, limits: Limits, tx: &'a UnboundedSender<RunEvent>, states: &'a Arc<Mutex<HashMap<String, BlockState>>>, ) -> Self
Sourcefn seed_roots(&mut self)
fn seed_roots(&mut self)
The blocks nothing leads to are ready first.
Sourceasync fn drive(&mut self) -> Result<(), String>
async fn drive(&mut self) -> Result<(), String>
Run blocks until none is ready and no edge is left to decide.
fn enqueue(&mut self, id: &'a str, forced: bool)
Sourcefn decide(&mut self, edge: &'a FlowEdge, carries: bool)
fn decide(&mut self, edge: &'a FlowEdge, carries: bool)
Record an edge’s outcome, and ready its target if that was the last one.
Sourcefn leave(&mut self, edge: &'a FlowEdge, carries: bool)
fn leave(&mut self, edge: &'a FlowEdge, carries: bool)
An edge whose source has finished. A edge out of a loop that is not taken waits, because another iteration may still take it.
async fn step(&mut self, id: &'a str, forced: bool) -> Result<(), String>
Sourcefn finish_step(
&mut self,
node: &'a FlowNode,
ran: Result<Value, String>,
) -> Result<(), String>
fn finish_step( &mut self, node: &'a FlowNode, ran: Result<Value, String>, ) -> Result<(), String>
What a block came to is taken up: a failure its graph handles becomes its output, the block is finished and the run goes on from it.
Sourcefn will_run(&self, id: &str, forced: bool) -> bool
fn will_run(&self, id: &str, forced: bool) -> bool
Whether a ready block runs: it is a root, or was forced, or an edge into it was taken, or it is a Join that a branch failed into. Otherwise it is skipped.
fn has_error_edge(&self, id: &str) -> bool
fn cap_reached(&self, block_id: &str, reason: &str)
Sourceasync fn guarded(
&mut self,
node: &'a FlowNode,
kind: BlockKind,
) -> Result<Value, String>
async fn guarded( &mut self, node: &'a FlowNode, kind: BlockKind, ) -> Result<Value, String>
A block’s code, ended when the run is cancelled (an Agent block’s process goes with it) or the block passes its timeout.
Sourceasync fn attempt(
&mut self,
node: &'a FlowNode,
kind: BlockKind,
) -> Result<Value, String>
async fn attempt( &mut self, node: &'a FlowNode, kind: BlockKind, ) -> Result<Value, String>
One run of a block’s code, within its time limit.
Sourceasync fn dispatch(
&mut self,
node: &'a FlowNode,
kind: BlockKind,
) -> Result<Value, String>
async fn dispatch( &mut self, node: &'a FlowNode, kind: BlockKind, ) -> Result<Value, String>
Hand a block to the code for its kind. A for-each runs its body block
through run_block, so it is handled here, not in
blocks.
Sourceasync fn run_block(&mut self, node: &'a FlowNode) -> Result<Value, String>
async fn run_block(&mut self, node: &'a FlowNode) -> Result<Value, String>
Run one block with its events and its recorded state.
Sourceasync fn begin_block(&mut self, node: &'a FlowNode) -> i64
async fn begin_block(&mut self, node: &'a FlowNode) -> i64
A block starts: its event and its running state. Gives when it started, which the states it ends with carry too.
Sourceasync fn end_block(
&mut self,
node: &'a FlowNode,
kind: BlockKind,
result: Result<Value, String>,
__arg4: (i64, f64),
) -> Result<Value, String>
async fn end_block( &mut self, node: &'a FlowNode, kind: BlockKind, result: Result<Value, String>, __arg4: (i64, f64), ) -> Result<Value, String>
A block ends with result: its output is kept, its cost counted, its event and its state.
Sourcefn mark_bits(&mut self, node: &FlowNode, kind: BlockKind)
fn mark_bits(&mut self, node: &FlowNode, kind: BlockKind)
What a block’s output is made of, for the taint bits: an Agent’s answer, an API response and a message reply are outside text; a Condition’s result is a boolean made from what it read (derived when that was tainted); a Response is its template filled in. A Variables block sets its own.
Sourcefn keep_history(&mut self, id: &'a str, output: &mut Value)
fn keep_history(&mut self, id: &'a str, output: &mut Value)
A block that runs again carries its earlier outputs, newest last, as
{{block.history}}.
Sourcefn route(
&mut self,
node: &'a FlowNode,
output: &Value,
failed: bool,
) -> Result<(), String>
fn route( &mut self, node: &'a FlowNode, output: &Value, failed: bool, ) -> Result<(), String>
Send the run along the edges out of a block that ran, and count a loop’s iteration when a guard takes it round.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Scheduler<'a>
impl<'a> !UnwindSafe for Scheduler<'a>
impl<'a> Freeze for Scheduler<'a>
impl<'a> Send for Scheduler<'a>
impl<'a> Sync for Scheduler<'a>
impl<'a> Unpin for Scheduler<'a>
impl<'a> UnsafeUnpin for Scheduler<'a>
Blanket Implementations§
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more