diff --git a/ofborg/src/bin/gerrit-build-filter.rs b/ofborg/src/bin/gerrit-build-filter.rs new file mode 100644 index 0000000..f4d252c --- /dev/null +++ b/ofborg/src/bin/gerrit-build-filter.rs @@ -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> { + ofborg::setup_log(); + + let arg = env::args() + .nth(1) + .expect("usage: gerrit-events-filter "); + 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(()) +}