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:
parent
3af7e6976b
commit
69f6ae8cc2
|
@ -51,17 +51,18 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
)
|
)
|
||||||
.await;
|
.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();
|
let event_stream = gerrit_api.stream_events().await.unwrap();
|
||||||
pin_mut!(event_stream);
|
pin_mut!(event_stream);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let raw_evt = event_stream.next().await;
|
let raw_evt = event_stream.next().await;
|
||||||
tracing::debug!("{:?}", raw_evt);
|
tracing::debug!("{:?}", raw_evt);
|
||||||
|
|
||||||
match raw_evt {
|
match raw_evt {
|
||||||
Some(Ok(event)) => {
|
Some(Ok(event)) => {
|
||||||
println!("{:#?}", event);
|
|
||||||
let queue_message =
|
let queue_message =
|
||||||
prepare_queue_message(Some(exchange_name), Some(routing_key), &event);
|
prepare_queue_message(Some(exchange_name), Some(routing_key), &event);
|
||||||
let props = BasicProperties::default()
|
let props = BasicProperties::default()
|
||||||
|
@ -86,11 +87,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Err(_err)) => {
|
Some(Err(err)) => {
|
||||||
// notify the event
|
tracing::error!("Failed to read a new Gerrit event: {}", err);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// notify the event
|
tracing::warn!("No event in the Gerrit stream, retrying...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue