Skip to content

Commit

Permalink
fix: redis check improved
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-affinidi committed Dec 20, 2024
1 parent 2feaf9f commit 79536b5
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions affinidi-messaging-mediator/src/database/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,28 @@ async fn _check_server_version(database: &DatabaseHandler) -> Result<String, Med
})
.next();

let redis_version_req: VersionReq = match VersionReq::parse(REDIS_VERSION_REQ) {
Ok(result) => result,
Err(err) => {
error!("Couldn't process required Redis version. Reason: {}", err);
return Err(MediatorError::ConfigError(
"NA".into(),
format!("Couldn't process required Redis version. Reason: {}", err),
));
}
};

if let Some(version) = server_version {
let semver_version = Version::parse(&version).unwrap();
let redis_version_req: VersionReq = VersionReq::parse(REDIS_VERSION_REQ).unwrap();
let semver_version: Version = match Version::parse(&version) {
Ok(result) => result,
Err(err) => {
error!("Cannot parse Redis version ({}). Reason: {}", version, err);
return Err(MediatorError::DatabaseError(
"NA".into(),
format!("Cannot parse Redis version ({}). Reason: {}", version, err),
));
}
};
if redis_version_req.matches(&semver_version) {
info!("Redis version is compatible: {}", version);
Ok(version.to_owned())
Expand Down

0 comments on commit 79536b5

Please sign in to comment.