-
Notifications
You must be signed in to change notification settings - Fork 3
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
7276502
commit 8714799
Showing
8 changed files
with
136 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod liveness; | ||
pub mod readiness; |
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,46 @@ | ||
use agent_shared::config::config; | ||
use agent_shared::config::EventStoreType; | ||
use agent_store::postgres::check_connection; | ||
use axum::http::StatusCode; | ||
use axum::response::IntoResponse; | ||
|
||
#[axum_macros::debug_handler] | ||
pub async fn readyz_handler() -> impl IntoResponse { | ||
// check database connection | ||
// check message queue connection | ||
|
||
let event_store_type = config().event_store.type_.clone(); | ||
|
||
// write code: if config is postgres, then call the postgres check_connection function | ||
let status_code = match event_store_type { | ||
EventStoreType::InMemory => { | ||
println!("Checking Postgres connection ..."); | ||
|
||
// check_connection().await; | ||
|
||
if check_connection().await { | ||
StatusCode::OK | ||
} else { | ||
StatusCode::SERVICE_UNAVAILABLE | ||
} | ||
// StatusCode::OK | ||
|
||
// if postgres::check_connection().await { | ||
// return axum::http::StatusCode::OK; | ||
// } else { | ||
// return axum::http::StatusCode::SERVICE_UNAVAILABLE; | ||
// } | ||
// if let Err(e) = postgres::check_connection().await { | ||
// return axum::http::StatusCode::SERVICE_UNAVAILABLE; | ||
// } | ||
} | ||
EventStoreType::Postgres => { | ||
// do nothing | ||
StatusCode::OK | ||
} | ||
}; | ||
|
||
// Response::new("foobar".into()) | ||
|
||
status_code | ||
} |
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 |
---|---|---|
|
@@ -21,3 +21,4 @@ sqlx = { version = "0.7", features = [ | |
"json", | ||
] } | ||
tokio.workspace = true | ||
tracing.workspace = true |
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