feat(core): dispatch durable dataflow runs
This commit is contained in:
@@ -10,6 +10,7 @@ from govoplan_core.core.events import PlatformEvent
|
||||
|
||||
|
||||
CAPABILITY_DATAFLOW_RUN_LIFECYCLE = "dataflow.runLifecycle"
|
||||
CAPABILITY_DATAFLOW_RUN_WORKER = "dataflow.runWorker"
|
||||
CAPABILITY_DATAFLOW_TRIGGER_DISPATCHER = "dataflow.triggerDispatcher"
|
||||
|
||||
|
||||
@@ -47,6 +48,10 @@ class DataflowRunRequest:
|
||||
revision: int
|
||||
idempotency_key: str
|
||||
row_limit: int = 500
|
||||
execution_backend: str = "auto"
|
||||
environment: str = "development"
|
||||
max_attempts: int = 3
|
||||
retention_days: int = 30
|
||||
publication: DataflowPublicationTarget | None = None
|
||||
invocation: AutomationInvocation = field(
|
||||
default_factory=AutomationInvocation
|
||||
@@ -126,6 +131,34 @@ class DataflowTriggerDispatcher(Protocol):
|
||||
...
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class DataflowRunWorker(Protocol):
|
||||
"""Durable worker boundary for queued Dataflow execution.
|
||||
|
||||
Implementations own claim transaction boundaries so a lease is committed
|
||||
before potentially long-running execution starts.
|
||||
"""
|
||||
|
||||
def dispatch_pending(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
now: datetime | None = None,
|
||||
limit: int = 10,
|
||||
worker_id: str | None = None,
|
||||
) -> Mapping[str, object]:
|
||||
...
|
||||
|
||||
def purge_expired(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
now: datetime | None = None,
|
||||
limit: int = 500,
|
||||
) -> Mapping[str, object]:
|
||||
...
|
||||
|
||||
|
||||
def dataflow_run_lifecycle(
|
||||
registry: object | None,
|
||||
) -> DataflowRunLifecycleProvider | None:
|
||||
@@ -133,6 +166,13 @@ def dataflow_run_lifecycle(
|
||||
return capability if isinstance(capability, DataflowRunLifecycleProvider) else None
|
||||
|
||||
|
||||
def dataflow_run_worker(
|
||||
registry: object | None,
|
||||
) -> DataflowRunWorker | None:
|
||||
capability = _capability(registry, CAPABILITY_DATAFLOW_RUN_WORKER)
|
||||
return capability if isinstance(capability, DataflowRunWorker) else None
|
||||
|
||||
|
||||
def dataflow_trigger_dispatcher(
|
||||
registry: object | None,
|
||||
) -> DataflowTriggerDispatcher | None:
|
||||
@@ -157,6 +197,7 @@ def _capability(registry: object | None, name: str) -> object | None:
|
||||
|
||||
__all__ = [
|
||||
"CAPABILITY_DATAFLOW_RUN_LIFECYCLE",
|
||||
"CAPABILITY_DATAFLOW_RUN_WORKER",
|
||||
"CAPABILITY_DATAFLOW_TRIGGER_DISPATCHER",
|
||||
"DataflowPublicationTarget",
|
||||
"DataflowRunConflictError",
|
||||
@@ -166,7 +207,9 @@ __all__ = [
|
||||
"DataflowRunNotFoundError",
|
||||
"DataflowRunRequest",
|
||||
"DataflowRunUnavailableError",
|
||||
"DataflowRunWorker",
|
||||
"DataflowTriggerDispatcher",
|
||||
"dataflow_run_lifecycle",
|
||||
"dataflow_run_worker",
|
||||
"dataflow_trigger_dispatcher",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user