Skip to main content

Crate hyperi_rustlib

Crate hyperi_rustlib 

Source
Expand description

§hyperi-rustlib

Shared utility library for HyperI Rust applications.

Provides configuration management, structured logging, Prometheus metrics, and environment detection - matching the functionality of hyperi-pylib (Python) and hyperi-golib (Go).

§Quick Start

use hyperi_rustlib::{env, config, logger, metrics};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Detect runtime environment
    let environment = env::Environment::detect();
    println!("Running in: {:?}", environment);

    // Initialise logger (respects LOG_LEVEL env var)
    logger::setup_default()?;

    // Load configuration with 7-layer cascade
    config::setup(config::ConfigOptions {
        env_prefix: "MYAPP".into(),
        ..Default::default()
    })?;

    // Access config
    let cfg = config::get();
    let db_host = cfg.get_string("database.host").unwrap_or_default();

    // Create metrics
    let metrics_mgr = metrics::MetricsManager::new("myapp");
    let _counter = metrics_mgr.counter("requests_total", "Total requests processed");

    tracing::info!(db_host = %db_host, "Application started");
    Ok(())
}

See [docs/CORE-PILLARS.md] for the auto-wiring architecture.

Re-exports§

pub use env::Environment;
pub use kafka_config::DfeSource;
pub use kafka_config::KafkaConfigError;
pub use kafka_config::KafkaConfigResult;
pub use kafka_config::ServiceRole;
pub use kafka_config::TOPIC_SUFFIX_LAND;
pub use kafka_config::TOPIC_SUFFIX_LOAD;
pub use kafka_config::config_from_file;
pub use kafka_config::config_from_properties_str;
pub use sensitive::SensitiveString;
pub use runtime::RuntimePaths;
pub use health::HealthRegistry;
pub use health::HealthStatus;
pub use config::Config;
pub use config::ConfigError;
pub use config::ConfigOptions;
pub use config::flat_env::ApplyFlatEnv;
pub use config::flat_env::EnvVarDoc;
pub use config::flat_env::Normalize;
pub use logger::LogFormat;
pub use logger::LoggerError;
pub use logger::LoggerOptions;
pub use logger::SecurityEvent;
pub use logger::SecurityOutcome;
pub use logger::ThrottleConfig;
pub use metrics::DfeMetrics;
pub use metrics::MetricsConfig;
pub use metrics::MetricsError;
pub use metrics::MetricsManager;

Modules§

config
Configuration management with 8-layer cascade.
env
Runtime environment detection.
health
Unified health registry for service readiness and liveness.
kafka_config
Shared Kafka librdkafka configuration profiles, merge helper, and file loader.
logger
Structured logging with JSON output and sensitive data masking.
metrics
Metrics with Prometheus and/or OpenTelemetry backends.
runtime
Runtime path management.
sensitive
Sensitive string type for fields that must never be exposed.
shutdown
Unified graceful shutdown manager.

Constants§

VERSION
Library version

Functions§

init
Initialise all library components with default settings.