Skip to content

Commit 5a8e55c

Browse files
author
Devdutt Shenoi
committed
refactor: simplifications
1 parent 4cdd9bd commit 5a8e55c

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/handlers/http/modal/ingest_server.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ use crate::{handlers::http::base_path, option::CONFIG};
4545
use actix_web::web;
4646
use actix_web::web::resource;
4747
use actix_web::Scope;
48-
use anyhow::anyhow;
4948
use async_trait::async_trait;
5049
use base64::Engine;
5150
use bytes::Bytes;
@@ -292,9 +291,7 @@ pub async fn set_ingestor_metadata() -> anyhow::Result<()> {
292291
let path = ingestor_metadata_path(None);
293292

294293
// we are considering that we can always get from object store
295-
if storage_ingestor_metadata.is_some() {
296-
let mut store_data = storage_ingestor_metadata.unwrap();
297-
294+
if let Some(mut store_data) = storage_ingestor_metadata {
298295
if store_data.domain_name != INGESTOR_META.domain_name {
299296
store_data
300297
.domain_name
@@ -304,10 +301,7 @@ pub async fn set_ingestor_metadata() -> anyhow::Result<()> {
304301
let resource = Bytes::from(serde_json::to_vec(&store_data)?);
305302

306303
// if pushing to object store fails propagate the error
307-
return store
308-
.put_object(&path, resource)
309-
.await
310-
.map_err(|err| anyhow!(err));
304+
store.put_object(&path, resource).await?;
311305
}
312306
} else {
313307
let resource = Bytes::from(serde_json::to_vec(&resource)?);
@@ -324,18 +318,19 @@ async fn check_querier_state() -> anyhow::Result<Option<Bytes>, ObjectStorageErr
324318
// how do we check for querier state?
325319
// based on the work flow of the system, the querier will always need to start first
326320
// i.e the querier will create the `.parseable.json` file
321+
let parseable_json = CONFIG
322+
.storage()
323+
.get_object_store()
324+
.get_object(&parseable_json_path())
325+
.await
326+
.map_err(|_| {
327+
ObjectStorageError::Custom(
328+
"Query Server has not been started yet. Please start the querier server first."
329+
.to_string(),
330+
)
331+
})?;
327332

328-
let store = CONFIG.storage().get_object_store();
329-
let path = parseable_json_path();
330-
331-
let parseable_json = store.get_object(&path).await;
332-
match parseable_json {
333-
Ok(_) => Ok(Some(parseable_json.unwrap())),
334-
Err(_) => Err(ObjectStorageError::Custom(
335-
"Query Server has not been started yet. Please start the querier server first."
336-
.to_string(),
337-
)),
338-
}
333+
Ok(Some(parseable_json))
339334
}
340335

341336
async fn validate_credentials() -> anyhow::Result<()> {

0 commit comments

Comments
 (0)