feat: finish gerrit-event-streamer

Drop the logging, use a proper routing key, add error reporting for
error cases.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
raito 2024-12-15 22:10:40 +01:00
parent 3af7e6976b
commit 69f6ae8cc2

View file

@ -51,17 +51,18 @@ async fn main() -> Result<(), Box<dyn Error>> {
)
.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<dyn Error>> {
}
}
}
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...");
}
}
}