ebea70573b
- Repository structure for all services, infra, lakehouse, dashboards - K8s manifests targeting stonks-oracle namespace with GHCR images - Ingress via Traefik with ca-issuer TLS for internal services - ConfigMap wired to existing cluster services (pg, redis, minio, ollama) - GitHub Actions workflow for lint, test, multi-service container builds - Dockerfile with build-arg CMD per service - Makefile for local build/push/deploy - Steering rules for TDD workflow, K8s conventions, project context - Agent hooks for lint-on-save, test-on-save, k8s-validate, phase-commit - Ruff linter config, all lint issues fixed - 14 passing tests for schemas, config, redis keys - PostgreSQL migrations, Trino catalogs, Superset config, MinIO lifecycle
57 lines
1.2 KiB
Python
57 lines
1.2 KiB
Python
"""Redis key conventions and queue abstractions."""
|
|
|
|
# --- Key prefixes ---
|
|
PREFIX = "stonks"
|
|
|
|
# Distributed locks
|
|
LOCK_PREFIX = f"{PREFIX}:lock"
|
|
|
|
# Rate limit counters
|
|
RATE_LIMIT_PREFIX = f"{PREFIX}:ratelimit"
|
|
|
|
# Job queues
|
|
QUEUE_PREFIX = f"{PREFIX}:queue"
|
|
|
|
# Dedupe markers
|
|
DEDUPE_PREFIX = f"{PREFIX}:dedupe"
|
|
|
|
# Cache
|
|
CACHE_PREFIX = f"{PREFIX}:cache"
|
|
|
|
# Retry backoff state
|
|
RETRY_PREFIX = f"{PREFIX}:retry"
|
|
|
|
|
|
def lock_key(resource: str) -> str:
|
|
return f"{LOCK_PREFIX}:{resource}"
|
|
|
|
|
|
def rate_limit_key(source: str, window: str) -> str:
|
|
return f"{RATE_LIMIT_PREFIX}:{source}:{window}"
|
|
|
|
|
|
def queue_key(queue_name: str) -> str:
|
|
return f"{QUEUE_PREFIX}:{queue_name}"
|
|
|
|
|
|
def dedupe_key(content_hash: str) -> str:
|
|
return f"{DEDUPE_PREFIX}:{content_hash}"
|
|
|
|
|
|
def cache_key(namespace: str, key: str) -> str:
|
|
return f"{CACHE_PREFIX}:{namespace}:{key}"
|
|
|
|
|
|
def retry_key(job_id: str) -> str:
|
|
return f"{RETRY_PREFIX}:{job_id}"
|
|
|
|
|
|
# --- Queue names ---
|
|
QUEUE_INGESTION = "ingestion"
|
|
QUEUE_PARSING = "parsing"
|
|
QUEUE_EXTRACTION = "extraction"
|
|
QUEUE_AGGREGATION = "aggregation"
|
|
QUEUE_RECOMMENDATION = "recommendation"
|
|
QUEUE_LAKE_PUBLISH = "lake_publish"
|
|
QUEUE_TRADE = "trade"
|