implement Drop for Job - prevent jobs from hanging in progress forever

feat/vaults
Tomáš Mládek 2022-02-28 17:00:27 +01:00
parent 019a451d4e
commit ce50f5ad80
No known key found for this signature in database
GPG Key ID: 65E225C8B3E2ED8A
1 changed files with 9 additions and 3 deletions

View File

@ -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,