
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 - 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
= "<latest>"
2) Environment variables
# REQUIRED Redis connection
# REQUIRED 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/jobs/qrush.rs
use web;
use Arc;
use Notify;
use ;
use register_job;
use crateNotifyUser;
use qrush_metrics_routes;
;
5) 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 crateQrushInitializer;
use ;
use crateNotifyUser;
async
async
6) Enqueue from anywhere
use ;
let _ = enqueue.await;
let _ = enqueue_in.await; // in 300 seconds
7) Run
# Start Redis
# Run your service
Open:
- Dashboard:
http://localhost:8080/qrush/metrics - Per-queue:
http://localhost:8080/qrush/metrics/queues/default - Health:
http://localhost:8080/qrush/metrics/health
If you set QRUSH_BASIC_AUTH, include Basic auth in requests:
8) 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/workers— worker statusGET /health— health probePOST /jobs/action— job actions ({"action":"retry|delete|queue","job_id":"..."})
Notes & tips
- Scheduling:
enqueue_in(job, delay_secs)uses seconds (integer), matching your test app. - QueueConfig: you used two queues (
default,critical) with different concurrency/priority; tune as needed. - 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)