Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds additional request logging #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
REDIS_URL=redis://localhost
REDIS_URL=redis://localhost
# REDIS_HOST=localhost
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these meant to be included in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup just example vars

# REDIS_PORT=6379
# REDIS_USERNAME=default
# REDIS_USE_TLS=true
# REDIS_PASSWORD=
18 changes: 11 additions & 7 deletions src/routes/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,17 @@ async fn get_request(
.await
.map_err(handle_redis_error)?;

serde_json::from_slice(&value.unwrap())
.map_or(Err(StatusCode::INTERNAL_SERVER_ERROR), |value| {
serde_json::from_slice(&value.unwrap()).map_or(
Err(StatusCode::INTERNAL_SERVER_ERROR),
|value| {
tracing::info!(
"{}",
format!("Successfully retrieved /request: {request_id}")
);

Ok(Json(value))
})
},
)
}

async fn insert_request(
Expand Down Expand Up @@ -107,10 +114,7 @@ async fn insert_request(
.await
.map_err(handle_redis_error)?;

tracing::info!(
"{}",
format!("Successfully processed /request: {request_id}")
);
tracing::info!("{}", format!("Successfully stored /request: {request_id}"));

Ok(Json(CustomResponse { request_id }))
}
6 changes: 6 additions & 0 deletions src/routes/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ async fn get_response(
return serde_json::from_slice(&value).map_or(
Err(StatusCode::INTERNAL_SERVER_ERROR),
|value| {
tracing::info!(
"{}",
format!("Successfully retrieved /response: {request_id}")
);
Ok(Json(Response {
response: value,
status: RequestStatus::Completed,
Expand Down Expand Up @@ -118,5 +122,7 @@ async fn insert_response(
.await
.map_err(handle_redis_error)?;

tracing::info!("{}", format!("Successfully stored /response: {request_id}"));

Ok(StatusCode::CREATED)
}