Hammerwork
A high-performance, database-driven job queue for Rust with comprehensive features for production workloads.
Features
- Multi-database support: PostgreSQL and MySQL backends
- Job prioritization: Five priority levels with weighted and strict scheduling algorithms
- Batch operations: High-performance bulk job enqueuing with optimized worker processing
- Cron scheduling: Full cron expression support with timezone awareness
- Rate limiting: Token bucket rate limiting with configurable burst limits
- Monitoring: Prometheus metrics and advanced alerting (enabled by default)
- Job timeouts: Per-job and worker-level timeout configuration
- Statistics: Comprehensive job statistics and dead job management
- Async/await: Built on Tokio for high concurrency
- Type-safe: Leverages Rust's type system for reliability
Installation
[]
# Default features include metrics and alerting
= { = "0.7", = ["postgres"] }
# or
= { = "0.7", = ["mysql"] }
# Minimal installation
= { = "0.7", = ["postgres"], = false }
Feature Flags: postgres, mysql, metrics (default), alerting (default)
Quick Start
See the Quick Start Guide for complete examples with PostgreSQL and MySQL.
Documentation
- Quick Start Guide - Get started with PostgreSQL and MySQL
- Job Types & Configuration - Job creation, priorities, timeouts, cron jobs
- Worker Configuration - Worker setup, rate limiting, statistics
- Cron Scheduling - Recurring jobs with timezone support
- Priority System - Five-level priority system with weighted scheduling
- Batch Operations - High-performance bulk job processing
- Database Migrations - Progressive schema updates and database setup
- Monitoring & Alerting - Prometheus metrics and notification systems
Basic Example
use ;
use json;
use Arc;
async
Database Setup
Using Migrations (Recommended)
Hammerwork provides a migration system for progressive schema updates:
# Build the migration tool
# Run migrations
# Check migration status
Application Usage
Once migrations are run, your application can use the queue directly:
// In your application - no setup needed, just use the queue
let pool = connect.await?;
let queue = new;
// Start enqueuing jobs immediately
let job = new;
queue.enqueue.await?;
Database Schema
Hammerwork uses optimized tables with comprehensive indexing:
hammerwork_jobs- Main job table with priorities, timeouts, cron scheduling, and result storagehammerwork_batches- Batch metadata and tracking (v0.7.0+)hammerwork_migrations- Migration tracking for schema evolution
The schema supports all features including job prioritization, timeouts, cron scheduling, batch processing, result storage, and comprehensive lifecycle tracking. See Database Migrations for details.
Development
Comprehensive testing with Docker containers:
# Start databases and run all tests
# Run specific database tests
See docs/integration-testing.md for complete development setup.
Examples
Working examples in examples/:
postgres_example.rs- PostgreSQL with timeouts and statisticsmysql_example.rs- MySQL with workers and prioritiescron_example.rs- Cron scheduling with timezonespriority_example.rs- Priority system demonstrationbatch_example.rs- Bulk job enqueuing and processingworker_batch_example.rs- Worker batch processing features
Contributing
- Fork the repository and create a feature branch
- Run tests:
make integration-all - Ensure code follows Rust standards (
cargo fmt,cargo clippy) - Submit a pull request with tests and documentation
License
This project is licensed under the MIT License - see the LICENSE-MIT file for details.