# Workers

## Rust binaries

Background tasks: email, processing, sync, etc.

## Architecture

- Same standard as Backend
- Independent binaries
- Configuration via env vars

## Deploy

- Fly.io (separate process or machine)
- Dedicated Dockerfile per worker

## Health endpoint

If it exposes HTTP: GET /health with env!("CARGO_PKG_VERSION")

## Connection pool

Same rules as Backend (see apis.md):

- max_connections proportional to RAM
- idle_timeout ≤ 120s
- acquire_timeout ≤ 10s

## Timeouts (if it exposes HTTP)

- TimeoutLayer mandatory (30s)
- tcp_keepalive mandatory (60s)

## Graceful shutdown

Mandatory: handle SIGTERM to shut down cleanly.

- Loop workers: shutdown flag + drain
- HTTP workers: with_graceful_shutdown()
