```
feat(feishu): 添加飞书入站事件inbox和混合数据库协调功能 - 实现飞书入站事件持久化inbox机制,支持状态管理、租约锁定和重试退避 - 添加混合数据库基线协调工具,确保平台PostgreSQL结构安全对齐 - 增加运行组件心跳检测和readiness就绪检查机制 - 实现app_ticket事件的安全轮换和验证处理 - 添加生产环境运行编排和fail-closed安全机制 - 支持webhook快速确认和长连接独立进程处理 - 完善个人数据擦除时的待处理事件清理功能 ```
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from app.tasks.app import celery_app
|
||||
from app.tasks import events as _events # noqa: F401
|
||||
from app.tasks import feishu as _feishu # noqa: F401
|
||||
from app.tasks import legacy as _legacy # noqa: F401
|
||||
from app.tasks import lifecycle as _lifecycle # noqa: F401
|
||||
from app.tasks import market as _market # noqa: F401
|
||||
from app.tasks import observability as _observability # noqa: F401
|
||||
from app.tasks import reports as _reports # noqa: F401
|
||||
from app.tasks import risk as _risk # noqa: F401
|
||||
from app.tasks import subscriptions as _subscriptions # noqa: F401
|
||||
|
||||
@@ -12,3 +12,6 @@ TASK_RUN_LIFECYCLE = "reports.run_lifecycle"
|
||||
TASK_RUN_MARKET_REPORT = "market.report.run"
|
||||
TASK_RUN_MARKET_CLOSE = TASK_RUN_MARKET_REPORT
|
||||
TASK_RUN_SUBSCRIPTION_CYCLE = "subscriptions.run_cycle"
|
||||
TASK_PROCESS_FEISHU_INBOUND = "feishu.process_inbound"
|
||||
TASK_PROCESS_DUE_FEISHU_INBOUND = "feishu.process_inbound_due"
|
||||
TASK_RECORD_WORKER_HEARTBEAT = "observability.record_worker_heartbeat"
|
||||
|
||||
29
app/tasks/feishu.py
Normal file
29
app/tasks/feishu.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Any
|
||||
|
||||
from app.application.feishu.inbound import (
|
||||
process_due_feishu_inbound_events,
|
||||
process_feishu_inbound_event,
|
||||
)
|
||||
from app.core.constants import ActorValue
|
||||
from app.modules.feishu.constants import FEISHU_INBOUND_BATCH_SIZE
|
||||
from app.tasks.app import celery_app
|
||||
from app.tasks.constants import (
|
||||
TASK_PROCESS_DUE_FEISHU_INBOUND,
|
||||
TASK_PROCESS_FEISHU_INBOUND,
|
||||
)
|
||||
|
||||
|
||||
@celery_app.task(name=TASK_PROCESS_FEISHU_INBOUND)
|
||||
def process_feishu_inbound_event_task(
|
||||
event_key: str,
|
||||
actor: str = ActorValue.WORKER,
|
||||
) -> dict[str, Any]:
|
||||
return process_feishu_inbound_event(event_key, actor=actor)
|
||||
|
||||
|
||||
@celery_app.task(name=TASK_PROCESS_DUE_FEISHU_INBOUND)
|
||||
def process_due_feishu_inbound_events_task(
|
||||
limit: int = FEISHU_INBOUND_BATCH_SIZE,
|
||||
actor: str = ActorValue.WORKER,
|
||||
) -> list[dict[str, Any]]:
|
||||
return process_due_feishu_inbound_events(limit=limit, actor=actor)
|
||||
25
app/tasks/observability.py
Normal file
25
app/tasks/observability.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from socket import gethostname
|
||||
|
||||
from app.core.constants import ActorValue
|
||||
from app.core.database import SessionLocal
|
||||
from app.modules.observability.constants import HeartbeatComponent
|
||||
from app.modules.observability.service import ObservabilityService
|
||||
from app.tasks.app import celery_app
|
||||
from app.tasks.constants import TASK_RECORD_WORKER_HEARTBEAT
|
||||
|
||||
|
||||
@celery_app.task(name=TASK_RECORD_WORKER_HEARTBEAT)
|
||||
def record_worker_heartbeat_task(
|
||||
actor: str = ActorValue.WORKER,
|
||||
) -> dict:
|
||||
"""Record liveness from the Celery process that actually executes the task."""
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
return ObservabilityService(db).record_heartbeat(
|
||||
component=HeartbeatComponent.WORKER,
|
||||
instance_id=gethostname(),
|
||||
actor=actor,
|
||||
)
|
||||
finally:
|
||||
db.close()
|
||||
Reference in New Issue
Block a user