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::new()
.with_bind_address("127.0.0.1", 8080)
.with_database_url("postgresql://localhost/hammerwork");
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)
.with_allowed_origin("https://ops.example.com");
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::default()
.with_enabled(true)
.with_username("admin".to_string())
.with_password_hash("$2b$12$hash...".to_string())
.with_session_timeout(Duration::from_secs(8 * 60 * 60)) // 8 hours
.with_max_failed_attempts(5)
.with_lockout_duration(Duration::from_secs(15 * 60)); // 15 minutes
assert!(auth_config.enabled);
assert_eq!(auth_config.max_failed_attempts, 5);Structs§
- Auth
Config - Authentication configuration for the web dashboard.
- Dashboard
Config - Main configuration for the web dashboard.
- WebDashboard
- Main web dashboard server.
- WebSocket
Config - WebSocket configuration
Type Aliases§
- Result
- Result type alias for consistent error handling