
QRush Integration Guide (Actix Web)
This guide shows how to integrate QRush into an Actix Web application — exactly like your test app:
- Redis-backed queue
- Workers & delayed mover
- Jobs with
Jobtrait - Cron scheduling with
CronJobtrait - Metrics UI mounted at
/qrush/metrics - Optional Basic Auth for the metrics panel
- Seconds-based scheduling (
enqueue_in(job, delay_secs))
1) Add dependencies
# Cargo.toml
[]
= "4"
= "0.15"
= { = "1", = ["rt-multi-thread", "macros"] }
= { = "1", = ["derive"] }
= "1"
= "0.1"
# the queue
= "0.5.0"
2) Environment variables
# REQUIRED Redis connection
# OPTIONAL Basic Auth for metrics (username:password)
# Optional: server bind (used by your test app)
3) Define a job
Implement the Job trait for your payload. Keep name() and queue() consistent with registration.
// /test/src/jobs/notify_user.rs
use Job;
use async_trait;
use ;
4) QRush initializer (as in your test app)
This sets optional Basic Auth, registers jobs, initializes queues in a background task, then waits until ready.
// /test/src/qrushes/qrush_integration.rs
use web;
use Arc;
use ;
use ;
use register_job;
use CronScheduler;
use qrush_metrics_routes;
use crateNotifyUser;
use crateDailyReportJob;
static QRUSH_INTEGRATED_INIT: = const_new;
;
5) Define cron jobs (optional)
For recurring scheduled jobs, implement both Job and CronJob traits:
// /test/src/qrushes/crons/daily_report_job.rs
use async_trait;
use Job;
use CronJob;
use ;
6) Wire it into main.rs
- Initialize QRush (awaits until queues are ready).
- Mount metrics under
/qrush/metrics. - Seed a few jobs to verify the dashboard.
// /test/src/main.rs
use ;
use dotenv;
use env;
use crateQrushIntegration;
async
7) Enqueue from anywhere
use ;
let _ = enqueue.await;
let _ = enqueue_in.await; // in 300 seconds
8) Run
# Start Redis
# Run your service
Open:
- Dashboard:
http://localhost:8080/qrush/metrics - Per-queue:
http://localhost:8080/qrush/metrics/queues/default - Cron Jobs:
http://localhost:8080/qrush/metrics/extras/cron - Health:
http://localhost:8080/qrush/metrics/health
If you set QRUSH_BASIC_AUTH, include Basic auth in requests:
9) Endpoints (under /qrush/metrics)
GET /— queues overview (success / failed / retry / pending)GET /queues/{queue}— jobs in a queueGET /queues/{queue}/export— CSV exportGET /extras/delayed— delayed jobsGET /extras/dead— dead jobsGET /extras/scheduled— scheduled jobsGET /extras/cron— cron jobs managementGET /extras/workers— worker statusGET /extras/summary— metrics summary with chartsGET /health— health probePOST /jobs/action— job actions ({"action":"retry|delete|queue","job_id":"..."})POST /cron/action— cron actions ({"action":"toggle|delete|run_now","job_id":"..."})
10) CLI Usage (Optional)
Build the CLI tool for advanced management:
Basic Commands
# Start workers
# Check status
# View queue statistics
# List jobs
# Retry failed jobs
# Manage cron jobs
# Start web UI
Common Cron Expressions
"0 * * * * *"- Every minute"0 */5 * * * *"- Every 5 minutes"0 0 * * * *"- Every hour"0 0 0 * * *"- Daily at midnight"0 0 0 * * 1"- Every Monday"0 0 0 1 * *"- First day of month
Notes & tips
- Scheduling:
enqueue_in(job, delay_secs)uses seconds (integer), matching your test app. - QueueConfig: you used three queues (
default,critical,integrated) with different concurrency/priority; tune as needed. - CronJobs: implement both
JobandCronJobtraits, register withCronScheduler::register_cron_job()after queue initialization, supports standard cron expressions with 6-field format (sec min hour day month weekday). - Register jobs before init: ensure
register_job(name, handler)runs before workers start. - Templates: metrics UI uses Tera templates. If a Tera parse error occurs, restart the process (once_cell poison).
- Security: protect metrics with Basic Auth via
QRUSH_BASIC_AUTHor your own middleware.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with Actix Web - Fast, powerful web framework
- UI powered by TailwindCSS - Utility-first CSS framework
📞 Support
- 📖 How it works
- 📖 Support
- 📖 Documentation
- 💬 Discussions
- 🐛 Issues
- 📧 Email: sxmmaurya@gmail.com
Made with ❤️ by the rustacean360 (Snm Maurya)
Support
- Documentation: docs.rs/qrush
- Issues: GitHub Issues
- Discussions: GitHub Discussions