clean code
This commit is contained in:
+19
-33
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user