보유종목 1분마다 호출하는부분 수정
This commit is contained in:
@@ -9,6 +9,7 @@ Supported task types:
|
||||
- insert_trade_history : dict → TradeHistory INSERT
|
||||
- upsert_stock_analysis : dict → StockAnalysis single UPSERT
|
||||
- bulk_upsert_stock_analysis : list → StockAnalysis batch UPSERT
|
||||
- log_mcp_deny : dict → MCP 거부 이벤트 로그 (DB 저장 없이 로그만)
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
@@ -44,6 +45,15 @@ async def enqueue_bulk_upsert_analysis(rows: list[dict]) -> None:
|
||||
await db_task_queue.put({"type": "bulk_upsert_stock_analysis", "data": rows})
|
||||
|
||||
|
||||
async def enqueue_db_write(task: dict) -> None:
|
||||
"""범용 DB 쓰기 태스크를 큐에 등록.
|
||||
|
||||
task 는 반드시 'type' 키를 포함해야 하며, 워커가 지원하는 task type 중 하나여야 한다.
|
||||
예: {"type": "log_mcp_deny", "reason": "...", "trade_plan": {...}}
|
||||
"""
|
||||
await db_task_queue.put(task)
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# 워커 본체
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
@@ -89,6 +99,15 @@ async def db_writer_worker() -> None:
|
||||
"✅ [Worker] Bulk StockAnalysis upsert: %d rows", len(data)
|
||||
)
|
||||
|
||||
# ── 4. MCP 거부 이벤트 로그 ───────────────────────────────────
|
||||
elif task_type == "log_mcp_deny":
|
||||
# DB 저장 없이 로그만 기록 (필요 시 별도 테이블 확장 가능)
|
||||
logger.warning(
|
||||
"🛑 [Worker] MCP DENY logged: reason=%s, trade_plan=%s",
|
||||
task.get("reason", "unknown"),
|
||||
task.get("trade_plan"),
|
||||
)
|
||||
|
||||
else:
|
||||
logger.warning("⚠️ [Worker] Unknown task type: %s", task_type)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user