forge-jobs-api
HTTP transport for forge-jobs — Axum routes over
the same handler bodies the in-process Tauri / desktop binding would
call. Lets ops poke a deployed queue without an in-process Rust
binding and gives sidecar tooling a stable JSON contract.
Install
[]
= "0.1"
= "0.1"
# For Postgres-backed deploys:
= { = "0.1", = ["postgres"] }
= { = "0.1", = ["postgres"] }
Use
The crate exposes:
forge_jobs_api::router()— AxumRouteryou mount under your service. Routes are versioned-flat (no/v1/prefix today; the internal API is still settling).forge_jobs_api::handlers::*— pure async functions over&Storage. Same bodies the Tauri plugin's IPC commands call, so the two transports can't drift apart. Test against an in-memory SQLite — no router or HTTP container needed.forge_jobs_api::dto::*— request/response shapes shared between HTTP and IPC consumers.forge_jobs_api::Error— handler error type. Implementsaxum::response::IntoResponseso each variant maps to a sensible HTTP status code (400 / 404 / 409 / 429 / 500).
⚠️ Security — the routes are unauthenticated
router() returns an Axum Router with no auth, no rate
limiting, no body-size limit, no CORS. Some routes mutate state
(POST /queue/:name/backoff). You MUST either:
- Bind to loopback (
127.0.0.1) so only same-host processes can hit it, or - Mount behind your own middleware that enforces auth before
the request reaches
router():use Router; let app: Router = new .nest .layer;
A future minor release will add an optional auth feature with a
pluggable token check; today, that's on you.
Wiring it up
use Arc;
use ;
use ;
use router;
async
jobs-server binary
The crate also ships a small reference binary:
# Default: SQLite via $JOBS_DATA_DIR / $JOBS_CONFIG_DIR env vars.
# Postgres:
Bind address and worker count are env-configured — see
src/bin/jobs-server.rs.
Routes
| Method | Path | Description |
|---|---|---|
GET |
/queue/overview |
All queues' status counts + live workers + retention settings |
POST |
/queue/:name/backoff |
Set per-queue exponential backoff curve |
GET |
/storage/info |
Backend identifier + boot-time facts |
GET |
/metrics |
Prometheus exposition (queue depth, latency percentiles) |
More routes land as the in-process IPC surface formalizes. The Tauri-plugin's commands and these handlers share the same DTOs, so divergence is structurally impossible.
Status
0.1 — tracks forge-jobs major version. The handler bodies are
stable; route shapes may evolve before 1.0 as we tighten the
externally-facing contract.
License
Dual-licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option. Contributions intentionally submitted for inclusion in this crate shall be dual-licensed as above, without any additional terms or conditions.