update Runner.run signature + adapt message enum
This commit is contained in:
+5
-2
@@ -2,6 +2,7 @@ use std::{thread, time};
|
||||
|
||||
use super::{Runner, RunnerStatus, Storer};
|
||||
use crate::error::StorerError;
|
||||
use crate::message::Message;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
@@ -28,7 +29,7 @@ impl Job {
|
||||
}
|
||||
}
|
||||
|
||||
fn deploy_megaport(&mut self) {
|
||||
fn deploy_megaport(&mut self) -> Result<Message, String> {
|
||||
self.set_status(RunnerStatus::Running);
|
||||
println!(
|
||||
"[job({} - {:?} - {:?})] deploying megaport...",
|
||||
@@ -43,6 +44,8 @@ impl Job {
|
||||
"[job({} - {:?} - {:?})] megaport deployed",
|
||||
self.id, self.action, self.status
|
||||
);
|
||||
|
||||
Ok(Message::check_deploy(self.id.try_into().unwrap(), ""))
|
||||
}
|
||||
|
||||
fn set_status(&mut self, status: RunnerStatus) {
|
||||
@@ -51,7 +54,7 @@ impl Job {
|
||||
}
|
||||
|
||||
impl Runner for Job {
|
||||
fn run(&mut self) {
|
||||
fn run(&mut self) -> Result<Message, String> {
|
||||
match self.action {
|
||||
JobAction::MegaportDeploy => self.deploy_megaport(),
|
||||
JobAction::MegaportUndeploy => todo!(),
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
use crate::error::StorerError;
|
||||
use crate::message::Message;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
@@ -10,7 +11,7 @@ pub enum RunnerStatus {
|
||||
}
|
||||
|
||||
pub trait Runner {
|
||||
fn run(&mut self);
|
||||
fn run(&mut self) -> Result<Message, String>;
|
||||
}
|
||||
|
||||
pub trait Storer {
|
||||
|
||||
Reference in New Issue
Block a user