pub trait AsyncJobProvider {
// Required methods
fn create_job(
&self,
tenant: &TenantId,
project: &ProjectId,
job: CreateAsyncJob,
) -> impl Future<Output = Result<AsyncJob, OperationOutcomeError>> + Send;
fn read_job(
&self,
tenant: &TenantId,
project: &ProjectId,
id: &str,
) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send;
fn count_live_jobs(
&self,
tenant: &TenantId,
project: &ProjectId,
) -> impl Future<Output = Result<i64, OperationOutcomeError>> + Send;
fn cancel_job(
&self,
tenant: &TenantId,
project: &ProjectId,
id: &str,
) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send;
fn claim_job(
&self,
kinds: &[&str],
lease: &JobLease,
) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send;
fn renew_lease(
&self,
id: &str,
lease: &JobLease,
progress: Option<&str>,
) -> impl Future<Output = Result<LeaseRenewal, OperationOutcomeError>> + Send;
fn finish_job(
&self,
id: &str,
worker: &str,
result: JobResult,
retention: Duration,
) -> impl Future<Output = Result<bool, OperationOutcomeError>> + Send;
fn fail_abandoned_jobs(
&self,
outcome: &Value,
retention: Duration,
) -> impl Future<Output = Result<u64, OperationOutcomeError>> + Send;
fn delete_expired_jobs(
&self,
limit: i64,
) -> impl Future<Output = Result<Vec<AsyncJob>, OperationOutcomeError>> + Send;
}Required Methods§
Sourcefn create_job(
&self,
tenant: &TenantId,
project: &ProjectId,
job: CreateAsyncJob,
) -> impl Future<Output = Result<AsyncJob, OperationOutcomeError>> + Send
fn create_job( &self, tenant: &TenantId, project: &ProjectId, job: CreateAsyncJob, ) -> impl Future<Output = Result<AsyncJob, OperationOutcomeError>> + Send
Queues a job. Its id is generated here and is what the status URL carries.
Sourcefn read_job(
&self,
tenant: &TenantId,
project: &ProjectId,
id: &str,
) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send
fn read_job( &self, tenant: &TenantId, project: &ProjectId, id: &str, ) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send
A job of this project, whatever its state, until it expires.
Sourcefn count_live_jobs(
&self,
tenant: &TenantId,
project: &ProjectId,
) -> impl Future<Output = Result<i64, OperationOutcomeError>> + Send
fn count_live_jobs( &self, tenant: &TenantId, project: &ProjectId, ) -> impl Future<Output = Result<i64, OperationOutcomeError>> + Send
Jobs of this project that are queued or running. Kick-offs cap this.
Sourcefn cancel_job(
&self,
tenant: &TenantId,
project: &ProjectId,
id: &str,
) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send
fn cancel_job( &self, tenant: &TenantId, project: &ProjectId, id: &str, ) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send
Cancels a job of this project. A queued job never runs; a running one
finds out at its next lease renewal; a finished one gives up its
result. Returns the job as it was before, or None if there is no
such job or it was already cancelled.
Sourcefn claim_job(
&self,
kinds: &[&str],
lease: &JobLease,
) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send
fn claim_job( &self, kinds: &[&str], lease: &JobLease, ) -> impl Future<Output = Result<Option<AsyncJob>, OperationOutcomeError>> + Send
Takes the oldest claimable job of one of kinds for lease.worker:
queued, or in progress with a lapsed lease, and with attempts left.
Claiming is one statement, so two workers never take the same job.
Sourcefn renew_lease(
&self,
id: &str,
lease: &JobLease,
progress: Option<&str>,
) -> impl Future<Output = Result<LeaseRenewal, OperationOutcomeError>> + Send
fn renew_lease( &self, id: &str, lease: &JobLease, progress: Option<&str>, ) -> impl Future<Output = Result<LeaseRenewal, OperationOutcomeError>> + Send
Extends the lease on a job this worker holds and records progress
if given. Lost means stop: the job was cancelled or taken over.
Sourcefn finish_job(
&self,
id: &str,
worker: &str,
result: JobResult,
retention: Duration,
) -> impl Future<Output = Result<bool, OperationOutcomeError>> + Send
fn finish_job( &self, id: &str, worker: &str, result: JobResult, retention: Duration, ) -> impl Future<Output = Result<bool, OperationOutcomeError>> + Send
Records the result of a job this worker holds and releases the lease. Returns false if the job was no longer this worker’s to finish (it was cancelled or taken over meanwhile), in which case the result is dropped.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".