Expose next_queue, add docs

This commit is contained in:
asonix 2020-03-22 16:04:49 -05:00
parent 0df808e97d
commit 799391811c
2 changed files with 9 additions and 2 deletions

View file

@ -179,6 +179,7 @@ impl JobInfo {
self.id self.id
} }
/// How long (in milliseconds) before this job is considered failed and can be requeued
pub fn timeout(&self) -> i64 { pub fn timeout(&self) -> i64 {
self.timeout self.timeout
} }
@ -191,13 +192,18 @@ impl JobInfo {
} }
} }
/// If the job is queued to run in the future, when is that
pub fn next_queue(&self) -> Option<DateTime<Utc>> {
self.next_queue
}
pub(crate) fn increment(&mut self) -> ShouldStop { pub(crate) fn increment(&mut self) -> ShouldStop {
self.updated(); self.updated();
self.retry_count += 1; self.retry_count += 1;
self.max_retries.compare(self.retry_count) self.max_retries.compare(self.retry_count)
} }
fn next_queue(&mut self) { fn set_next_queue(&mut self) {
let now = Utc::now(); let now = Utc::now();
let next_queue = match self.backoff_strategy { let next_queue = match self.backoff_strategy {
@ -231,7 +237,7 @@ impl JobInfo {
if should_retry { if should_retry {
self.pending(); self.pending();
self.next_queue(); self.set_next_queue();
} }
should_retry should_retry

View file

@ -136,6 +136,7 @@ impl std::fmt::Display for JobStatus {
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, thiserror::Error)] #[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, thiserror::Error)]
#[error("Invalid job status")] #[error("Invalid job status")]
/// The error generated when parsing a job's status if it's not 'Pending' or 'Running'
pub struct JobStatusError; pub struct JobStatusError;
impl std::str::FromStr for JobStatus { impl std::str::FromStr for JobStatus {