Unify parsing workers, analytics API with PostgreSQL, map UI, and PI distribution into centers/ with Docker Compose. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
477 B
Python
21 lines
477 B
Python
import json
|
|
import os
|
|
|
|
import redis
|
|
|
|
REDIS_URL = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
|
JOB_QUEUE_KEY = "cp:jobs"
|
|
|
|
|
|
def get_redis() -> redis.Redis:
|
|
return redis.from_url(REDIS_URL, decode_responses=True)
|
|
|
|
|
|
def enqueue_job(job_id: int, source_type: str, source_config: dict) -> None:
|
|
payload = {
|
|
"job_id": job_id,
|
|
"source_type": source_type,
|
|
"source_config": source_config,
|
|
}
|
|
get_redis().rpush(JOB_QUEUE_KEY, json.dumps(payload))
|