side project, trying to get unrust at rust (pun intended). basically a public stylua service for luau, web based, publicly accessible, with a studio plugin on top
since most plugins either compile rust --> wasm --> lua through wasynth and pack each plugin distribution with stylua (super slow), or they require an external/local web server making them super annoying to setup. if i just host one plugin-facing public api the whole community can use it, and bonus points i get to unrust
three crates:
crates/api- axum server, formats inline when theres capacity, otherwise queues the job and hands you a session idcrates/worker- drains the queue, visibility timeout + reaper so dead workers dont eat jobscrates/shared- types, redis store, config parsing
config is just stylua config as json. unknown keys get ignored, actually invalid values (like a garbage enum variant) get you a 400 instead of silently formatting with defaults
GET /healthPOST /v1/format-{ "code": "...", "config": { ... } }, 256kb max. formats inline when it can,202+ session id when it cantPOST /v1/sessions- same body, always queuesGET /v1/sessions/{id}- session statusGET /v1/sessions/{id}/result- formatted code,409if not ready yet,422if formatting failedDELETE /v1/sessions/{id}
needs redis, then:
REDIS_URL=redis://localhost:6379 cargo run -p api
REDIS_URL=redis://localhost:6379 cargo run -p worker
env vars, everything except REDIS_URL is optional:
PORT- api port, default 3000MAX_QUEUE- queue cap before the api starts returning 503, default 1000VISIBILITY_TIMEOUT_SECS- how long a worker can hold a job before the reaper requeues it, default 30POLL_INTERVAL_MS- worker poll rate, default 200FORMAT_TIMEOUT_SECS- per job format timeout, default 5REAP_INTERVAL_SECS- default 10
Dockerfile builds the api, Dockerfile.worker builds the worker