feat(feishu): 添加飞书入站事件inbox和混合数据库协调功能

- 实现飞书入站事件持久化inbox机制,支持状态管理、租约锁定和重试退避
- 添加混合数据库基线协调工具,确保平台PostgreSQL结构安全对齐
- 增加运行组件心跳检测和readiness就绪检查机制
- 实现app_ticket事件的安全轮换和验证处理
- 添加生产环境运行编排和fail-closed安全机制
- 支持webhook快速确认和长连接独立进程处理
- 完善个人数据擦除时的待处理事件清理功能
```
This commit is contained in:
2026-07-27 17:14:37 +08:00
parent d7db84571d
commit eb8267ed18
61 changed files with 8703 additions and 183 deletions

View File

@@ -1,5 +1,5 @@
from collections.abc import Callable
from datetime import date
from datetime import UTC, date, datetime
from socket import gethostname
from typing import Any
@@ -40,6 +40,7 @@ def create_scheduler(app: FastAPI | None = None) -> Any:
enqueue_attendance_summary_push,
enqueue_daily_brief_push,
enqueue_event_dispatch,
enqueue_feishu_inbound_cycle,
enqueue_legacy_project_sync,
enqueue_legacy_task_sync,
enqueue_lifecycle_report,
@@ -47,6 +48,7 @@ def create_scheduler(app: FastAPI | None = None) -> Any:
enqueue_project_weekly_push,
enqueue_risk_progress_push,
enqueue_subscription_cycle,
enqueue_worker_heartbeat,
enqueue_work_daily_push,
enqueue_work_weekly_push,
)
@@ -186,6 +188,10 @@ def create_scheduler(app: FastAPI | None = None) -> Any:
)
_set_state(app, "last_event_dispatch", dispatch)
def run_feishu_inbound_cycle() -> None:
dispatch = enqueue_feishu_inbound_cycle(actor=ActorValue.SCHEDULER)
_set_state(app, "last_feishu_inbound_cycle", dispatch)
def record_scheduler_heartbeat() -> None:
db = SessionLocal()
try:
@@ -202,6 +208,10 @@ def create_scheduler(app: FastAPI | None = None) -> Any:
dispatch = enqueue_subscription_cycle(actor=ActorValue.SCHEDULER)
_set_state(app, "last_subscription_cycle", dispatch)
def run_worker_heartbeat() -> None:
dispatch = enqueue_worker_heartbeat(actor=ActorValue.SCHEDULER)
_set_state(app, "last_worker_heartbeat", dispatch)
def run_personalization_retention_cleanup() -> None:
db = SessionLocal()
try:
@@ -285,6 +295,7 @@ def create_scheduler(app: FastAPI | None = None) -> Any:
trigger="cron",
minute=settings.event_dispatch_cron_minute,
id="event_dispatch",
next_run_time=datetime.now(UTC),
replace_existing=True,
)
if settings.market_analysis_enabled:
@@ -320,6 +331,23 @@ def create_scheduler(app: FastAPI | None = None) -> Any:
trigger="interval",
seconds=settings.heartbeat_interval_seconds,
id="scheduler_heartbeat",
next_run_time=datetime.now(UTC),
replace_existing=True,
)
if settings.task_queue_enabled:
scheduler.add_job(
run_worker_heartbeat,
trigger="interval",
seconds=settings.heartbeat_interval_seconds,
id="worker_heartbeat",
next_run_time=datetime.now(UTC),
replace_existing=True,
)
scheduler.add_job(
run_feishu_inbound_cycle,
trigger="interval",
minutes=1,
id="feishu_inbound_event_cycle",
replace_existing=True,
)
if settings.feishu_user_features_enabled: