pub struct BackgroundJobs { /* private fields */ }Expand description
One session’s background jobs. Dropping the store (with the session’s tools) cancels every job still running.
Implementations§
Source§impl BackgroundJobs
impl BackgroundJobs
Sourcepub fn new(limit: usize, finished: Option<UnboundedSender<()>>) -> Self
pub fn new(limit: usize, finished: Option<UnboundedSender<()>>) -> Self
At most limit jobs run at once. finished is woken as jobs finish.
Sourcepub fn with_approvals(self, gate: Arc<dyn ApprovalGate>) -> Self
pub fn with_approvals(self, gate: Arc<dyn ApprovalGate>) -> Self
Decide running jobs’ nested approval requests with gate, which must
never grant more than the session’s foreground would.
Sourcepub fn take_changes(&self, call_id: &str) -> Vec<JobChange>
pub fn take_changes(&self, call_id: &str) -> Vec<JobChange>
The jobs the call call_id started or showed the model the result of,
for its tool.completed.
Sourcepub fn take_unreported(&self) -> Vec<JobReport>
pub fn take_unreported(&self) -> Vec<JobReport>
Finished jobs the model has not seen yet whose report is due, at most
a few, for a report turn. Each stays unreported, and is not taken
again, until the turn ends: report_settled
or report_failed.
Sourcepub fn report_settled(&self, jobs: &[String])
pub fn report_settled(&self, jobs: &[String])
The report turn about jobs ended without failing: it completed, so
the model has seen them, or the user cancelled it. Either settles them.
Sourcepub fn report_failed(&self, jobs: &[String], retry: bool) -> ReportFailure
pub fn report_failed(&self, jobs: &[String], retry: bool) -> ReportFailure
The report turn about jobs failed, so the model has not seen them
(a failed turn leaves no history). With retry, another turn is due
after a delay, up to three turns in all; otherwise, or once they are
used up, the jobs are settled and returned for the server to report
directly. A turn that reported several jobs decides for all of them,
by the one that failed most.
Sourcepub fn retry_now(&self) -> bool
pub fn retry_now(&self) -> bool
Make every report waiting out a failed turn due now, as once a turn succeeds and the model is evidently reachable again. Whether any was waiting.
Sourcepub fn next_retry(&self) -> Option<Instant>
pub fn next_retry(&self) -> Option<Instant>
When the earliest report waiting out a failed turn is due; it may already have passed.