add id getter for message body
This commit is contained in:
parent
0c3a8acae0
commit
6d26f1032d
@ -1,6 +1,8 @@
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Message {
|
||||
CheckDeploy(MessageBody),
|
||||
StopManager,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
@ -10,6 +12,12 @@ pub struct MessageBody {
|
||||
content: String,
|
||||
}
|
||||
|
||||
impl MessageBody {
|
||||
pub fn get_id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
impl Message {
|
||||
pub fn check_deploy(id: u32, content: &str) -> Self {
|
||||
let body = MessageBody {
|
||||
|
||||
@ -19,7 +19,7 @@ impl CheckHandler {
|
||||
impl Handler for CheckHandler {
|
||||
fn handle(&self, res: Result<Message, String>) {
|
||||
match res {
|
||||
Ok(_m) => todo!(),
|
||||
Ok(_m) => (),
|
||||
Err(_e) => todo!(),
|
||||
}
|
||||
}
|
||||
@ -36,12 +36,15 @@ impl DeployHandler {
|
||||
|
||||
fn manage_message(&self, message: Message) {
|
||||
match message {
|
||||
Message::CheckDeploy(_body) => {
|
||||
Message::CheckDeploy(body) => {
|
||||
let guard = self.sender.lock().unwrap();
|
||||
if let Err(e) = guard.send(Job::new(1, JobAction::MegaportCheckDeploy)) {
|
||||
let id: i32 = body.get_id().try_into().unwrap();
|
||||
|
||||
if let Err(e) = guard.send(Job::new(id, JobAction::MegaportCheckDeploy)) {
|
||||
println!("[handler(deploy)] error: {}", e);
|
||||
}
|
||||
}
|
||||
Message::StopManager => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user