Crate hammerwork_web

Crate hammerwork_web 

Source
Expand description

§Hammerwork Web Dashboard

A web-based admin dashboard for monitoring and managing Hammerwork job queues.

This crate provides a comprehensive web interface for:

  • Real-time queue monitoring and statistics
  • Job management (retry, cancel, inspect)
  • Worker status and utilization
  • Dead job analysis and bulk operations
  • System health monitoring

§Usage

§As a Binary

# Install the web dashboard
cargo install hammerwork-web --features postgres

# Start the dashboard
hammerwork-web --database-url postgresql://localhost/hammerwork --bind 0.0.0.0:8080

§As a Library

§Basic Usage
use hammerwork_web::{WebDashboard, DashboardConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = DashboardConfig {
        bind_address: "127.0.0.1".to_string(),
        port: 8080,
        database_url: "postgresql://localhost/hammerwork".to_string(),
        ..Default::default()
    };

    let dashboard = WebDashboard::new(config).await?;
    dashboard.start().await?;

    Ok(())
}
§Builder Pattern Configuration
use hammerwork_web::DashboardConfig;
use std::time::Duration;

let config = DashboardConfig::new()
    .with_bind_address("0.0.0.0", 9090)
    .with_database_url("postgresql://localhost/hammerwork")
    .with_auth("admin", "bcrypt_hash_here")
    .with_cors(true);

assert_eq!(config.bind_addr(), "0.0.0.0:9090");
assert_eq!(config.database_url, "postgresql://localhost/hammerwork");
assert!(config.auth.enabled);
assert!(config.enable_cors);
§Configuration from File
use hammerwork_web::DashboardConfig;

// Load from TOML file
let config = DashboardConfig::from_file("dashboard.toml")?;

// Save configuration
config.save_to_file("dashboard.toml")?;
§Authentication Configuration
use hammerwork_web::AuthConfig;
use std::time::Duration;

let auth_config = AuthConfig {
    enabled: true,
    username: "admin".to_string(),
    password_hash: "$2b$12$hash...".to_string(),
    session_timeout: Duration::from_secs(8 * 60 * 60), // 8 hours
    max_failed_attempts: 5,
    lockout_duration: Duration::from_secs(15 * 60), // 15 minutes
};

assert!(auth_config.enabled);
assert_eq!(auth_config.max_failed_attempts, 5);

Re-exports§

pub use config::AuthConfig;
pub use config::DashboardConfig;
pub use server::WebDashboard;

Modules§

api
REST API endpoints for the Hammerwork web dashboard.
auth
Authentication middleware for the web dashboard.
config
Configuration for the Hammerwork web dashboard.
server
Web server implementation for the Hammerwork dashboard.
websocket
WebSocket implementation for real-time dashboard updates.

Type Aliases§

Result
Result type alias for consistent error handling