Crate armature_ferron

Crate armature_ferron 

Source
Expand description

§Armature Ferron Integration

This crate provides integration between Armature web applications and the Ferron reverse proxy server.

§Features

  • Configuration Generation: Generate Ferron config files from Armature app metadata
  • Process Management: Start, stop, and reload Ferron instances
  • Health Checking: Monitor backend services and Ferron health
  • Service Discovery: Dynamic backend registration and discovery
  • Load Balancing: Configure load balancing strategies
  • TLS Management: Automatic certificate configuration

§Quick Start

use armature_ferron::{FerronConfig, Backend, ProxyRoute};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a Ferron configuration
    let config = FerronConfig::builder()
        .domain("api.example.com")
        .backend(Backend::new("http://localhost:3000"))
        .tls_auto(true)
        .build()?;

    // Generate the configuration file
    let kdl_config = config.to_kdl()?;
    println!("{}", kdl_config);

    Ok(())
}

§Load Balancing

use armature_ferron::{FerronConfig, Backend, LoadBalancer, LoadBalanceStrategy};

let config = FerronConfig::builder()
    .domain("api.example.com")
    .load_balancer(
        LoadBalancer::new()
            .strategy(LoadBalanceStrategy::RoundRobin)
            .backend(Backend::new("http://backend1:3000").weight(3))
            .backend(Backend::new("http://backend2:3000").weight(1))
            .health_check_interval(30)
    )
    .build()
    .unwrap();

§Service Discovery Integration

use armature_ferron::{FerronManager, ServiceRegistry};

// Create a service registry
let registry = ServiceRegistry::new();

// Register services dynamically
registry.register("api-service", "http://localhost:3000").await?;
registry.register("api-service", "http://localhost:3001").await?;

// Create manager with auto-discovery
let manager = FerronManager::builder()
    .config_path("/etc/ferron/ferron.conf")
    .service_registry(registry)
    .auto_reload(true)
    .build()?;

// Start Ferron with discovered backends
manager.start().await?;

Re-exports§

pub use config::Backend;
pub use config::FerronConfig;
pub use config::FerronConfigBuilder;
pub use config::LoadBalanceStrategy;
pub use config::LoadBalancer;
pub use config::Location;
pub use config::ProxyRoute;
pub use config::RateLimitConfig;
pub use config::TlsConfig;
pub use error::FerronError;
pub use error::Result;
pub use health::HealthCheck;
pub use health::HealthCheckConfig;
pub use health::HealthStatus;
pub use manager::FerronManager;
pub use process::FerronProcess;
pub use process::ProcessConfig;
pub use process::ProcessStatus;
pub use registry::ServiceInstance;
pub use registry::ServiceRegistry;

Modules§

config
Ferron configuration generation
error
Error types for Ferron integration
health
Health checking for backend services
manager
Ferron manager for integrated proxy management
prelude
Prelude module for convenient imports
process
Ferron process management
registry
Service registry for dynamic backend discovery