pub struct QueuedJob {Show 15 fields
pub id: Uuid,
pub kind: String,
pub payload: String,
pub state: JobState,
pub lane: Option<String>,
pub running_lane: Option<String>,
pub dedupe_key: String,
pub attempts: u64,
pub max_attempts: u64,
pub run_at: Timestamp,
pub locked_until: Option<Timestamp>,
pub last_error: Option<String>,
pub created_at: Timestamp,
pub finished_at: Option<Timestamp>,
pub version: u64,
}Expand description
One unit of background work, written by enqueue and run by a
Worker.
It is a PanelModel, so an app can list the queue through a
resource of its own, and give a Dead job its attempts back by setting its
state to Queued, attempts to 0 and run_at to now.
Fields§
§id: Uuid§kind: StringThe Job::KIND that runs it.
payload: StringThe job’s fields, as JSON.
state: JobState§lane: Option<String>The Job::lane it runs in: one job of a lane runs at a time.
running_lane: Option<String>The lane while the job runs, and None otherwise. Unique, so the database refuses a
second running job in one lane, whichever worker claims it.
dedupe_key: StringThe kind and the dedupe key, or the id. While the job waits
for its first run, a second enqueue with the same key adds nothing. A claim sets it to the
id, so work arriving during a run, or during the backoff after one, queues behind it.
attempts: u64§max_attempts: u64§run_at: TimestampNot before this instant.
locked_until: Option<Timestamp>When a running job’s worker gives it up, alive or not.
last_error: Option<String>The last failure, for whoever reads a dead job.
created_at: Timestamp§finished_at: Option<Timestamp>§version: u64Makes a claim a compare-and-swap: of two workers, the second fails its update.
Implementations§
Source§impl QueuedJob
impl QueuedJob
Sourcepub fn fields() -> QueuedJobFields<QueuedJob>
pub fn fields() -> QueuedJobFields<QueuedJob>
Returns a handle used to reference QueuedJob’s fields when building query expressions.
Sourcepub async fn get_by_id(
executor: &mut dyn Executor,
id: impl IntoExpr<FieldExprTarget<Uuid>>,
) -> Result<QueuedJob>
pub async fn get_by_id( executor: &mut dyn Executor, id: impl IntoExpr<FieldExprTarget<Uuid>>, ) -> Result<QueuedJob>
Fetches the single QueuedJob where id matches, erroring if none exists.
Sourcepub fn update_by_id(id: impl IntoExpr<FieldExprTarget<Uuid>>) -> QueuedJobUpdate
pub fn update_by_id(id: impl IntoExpr<FieldExprTarget<Uuid>>) -> QueuedJobUpdate
Returns a builder that updates the QueuedJob where id matches.
Sourcepub async fn delete_by_id(
executor: &mut dyn Executor,
id: impl IntoExpr<FieldExprTarget<Uuid>>,
) -> Result<()>
pub async fn delete_by_id( executor: &mut dyn Executor, id: impl IntoExpr<FieldExprTarget<Uuid>>, ) -> Result<()>
Deletes the QueuedJob where id matches.
Sourcepub fn filter_by_id(id: impl IntoExpr<FieldExprTarget<Uuid>>) -> QueuedJobQuery
pub fn filter_by_id(id: impl IntoExpr<FieldExprTarget<Uuid>>) -> QueuedJobQuery
Returns a query selecting the QueuedJob records where id matches.
Sourcepub async fn get_by_kind(
executor: &mut dyn Executor,
kind: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<QueuedJob>
pub async fn get_by_kind( executor: &mut dyn Executor, kind: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<QueuedJob>
Fetches the single QueuedJob where kind matches, erroring if none exists.
Sourcepub fn update_by_kind(
kind: impl IntoExpr<FieldExprTarget<String>>,
) -> QueuedJobUpdate
pub fn update_by_kind( kind: impl IntoExpr<FieldExprTarget<String>>, ) -> QueuedJobUpdate
Returns a builder that updates the QueuedJob where kind matches.
Sourcepub async fn delete_by_kind(
executor: &mut dyn Executor,
kind: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<()>
pub async fn delete_by_kind( executor: &mut dyn Executor, kind: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<()>
Deletes the QueuedJob where kind matches.
Sourcepub fn filter_by_kind(
kind: impl IntoExpr<FieldExprTarget<String>>,
) -> QueuedJobQuery
pub fn filter_by_kind( kind: impl IntoExpr<FieldExprTarget<String>>, ) -> QueuedJobQuery
Returns a query selecting the QueuedJob records where kind matches.
Sourcepub async fn get_by_lane(
executor: &mut dyn Executor,
lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> Result<QueuedJob>
pub async fn get_by_lane( executor: &mut dyn Executor, lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> Result<QueuedJob>
Fetches the single QueuedJob where lane matches, erroring if none exists.
Sourcepub fn update_by_lane(
lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> QueuedJobUpdate
pub fn update_by_lane( lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> QueuedJobUpdate
Returns a builder that updates the QueuedJob where lane matches.
Sourcepub async fn delete_by_lane(
executor: &mut dyn Executor,
lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> Result<()>
pub async fn delete_by_lane( executor: &mut dyn Executor, lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> Result<()>
Deletes the QueuedJob where lane matches.
Sourcepub fn filter_by_lane(
lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> QueuedJobQuery
pub fn filter_by_lane( lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> QueuedJobQuery
Returns a query selecting the QueuedJob records where lane matches.
Sourcepub async fn get_by_running_lane(
executor: &mut dyn Executor,
running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> Result<QueuedJob>
pub async fn get_by_running_lane( executor: &mut dyn Executor, running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> Result<QueuedJob>
Fetches the single QueuedJob where running_lane matches, erroring if none exists.
Sourcepub fn update_by_running_lane(
running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> QueuedJobUpdate
pub fn update_by_running_lane( running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> QueuedJobUpdate
Returns a builder that updates the QueuedJob where running_lane matches.
Sourcepub async fn delete_by_running_lane(
executor: &mut dyn Executor,
running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> Result<()>
pub async fn delete_by_running_lane( executor: &mut dyn Executor, running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> Result<()>
Deletes the QueuedJob where running_lane matches.
Sourcepub fn filter_by_running_lane(
running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> QueuedJobQuery
pub fn filter_by_running_lane( running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> QueuedJobQuery
Returns a query selecting the QueuedJob records where running_lane matches.
Sourcepub async fn get_by_dedupe_key(
executor: &mut dyn Executor,
dedupe_key: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<QueuedJob>
pub async fn get_by_dedupe_key( executor: &mut dyn Executor, dedupe_key: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<QueuedJob>
Fetches the single QueuedJob where dedupe_key matches, erroring if none exists.
Sourcepub fn update_by_dedupe_key(
dedupe_key: impl IntoExpr<FieldExprTarget<String>>,
) -> QueuedJobUpdate
pub fn update_by_dedupe_key( dedupe_key: impl IntoExpr<FieldExprTarget<String>>, ) -> QueuedJobUpdate
Returns a builder that updates the QueuedJob where dedupe_key matches.
Sourcepub async fn delete_by_dedupe_key(
executor: &mut dyn Executor,
dedupe_key: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<()>
pub async fn delete_by_dedupe_key( executor: &mut dyn Executor, dedupe_key: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<()>
Deletes the QueuedJob where dedupe_key matches.
Sourcepub fn filter_by_dedupe_key(
dedupe_key: impl IntoExpr<FieldExprTarget<String>>,
) -> QueuedJobQuery
pub fn filter_by_dedupe_key( dedupe_key: impl IntoExpr<FieldExprTarget<String>>, ) -> QueuedJobQuery
Returns a query selecting the QueuedJob records where dedupe_key matches.
Sourcepub async fn get_by_run_at(
executor: &mut dyn Executor,
run_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> Result<QueuedJob>
pub async fn get_by_run_at( executor: &mut dyn Executor, run_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> Result<QueuedJob>
Fetches the single QueuedJob where run_at matches, erroring if none exists.
Sourcepub fn update_by_run_at(
run_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> QueuedJobUpdate
pub fn update_by_run_at( run_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> QueuedJobUpdate
Returns a builder that updates the QueuedJob where run_at matches.
Sourcepub async fn delete_by_run_at(
executor: &mut dyn Executor,
run_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> Result<()>
pub async fn delete_by_run_at( executor: &mut dyn Executor, run_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> Result<()>
Deletes the QueuedJob where run_at matches.
Sourcepub fn filter_by_run_at(
run_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> QueuedJobQuery
pub fn filter_by_run_at( run_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> QueuedJobQuery
Returns a query selecting the QueuedJob records where run_at matches.
Sourcepub fn create() -> QueuedJobCreate
pub fn create() -> QueuedJobCreate
Returns a builder that inserts a new QueuedJob record.
Typically constructed through the toasty::create! macro.
Sourcepub fn create_many() -> CreateMany<QueuedJob>
pub fn create_many() -> CreateMany<QueuedJob>
Returns a builder that inserts multiple QueuedJob records at once.
Sourcepub fn update(&mut self) -> QueuedJobUpdate<&mut Self>
pub fn update(&mut self) -> QueuedJobUpdate<&mut Self>
Returns a builder that updates this QueuedJob record in place.
Source§impl QueuedJob
impl QueuedJob
Sourcepub fn upsert_by_id(
id: impl IntoExpr<FieldExprTarget<Uuid>>,
) -> QueuedJobUpsertById
pub fn upsert_by_id( id: impl IntoExpr<FieldExprTarget<Uuid>>, ) -> QueuedJobUpsertById
Returns a builder that creates QueuedJob or updates the record whose id constraint matches.
The target arguments initialize a new record and remain unchanged when an existing record is updated.
Source§impl QueuedJob
impl QueuedJob
Sourcepub fn upsert_by_running_lane(
running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>,
) -> QueuedJobUpsertByRunningLane
pub fn upsert_by_running_lane( running_lane: impl IntoExpr<FieldExprTarget<Option<String>>>, ) -> QueuedJobUpsertByRunningLane
Returns a builder that creates QueuedJob or updates the record whose running_lane constraint matches.
The target arguments initialize a new record and remain unchanged when an existing record is updated.
Source§impl QueuedJob
impl QueuedJob
Sourcepub fn upsert_by_dedupe_key(
dedupe_key: impl IntoExpr<FieldExprTarget<String>>,
) -> QueuedJobUpsertByDedupeKey
pub fn upsert_by_dedupe_key( dedupe_key: impl IntoExpr<FieldExprTarget<String>>, ) -> QueuedJobUpsertByDedupeKey
Returns a builder that creates QueuedJob or updates the record whose dedupe_key constraint matches.
The target arguments initialize a new record and remain unchanged when an existing record is updated.
Source§impl QueuedJob
impl QueuedJob
Sourcepub fn columns() -> QueuedJobColumns
pub fn columns() -> QueuedJobColumns
Each field the default table or detail page of QueuedJob shows, as a FieldColumn: placed as it is, the column the derive picks there, with the field’s #[columns(..)] keys; through a kind method, such as .text() or .toggle(), that column type’s own builder over the field.
Trait Implementations§
Source§impl Load for QueuedJob
impl Load for QueuedJob
Source§fn reload(target: &mut Self, value: Value) -> Result<()>
fn reload(target: &mut Self, value: Value) -> Result<()>
§fn ty_relation() -> Type
fn ty_relation() -> Type
stmt::Type] used when this type appears as a relation
target. The default delegates to ty().§fn load_relation(value: Value) -> Result<Self::Output, Error>
fn load_relation(value: Value) -> Result<Self::Output, Error>
Source§impl Model for QueuedJob
impl Model for QueuedJob
Source§type Query<__T> = QueuedJobQuery<__T>
type Query<__T> = QueuedJobQuery<__T>
Source§type UpdateQuery = QueuedJobUpdate
type UpdateQuery = QueuedJobUpdate
Source§type PrimaryKey = Uuid
type PrimaryKey = Uuid
Source§type ManyField<__Origin> = QueuedJobListFields<__Origin>
type ManyField<__Origin> = QueuedJobListFields<__Origin>
Source§type OneField<__Origin, __Target> = QueuedJobFields<__Origin, __Target>
type OneField<__Origin, __Target> = QueuedJobFields<__Origin, __Target>
Source§fn register(model_set: &mut ModelSet)
fn register(model_set: &mut ModelSet)
ModelSet]. Read moreSource§fn new_path<__Origin>(path: Path<__Origin, Self>) -> Self::Path<__Origin>
fn new_path<__Origin>(path: Path<__Origin, Self>) -> Self::Path<__Origin>
Path] targeting this model.Source§fn new_many_field<__Origin>(
path: Path<__Origin, List<Self>>,
) -> QueuedJobListFields<__Origin>
fn new_many_field<__Origin>( path: Path<__Origin, List<Self>>, ) -> QueuedJobListFields<__Origin>
ManyField from a path targeting a list
of this model.Source§fn find_by_primary_key(id: Expr<Self::PrimaryKey>) -> Self::Query<List<Self>>
fn find_by_primary_key(id: Expr<Self::PrimaryKey>) -> Self::Query<List<Self>>
Source§fn wrap_query<__T>(stmt: Query<__T>) -> Self::Query<__T>
fn wrap_query<__T>(stmt: Query<__T>) -> Self::Query<__T>
Query in this model’s
query builder, preserving the result shape T. This is the single
constructor generic code uses to build any query shape; callers narrow
at the statement level (.one(), .first()) before wrapping.Source§fn query_one(query: Self::Query<List<Self>>) -> Self::Query<Self>
fn query_one(query: Self::Query<List<Self>>) -> Self::Query<Self>
Source§fn query_first(query: Self::Query<List<Self>>) -> Self::Query<Option<Self>>
fn query_first(query: Self::Query<List<Self>>) -> Self::Query<Option<Self>>
Source§fn field_name_to_id(name: &str) -> FieldId
fn field_name_to_id(name: &str) -> FieldId
FieldId]. Read more§fn new_root_path() -> Self::Path<Self>
fn new_root_path() -> Self::Path<Self>
§fn path_field<U>(index: usize) -> Path<Self, U>
fn path_field<U>(index: usize) -> Path<Self, U>
Path] from this model to the field at index.§fn path_model_list() -> Path<List<Self>, List<Self>>
fn path_model_list() -> Path<List<Self>, List<Self>>
Path] rooted at a list of this model, used as the root of
has-many relation scopes.§fn new_create() -> Self::Create
fn new_create() -> Self::Create
Source§impl ModelCodegen for QueuedJob
impl ModelCodegen for QueuedJob
Source§fn to_relation_expr(&self, fields: &[&str]) -> Expr
fn to_relation_expr(&self, fields: &[&str]) -> Expr
Source§fn new_one_field<__Origin, __Target>(
path: Path<__Origin, __Target>,
) -> Self::OneField<__Origin, __Target>
fn new_one_field<__Origin, __Target>( path: Path<__Origin, __Target>, ) -> Self::OneField<__Origin, __Target>
Source§impl PanelModel for QueuedJob
impl PanelModel for QueuedJob
Source§const TENANT_COLUMNS: &'static [&'static str]
const TENANT_COLUMNS: &'static [&'static str]
Source§const UNLOADS_RELATIONS: bool = true
const UNLOADS_RELATIONS: bool = true
Source§fn detail() -> Detail<QueuedJob>
fn detail() -> Detail<QueuedJob>
Source§impl UpdateTarget for &mut QueuedJob
impl UpdateTarget for &mut QueuedJob
Source§fn to_update_stmt(&mut self, assignments: Assignments) -> Update<QueuedJob>
fn to_update_stmt(&mut self, assignments: Assignments) -> Update<QueuedJob>
Source§fn apply_result(self, value: Value) -> Result<()>
fn apply_result(self, value: Value) -> Result<()>
Source§impl ViaTarget for QueuedJob
impl ViaTarget for QueuedJob
Source§type Query = QueuedJobQuery
type Query = QueuedJobQuery
Source§type Path<__Origin> = <QueuedJob as Model>::ManyField<__Origin>
type Path<__Origin> = <QueuedJob as Model>::ManyField<__Origin>
#[has_many(via = …)] field’s accessor returns,
parameterized by the origin model. Mirrors Model::Path for the
via-many case. Read moreSource§fn new_path<__Origin>(
path: Path<__Origin, List<QueuedJob>>,
) -> Self::Path<__Origin>
fn new_path<__Origin>( path: Path<__Origin, List<QueuedJob>>, ) -> Self::Path<__Origin>
Path handle from the typed path reaching this
terminal. A model terminal wraps the path in its chainable ManyField; a
scalar terminal is a leaf, so the path is the handle.Source§fn via_field_ty(singular: Name, path: Path) -> FieldTy
fn via_field_ty(singular: Name, path: Path) -> FieldTy
FieldTy::Via] for a #[has_many(via = …)] field whose
terminal element type is Self. Read moreSource§fn make_via_query(assoc: Association<List<QueuedJob>>) -> Self::Query
fn make_via_query(assoc: Association<List<QueuedJob>>) -> Self::Query
Auto Trait Implementations§
impl Freeze for QueuedJob
impl RefUnwindSafe for QueuedJob
impl Send for QueuedJob
impl Sync for QueuedJob
impl Unpin for QueuedJob
impl UnsafeUnpin for QueuedJob
impl UnwindSafe for QueuedJob
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<M> RelationOneField for Mwhere
M: Model,
impl<M> RelationOneField for Mwhere
M: Model,
§type One = <M as Model>::Query<M>
type One = <M as Model>::Query<M>
<Target as Model>::Query<Target>; for nullable impls it is
<Target as Model>::Query<Option<Target>>.§type Expr = M
type Expr = M
Self::Target for non-nullable impls and
Option<Self::Target> for nullable impls.§fn make_one(
query: <<M as RelationOneField>::Target as Model>::Query<List<<M as RelationOneField>::Target>>,
) -> <M as RelationOneField>::One
fn make_one( query: <<M as RelationOneField>::Target as Model>::Query<List<<M as RelationOneField>::Target>>, ) -> <M as RelationOneField>::One
Query<Model> for non-nullable impls and
Query<Option<Model>> for nullable impls. Read more§fn reload(target: &mut Self, value: Value) -> Result<(), Error>
fn reload(target: &mut Self, value: Value) -> Result<(), Error>
§fn has_one_relation_field_ty(
pair: Option<FieldId>,
via: Option<Path>,
) -> FieldTy
fn has_one_relation_field_ty( pair: Option<FieldId>, via: Option<Path>, ) -> FieldTy
FieldTy] for a HasOne relation field, given an
optional paired BelongsTo field on the target model resolved
from #[has_one(pair = <field>)]. When None, the linker selects
the pair by searching the target for a unique BelongsTo back to
the source. Read more§fn belongs_to_relation_field_ty(foreign_key: ForeignKey) -> FieldTy
fn belongs_to_relation_field_ty(foreign_key: ForeignKey) -> FieldTy
FieldTy] for a BelongsTo relation field, given the
foreign key resolved from the field’s #[belongs_to(...)] attribute.