Skip to content

Commit

Permalink
chore!: Rename/move the health_check mod to health::check (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencewenski authored Jan 20, 2025
1 parent f7dd989 commit 35ebe7c
Show file tree
Hide file tree
Showing 30 changed files with 44 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions examples/app-builder/src/health/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod check;
2 changes: 1 addition & 1 deletion examples/app-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/app-builder/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/full/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/full/src/health/example.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/api/core/health.rs
Original file line number Diff line number Diff line change
@@ -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"))]
Expand Down
2 changes: 1 addition & 1 deletion src/api/http/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
4 changes: 2 additions & 2 deletions src/app/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
4 changes: 2 additions & 2 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/app/roadster_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/config/health/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod check;
7 changes: 4 additions & 3 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
10 changes: 5 additions & 5 deletions src/health_check/default.rs → src/health/check/default.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/health_check/mod.rs → src/health/check/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::time::Duration;

#[cfg(feature = "db-sql")]
pub mod database;
pub mod default;
Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/health_check/registry.rs → src/health/check/registry.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/health_check/default.rs
source: src/health/check/default.rs
expression: health_checks
---
[]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/health_check/default.rs
source: src/health/check/default.rs
expression: health_checks
---
[
Expand Down
1 change: 1 addition & 0 deletions src/health/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod check;
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
6 changes: 3 additions & 3 deletions src/lifecycle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(())
Expand Down
4 changes: 2 additions & 2 deletions src/service/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 35ebe7c

Please sign in to comment.