HealthCheck

Derive Macro HealthCheck 

Source
#[derive(HealthCheck)]
{
    // Attributes available to this derive:
    #[health]
}
Expand description

Derive macro for automatic HealthCheck implementation

Generates the HealthCheck trait implementation by collecting all fields that implement the Dependency trait.

§Example

use allframe_macros::HealthCheck;
use allframe_core::health::{Dependency, DependencyStatus};

struct RedisDependency { /* ... */ }
impl Dependency for RedisDependency { /* ... */ }

struct DatabaseDependency { /* ... */ }
impl Dependency for DatabaseDependency { /* ... */ }

#[derive(HealthCheck)]
struct AppHealth {
    #[health(timeout = "5s", critical = true)]
    redis: RedisDependency,

    #[health(timeout = "10s", critical = false)]
    database: DatabaseDependency,

    #[health(skip)]
    config: Config, // Not a dependency
}

// Auto-generates:
// impl HealthCheck for AppHealth { ... }

§Attributes

  • #[health(skip)] - Skip this field from health checks
  • #[health(critical = true)] - Mark dependency as critical (default: true)
  • #[health(timeout = "5s")] - Set check timeout (default: 5s)