ForcePilot/backend/package/yuxi/external_systems/integrations/slack/constants.py

39 lines
1.2 KiB
Python
Raw Normal View History

"""Slack Web API 常量定义。
集中管理 Slack Web API 的基础 URL通用请求头退避参数与常用方法名
版本升级或参数调整时仅需修改本文件
"""
from __future__ import annotations
from typing import Any
BASE_URL = "https://slack.com/api"
# Slack 通用请求头(除 Authorization 外,由 executor 注入)
# 写操作必须显式设置 Content-Type: application/json
_SLACK_HEADERS: dict[str, str] = {
"Accept": "application/json",
}
# 运行时工具执行的 429/5xx 退避:通过 retry_policy 配置
# executor 基于 tenacity 重试retry_status_codes 非空时按配置重试
_RUNTIME_RETRY_POLICY: dict[str, Any] = {
"max_attempts": 3,
"retry_delay": 1.0,
"retry_backoff": 2.0,
"retry_status_codes": [429, 502, 503, 504],
"retry_on_timeout": True,
"retry_on_connection_error": True,
}
# discover/preview/create 阶段 429 退避参数
_RETRY_MAX_ATTEMPTS = 5
_RETRY_BASE_DELAY = 1.0
# cursor 分页单页条数Slack 推荐值,过小会导致分页次数过多触发限流)
PAGE_SIZE = 200
# conversations.list 默认 types 参数(覆盖公开/私有频道、IM、MPIM
CONVERSATION_TYPES = "public_channel,private_channel,mpim,im"