落地海运协同群:测服靠会话存档听群话,报价单能带上协同字段。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -44,7 +44,12 @@ STREAM_WAKE = "stream:wake"
|
||||
IDEMPOTENCY = "idem"
|
||||
RATE_LIMIT = "ratelimit"
|
||||
TOKEN_WECOM = "token:wecom"
|
||||
TOKEN_WSHOTO = "token:wshoto"
|
||||
TOKEN_COPY_TICKET = "token:copy_ticket"
|
||||
TOKEN_JSAPI = "token:jsapi"
|
||||
# 微盛查询游标(本前缀下的 last_seq,不是现网官方 SDK 消费游标)
|
||||
WSHOTO_LAST_SEQ = "wshoto:last_seq"
|
||||
WSHOTO_ROOMS = "wshoto:rooms"
|
||||
WSHOTO_ROOM_TICKET = "wshoto:room_ticket"
|
||||
# Worker 出完报价文件后写给 HTTP:短协调,不当六态
|
||||
QUOTE_FILE_READY = "quote_file_ready"
|
||||
|
||||
@@ -11,7 +11,7 @@ import logging
|
||||
from typing import Optional
|
||||
|
||||
from agent.redis_coord.client import RedisClient
|
||||
from agent.redis_coord.keys import TOKEN_WECOM
|
||||
from agent.redis_coord.keys import TOKEN_WECOM, TOKEN_WSHOTO
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -40,3 +40,25 @@ def set_wecom_token(
|
||||
key = client.key(TOKEN_WECOM, agent_id)
|
||||
client.raw.set(key, token, ex=ttl_seconds)
|
||||
logger.info("企微 token 已缓存 agent_id=%s ttl=%s", agent_id, ttl_seconds)
|
||||
|
||||
|
||||
def get_wshoto_token(client: RedisClient, *, app_id: str) -> Optional[str]:
|
||||
"""读取微盛 access_token 缓存;未命中返回 None。不把 token 当业务真相。"""
|
||||
key = client.key(TOKEN_WSHOTO, app_id or "default")
|
||||
val = client.raw.get(key)
|
||||
if val is None:
|
||||
return None
|
||||
return val if isinstance(val, str) else val.decode("utf-8")
|
||||
|
||||
|
||||
def set_wshoto_token(
|
||||
client: RedisClient,
|
||||
*,
|
||||
app_id: str,
|
||||
token: str,
|
||||
ttl_seconds: int = 7000,
|
||||
) -> None:
|
||||
"""写入微盛 token;TTL 略短于接口 expires_in,避免用过期票去拉群。"""
|
||||
key = client.key(TOKEN_WSHOTO, app_id or "default")
|
||||
client.raw.set(key, token, ex=max(60, int(ttl_seconds)))
|
||||
logger.info("微盛 token 已缓存 ttl=%s", ttl_seconds)
|
||||
|
||||
Reference in New Issue
Block a user