- Add worker storage layer with PostgreSQL/sqlc setup - Add migration files for worker backbone schema - Add job runner and built-in jobs implementation - Add Redis key definitions for worker state management - Archive socket-session-loop milestone (completed/renamed) - Update roadmap current.md and foundation-alignment phase - Add socket endpoint integration and runtime smoke tests - Add infra-check, worker-storage-check, worker-storage-gen CLI tools - Update API socket server and config - Add pubspec dependencies and client socket endpoint changes - Add config tests for API and worker services
1.5 KiB
1.5 KiB
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:
<prefix>:worker:<purpose>:<id>
<prefix>: Configured viaALT_REDIS_KEY_PREFIX(defaults toalt). This segregates environments or local dev workspaces.worker: Hardcoded namespace denoting worker-owned keys.<purpose>: Lowercase segment describing the domain or usage (e.g.job,lock,cache).<id>: 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 |