From adcff00463d4935ed0971e88f94d39cccf939b3a Mon Sep 17 00:00:00 2001 From: Simeon Romanov Date: Sun, 21 Jan 2024 08:32:45 +0300 Subject: [PATCH] postrebase fix + better logging --- backend/src/services/api.rs | 4 ++++ backend/src/services/auth.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/src/services/api.rs b/backend/src/services/api.rs index ebe7c5a8..d9a25b34 100644 --- a/backend/src/services/api.rs +++ b/backend/src/services/api.rs @@ -16,6 +16,7 @@ use super::prelude::*; ), security(("api_key" = [])) ))] +#[tracing::instrument(ret, skip(client), level = "info", fields(method = "GET"))] pub async fn get_disks_count(Extension(client): Extension) -> Json { tracing::info!("get /disks/count : {:?}", client); @@ -83,6 +84,7 @@ pub async fn get_disks_count(Extension(client): Extension) -> Jso ), security(("api_key" = [])) ))] +#[tracing::instrument(ret, skip(client), level = "info", fields(method = "GET"))] pub async fn get_nodes_count(Extension(client): Extension) -> Json { tracing::info!("get /nodes/count : {:?}", client); @@ -130,6 +132,7 @@ pub async fn get_nodes_count(Extension(client): Extension) -> Jso ), security(("api_key" = [])) ))] +#[tracing::instrument(ret, skip(client), level = "info", fields(method = "GET"))] pub async fn get_rps(Extension(client): Extension) -> Json { tracing::info!("get /nodes/rps : {:?}", client); @@ -168,6 +171,7 @@ pub async fn get_rps(Extension(client): Extension) -> Json { ), security(("api_key" = [])) ))] +#[tracing::instrument(ret, skip(client), level = "info", fields(method = "GET"))] pub async fn get_space(Extension(client): Extension) -> Json { tracing::info!("get /space : {:?}", client); let mut spaces: FuturesUnordered<_> = client diff --git a/backend/src/services/auth.rs b/backend/src/services/auth.rs index 0b01ecbb..d5d5822a 100644 --- a/backend/src/services/auth.rs +++ b/backend/src/services/auth.rs @@ -68,7 +68,7 @@ pub async fn login( Extension(request_timeout): Extension, Json(bob): Json, ) -> AxumResult { - let bob_client = BobClient::::try_new(bob.clone(), request_timeout) + let bob_client = BobClient::<_, HttpClient>::try_new(bob.clone(), request_timeout) .await .map_err(|err| { tracing::error!("{err:?}"); @@ -109,7 +109,13 @@ pub async fn login( tracing::error!("{err:?}"); StatusCode::UNAUTHORIZED })?; - auth.client_store.insert(*bob_client.id(), bob_client); + auth.client_store + .save(*bob_client.id(), bob_client) + .await + .map_err(|err| { + tracing::error!("{err:?}"); + StatusCode::INTERNAL_SERVER_ERROR + })?; } Ok(res)