sync update from LAN repo (source master @ ca48c4ec)
This commit is contained in:
1 parent
8bc8b0e082
commit
ea9dcff9c0
873 files changed
+107866
-14011
No files matched your search
+28
-1
@@ -119,6 +119,7 @@ class RoundtableJobRepository:
|
||||
request_hash: str | None = None,
|
||||
active_dedupe_key: str | None = None,
|
||||
input_snapshot: dict[str, Any] | None = None,
|
||||
room_started_at: datetime | None = None,
|
||||
) -> RoundtableJobRow:
|
||||
now = datetime.now(UTC)
|
||||
return RoundtableJobRow(
|
||||
@@ -145,7 +146,7 @@ class RoundtableJobRepository:
|
||||
error=None,
|
||||
attempt=0,
|
||||
version=0,
|
||||
created_at=now,
|
||||
created_at=room_started_at or now,
|
||||
updated_at=now,
|
||||
)
|
||||
|
||||
@@ -204,6 +205,7 @@ class RoundtableJobRepository:
|
||||
request_id: str | None = None,
|
||||
request_hash: str | None = None,
|
||||
input_snapshot: dict[str, Any] | None = None,
|
||||
room_started_at: datetime | None = None,
|
||||
) -> tuple[dict[str, Any], bool]:
|
||||
"""原子地「创建活跃作业 → 冲突则幂等返回已有活跃作业」(Phase 3 唯一活跃键版)。
|
||||
|
||||
@@ -240,6 +242,7 @@ class RoundtableJobRepository:
|
||||
request_hash=request_hash,
|
||||
active_dedupe_key=dedupe_key,
|
||||
input_snapshot=input_snapshot,
|
||||
room_started_at=room_started_at,
|
||||
)
|
||||
|
||||
# 无 draft_id → 无法去重,直接创建(保持原有行为)。
|
||||
@@ -462,6 +465,30 @@ class RoundtableJobRepository:
|
||||
result = await session.execute(stmt)
|
||||
return [r[0] for r in result.all()]
|
||||
|
||||
async def request_cancel_expired_step2(
|
||||
self,
|
||||
*,
|
||||
created_before: datetime,
|
||||
non_occupying_phases: tuple[str, ...],
|
||||
) -> int:
|
||||
"""Cancel unfinished Step-2 jobs that exceeded the room hard lifetime."""
|
||||
async with self._sf() as session:
|
||||
result = await session.execute(
|
||||
update(RoundtableJobRow)
|
||||
.where(
|
||||
RoundtableJobRow.status.in_(list(CANCELLABLE_STATUSES)),
|
||||
RoundtableJobRow.created_at <= created_before,
|
||||
RoundtableJobRow.phase.not_in(list(non_occupying_phases)),
|
||||
)
|
||||
.values(
|
||||
status="cancel_requested",
|
||||
version=RoundtableJobRow.version + 1,
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
)
|
||||
await session.commit()
|
||||
return int(result.rowcount or 0)
|
||||
|
||||
async def list_cancel_reapable(self, *, now: datetime, limit: int = 20) -> list[str]:
|
||||
"""列出可以由 dispatcher 收口的取消请求。
|
||||
|
||||
|
||||
Reference in new issue
Block a user