```
feat(feishu): 添加飞书入站事件inbox和混合数据库协调功能 - 实现飞书入站事件持久化inbox机制,支持状态管理、租约锁定和重试退避 - 添加混合数据库基线协调工具,确保平台PostgreSQL结构安全对齐 - 增加运行组件心跳检测和readiness就绪检查机制 - 实现app_ticket事件的安全轮换和验证处理 - 添加生产环境运行编排和fail-closed安全机制 - 支持webhook快速确认和长连接独立进程处理 - 完善个人数据擦除时的待处理事件清理功能 ```
This commit is contained in:
23
app/modules/feishu/services/context.py
Normal file
23
app/modules/feishu/services/context.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from collections.abc import Iterator
|
||||
from contextlib import contextmanager
|
||||
from contextvars import ContextVar
|
||||
|
||||
_CURRENT_INBOUND_EVENT_KEY: ContextVar[str | None] = ContextVar(
|
||||
"current_feishu_inbound_event_key",
|
||||
default=None,
|
||||
)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def bind_inbound_event(event_key: str) -> Iterator[None]:
|
||||
"""Expose the current inbox key to privacy-cleanup hooks."""
|
||||
|
||||
token = _CURRENT_INBOUND_EVENT_KEY.set(event_key)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
_CURRENT_INBOUND_EVENT_KEY.reset(token)
|
||||
|
||||
|
||||
def current_inbound_event_key() -> str | None:
|
||||
return _CURRENT_INBOUND_EVENT_KEY.get()
|
||||
Reference in New Issue
Block a user