From 69f6ae8cc2fc219d43e7c5a01c2c2e6777ce4f10 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sun, 15 Dec 2024 22:10:40 +0100 Subject: [PATCH] feat: finish gerrit-event-streamer Drop the logging, use a proper routing key, add error reporting for error cases. Signed-off-by: Raito Bezarius --- ofborg/src/bin/gerrit-event-streamer.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ofborg/src/bin/gerrit-event-streamer.rs b/ofborg/src/bin/gerrit-event-streamer.rs index d2166a7..4a0eb15 100644 --- a/ofborg/src/bin/gerrit-event-streamer.rs +++ b/ofborg/src/bin/gerrit-event-streamer.rs @@ -51,17 +51,18 @@ async fn main() -> Result<(), Box> { ) .await; - let routing_key = "abc"; + // TODO: add the specific instance name in multi-active contexts. + let routing_key = "gerrit.events"; let event_stream = gerrit_api.stream_events().await.unwrap(); pin_mut!(event_stream); + loop { let raw_evt = event_stream.next().await; tracing::debug!("{:?}", raw_evt); match raw_evt { Some(Ok(event)) => { - println!("{:#?}", event); let queue_message = prepare_queue_message(Some(exchange_name), Some(routing_key), &event); let props = BasicProperties::default() @@ -86,11 +87,11 @@ async fn main() -> Result<(), Box> { } } } - Some(Err(_err)) => { - // notify the event + Some(Err(err)) => { + tracing::error!("Failed to read a new Gerrit event: {}", err); } None => { - // notify the event + tracing::warn!("No event in the Gerrit stream, retrying..."); } } }