diff --git a/ofborg/src/notifyworker.rs b/ofborg/src/notifyworker.rs index 08193f1..a86f851 100644 --- a/ofborg/src/notifyworker.rs +++ b/ofborg/src/notifyworker.rs @@ -1,7 +1,7 @@ use crate::worker::Action; use amqp::protocol::basic::{BasicProperties, Deliver}; -use amqp::{Basic, Channel, Consumer}; +use amqp::Basic; use std::marker::Send; @@ -16,8 +16,8 @@ pub trait SimpleNotifyWorker { fn msg_to_job( &self, - method: &Deliver, - headers: &BasicProperties, + routing_key: &str, + content_type: &Option, body: &[u8], ) -> Result; } @@ -44,12 +44,15 @@ impl NotificationReceiver for DummyNotificationReceiver { } pub struct ChannelNotificationReceiver<'a> { - channel: &'a mut Channel, + channel: &'a mut amqp::Channel, delivery_tag: u64, } impl<'a> ChannelNotificationReceiver<'a> { - pub fn new(channel: &'a mut Channel, delivery_tag: u64) -> ChannelNotificationReceiver<'a> { + pub fn new( + channel: &'a mut amqp::Channel, + delivery_tag: u64, + ) -> ChannelNotificationReceiver<'a> { ChannelNotificationReceiver { channel, delivery_tag, @@ -92,17 +95,20 @@ pub fn new(worker: T) -> NotifyWorker { NotifyWorker { internal: worker } } -impl Consumer for NotifyWorker { +impl amqp::Consumer for NotifyWorker { fn handle_delivery( &mut self, - channel: &mut Channel, + channel: &mut amqp::Channel, method: Deliver, headers: BasicProperties, body: Vec, ) { let mut receiver = ChannelNotificationReceiver::new(channel, method.delivery_tag); - let job = self.internal.msg_to_job(&method, &headers, &body).unwrap(); + let job = self + .internal + .msg_to_job(&method.routing_key, &headers.content_type, &body) + .unwrap(); self.internal.consumer(&job, &mut receiver); } } diff --git a/ofborg/src/tasks/build.rs b/ofborg/src/tasks/build.rs index f43c825..0d8c42f 100644 --- a/ofborg/src/tasks/build.rs +++ b/ofborg/src/tasks/build.rs @@ -6,7 +6,6 @@ use crate::nix; use crate::notifyworker; use crate::worker; -use amqp::protocol::basic::{BasicProperties, Deliver}; use uuid::Uuid; use std::collections::VecDeque; @@ -260,7 +259,7 @@ impl<'a, 'b> JobActions<'a, 'b> { impl notifyworker::SimpleNotifyWorker for BuildWorker { type J = buildjob::BuildJob; - fn msg_to_job(&self, _: &Deliver, _: &BasicProperties, body: &[u8]) -> Result { + fn msg_to_job(&self, _: &str, _: &Option, body: &[u8]) -> Result { info!("lmao I got a job?"); match buildjob::from(body) { Ok(e) => Ok(e),