feat(core): reconcile durable workflow instances

This commit is contained in:
2026-07-30 03:09:58 +02:00
parent cf7afe9dda
commit e7c84e3227
3 changed files with 179 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
from __future__ import annotations
from collections.abc import Mapping
from datetime import datetime
from typing import Protocol, runtime_checkable
CAPABILITY_WORKFLOW_RUNTIME_WORKER = "workflow.runtimeWorker"
@runtime_checkable
class WorkflowRuntimeWorker(Protocol):
def reconcile_pending(
self,
session: object,
*,
now: datetime | None = None,
limit: int = 50,
) -> Mapping[str, object]:
...
def workflow_runtime_worker(
registry: object | None,
) -> WorkflowRuntimeWorker | None:
if (
registry is None
or not hasattr(registry, "has_capability")
or not registry.has_capability(CAPABILITY_WORKFLOW_RUNTIME_WORKER)
):
return None
capability = registry.capability(CAPABILITY_WORKFLOW_RUNTIME_WORKER)
return (
capability
if isinstance(capability, WorkflowRuntimeWorker)
else None
)
__all__ = [
"CAPABILITY_WORKFLOW_RUNTIME_WORKER",
"WorkflowRuntimeWorker",
"workflow_runtime_worker",
]