```
refactor(core,ai): 调整模块导入路径并移除废弃文件 - 修复 scheduler.py 中的导入路径错误,将 reports.service 改为 reports.services - 移除废弃的 app/core/background/task_queue.py 文件 - 移除废弃的 app/modules/ai_agent/adapters.py 文件 - 修复 ai_memory/service.py 中的导入路径错误,将 events.service 改为 events.services ```
This commit is contained in:
30
app/tasks/events.py
Normal file
30
app/tasks/events.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from socket import gethostname
|
||||
from typing import Any
|
||||
|
||||
from app.core.constants import ActorValue
|
||||
from app.core.database import SessionLocal
|
||||
from app.tasks.app import celery_app, settings
|
||||
|
||||
|
||||
@celery_app.task(name="events.dispatch_pending")
|
||||
def dispatch_pending_events(
|
||||
limit: int | None = None,
|
||||
actor: str = ActorValue.WORKER,
|
||||
) -> list[dict[str, Any]]:
|
||||
from app.modules.events.services import EventService
|
||||
from app.modules.observability.constants import HeartbeatComponent
|
||||
from app.modules.observability.service import ObservabilityService
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
ObservabilityService(db).record_heartbeat(
|
||||
component=HeartbeatComponent.WORKER,
|
||||
instance_id=gethostname(),
|
||||
actor=actor,
|
||||
)
|
||||
return EventService(db).dispatch_pending(
|
||||
limit=limit or settings.event_dispatch_batch_size,
|
||||
worker_id=f"{actor}:{gethostname()}",
|
||||
)
|
||||
finally:
|
||||
db.close()
|
||||
Reference in New Issue
Block a user