ADK-gateway/backend/app/constants.py
2026-08-05 16:33:27 +08:00

41 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Redis 键名与 TTL 常量、状态枚举。"""
from enum import Enum
class TaskStatus(str, Enum):
PENDING = "pending"
RUNNING = "running"
SUCCESS = "success"
FAILED = "failed"
class AgentStatus(str, Enum):
OFFLINE = "offline" # 离线:心跳失联(超时)
UNAVAILABLE = "unavailable" # 不可用:后台手动禁用(心跳不复活)
READY = "ready" # 就绪(注册后、空闲时),调度只分配此状态
PROCESSING = "processing" # 处理中(调度选中并下发后)
STOPPING = "stopping" # 正在停止(收到取消指令后)
# ---- 任务池键 ----
# 任务全量信息hash task:info:{request_id}
TASK_INFO_KEY = "task:info:{request_id}"
# 待调度任务集合
TASK_PENDING_SET = "task:pending"
# 执行中任务集合
TASK_RUNNING_SET = "task:running"
# ---- Agent 池键 ----
# Agent 全量信息hash agent:info:{agent_id}
AGENT_INFO_KEY = "agent:info:{agent_id}"
# 心跳时间戳 ZSetscore = 最后心跳时间
AGENT_HEARTBEAT_ZSET = "agent:heartbeat"
# 按能力标签索引 Agentset agent:tag:{tag}
AGENT_TAG_KEY = "agent:tag:{tag}"
# 全部在线 Agent 索引
AGENT_ALL_SET = "agent:all"
# ---- 分布式锁键 ----
LOCK_SCHEDULER = "lock:scheduler"
LOCK_HEARTBEAT = "lock:heartbeat"
LOCK_TIMEOUT = "lock:timeout"