Skip to content

Commit

Permalink
Respect assume_rw_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cceckman committed Mar 15, 2024
1 parent 87f5d9e commit 5c412ca
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,23 +443,32 @@ pub fn start_server(config: &Config, port: u16) -> Result<()> {
}
};

let cache_mode = runtime.block_on(async {
match raw_storage.check().await {
Ok(mode) => Ok(mode),
Err(err) => {
error!("storage check failed for: {err:?}");

notify_server_startup(
&notify,
ServerStartup::Err {
reason: err.to_string(),
},
)?;

Err(err)
let cache_mode = if let Some(rw_mode) = config.assume_rw_mode {
// We've been provided with a RW mode to assume this cache has.
// Use it.
Ok(rw_mode.into())
} else {
// Before starting to use this cache (raw_storage), we need to check whether it's ReadOnly or ReadWrite-
// or if it's altogether unreachable.
runtime.block_on(async {
match raw_storage.check().await {
Ok(mode) => Ok(mode),
Err(err) => {
error!("storage check failed for: {err:?}");

notify_server_startup(
&notify,
ServerStartup::Err {
reason: err.to_string(),
},
)?;

Err(err)
}
}
}
})?;
})
}?;

info!("server has setup with {cache_mode:?}");

let storage = match cache_mode {
Expand Down

0 comments on commit 5c412ca

Please sign in to comment.