bunqueue-client (Rust)
The official Rust client for bunqueue, the high performance job queue server.
Native TCP protocol (msgpack, length-prefixed frames), synchronous API, bounded threaded workers, rustls TLS with verified certificates.
Documentation · Protocol spec · Server · Changelog
The bunqueue server runs on Bun, distributed as a binary or a Docker image. This client lets any Rust service produce and consume jobs against it: one queue, any language.
Installation
Requires Rust 1.85+ (edition 2024). Dependencies: rmpv (msgpack values),
rustls (TLS), serde_json, thiserror.
Quick start
Start a server (bunx bunqueue start or the Docker image), then:
use ;
use ;
Defaults are localhost:6789, so constructors need no options on a local
setup.
Failure semantics
The processor returns Result<Value, ProcessError>:
use ProcessError;
// Normal failure: retried per the job's attempts/backoff settings
Err
// Terminal failure: no retries, straight to the dead letter queue
Err
Retries, backoff, priorities, delays, stall detection and the dead letter
queue all live in the server; the worker only pulls, heartbeats and
acknowledges. Automatic lock heartbeats renew active leases through an
independent connection, so jobs longer than the lock TTL survive; set
heartbeat_interval: None to disable them.
API surface
| Area | Capabilities |
|---|---|
| Produce | add, add_bulk (custom ids preserved), the complete wire job option set: priority, delay, attempts, backoff, jobId, deduplication, dependsOn, lifo, durable, ... |
| Query | jobs, states, results, progress, wait_for_job, counts, job logs, children values |
| Control | pause, resume, drain, clean, obliterate, promote, retry, change priority/delay, update data |
| DLQ | get, retry, purge |
| Schedulers | cron pattern or fixed interval, execution limit, get/list/remove |
| Admin | webhooks, rate limit with duration window and broker-side TTL, workers, stats, list queues, ping |
| Flows | FlowProducer: parent/child trees (add), chains (add_chain), best-effort rollback on failure |
| Worker | bounded thread pool, batch pulls capped by concurrency, ACK-gated completion, reconnect-safe registration |
Security
use ;
let queue = new;
Authentication uses server-side tokens (AUTH_TOKENS). TLS verifies
certificates by default via rustls with the system trust store or a custom
CA bundle. Auth tokens are redacted from ConnectionOptions debug output.
Telemetry
Opt-in, structured and payload-free: connections, commands, authentication, deadlines, reconnects, errors and worker retries.
use Arc;
use ;
let telemetry: TelemetryCallback = new;
let queue = new;
Callbacks run after the connection mutex is released, so they may safely call other SDK objects. A callback panic is isolated and never changes queue behavior. No token, payload or result ever reaches the callback.
Wire safety
Everything the protocol requires is enforced in the client: a recursive int64 guard (integers outside int32 travel as float64, exact up to 2^53), outgoing map/extension validation, ext-0 tolerance on responses, and a 64 MiB frame cap. Pass 64-bit identifiers such as snowflake IDs as strings to avoid precision loss.
Quality assurance
Every change runs the native suite (a real server spawned per run) and the cross-language conformance suite:
BUNQUEUE_SDK_SOAK_SECONDS=3600
&&
The native tests cover wire validation, frame limits, option mapping, error
shapes, telemetry, auth, timeout/reconnect, TLS verification, worker
registration, concurrency-safe batch pulls and flow rollback. Hardening adds
idempotent retry and single-lease contention races, generated MessagePack
payloads, malformed extension fuzzing, a 512-job spike and durable
SIGKILL/restart recovery. Integration tests require bun and openssl on
PATH.
License
MIT. See the LICENSE file. Documentation: bunqueue.dev/guide/sdks. Issues and feature requests: GitHub issues.