1
0
mirror of https://github.com/pcvolkmer/mv64e-kafka-to-rest-gateway synced 2025-09-13 17:22:52 +00:00

feat: do not commit records with invalid responses from DIP

This will retry HTTP requests on next start, e.g. if having wrong
DNPM_DIP_URI config.
This commit is contained in:
2025-08-28 13:17:27 +02:00
parent 4f2eb56b07
commit f933ae8886

View File

@@ -13,7 +13,7 @@ use std::error::Error;
use std::string::ToString;
use std::sync::LazyLock;
use std::time::Duration;
use tracing::{error, info};
use tracing::{error, info, warn};
mod cli;
mod http_client;
@@ -174,9 +174,13 @@ async fn main() -> Result<(), Box<dyn Error>> {
producer.send(response_record, Duration::from_secs(1)).await
};
consumer
.commit_message(&msg, CommitMode::Async)
.expect("Cound not commit message: {}");
if response.status_code == 200 || response.status_code == 201 || response.status_code == 400 || response.status_code == 422 {
consumer
.commit_message(&msg, CommitMode::Async)
.expect("Cound not commit message: {}");
} else {
warn!("Unexpected Status Code for Request '{}': HTTP {}", &request_id, response.status_code);
}
}
}
}