feat(core): reconcile durable workflow instances
This commit is contained in:
@@ -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",
|
||||
]
|
||||
Reference in New Issue
Block a user