pub struct RunLedger { /* private fields */ }Expand description
The run ledger, shared by the cron scheduler, the Drone handlers and the Schedule routes.
Implementations§
Source§impl RunLedger
impl RunLedger
Sourcepub fn event_input(&self, run_id: &str) -> Option<Value>
pub fn event_input(&self, run_id: &str) -> Option<Value>
The input kept for run run_id (what the graph reads as {{trigger.*}}). It stays while the run lives, so a
run that waited through a delay, its turn or a restart, and a retry of it, read the same event.
Sourcepub fn admit_event(
&self,
job: &CronJob,
event_id: &str,
source: &str,
input: &Value,
) -> Admission
pub fn admit_event( &self, job: &CronJob, event_id: &str, source: &str, input: &Value, ) -> Admission
Record the event event_id for job and decide whether its run starts. Taken is an event the job already
heard of; Skipped is a fire that Pause all, the rate limit, overlap policy or a cap refused (it has its row).
An event that starts no run stays heard but does not count toward the rate limit.
Source§impl RunLedger
impl RunLedger
Sourcepub fn install_jobs(&self, jobs: Arc<Store>)
pub fn install_jobs(&self, jobs: Arc<Store>)
Where jobs are, for the policy of other jobs’ runs.
Sourcepub fn install_worker_stop(&self, stop: BlockHook)
pub fn install_worker_stop(&self, stop: BlockHook)
How to stop a worker a spawn job started, once its run ended.
Sourcepub fn admit_cron(
&self,
job: &CronJob,
trigger: &str,
scheduled_for_ms: Option<i64>,
triggered_by: &str,
) -> Admission
pub fn admit_cron( &self, job: &CronJob, trigger: &str, scheduled_for_ms: Option<i64>, triggered_by: &str, ) -> Admission
Insert the row of a cron fire and decide whether it starts (see the
module doc). A scheduled slot that policy skips is a collapsed
skipped (overlap) row; Run now is refused.
Sourcepub fn stop_run(
&self,
run: &JobRun,
infra_status: &str,
why: &str,
summary: &str,
) -> bool
pub fn stop_run( &self, run: &JobRun, infra_status: &str, why: &str, summary: &str, ) -> bool
Close a running run that was stopped on purpose, and interrupt its
turn. false when it had ended already. A run another channel’s
instance follows isn’t closed here: that instance is asked to stop it
(remote.rs), so the row closes only once its agent’s turn is
interrupted. false for it too.
Sourcepub fn enforce_timeouts(&self) -> usize
pub fn enforce_timeouts(&self) -> usize
Stop this channel’s runs that ran past their job’s timeout_minutes
(infra timeout). Returns how many.
Sourcepub fn close_if_past_timeout(&self, drone_run_id: &str) -> bool
pub fn close_if_past_timeout(&self, drone_run_id: &str) -> bool
A Drone run a restart left open, that a job started and whose job’s
timeout_minutes ran out while AgentMux was down: close it as timed out
(the way the timeout pass does) and say so, so it is not taken up again
and able to act before the first pass. false for a run with no such
timeout, or one that has time left.
Sourcepub fn start_waiting(&self) -> Vec<Started> ⓘ
pub fn start_waiting(&self) -> Vec<Started> ⓘ
Start the waiting runs that policy now lets start, oldest first, each against what is running after the ones before it. Runs of a job that is gone or paused end; a retry waits out its backoff first. The caller starts the returned runs.
Sourcepub fn pending_may_start(&self, job: &CronJob, run_id: &str) -> bool
pub fn pending_may_start(&self, job: &CronJob, run_id: &str) -> bool
Whether a pending catch-up delivery of job may start now: the same
answer a waiting run gets (overlap, group, the global limit). A job that
would cancel its own running run does so here, as a new slot would.
Sourcepub fn pending_delivery_done(&self, run_id: &str)
pub fn pending_delivery_done(&self, run_id: &str)
The delivery of a pending fire ended (it started, or stays pending to be retried): its place is the ledger’s again.
Source§impl RunLedger
impl RunLedger
Sourcepub fn ingest_cloud_event(
&self,
envelope: &SignedJobEvent,
reporters: &Reporters,
jobs: &dyn CloudJobs,
now_ms: i64,
) -> Result<Applied, Dropped>
pub fn ingest_cloud_event( &self, envelope: &SignedJobEvent, reporters: &Reporters, jobs: &dyn CloudJobs, now_ms: i64, ) -> Result<Applied, Dropped>
Write one cloud event into the ledger, if it is genuine: its key pinned, its signature good, its job approved
with that key, and not seen before. A refused event is counted (drops) and logged, not shown as a run.
Source§impl RunLedger
impl RunLedger
Sourcepub fn follow_forwarded(
&self,
run_id: &str,
block_id: &str,
delivery_started_ms: i64,
) -> bool
pub fn follow_forwarded( &self, run_id: &str, block_id: &str, delivery_started_ms: i64, ) -> bool
A delivery this instance just placed in block_id was forwarded here
with request_id run_id. When that names a cron run another
channel fired and nobody follows yet, take the follow-up: mark it
running with this pane’s account, note this channel in its links and
follow its turn here, from delivery_started_ms, taken before the
injection: a turn the delivery started, even one already over, is
this run’s whole turn, as on the local path (record_delivery).
Called before the delivery’s answer goes back,
so the firing instance sees the run is followed. Never inserts a row,
so the slot lease stays the firing scheduler’s.
Sourcepub fn check_remote(&self, run_id: &str, armed_at_ms: i64, now: i64) -> bool
pub fn check_remote(&self, run_id: &str, armed_at_ms: i64, now: i64) -> bool
Judge the watched cross-channel run run_id at now and write a
close it calls for. true when it needs no more watching.
Sourcepub fn install_remote_stop(&self, hook: RemoteStopHook)
pub fn install_remote_stop(&self, hook: RemoteStopHook)
How to ask another channel’s instance to stop a run it follows.
Sourcepub fn remote_stop_done(&self, run_id: &str)
pub fn remote_stop_done(&self, run_id: &str)
The follower stopped the run: its row is closed. This instance’s Jobs tab and a run waiting on this one’s place move on.
Sourcepub fn remote_stop_failed(&self, run_id: &str, error: &str)
pub fn remote_stop_failed(&self, run_id: &str, error: &str)
The ask couldn’t be delivered: say why in the run’s links, where the operator and the next pass see it. The row stays open.
Sourcepub fn stop_followed_here(
&self,
run_id: &str,
block_id: &str,
from_channel: &str,
) -> Result<bool, String>
pub fn stop_followed_here( &self, run_id: &str, block_id: &str, from_channel: &str, ) -> Result<bool, String>
The following side of Self::request_remote_stop: close the run
this instance follows, as a local stop does, and interrupt its pane’s
turn, when from_channel fired the run and asked, in the run’s row,
for this stop. The status, reason and summary are the row’s, not the
request’s. Ok(false) when it had ended already; an error when the run
is not one this process follows in block_id, was fired by another
channel than from_channel, or carries no stop of that channel’s.
Source§impl RunLedger
impl RunLedger
Sourcepub fn install_caps(&self, limits: LimitsSource, target: TargetOf)
pub fn install_caps(&self, limits: LimitsSource, target: TargetOf)
Weigh runs against Settings’ caps from now on, finding each run’s
account and provider with target. Once. Without it the defaults
apply and only a job’s own spend is weighed.
pub fn limits(&self) -> Limits
Sourcepub fn run_cap_usd(&self, job: &CronJob) -> f64
pub fn run_cap_usd(&self, job: &CronJob) -> f64
The most one run of job may spend.
Sourcepub fn over_cap_today(&self, job: &CronJob) -> Option<&'static str>
pub fn over_cap_today(&self, job: &CronJob) -> Option<&'static str>
The cap job is over today, for the Jobs tab (“over cap today”): its
own daily cap or messages a day as of now, or an account cap that
skipped one of its runs today.
Source§impl RunLedger
impl RunLedger
Sourcepub fn watch_cloud(&self, jobs: &[WatchedJob], now_ms: i64) -> Watched
pub fn watch_cloud(&self, jobs: &[WatchedJob], now_ms: i64) -> Watched
One pass of the watchdog over jobs at now_ms. Blocking. A job that gave up a slot or a run is told to the
Jobs tab and the incident keeper. Running it again changes nothing.
Source§impl RunLedger
impl RunLedger
Sourcepub fn watch_local(
&self,
watch: &mut LocalWatch,
jobs: &[CronJob],
now_ms: i64,
) -> usize
pub fn watch_local( &self, watch: &mut LocalWatch, jobs: &[CronJob], now_ms: i64, ) -> usize
One pass over the enabled local jobs jobs at now_ms: a missed row (not_started) for each slot past its
grace with no row of any kind. Returns how many it wrote. Blocking; running it again changes nothing.
Source§impl RunLedger
impl RunLedger
Sourcepub fn new(
store: Arc<Store>,
mstore: Option<Arc<Store>>,
broker: Arc<Broker>,
) -> Arc<Self> ⓘ
pub fn new( store: Arc<Store>, mstore: Option<Arc<Store>>, broker: Arc<Broker>, ) -> Arc<Self> ⓘ
A ledger over store (the work store), following turns on
broker. Needs a tokio runtime (the follower’s task).
Sourcepub fn new_in(
store: Arc<Store>,
mstore: Option<Arc<Store>>,
broker: Arc<Broker>,
channel: &str,
) -> Arc<Self> ⓘ
pub fn new_in( store: Arc<Store>, mstore: Option<Arc<Store>>, broker: Arc<Broker>, channel: &str, ) -> Arc<Self> ⓘ
Self::new as the instance of channel: tests run two channels’
ledgers in one process.
pub fn store(&self) -> &Arc<Store> ⓘ
Sourcepub fn install_incidents(&self, jobs: Option<Arc<Store>>)
pub fn install_incidents(&self, jobs: Option<Arc<Store>>)
Open an incident when a job fails, from now on (§3.4). jobs is
where cron jobs are, for a job’s owner.
Sourcepub fn changed(&self, job_id: &str)
pub fn changed(&self, job_id: &str)
Tell the Jobs tab job job_id’s runs changed (JobsChanged); ""
for a change to every job. A job’s change is also looked at for an
incident.
Sourcepub fn paused_all(&self) -> Option<JobFlag>
pub fn paused_all(&self) -> Option<JobFlag>
Pause all, when the operator has it on: since when, and by whom.
Sourcepub fn set_paused_all(&self, on: bool, by: &str) -> Result<(), StoreError>
pub fn set_paused_all(&self, on: bool, by: &str) -> Result<(), StoreError>
Turn Pause all on or off. The caller has checked that the operator asked: agents can’t (§7).
Sourcepub fn record_skip_slot(&self, job: &CronJob, slot_ms: i64, why: &str)
pub fn record_skip_slot(&self, job: &CronJob, slot_ms: i64, why: &str)
A slot of job that didn’t fire because the job, or every job, was
paused (reason): counted into the job’s newest row when that is the
same skip, else a new skipped row; either way the slot keeps its own
leased row, so no scheduler fires it later (§3.1, §3.3).
Sourcepub fn begin_cron(
&self,
job: &CronJob,
trigger: &str,
scheduled_for_ms: Option<i64>,
triggered_by: &str,
) -> Begin
pub fn begin_cron( &self, job: &CronJob, trigger: &str, scheduled_for_ms: Option<i64>, triggered_by: &str, ) -> Begin
Insert the scheduled row of a cron fire before firing it. For a
slot, that insert is the lease (§3.1): a second scheduler sharing
the job finds the slot taken.
Sourcepub fn record_delivery(
&self,
run_id: &str,
job: &CronJob,
outcome: &FireOutcome,
scheduled: bool,
delivery_started_ms: i64,
)
pub fn record_delivery( &self, run_id: &str, job: &CronJob, outcome: &FireOutcome, scheduled: bool, delivery_started_ms: i64, )
Record what a cron fire’s delivery decided for run run_id of
job. delivery_started_ms is when the delivery began: delivery can
wait for the turn it starts, so that turn may begin, or even end,
before the answer. A scheduled fire also ends the job’s older pending
fire: it is superseded when this one is pending in its place, else
expired (its next fire time came).
Sourcepub fn record_pending_delivery(
&self,
run: &JobRun,
outcome: &FireOutcome,
delivery_started_ms: i64,
)
pub fn record_pending_delivery( &self, run: &JobRun, outcome: &FireOutcome, delivery_started_ms: i64, )
A pending fire was delivered, or failed for good, when its agent came
back (CronScheduler::deliver_pending, which expires it first once
its next fire time has passed). Still missing, or a failure the
held-jekt replay also retries (the agent still starting, a rate
limit, a full queue, not signed in yet), keeps it pending for the
next wake or sweep. delivery_started_ms as for Self::record_delivery.
Sourcepub fn expire_pending(&self, run_id: &str)
pub fn expire_pending(&self, run_id: &str)
End a pending fire whose next fire time passed, or whose job is gone.
Sourcepub fn waiting_here(&self) -> Vec<JobRun>
pub fn waiting_here(&self) -> Vec<JobRun>
This channel’s pending fires still waiting for their agent.
Sourcepub fn record_missed_while_off(
&self,
job: &CronJob,
first_slot_ms: i64,
count: i64,
)
pub fn record_missed_while_off( &self, job: &CronJob, first_slot_ms: i64, count: i64, )
Write the collapsed skip for slots missed while AgentMux was off
(app_not_running, §3.2): count slots from first_slot_ms.
Sourcepub fn turn_finished(
&self,
run_id: &str,
infra_status: &str,
cost: Option<RunCost>,
summary: &str,
)
pub fn turn_finished( &self, run_id: &str, infra_status: &str, cost: Option<RunCost>, summary: &str, )
The followed turn ended (or never showed up).
Sourcepub fn drone_started(
&self,
drone_run_id: &str,
drone_id: &str,
drone_name: &str,
started_at_ms: i64,
trigger: &Value,
) -> Option<String>
pub fn drone_started( &self, drone_run_id: &str, drone_id: &str, drone_name: &str, started_at_ms: i64, trigger: &Value, ) -> Option<String>
A Drone run started: its manual row, running, linked to the run.
Sourcepub fn drone_started_by(
&self,
drone_run_id: &str,
drone_id: &str,
drone_name: &str,
started_at_ms: i64,
trigger: &Value,
triggered_by: &str,
) -> Option<String>
pub fn drone_started_by( &self, drone_run_id: &str, drone_id: &str, drone_name: &str, started_at_ms: i64, trigger: &Value, triggered_by: &str, ) -> Option<String>
Self::drone_started for a run somebody other than the operator started: triggered_by is
the agent’s id (an agent that fires a drone with Drone is recorded as itself).
Sourcepub fn drone_attached(
&self,
run_id: &str,
drone_run_id: &str,
trigger: &Value,
now: i64,
)
pub fn drone_attached( &self, run_id: &str, drone_run_id: &str, trigger: &Value, now: i64, )
A job’s drone action started Drone run drone_run_id: the job’s
own row (made when the fire began) runs from now and links to it, and
drone_finished closes it. No transcript: the run is the Drone’s.
Sourcepub fn drone_finished(
&self,
run_id: &str,
ok: bool,
block_states: &HashMap<String, BlockState>,
error: &str,
)
pub fn drone_finished( &self, run_id: &str, ok: bool, block_states: &HashMap<String, BlockState>, error: &str, )
A Drone run ended: ok and the summed cost of its Agent blocks, or
error with its message.
Sourcepub fn drone_stopped(
&self,
run_id: &str,
block_states: &HashMap<String, BlockState>,
reason: &str,
)
pub fn drone_stopped( &self, run_id: &str, block_states: &HashMap<String, BlockState>, reason: &str, )
A Drone run was cancelled: its row closes interrupted with the reason,
unless whoever stopped it (a timeout, cancel_other) closed it already.
Sourcepub fn recover_after_restart(&self) -> usize
pub fn recover_after_restart(&self) -> usize
After a restart: close what this channel left open (§3.2). Cron runs
still scheduled or running, and Drone runs still running, were
interrupted, in the ledger and in db_drone_runs; so were the runs
it followed for another channel (#1988). A run another channel
follows goes on there, and is watched again from here. Pending fires
stay: they wait for their agent across a restart. Call before the
scheduler starts.
Sourcepub fn open_run_of_drone(&self, drone_run_id: &str) -> Option<String>
pub fn open_run_of_drone(&self, drone_run_id: &str) -> Option<String>
The open ledger row of Drone run drone_run_id, written by this channel:
the one a run taken up again after a restart goes on under.
Sourcepub fn recover_after_restart_except(&self, resuming: &HashSet<String>) -> usize
pub fn recover_after_restart_except(&self, resuming: &HashSet<String>) -> usize
recover_after_restart, except that the
Drone runs in resuming (by Drone run id) are being taken up again from
their checkpoints: their rows stay open, in the ledger and in
db_drone_runs, and they finish as any run does.
Auto Trait Implementations§
impl !Freeze for RunLedger
impl !RefUnwindSafe for RunLedger
impl !UnwindSafe for RunLedger
impl Send for RunLedger
impl Sync for RunLedger
impl Unpin for RunLedger
impl UnsafeUnpin for RunLedger
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