diff --git a/ofborg/src/bin/build-faker.rs b/ofborg/src/bin/build-faker.rs index 778e336..bfeadc9 100644 --- a/ofborg/src/bin/build-faker.rs +++ b/ofborg/src/bin/build-faker.rs @@ -1,24 +1,25 @@ +use std::env; +use std::error::Error; + +use async_std::task; +use lapin::message::Delivery; +use lapin::BasicProperties; + use ofborg::commentparser; use ofborg::config; -use ofborg::easyamqp; +use ofborg::easylapin; use ofborg::message::{buildjob, Pr, Repo}; -use ofborg::notifyworker::{self, NotificationReceiver}; +use ofborg::notifyworker::NotificationReceiver; use ofborg::worker; -use std::env; - -use tracing::info; - -fn main() { - let cfg = config::load(env::args().nth(1).unwrap().as_ref()); +fn main() -> Result<(), Box> { ofborg::setup_log(); - info!("Hello, world!"); + let arg = env::args().nth(1).expect("usage: build-faker "); + let cfg = config::load(arg.as_ref()); - let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - info!("Connected to rabbitmq"); - - let mut channel = session.open_channel(1).unwrap(); + let conn = easylapin::from_config(&cfg.rabbitmq)?; + let mut chan = task::block_on(conn.create_channel())?; let repo_msg = Repo { clone_url: "https://github.com/nixos/ofborg.git".to_owned(), @@ -46,7 +47,15 @@ fn main() { }; { - let mut recv = notifyworker::ChannelNotificationReceiver::new(&mut channel, 0); + let deliver = Delivery { + delivery_tag: 0, + exchange: "no-exchange".into(), + routing_key: "".into(), + redelivered: false, + properties: BasicProperties::default(), + data: vec![], + }; + let mut recv = easylapin::ChannelNotificationReceiver::new(&mut chan, &deliver); for _i in 1..2 { recv.tell(worker::publish_serde_action( @@ -57,8 +66,5 @@ fn main() { } } - channel.close(200, "Bye").unwrap(); - info!("Closed the channel"); - session.close(200, "Good Bye"); - info!("Closed the session... EOF"); + Ok(()) }