convert build faker to easylapin
Another utility used just for testing.
This commit is contained in:
parent
6014e08415
commit
b464c296ce
|
@ -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::commentparser;
|
||||||
use ofborg::config;
|
use ofborg::config;
|
||||||
use ofborg::easyamqp;
|
use ofborg::easylapin;
|
||||||
use ofborg::message::{buildjob, Pr, Repo};
|
use ofborg::message::{buildjob, Pr, Repo};
|
||||||
use ofborg::notifyworker::{self, NotificationReceiver};
|
use ofborg::notifyworker::NotificationReceiver;
|
||||||
use ofborg::worker;
|
use ofborg::worker;
|
||||||
|
|
||||||
use std::env;
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
|
|
||||||
ofborg::setup_log();
|
ofborg::setup_log();
|
||||||
|
|
||||||
info!("Hello, world!");
|
let arg = env::args().nth(1).expect("usage: build-faker <config>");
|
||||||
|
let cfg = config::load(arg.as_ref());
|
||||||
|
|
||||||
let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap();
|
let conn = easylapin::from_config(&cfg.rabbitmq)?;
|
||||||
info!("Connected to rabbitmq");
|
let mut chan = task::block_on(conn.create_channel())?;
|
||||||
|
|
||||||
let mut channel = session.open_channel(1).unwrap();
|
|
||||||
|
|
||||||
let repo_msg = Repo {
|
let repo_msg = Repo {
|
||||||
clone_url: "https://github.com/nixos/ofborg.git".to_owned(),
|
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 {
|
for _i in 1..2 {
|
||||||
recv.tell(worker::publish_serde_action(
|
recv.tell(worker::publish_serde_action(
|
||||||
|
@ -57,8 +66,5 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.close(200, "Bye").unwrap();
|
Ok(())
|
||||||
info!("Closed the channel");
|
|
||||||
session.close(200, "Good Bye");
|
|
||||||
info!("Closed the session... EOF");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue