From 35ebe7ca86a809550bb274179814448bce2fd4ca Mon Sep 17 00:00:00 2001 From: Spencer Ferris <3319370+spencewenski@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:28:37 -0800 Subject: [PATCH] chore!: Rename/move the `health_check` mod to `health::check` (#578) --- .../src/{health_check => health/check}/example.rs | 2 +- .../src/{health_check => health/check}/mod.rs | 0 examples/app-builder/src/health/mod.rs | 1 + examples/app-builder/src/lib.rs | 2 +- examples/app-builder/src/main.rs | 2 +- examples/full/src/app.rs | 2 +- examples/full/src/health/example.rs | 2 +- src/api/core/health.rs | 2 +- src/api/http/health.rs | 2 +- src/app/context.rs | 4 ++-- src/app/mod.rs | 4 ++-- src/app/roadster_app.rs | 4 ++-- src/config/{health_check => health/check}/default.toml | 0 src/config/{health_check => health/check}/mod.rs | 3 ++- src/config/health/mod.rs | 1 + src/config/mod.rs | 7 ++++--- src/{health_check => health/check}/database.rs | 2 +- src/{health_check => health/check}/default.rs | 10 +++++----- src/{health_check => health/check}/email/mod.rs | 0 src/{health_check => health/check}/email/smtp.rs | 2 +- src/{health_check => health/check}/mod.rs | 3 ++- src/{health_check => health/check}/registry.rs | 6 +++--- src/{health_check => health/check}/sidekiq_enqueue.rs | 2 +- src/{health_check => health/check}/sidekiq_fetch.rs | 2 +- ...ck__default__tests__default_middleware@case_1.snap} | 2 +- ...ck__default__tests__default_middleware@case_2.snap} | 2 +- src/health/mod.rs | 1 + src/lib.rs | 2 +- src/lifecycle/mod.rs | 6 +++--- src/service/runner.rs | 4 ++-- 30 files changed, 44 insertions(+), 38 deletions(-) rename examples/app-builder/src/{health_check => health/check}/example.rs (90%) rename examples/app-builder/src/{health_check => health/check}/mod.rs (100%) create mode 100644 examples/app-builder/src/health/mod.rs rename src/config/{health_check => health/check}/default.toml (100%) rename src/config/{health_check => health/check}/mod.rs (98%) create mode 100644 src/config/health/mod.rs rename src/{health_check => health/check}/database.rs (95%) rename src/{health_check => health/check}/default.rs (89%) rename src/{health_check => health/check}/email/mod.rs (100%) rename src/{health_check => health/check}/email/smtp.rs (95%) rename src/{health_check => health/check}/mod.rs (99%) rename src/{health_check => health/check}/registry.rs (94%) rename src/{health_check => health/check}/sidekiq_enqueue.rs (95%) rename src/{health_check => health/check}/sidekiq_fetch.rs (96%) rename src/{health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_1.snap => health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_1.snap} (50%) rename src/{health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_2.snap => health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_2.snap} (74%) create mode 100644 src/health/mod.rs diff --git a/examples/app-builder/src/health_check/example.rs b/examples/app-builder/src/health/check/example.rs similarity index 90% rename from examples/app-builder/src/health_check/example.rs rename to examples/app-builder/src/health/check/example.rs index 56a615a3..d8fab95a 100644 --- a/examples/app-builder/src/health_check/example.rs +++ b/examples/app-builder/src/health/check/example.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use roadster::error::RoadsterResult; -use roadster::health_check::{CheckResponse, HealthCheck, Status}; +use roadster::health::check::{CheckResponse, HealthCheck, Status}; use std::time::Duration; pub struct ExampleHealthCheck { diff --git a/examples/app-builder/src/health_check/mod.rs b/examples/app-builder/src/health/check/mod.rs similarity index 100% rename from examples/app-builder/src/health_check/mod.rs rename to examples/app-builder/src/health/check/mod.rs diff --git a/examples/app-builder/src/health/mod.rs b/examples/app-builder/src/health/mod.rs new file mode 100644 index 00000000..3e8ff0fc --- /dev/null +++ b/examples/app-builder/src/health/mod.rs @@ -0,0 +1 @@ +pub mod check; diff --git a/examples/app-builder/src/lib.rs b/examples/app-builder/src/lib.rs index 70f2e86a..f6feffe7 100644 --- a/examples/app-builder/src/lib.rs +++ b/examples/app-builder/src/lib.rs @@ -6,7 +6,7 @@ pub mod api; pub mod app_state; #[cfg(feature = "cli")] pub mod cli; -pub mod health_check; +pub mod health; pub mod lifecycle; #[cfg(feature = "db-sql")] pub mod model; diff --git a/examples/app-builder/src/main.rs b/examples/app-builder/src/main.rs index be28028b..c2cb964f 100644 --- a/examples/app-builder/src/main.rs +++ b/examples/app-builder/src/main.rs @@ -1,6 +1,6 @@ use app_builder::api::http; use app_builder::app_state::AppState; -use app_builder::health_check::example::ExampleHealthCheck; +use app_builder::health::check::example::ExampleHealthCheck; use app_builder::lifecycle::example::ExampleLifecycleHandler; use app_builder::worker::example::ExampleWorker; use app_builder::App; diff --git a/examples/full/src/app.rs b/examples/full/src/app.rs index f14c484f..7b715104 100644 --- a/examples/full/src/app.rs +++ b/examples/full/src/app.rs @@ -14,7 +14,7 @@ use roadster::app::metadata::AppMetadata; use roadster::app::App as RoadsterApp; use roadster::config::AppConfig; use roadster::error::RoadsterResult; -use roadster::health_check::registry::HealthCheckRegistry; +use roadster::health::check::registry::HealthCheckRegistry; use roadster::service::function::service::FunctionService; #[cfg(feature = "grpc")] use roadster::service::grpc::service::GrpcService; diff --git a/examples/full/src/health/example.rs b/examples/full/src/health/example.rs index 97942ea1..c33ec95d 100644 --- a/examples/full/src/health/example.rs +++ b/examples/full/src/health/example.rs @@ -1,7 +1,7 @@ use crate::app_state::{AppState, AppStateWeak}; use async_trait::async_trait; use roadster::error::RoadsterResult; -use roadster::health_check::{CheckResponse, ErrorData, HealthCheck, Status}; +use roadster::health::check::{CheckResponse, ErrorData, HealthCheck, Status}; use std::time::Duration; use tracing::error; diff --git a/src/api/core/health.rs b/src/api/core/health.rs index bf743fd1..ec98c5ad 100644 --- a/src/api/core/health.rs +++ b/src/api/core/health.rs @@ -1,6 +1,6 @@ use crate::app::context::AppContext; use crate::error::RoadsterResult; -use crate::health_check::{CheckResponse, ErrorData, HealthCheck, Status}; +use crate::health::check::{CheckResponse, ErrorData, HealthCheck, Status}; #[cfg(feature = "open-api")] use aide::OperationIo; #[cfg(any(feature = "sidekiq", feature = "email-smtp"))] diff --git a/src/api/http/health.rs b/src/api/http/health.rs index f638d5e7..9ba75958 100644 --- a/src/api/http/health.rs +++ b/src/api/http/health.rs @@ -3,7 +3,7 @@ use crate::api::http::build_path; use crate::app::context::AppContext; use crate::error::RoadsterResult; #[cfg(feature = "open-api")] -use crate::health_check::{CheckResponse, ErrorData, Status}; +use crate::health::check::{CheckResponse, ErrorData, Status}; #[cfg(feature = "open-api")] use aide::axum::routing::get_with; #[cfg(feature = "open-api")] diff --git a/src/app/context.rs b/src/app/context.rs index b509d6e9..89571314 100644 --- a/src/app/context.rs +++ b/src/app/context.rs @@ -2,8 +2,8 @@ use crate::app::metadata::AppMetadata; use crate::app::App; use crate::config::AppConfig; use crate::error::RoadsterResult; -use crate::health_check::registry::HealthCheckRegistry; -use crate::health_check::HealthCheck; +use crate::health::check::registry::HealthCheckRegistry; +use crate::health::check::HealthCheck; use anyhow::anyhow; use axum_core::extract::FromRef; #[cfg(feature = "db-sql")] diff --git a/src/app/mod.rs b/src/app/mod.rs index 28b45540..015cb314 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -33,7 +33,7 @@ use crate::app::metadata::AppMetadata; use crate::config::environment::Environment; use crate::config::{AppConfig, AppConfigOptions}; use crate::error::RoadsterResult; -use crate::health_check::registry::HealthCheckRegistry; +use crate::health::check::registry::HealthCheckRegistry; use crate::lifecycle::registry::LifecycleHandlerRegistry; use crate::service::registry::ServiceRegistry; use crate::tracing::init_tracing; @@ -517,7 +517,7 @@ where Ok(()) } - /// Provide the [crate::health_check::HealthCheck]s to use throughout the app. + /// Provide the [crate::health::check::HealthCheck]s to use throughout the app. async fn health_checks( &self, _registry: &mut HealthCheckRegistry, diff --git a/src/app/roadster_app.rs b/src/app/roadster_app.rs index 1195d572..799d612d 100644 --- a/src/app/roadster_app.rs +++ b/src/app/roadster_app.rs @@ -6,8 +6,8 @@ use crate::app::metadata::AppMetadata; use crate::app::App; use crate::config::AppConfig; use crate::error::RoadsterResult; -use crate::health_check::registry::HealthCheckRegistry; -use crate::health_check::HealthCheck; +use crate::health::check::registry::HealthCheckRegistry; +use crate::health::check::HealthCheck; use crate::lifecycle::registry::LifecycleHandlerRegistry; use crate::lifecycle::AppLifecycleHandler; use crate::service::registry::ServiceRegistry; diff --git a/src/config/health_check/default.toml b/src/config/health/check/default.toml similarity index 100% rename from src/config/health_check/default.toml rename to src/config/health/check/default.toml diff --git a/src/config/health_check/mod.rs b/src/config/health/check/mod.rs similarity index 98% rename from src/config/health_check/mod.rs rename to src/config/health/check/mod.rs index fe6bf609..49463750 100644 --- a/src/config/health_check/mod.rs +++ b/src/config/health/check/mod.rs @@ -127,7 +127,8 @@ pub struct MaxDuration { #[cfg(test)] mod tests { - use super::*; + use crate::app::context::AppContext; + use crate::config::health::check::CommonConfig; use crate::config::AppConfig; use rstest::rstest; diff --git a/src/config/health/mod.rs b/src/config/health/mod.rs new file mode 100644 index 00000000..3e8ff0fc --- /dev/null +++ b/src/config/health/mod.rs @@ -0,0 +1 @@ +pub mod check; diff --git a/src/config/mod.rs b/src/config/mod.rs index 8dad2766..93dc5204 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -4,7 +4,6 @@ use crate::config::database::Database; #[cfg(feature = "email")] use crate::config::email::Email; use crate::config::environment::{Environment, ENVIRONMENT_ENV_VAR_NAME}; -use crate::config::health_check::HealthCheck; use crate::config::lifecycle::LifecycleHandler; use crate::config::service::Service; use crate::config::tracing::Tracing; @@ -15,6 +14,8 @@ use cfg_if::cfg_if; use config::builder::DefaultState; use config::{Case, Config, ConfigBuilder, FileFormat}; use dotenvy::dotenv; +use health::check; +use health::check::HealthCheck; use serde_derive::{Deserialize, Serialize}; use serde_json::Value; use std::collections::BTreeMap; @@ -30,7 +31,7 @@ pub mod database; #[cfg(feature = "email")] pub mod email; pub mod environment; -pub mod health_check; +pub mod health; pub mod lifecycle; pub mod service; pub mod tracing; @@ -268,7 +269,7 @@ impl AppConfig { let config = config.add_source(lifecycle::default_config()); - let config = config.add_source(health_check::default_config()); + let config = config.add_source(check::default_config()); #[cfg(feature = "email-sendgrid")] let config = { diff --git a/src/health_check/database.rs b/src/health/check/database.rs similarity index 95% rename from src/health_check/database.rs rename to src/health/check/database.rs index d9634cf9..63a14f21 100644 --- a/src/health_check/database.rs +++ b/src/health/check/database.rs @@ -1,7 +1,7 @@ use crate::api::core::health::db_health; use crate::app::context::{AppContext, AppContextWeak}; use crate::error::RoadsterResult; -use crate::health_check::{missing_context_response, CheckResponse, HealthCheck}; +use crate::health::check::{missing_context_response, CheckResponse, HealthCheck}; use async_trait::async_trait; use tracing::instrument; diff --git a/src/health_check/default.rs b/src/health/check/default.rs similarity index 89% rename from src/health_check/default.rs rename to src/health/check/default.rs index c104b926..d36147aa 100644 --- a/src/health_check/default.rs +++ b/src/health/check/default.rs @@ -1,13 +1,13 @@ use crate::app::context::AppContext; #[cfg(feature = "db-sql")] -use crate::health_check::database::DatabaseHealthCheck; +use crate::health::check::database::DatabaseHealthCheck; #[cfg(feature = "email-smtp")] -use crate::health_check::email::smtp::SmtpHealthCheck; +use crate::health::check::email::smtp::SmtpHealthCheck; #[cfg(feature = "sidekiq")] -use crate::health_check::sidekiq_enqueue::SidekiqEnqueueHealthCheck; +use crate::health::check::sidekiq_enqueue::SidekiqEnqueueHealthCheck; #[cfg(feature = "sidekiq")] -use crate::health_check::sidekiq_fetch::SidekiqFetchHealthCheck; -use crate::health_check::HealthCheck; +use crate::health::check::sidekiq_fetch::SidekiqFetchHealthCheck; +use crate::health::check::HealthCheck; use std::collections::BTreeMap; use std::sync::Arc; diff --git a/src/health_check/email/mod.rs b/src/health/check/email/mod.rs similarity index 100% rename from src/health_check/email/mod.rs rename to src/health/check/email/mod.rs diff --git a/src/health_check/email/smtp.rs b/src/health/check/email/smtp.rs similarity index 95% rename from src/health_check/email/smtp.rs rename to src/health/check/email/smtp.rs index b5561143..3c4523ff 100644 --- a/src/health_check/email/smtp.rs +++ b/src/health/check/email/smtp.rs @@ -1,7 +1,7 @@ use crate::api::core::health::smtp_health; use crate::app::context::{AppContext, AppContextWeak}; use crate::error::RoadsterResult; -use crate::health_check::{missing_context_response, CheckResponse, HealthCheck}; +use crate::health::check::{missing_context_response, CheckResponse, HealthCheck}; use async_trait::async_trait; use tracing::instrument; diff --git a/src/health_check/mod.rs b/src/health/check/mod.rs similarity index 99% rename from src/health_check/mod.rs rename to src/health/check/mod.rs index dce0f5d3..93c3bfec 100644 --- a/src/health_check/mod.rs +++ b/src/health/check/mod.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + #[cfg(feature = "db-sql")] pub mod database; pub mod default; @@ -16,7 +18,6 @@ use schemars::JsonSchema; use serde_derive::{Deserialize, Serialize}; use serde_json::Value; use serde_with::{serde_as, skip_serializing_none}; -use std::time::Duration; use tracing::error; use typed_builder::TypedBuilder; diff --git a/src/health_check/registry.rs b/src/health/check/registry.rs similarity index 94% rename from src/health_check/registry.rs rename to src/health/check/registry.rs index e5fad317..4d0386e7 100644 --- a/src/health_check/registry.rs +++ b/src/health/check/registry.rs @@ -1,7 +1,7 @@ use crate::app::context::AppContext; use crate::error::RoadsterResult; -use crate::health_check::default::default_health_checks; -use crate::health_check::HealthCheck; +use crate::health::check::default::default_health_checks; +use crate::health::check::HealthCheck; use anyhow::anyhow; use std::collections::BTreeMap; use std::sync::Arc; @@ -60,7 +60,7 @@ impl HealthCheckRegistry { mod tests { use super::*; use crate::config::AppConfig; - use crate::health_check::MockHealthCheck; + use crate::health::check::MockHealthCheck; use rstest::rstest; #[rstest] diff --git a/src/health_check/sidekiq_enqueue.rs b/src/health/check/sidekiq_enqueue.rs similarity index 95% rename from src/health_check/sidekiq_enqueue.rs rename to src/health/check/sidekiq_enqueue.rs index ddc21454..1166efcd 100644 --- a/src/health_check/sidekiq_enqueue.rs +++ b/src/health/check/sidekiq_enqueue.rs @@ -1,7 +1,7 @@ use crate::api::core::health::redis_health; use crate::app::context::{AppContext, AppContextWeak}; use crate::error::RoadsterResult; -use crate::health_check::{missing_context_response, CheckResponse, HealthCheck}; +use crate::health::check::{missing_context_response, CheckResponse, HealthCheck}; use async_trait::async_trait; use tracing::instrument; diff --git a/src/health_check/sidekiq_fetch.rs b/src/health/check/sidekiq_fetch.rs similarity index 96% rename from src/health_check/sidekiq_fetch.rs rename to src/health/check/sidekiq_fetch.rs index 732f6730..b88def1b 100644 --- a/src/health_check/sidekiq_fetch.rs +++ b/src/health/check/sidekiq_fetch.rs @@ -1,7 +1,7 @@ use crate::api::core::health::redis_health; use crate::app::context::{AppContext, AppContextWeak}; use crate::error::RoadsterResult; -use crate::health_check::{missing_context_response, CheckResponse, HealthCheck}; +use crate::health::check::{missing_context_response, CheckResponse, HealthCheck}; use anyhow::anyhow; use async_trait::async_trait; use tracing::instrument; diff --git a/src/health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_1.snap b/src/health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_1.snap similarity index 50% rename from src/health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_1.snap rename to src/health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_1.snap index c3b7bad8..e7167d6f 100644 --- a/src/health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_1.snap +++ b/src/health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_1.snap @@ -1,5 +1,5 @@ --- -source: src/health_check/default.rs +source: src/health/check/default.rs expression: health_checks --- [] diff --git a/src/health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_2.snap b/src/health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_2.snap similarity index 74% rename from src/health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_2.snap rename to src/health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_2.snap index 3b0252f1..6ca4a1fa 100644 --- a/src/health_check/snapshots/roadster__health_check__default__tests__default_middleware@case_2.snap +++ b/src/health/check/snapshots/roadster__health__check__default__tests__default_middleware@case_2.snap @@ -1,5 +1,5 @@ --- -source: src/health_check/default.rs +source: src/health/check/default.rs expression: health_checks --- [ diff --git a/src/health/mod.rs b/src/health/mod.rs new file mode 100644 index 00000000..3e8ff0fc --- /dev/null +++ b/src/health/mod.rs @@ -0,0 +1 @@ +pub mod check; diff --git a/src/lib.rs b/src/lib.rs index 3ef2fb13..33faee82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ pub mod api; pub mod app; pub mod config; pub mod error; -pub mod health_check; +pub mod health; pub mod lifecycle; pub mod middleware; #[cfg(feature = "db-sql")] diff --git a/src/lifecycle/mod.rs b/src/lifecycle/mod.rs index 432921c9..09106ad4 100644 --- a/src/lifecycle/mod.rs +++ b/src/lifecycle/mod.rs @@ -16,12 +16,12 @@ use axum_core::extract::FromRef; /// 2. Initialize tracing to enable logs/traces /// 3. Build the [`crate::app::context::AppContext`] and the [`crate::app::App`]'s custom state /// 4. Run the roadster/app CLI command, if one was specified when the app was started -/// 5. Register [`AppLifecycleHandler`]s, [`crate::health_check::HealthCheck`]s, and +/// 5. Register [`AppLifecycleHandler`]s, [`crate::health::check::HealthCheck`]s, and /// [`crate::service::AppService`]s /// 6. Run the app's registered [`AppLifecycleHandler::before_service_cli`] hooks. /// 7. Run any CLI commands that are implemented by [`crate::service::AppService::handle_cli`] /// 8. Run the app's registered [`AppLifecycleHandler::before_health_checks`] hooks. -/// 9. Run the registered [`crate::health_check::HealthCheck`]s +/// 9. Run the registered [`crate::health::check::HealthCheck`]s /// 10. Run the app's registered [`AppLifecycleHandler::before_services`] hooks. /// 11. Run the registered [`crate::service::AppService`]s /// 12. Wait for a shutdown signal, e.g., `Ctrl+c` or a custom signal from @@ -67,7 +67,7 @@ where Ok(()) } - /// This method is run right before the app's [`crate::health_check::HealthCheck`]s during + /// This method is run right before the app's [`crate::health::check::HealthCheck`]s during /// app startup. async fn before_health_checks(&self, _state: &S) -> RoadsterResult<()> { Ok(()) diff --git a/src/service/runner.rs b/src/service/runner.rs index d7e2b85d..e2abe2bf 100644 --- a/src/service/runner.rs +++ b/src/service/runner.rs @@ -4,8 +4,8 @@ use crate::api::core::health::health_check_with_checks; use crate::app::context::AppContext; use crate::app::App; use crate::error::RoadsterResult; -use crate::health_check::HealthCheck; -use crate::health_check::Status; +use crate::health::check::HealthCheck; +use crate::health::check::Status; use crate::service::registry::ServiceRegistry; use anyhow::anyhow; use axum_core::extract::FromRef;