implement Drop for Job - prevent jobs from hanging in progress forever
This commit is contained in:
parent
019a451d4e
commit
ce50f5ad80
1 changed files with 9 additions and 3 deletions
|
@ -17,17 +17,23 @@ impl Job {
|
|||
S: AsRef<str>,
|
||||
IS: Into<Option<S>>,
|
||||
{
|
||||
return Job {
|
||||
Job {
|
||||
job_type: job_type.into().map(|jt| String::from(jt.as_ref())),
|
||||
title: String::from(title.as_ref()),
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Job {
|
||||
fn drop(&mut self) {
|
||||
self.state = State::Failed;
|
||||
}
|
||||
}
|
||||
|
||||
pub type JobType = String;
|
||||
|
||||
#[derive(Serialize, Clone, PartialEq)]
|
||||
#[derive(Serialize, Clone, Copy, PartialEq)]
|
||||
pub enum State {
|
||||
InProgress,
|
||||
Done,
|
||||
|
|
Loading…
Reference in a new issue