feat: add a gerrit event streamer

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
raito 2024-10-30 00:32:19 +01:00
parent e365acc085
commit 928c60f6d5

View file

@ -0,0 +1,43 @@
/// This is a Gerrit event streamer into AMQP
/// It declares a `gerrit-events` exchange where events are published per topic (i.e. type).
/// The list of event type listened to is static.
use std::env;
use std::error::Error;
use async_std::task;
use tracing::info;
use ofborg::config;
use ofborg::easyamqp::{self, ChannelExt};
use ofborg::easylapin;
fn main() -> Result<(), Box<dyn Error>> {
ofborg::setup_log();
let arg = env::args()
.nth(1)
.expect("usage: gerrit-events-filter <config>");
let cfg = config::load(arg.as_ref());
let conn = easylapin::from_config(&cfg.rabbitmq)?;
let mut chan = task::block_on(conn.create_channel())?;
let exchange_name = "gerrit-events";
chan.declare_exchange(easyamqp::ExchangeConfig {
exchange: exchange_name.to_owned(),
exchange_type: easyamqp::ExchangeType::Topic,
passive: false,
durable: true,
auto_delete: false,
no_wait: false,
internal: false,
})?;
info!("Publishing events from Gerrit into {}", &exchange_name);
//task::block_on(handle);
drop(conn); // Close connection.
info!("Closed the session... EOF");
Ok(())
}