Expand description
Actix-web integration for asyncq — admin REST endpoints with Prometheus metrics.
§Setup
Mount the admin scope in your actix-web application:
use asyncq::{Queue, backends::InMemoryBackend};
use asyncq_actix::admin;
use actix_web::{web, App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let queue = Queue::new(InMemoryBackend::new());
HttpServer::new(move || {
App::new()
.service(web::scope("/admin").configure(admin(queue.clone())))
})
.bind("127.0.0.1:8080")?
.run()
.await
}For live Prometheus metrics, use admin_with_queues:
use asyncq_actix::admin_with_queues;
App::new()
.service(
web::scope("/admin")
.configure(admin_with_queues(queue, vec!["emails".into(), "payments".into()]))
);§Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /admin/queues/{name} | Stats for a queue |
| GET | /admin/queues/{name}/dlq | Dead-letter queue (paginated) |
| POST | /admin/queues/{name}/dlq/retry-all | Requeue all dead jobs |
| DELETE | /admin/queues/{name}/dlq/{id} | Retry one dead job by ID |
| GET | /admin/metrics | Prometheus text metrics |
Functions§
- admin
- Returns an actix-web configurator that mounts admin endpoints.
Apply to a scope:
web::scope("/admin").configure(admin(queue)). - admin_
with_ queues - Returns an actix-web configurator with live Prometheus metrics for the given queues.