pub struct Backend {
pub connection: PgConnection,
}Expand description
Provides an interface to the Postgres task store
Fields§
§connection: PgConnectionThe Diesel PgConnection object
Implementations§
Source§impl Backend
Instance methods
impl Backend
Instance methods
Sourcepub fn mark_imported(
&mut self,
imported_tasks: &[NewTask],
) -> Result<usize, Error>
pub fn mark_imported( &mut self, imported_tasks: &[NewTask], ) -> Result<usize, Error>
Insert a vector of new NewTask tasks into the Task store
For example, on import, or when a new service is activated on a corpus
Sourcepub fn mark_done(&mut self, reports: &[TaskReport]) -> Result<(), Error>
pub fn mark_done(&mut self, reports: &[TaskReport]) -> Result<(), Error>
Insert a vector of TaskReport reports into the Task store, also marking their tasks as
completed with the correct status code.
Sourcepub fn mark_rerun(&mut self, options: RerunOptions<'_>) -> Result<(), Error>
pub fn mark_rerun(&mut self, options: RerunOptions<'_>) -> Result<(), Error>
Given a complex selector, of a Corpus, Service, and the optional severity, category
and what mark all matching tasks to be rerun
Sourcepub fn pause_run(
&mut self,
corpus_id: i32,
service_id: i32,
) -> Result<usize, Error>
pub fn pause_run( &mut self, corpus_id: i32, service_id: i32, ) -> Result<usize, Error>
Pause a (corpus, service) run: block every in-progress task (status >= 0) so the
dispatcher stops leasing them. Returns the number paused. The CLI/agent twin of the report
screen’s “Pause run”. Reversible with Backend::resume_run.
Sourcepub fn resume_run(
&mut self,
corpus_id: i32,
service_id: i32,
) -> Result<usize, Error>
pub fn resume_run( &mut self, corpus_id: i32, service_id: i32, ) -> Result<usize, Error>
Resume a paused (corpus, service) run: return every Blocked task (status < -5) to TODO
so the dispatcher picks them up. Returns the number resumed. The inverse of
Backend::pause_run.
Sourcepub fn mark_new_run(
&mut self,
corpus: &Corpus,
service: &Service,
owner: String,
description: String,
) -> Result<(), Error>
pub fn mark_new_run( &mut self, corpus: &Corpus, service: &Service, owner: String, description: String, ) -> Result<(), Error>
While not changing any status information for Tasks, add a new historical run bookmark
Sourcepub fn save_historical_tasks(
&mut self,
corpus: &Corpus,
service: &Service,
) -> Result<usize, Error>
pub fn save_historical_tasks( &mut self, corpus: &Corpus, service: &Service, ) -> Result<usize, Error>
Save the current historical tasks for reference
Sourcepub fn delete<Model: CortexDeletable>(
&mut self,
object: &Model,
) -> Result<usize, Error>
pub fn delete<Model: CortexDeletable>( &mut self, object: &Model, ) -> Result<usize, Error>
Generic delete method, uses primary “id” field
Sourcepub fn delete_by<Model: CortexDeletable>(
&mut self,
object: &Model,
field: &str,
) -> Result<usize, Error>
pub fn delete_by<Model: CortexDeletable>( &mut self, object: &Model, field: &str, ) -> Result<usize, Error>
Delete all entries matching the “field” value of a given object
Sourcepub fn add<Model: CortexInsertable>(
&mut self,
object: &Model,
) -> Result<usize, Error>
pub fn add<Model: CortexInsertable>( &mut self, object: &Model, ) -> Result<usize, Error>
Generic addition method, attempting to insert in the DB a Task store datum
applicable for any struct implementing the CortexORM trait
(for example Corpus, Service, Task)
Sourcepub fn fetch_tasks(
&mut self,
service: &Service,
limit: usize,
) -> Result<Vec<Task>, Error>
pub fn fetch_tasks( &mut self, service: &Service, limit: usize, ) -> Result<Vec<Task>, Error>
Fetches no more than limit queued tasks for a given Service
Sourcepub fn clear_limbo_tasks(&mut self) -> Result<usize, Error>
pub fn clear_limbo_tasks(&mut self) -> Result<usize, Error>
Globally resets any “in progress” tasks back to “queued”. Particularly useful for dispatcher restarts, when all “in progress” tasks need to be invalidated
Sourcepub fn clear_limbo_tasks_except(
&mut self,
in_flight: &[i64],
) -> Result<usize, Error>
pub fn clear_limbo_tasks_except( &mut self, in_flight: &[i64], ) -> Result<usize, Error>
Like Self::clear_limbo_tasks, but preserves the given in-flight task ids (the live
progress_queue on a ventilator restart) so tasks a worker is actively processing are not
reset to TODO and double-dispatched. See tasks_aggregate::clear_limbo_tasks_except.
Sourcepub fn register_service(
&mut self,
service: &Service,
corpus: &Corpus,
owner: String,
description: String,
) -> Result<(), Error>
pub fn register_service( &mut self, service: &Service, corpus: &Corpus, owner: String, description: String, ) -> Result<(), Error>
Activates an existing service on the given corpus.
if the service has previously been registered, this call will RESET the service into a mint
state also removing any related log messages. The new run is attributed to owner with
description (the UI/API thread the actor; the CLI passes a default). Takes the resolved
Corpus (not a path): a sandbox shares its parent’s path, so a path lookup would hit the
parent.
Sourcepub fn extend_service(
&mut self,
service: &Service,
corpus: &Corpus,
) -> Result<(), Error>
pub fn extend_service( &mut self, service: &Service, corpus: &Corpus, ) -> Result<(), Error>
Extends an existing service on the given corpus.
if the service has previously been registered, this call will ignore existing entries and
simply add newly encountered ones. Takes the resolved Corpus (not a path) for the same
sandbox-shares-parent-path reason as register_service.
Sourcepub fn destroy_service_by_name(&mut self, name: &str) -> Result<usize, Error>
pub fn destroy_service_by_name(&mut self, name: &str) -> Result<usize, Error>
Permanently destroys a service by name — its definition plus all of its tasks + log_* rows
across every corpus, in one transaction (orphan-free + crash-consistent; closes R-6). Refuses
the magic init/import services. See [services_aggregate::destroy_service_by_name].
Sourcepub fn corpora(&mut self) -> Vec<Corpus>
pub fn corpora(&mut self) -> Vec<Corpus>
Returns a vector of currently available corpora in the Task store
Sourcepub fn tasks(
&mut self,
corpus: &Corpus,
service: &Service,
task_status: &TaskStatus,
) -> Vec<Task>
pub fn tasks( &mut self, corpus: &Corpus, service: &Service, task_status: &TaskStatus, ) -> Vec<Task>
Returns a vector of tasks for a given Corpus, Service and status
Sourcepub fn entries(
&mut self,
corpus: &Corpus,
service: &Service,
task_status: &TaskStatus,
) -> Vec<String>
pub fn entries( &mut self, corpus: &Corpus, service: &Service, task_status: &TaskStatus, ) -> Vec<String>
Returns a vector of task entry paths for a given Corpus, Service and status
Sourcepub fn task_report(
&mut self,
options: TaskReportOptions<'_>,
) -> Vec<HashMap<String, String>>
pub fn task_report( &mut self, options: TaskReportOptions<'_>, ) -> Vec<HashMap<String, String>>
Given a complex selector, of a Corpus, Service, and the optional severity, category
and what, Provide a progress report at the chosen granularity
Sourcepub fn progress_report(
&mut self,
corpus: &Corpus,
service: &Service,
) -> HashMap<String, f64>
pub fn progress_report( &mut self, corpus: &Corpus, service: &Service, ) -> HashMap<String, f64>
Provides a progress report, grouped by severity, for a given Corpus and Service pair
Sourcepub fn refresh_report_summary(&mut self) -> Result<(), Error>
pub fn refresh_report_summary(&mut self) -> Result<(), Error>
Recomputes the report_summary rollup (Arm 14 #6); call on the run-completion path so the
cheap category/what report reads stay fresh.
Sourcepub fn invalidate_report_cache(
&mut self,
corpus_id: i32,
service_id: i32,
) -> Result<(), Error>
pub fn invalidate_report_cache( &mut self, corpus_id: i32, service_id: i32, ) -> Result<(), Error>
Drop the cached report grains for one (corpus, service) scope so the next report view
repopulates from current data. Called per touched scope on the run-completion path — scoped, a
cheap keyed DELETE, never the global all-corpora scan that used to stall conversions.
Sourcepub fn complete_run_if_drained(
&mut self,
corpus_id: i32,
service_id: i32,
) -> Result<bool, Error>
pub fn complete_run_if_drained( &mut self, corpus_id: i32, service_id: i32, ) -> Result<bool, Error>
Run-completion-on-drain: close the (corpus, service) pair’s open historical run iff its work
is exhausted (every task terminal). Delegates to
HistoricalRun::complete_if_drained;
returns true iff a run was closed. Called per touched scope from the dispatcher’s finalize
loop when the queue idles, so a finished run is closed at once rather than at the next rerun.
Sourcepub fn category_rollup(
&mut self,
corpus: &Corpus,
service: &Service,
severity: &str,
limit: i64,
offset: i64,
) -> Vec<ReportSummaryRow>
pub fn category_rollup( &mut self, corpus: &Corpus, service: &Service, severity: &str, limit: i64, offset: i64, ) -> Vec<ReportSummaryRow>
Category-grain report for (corpus, service, severity), read from the report_summary
rollup, windowed to [offset, offset + limit) (ordered by descending task count).
Sourcepub fn what_rollup(
&mut self,
corpus: &Corpus,
service: &Service,
severity: &str,
category: &str,
limit: i64,
offset: i64,
) -> Vec<ReportSummaryRow>
pub fn what_rollup( &mut self, corpus: &Corpus, service: &Service, severity: &str, category: &str, limit: i64, offset: i64, ) -> Vec<ReportSummaryRow>
what-grain drill-down for (corpus, service, severity, category), read from the rollup,
windowed to [offset, offset + limit) (ordered by descending task count).
Sourcepub fn severity_totals(
&mut self,
corpus: &Corpus,
service: &Service,
severity: &str,
) -> (i64, i64)
pub fn severity_totals( &mut self, corpus: &Corpus, service: &Service, severity: &str, ) -> (i64, i64)
The per-severity grand totals (distinct tasks, total messages) for (corpus, service, severity), read from the rollup — the denominators the category-grain report shows. (0, 0)
when the severity has no logged messages.
Sourcepub fn category_totals(
&mut self,
corpus: &Corpus,
service: &Service,
severity: &str,
category: &str,
) -> (i64, i64)
pub fn category_totals( &mut self, corpus: &Corpus, service: &Service, severity: &str, category: &str, ) -> (i64, i64)
The category-grain totals (distinct tasks, total messages) for (corpus, service, severity, category) — the denominators the what drill-down shows. (0, 0) when the category is
empty.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Backend
impl !Sync for Backend
impl !UnwindSafe for Backend
impl Freeze for Backend
impl Send for Backend
impl Unpin for Backend
impl UnsafeUnpin for Backend
Blanket Implementations§
§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read more§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read more§fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
§fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
self into a collection.fn mapped<U, F, A>(self, f: F) -> SmallVec<A>where
F: FnMut(T) -> U,
A: Array<Item = U>,
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§impl<T> IntoSql for T
impl<T> IntoSql for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);