-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
925ed2f
commit b9cee39
Showing
6 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use axum::{extract::State, Json}; | ||
|
||
use crate::{ | ||
error::ApiError, | ||
handlers::get_core_response, | ||
http::AppState, | ||
proto::{core_request, core_response, InstanceInfoRequest, InstanceInfoResponse}, | ||
}; | ||
|
||
#[instrument(level = "debug", skip(state))] | ||
pub async fn info( | ||
State(state): State<AppState>, | ||
Json(req): Json<InstanceInfoRequest>, | ||
) -> Result<Json<InstanceInfoResponse>, ApiError> { | ||
debug!("Retrieving info for polling request"); | ||
let rx = state | ||
.grpc_server | ||
.send(Some(core_request::Payload::InstanceInfo(req.clone())), None)?; | ||
let payload = get_core_response(rx).await?; | ||
|
||
if let core_response::Payload::InstanceInfo(response) = payload { | ||
info!("Retrieved info for polling request"); | ||
Ok(Json(response)) | ||
} else { | ||
error!("Received invalid gRPC response type: {payload:#?}"); | ||
Err(ApiError::InvalidResponseType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters