# ALT Worker Service The Worker service handles background tasks, such as market data imports, data normalization, and backtest execution. ## Redis Usage Guidelines ### Purpose Redis is used as a lightweight, high-performance messaging, coordination, and caching layer for background jobs. It is **not** a source of truth. All critical system states and historical datasets reside in PostgreSQL. ### Key Prefixing Standard To avoid key collisions and maintain organization, all keys created by the worker **must** use the designated helper package `internal/rediskeys` and strictly follow the format: ``` :worker:: ``` - ``: Configured via `ALT_REDIS_KEY_PREFIX` (defaults to `alt`). This segregates environments or local dev workspaces. - `worker`: Hardcoded namespace denoting worker-owned keys. - ``: Lowercase segment describing the domain or usage (e.g. `job`, `lock`, `cache`). - ``: Unique identifier for the specific object (e.g., job ID, lock name). Always utilize `rediskeys.WorkerKey(prefix, purpose, id)` instead of assembling key strings manually. ## Configuration Environment variables can be used to customize worker runtime: | Variable | Description | Default | |---|---|---| | `DATABASE_URL` | PostgreSQL connection string | `postgres://alt:alt@localhost:5432/alt?sslmode=disable` | | `REDIS_URL` | Redis connection string | `redis://localhost:6379/0` | | `ALT_REDIS_KEY_PREFIX` | Namespace prefix for Redis keys | `alt` | | `ALT_WORKER_QUEUE` | Target worker queue to consume from | `default` |