Qrush
A lightweight, production-ready job queue and task scheduler for Rust applications built on Actix Web and Redis. Qrush provides both integrated and separate process modes, making it suitable for everything from simple background tasks to large-scale distributed systems.
Features
- 🚀 Dual Deployment Modes: Integrated (single process) or separate worker process
- ⚡ High Performance: Built on Actix Web and Redis for maximum throughput
- 📅 Cron Scheduling: Full cron expression support for recurring tasks
- ⏱️ Delayed Jobs: Schedule jobs to run after a specified delay
- 📊 Built-in Metrics UI: Real-time dashboard for monitoring queues, jobs, and workers
- 🔒 Security: Optional Basic Auth for metrics endpoints
- 🎯 Type-Safe: Leverages Rust's type system for safe job handling
- 🔄 Graceful Shutdown: Clean worker shutdown with configurable grace periods
- 📈 Scalable: Support for multiple queues with different priorities and concurrency levels
Quick Start
Installation
Add to your Cargo.toml:
[]
= "0.6.0"
= { = "1", = ["rt-multi-thread", "macros"] }
= { = "1", = ["derive"] }
= "0.1"
= "1"
Basic Usage (Integrated Mode)
use Job;
use ;
use QueueConfig;
use register_job;
use async_trait;
use ;
use BoxFuture;
use Result;
async
Architecture
QRush supports two deployment modes:
Integrated Mode
Workers run in the same process as your application. Perfect for small to medium applications.
┌─────────────────────┐
│ Application │
│ (Single Process) │
│ │
│ • HTTP Server │
│ • Enqueue Jobs │
│ • Process Jobs │ ← Workers here
└─────────────────────┘
Separate Process Mode
Workers run in a dedicated process. Recommended for production environments.
┌─────────────────────┐ ┌─────────────────────┐
│ Web Server │ │ qrush-engine │
│ (cargo run) │ │ (separate process) │
│ │ │ │
│ • HTTP Server │ │ • Worker Pools │
│ • Enqueue Jobs ─────┼──Redis──┼─▶ Process Jobs │
│ • Serve Routes │ │ • Cron Scheduler │
└─────────────────────┘ └─────────────────────┘
Documentation
Integrated Mode
See Part 1: Integrated Mode below for complete setup instructions.
Separate Process Mode
See Part 2: Separate Process Mode below for production deployment.
API Reference
Core Traits
Job: Implement this trait for your job typesCronJob: Implement for recurring scheduled jobs
Core Functions
enqueue(job): Enqueue a job immediatelyenqueue_in(job, delay_secs): Enqueue a job with a delayregister_job(name, handler): Register a job handlerQueueConfig::initialize(redis_url, queues): Start worker pools
Engine Runtime
qrush::engine::run_engine(redis_url, queues, shutdown_grace_secs): Run worker processqrush::engine::parse_queues(spec): Parse queue specification string
Examples
Cron Jobs
use CronJob;
use CronScheduler;
// Register cron job
let job = EmailJob ;
register_cron_job.await?;
Multiple Queues
let queues = vec!;
Metrics UI
Access the built-in metrics dashboard at /qrush/metrics:
- Queue statistics and job counts
- Worker status and health
- Cron job management
- Job retry and deletion
- CSV export
Requirements
- Rust 1.89.0 or later
- Redis 6.0 or later
- Tokio runtime (multi-threaded)
Environment Variables
# Required
REDIS_URL=redis://127.0.0.1:6379
# Optional
QRUSH_BASIC_AUTH=admin:password # Basic auth for metrics
RUST_LOG=info,qrush=info # Logging level
Detailed Documentation
Integrated Mode (Detailed)
Use this mode when: You want a simple setup with workers running in the same process as your web server.
1. Add Dependencies
[]
= "0.6.0"
= "4"
= { = "1", = ["rt-multi-thread", "macros"] }
= { = "1", = ["derive"] }
= "0.1"
= "1"
= "0.3"
2. Define a Job
use Job;
use async_trait;
use ;
use BoxFuture;
use Result;
3. Initialize QRush
use ;
use register_job;
use ;
async
4. Enqueue Jobs
use ;
// Immediate
enqueue.await?;
// Delayed (300 seconds)
enqueue_in.await?;
Separate Process Mode (Detailed)
Use this mode when: You want production-ready separation with workers in a dedicated process.
1. Create Engine Binary
Create src/bin/qrush_engine.rs:
use ;
use set_redis_url;
use register_job;
use CronScheduler;
// Your job types
use NotifyUser;
async
2. Update Cargo.toml
[[]]
= "qrush_engine"
= "src/bin/qrush_engine.rs"
3. Web Server (No Workers)
In your web server main.rs, only register jobs for enqueueing:
use set_redis_url;
use register_job;
async
4. Run Both Processes
Terminal 1 - Web Server:
Terminal 2 - Worker Engine:
Cron Expressions
QRush uses 6-field cron expressions (seconds, minutes, hours, day, month, weekday):
"0 * * * * *"- Every minute"0 */5 * * * *"- Every 5 minutes"0 0 * * * *"- Every hour"0 0 0 * * *"- Daily at midnight"0 0 0 * * 1"- Every Monday at midnight"0 0 0 1 * *"- First day of month at midnight
Metrics Endpoints
GET /qrush/metrics- Dashboard overviewGET /qrush/metrics/queues/{queue}- Queue detailsGET /qrush/metrics/extras/cron- Cron job managementGET /qrush/metrics/extras/workers- Worker statusGET /qrush/metrics/health- Health checkPOST /qrush/metrics/jobs/action- Job actions (retry/delete)
Production Tips
- Use separate process mode for production
- Set
QRUSH_BASIC_AUTHto protect metrics endpoints - Configure appropriate queue concurrency based on your workload
- Monitor Redis memory usage
- Use graceful shutdown for zero-downtime deployments
- Scale workers horizontally by running multiple engine processes
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
- Documentation: docs.rs/qrush
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with ❤️ by Srotas Space