clean code

This commit is contained in:
rmanach
2023-04-18 14:37:38 +02:00
parent 8a0fd00fb9
commit b8e1afc679
2 changed files with 38 additions and 47 deletions
+19 -33
View File
@@ -28,46 +28,32 @@ impl Job {
}
}
pub fn set_status(&mut self, status: RunnerStatus) {
self.status = status;
fn deploy_megaport(&mut self) {
self.set_status(RunnerStatus::Running);
println!(
"[job({} - {:?} - {:?})] deploying megaport...",
self.id, self.action, self.status
);
let wait = time::Duration::from_millis(5);
thread::sleep(wait);
self.set_status(RunnerStatus::Success);
println!(
"[job({} - {:?} - {:?})] megaport deployed",
self.id, self.action, self.status
);
}
}
impl Runner for Job {
fn run(&mut self) {
self.set_status(RunnerStatus::Running);
match self.action {
JobAction::MegaportDeploy => {
println!(
"[job({} - {:?} - {:?})] deploying megaport...",
self.id, self.action, self.status
);
}
JobAction::MegaportUndeploy => {
println!(
"[job({} - {:?} - {:?})] undeploying megaport...",
self.id, self.action, self.status
);
}
JobAction::MegaportCheckDeploy => {
println!(
"[job({} - {:?} - {:?})] checking megaport deployement...",
self.id, self.action, self.status
);
}
JobAction::MegaportCheckUndeploy => {
println!(
"[job({} - {:?} - {:?})] checking megaport undeployement...",
self.id, self.action, self.status
);
}
JobAction::MegaportDeploy => self.deploy_megaport(),
JobAction::MegaportUndeploy => todo!(),
JobAction::MegaportCheckDeploy => todo!(),
JobAction::MegaportCheckUndeploy => todo!(),
}
let wait = time::Duration::from_millis(1);
thread::sleep(wait);
self.set_status(RunnerStatus::Success);
}
fn set_status(&mut self, status: RunnerStatus) {