alt/services/worker
toki 132e92eb68 feat(api, worker): Hello 요청에 context cancellation 처리 및 테스트 보강
- API 서비스 workerclient Hello 함수에 context.Err() 선행 검증 추가
- Hello 요청을 goroutine으로 비동기 처리하고 select로 ctx.Done() 감지
- 이미 초과된 deadline인 경우 즉시 에러 반환
- worker 서비스 config에서 strconv import를 config.go로 이동
- worker socket session handler 및 registerHandlers 테스트 추가
- parser_map 테스트 파일 신규 추가
2026-05-30 19:37:26 +09:00
..
cmd refactor: update API socket handlers and contract parsers 2026-05-30 19:14:07 +09:00
internal feat(api, worker): Hello 요청에 context cancellation 처리 및 테스트 보강 2026-05-30 19:37:26 +09:00
testdata/providers/kis feat: Korea daily data foundation task and documentation updates 2026-05-29 19:28:03 +09:00
go.mod feat(api, worker): Hello 요청에 context cancellation 처리 및 테스트 보강 2026-05-30 19:37:26 +09:00
go.sum feat(api, worker): Hello 요청에 context cancellation 처리 및 테스트 보강 2026-05-30 19:37:26 +09:00
README.md feat: Korea daily data foundation task and documentation updates 2026-05-29 19:28:03 +09:00
sqlc.yaml feat: worker persistence layer and socket session updates 2026-05-28 19:05:10 +09:00
tools.go feat: worker persistence layer and socket session updates 2026-05-28 19:05:10 +09:00

ALT Worker Service

The Worker service handles background tasks, such as market data imports, data normalization, and backtest execution.

Market Data Provider Boundary

ALT starts with KIS/Korea daily bars as the first provider and venue validation path, but the worker boundary should keep the canonical model equity venue-agnostic. KRX-specific or KIS-specific fields belong in provider adapters, venue metadata, raw payload storage, or explicit extension metadata instead of becoming required core columns.

Crypto is out of scope for the current stock-oriented market model. If a later crypto data domain is added, it may reuse generic import-run, provider mapping, raw-payload, and OHLCV pipeline concepts, but pair/funding/24-7 market semantics should not be forced into the equity model.

Provider Reference and Mock Fixtures

KIS adapter mapping should start from the locally cached official sample repository, not from a required Postman export. The cache path is documented in the private rules because it is local machine state, not an ALT source dependency.

  • Store mock-provider request/response fixtures under services/worker/testdata/providers/kis/.
  • Remove app keys, tokens, account numbers, personal identifiers, and live secret references before committing any fixture.
  • Prefer JSON for initial adapter mapping because it is readable, diffable, and close to the KIS REST payload shape.
  • Consider SQLite only after the fixture corpus is large enough to need indexed lookup or query-based comparison.

Provider credentials are not required for mock tests. When live KIS smoke tests are added later, credentials should be supplied at runtime through 1Password CLI or a later secret-provider implementation. Do not use checked-in .env files for provider secrets.

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 via ALT_REDIS_KEY_PREFIX (defaults to alt). 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