Skip to content

dally: rewrite the prototype as a job queue server, plus README and repo polish - #1

Open
platonv wants to merge 24 commits into
mainfrom
polish
Open

platonv wants to merge 24 commits into
mainfrom
polish

Conversation

@platonv

@platonv platonv commented Nov 22, 2026

Copy link
Copy Markdown
Owner

This lands the dally rewrite on main and polishes it for the repo's front page.

What's in it

The redesign branch (30 commits, unchanged). It replaces the delayed-queue-rs prototype with dally, a job queue server: a Cargo workspace (dally-core, dally-server, dally-client, dally-ui, dally) with PostgreSQL, SQLite and Redis backends behind one conformance suite, an HTTP API with long polling, push delivery, cron, API keys, metrics, OpenAPI, a web UI, a Dockerfile and CI. It was pushed on 2026-11-21 but never opened as a PR.

Polish on top (3 commits):

  • .env stays out of the repo: it's now in .gitignore, and .env.example documents the DALLY_* variables. The prototype's committed .env had no password in it (postgres://postgres@localhost/...), and the rewrite already deleted it. History is unchanged.
  • The README now has the background (crediting the alexn.org article the prototype was based on), a "How it works" section with a mermaid sequence diagram of schedule, lease and ack, a quickstart that builds from source because dally isn't on crates.io yet (cargo install dally would have failed), Postgres-in-Docker steps, Rust client and CLI examples, a status/roadmap section, and CI/license badges.
  • The author name now matches git and GitHub ("Vlad Platon" instead of "Platon Vlad") in LICENSE-MIT, Cargo.toml and docs/openapi.json, which the snapshot test keeps in sync.

Left for you to decide

  • Renaming the repo to dally. Cargo.toml and the client docs already point at github.com/platonv/dally, which doesn't exist until the repo is renamed. The README links use the current URL, and GitHub redirects them after a rename.
  • License. The rewrite is dual-licensed MIT OR Apache-2.0, the usual choice for Rust crates. I kept that instead of switching to MIT only.

Testing

CI on this PR runs fmt, clippy with -D warnings, the full test suite against Postgres 17 and Redis 8 service containers, and an MSRV check (1.94). I didn't change any Rust code; cargo fmt --check passes locally.

🤖 Generated with Claude Code

platonv and others added 24 commits November 19, 2026 16:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Replace the prototype with the design from docs/design.md: queues with
settings, messages with statuses and lease tokens, a Storage trait, the
Service that holds the rules, and a PostgreSQL backend using SKIP LOCKED
and LISTEN/NOTIFY. A conformance suite runs the same behaviour tests
against every backend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
dally-server serves the v1 API with axum, loads configuration from TOML
and DALLY_* variables, applies configured queues on startup and runs a
janitor that prunes finished messages. The dally binary wraps it with
logging and graceful shutdown on Ctrl-C and SIGTERM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
The minimum supported Rust version is 1.94, set by sqlx 0.9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
WAL mode with one writer connection and a small reader pool. Leasing
runs under BEGIN IMMEDIATE so concurrent pollers never share a message.
An exclusive lock file keeps a second server process away from the
database, and timestamps are integer milliseconds from the process
clock. SQLite becomes a default feature of the dally binary, so
'dally server' works with no configuration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Plain 'curl -d' sends form-urlencoded, which axum::Json rejects. Every
body in the API is JSON, so parse it regardless of the header. Also
bring over the SQLite docs page and fix a collapsible-if lint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Messages are hashes; each queue keeps sorted sets for delayed, ready,
running and finished messages plus one index per status. Every operation
that touches more than one key is a Lua script, timed by the Redis clock,
so it is atomic and several servers agree on what is due. Long polls are
woken through pub/sub. A prefix URL parameter namespaces the keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Queues with push settings get a delivery task that long-polls for as
many messages as it has free slots and POSTs each payload to the
endpoint, signed with HMAC-SHA256 when the queue has a secret. A 2xx
acks the message; anything else nacks it, honouring Retry-After on 429
and 503. A supervisor restarts tasks when push settings change and stops
them when a queue is paused.

Cron jobs are declared per queue in the config file. Every server runs
the ticker and schedules each occurrence with the idempotency key
cron:{name}:{time}, so several servers create one message without a
leader. After downtime only the latest missed occurrence is scheduled.

start_background_tasks lets embedders run the janitor, push dispatcher
and cron ticker next to their own axum app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Client covers the whole v1 API with typed results and errors that keep
the server's error code. Worker long-polls a queue and runs an async
handler per message with bounded concurrency: Ok acks, Err and panics
nack, undecodable payloads are nacked with the serde error, server
errors back off from 1 to 30 seconds, and run_until waits for running
jobs before returning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
dally queues, schedule, inspect, messages and dead talk to a running
server through dally-client. Output is aligned plain text by default and
JSON with --json; logs now go to stderr so JSON output stays parseable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
The wire types derive utoipa::ToSchema behind a new openapi feature, so
users of dally-core who do not generate a spec do not pull in utoipa.
Durations are described as humantime strings and ids as UUIDs.

Storage::oldest_due reports how long the oldest due message in each
queue has been waiting, for metrics. It defaults to None; Postgres and
SQLite implement it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Keys come from [auth] in the config, inline or from an environment
variable, with a client or admin role. Every /v1 request needs a valid
bearer key once any are configured; keys are compared in constant time
and never logged. Admin-only handlers take an Admin argument.

GET /metrics serves message counters, fed by a new Observer hook on
Service so push delivery and cron are counted too, HTTP request counts
and durations labelled by route template, and queue gauges read from
storage with a short cache. It can optionally require a key.

Server ties service, auth and metrics together and replaces the free
router and start_background_tasks functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Every handler carries a utoipa path annotation, and the spec is served at
GET /v1/openapi.json and committed as docs/openapi.json. One test fails
when the committed file is stale (regenerate with UPDATE_OPENAPI=1),
another requests every documented route to check the router serves it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
With the otel feature, the dally binary exports spans over OTLP/HTTP
when OTEL_EXPORTER_OTLP_ENDPOINT is set, and flushes them on shutdown.
Logging is now set up before the async runtime starts, because the OTLP
client is blocking.

docs/operations.md covers storage choice, API keys, health checks,
metrics with example alerts, tracing, logs and shutdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
dally-ui renders pages with askama and refreshes the queue table with
htmx, and every page and button also works without JavaScript. It builds
every page from the public HTTP API through dally-client and never
touches storage. Visitors log in with their own API key, kept in an
HttpOnly, SameSite=Strict cookie, so the UI can do exactly what that key
allows.

dally server --ui mounts it at /ui; dally ui serves it on its own for a
remote server. The ui feature of the binary (on by default) leaves it
out when disabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
Update the design doc's Storage trait, API table and CLI list, mention
dally-ui and regenerating the OpenAPI spec in CONTRIBUTING, note the one
metric Redis does not report, and let the Dockerfile limit compile jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FpQG759EykdkR9CG85GrV
The prototype committed a .env with a local DATABASE_URL. The rewrite
already deleted it; this keeps it out for good and documents the DALLY_*
variables used in development instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Credit the alexn.org article the project grew out of, explain how messages
are stored and leased with a sequence diagram, replace the cargo install
quickstart (dally is not on crates.io yet) with build-from-source and
Postgres-in-Docker steps, add Rust client and CLI examples, and state
plainly what is done and what is not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant