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