2 releases

0.1.1 Dec 30, 2025
0.1.0 Dec 26, 2025

#13 in #load-balancer

Apache-2.0

105KB
2K SLoC

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?;

armature-ferron

Ferron reverse proxy integration for the Armature framework.

Features

  • Reverse Proxy - Route requests to backends
  • Load Balancing - Distribute traffic
  • SSL Termination - Handle TLS at proxy
  • Health Checks - Monitor backend health

Installation

[dependencies]
armature-ferron = "0.1"

Quick Start

use armature_ferron::FerronProxy;

let proxy = FerronProxy::new()
    .backend("http://localhost:8001")
    .backend("http://localhost:8002")
    .health_check("/health")
    .build();

proxy.listen("0.0.0.0:80").await?;

License

MIT OR Apache-2.0

Dependencies

~20–38MB
~467K SLoC