feat(core): dispatch durable dataflow runs
This commit is contained in:
@@ -4,9 +4,12 @@ import unittest
|
||||
|
||||
from govoplan_core.core.dataflows import (
|
||||
CAPABILITY_DATAFLOW_RUN_LIFECYCLE,
|
||||
CAPABILITY_DATAFLOW_RUN_WORKER,
|
||||
DataflowRunDescriptor,
|
||||
DataflowRunLifecycleProvider,
|
||||
DataflowRunWorker,
|
||||
dataflow_run_lifecycle,
|
||||
dataflow_run_worker,
|
||||
)
|
||||
from govoplan_core.core.modules import ModuleContext, ModuleManifest
|
||||
from govoplan_core.core.registry import PlatformRegistry
|
||||
@@ -49,10 +52,27 @@ class _Provider:
|
||||
)
|
||||
|
||||
|
||||
class _Worker:
|
||||
def dispatch_pending(
|
||||
self,
|
||||
session,
|
||||
*,
|
||||
now=None,
|
||||
limit=10,
|
||||
worker_id=None,
|
||||
):
|
||||
return {"claimed": 0}
|
||||
|
||||
def purge_expired(self, session, *, now=None, limit=500):
|
||||
return {"purged": 0}
|
||||
|
||||
|
||||
class DataflowContractTests(unittest.TestCase):
|
||||
def test_run_lifecycle_is_runtime_checkable_and_resolved(self) -> None:
|
||||
provider = _Provider()
|
||||
worker = _Worker()
|
||||
self.assertIsInstance(provider, DataflowRunLifecycleProvider)
|
||||
self.assertIsInstance(worker, DataflowRunWorker)
|
||||
registry = PlatformRegistry()
|
||||
registry.register(
|
||||
ModuleManifest(
|
||||
@@ -61,6 +81,7 @@ class DataflowContractTests(unittest.TestCase):
|
||||
version="test",
|
||||
capability_factories={
|
||||
CAPABILITY_DATAFLOW_RUN_LIFECYCLE: lambda context: provider,
|
||||
CAPABILITY_DATAFLOW_RUN_WORKER: lambda context: worker,
|
||||
},
|
||||
)
|
||||
)
|
||||
@@ -69,7 +90,9 @@ class DataflowContractTests(unittest.TestCase):
|
||||
)
|
||||
|
||||
self.assertIs(provider, dataflow_run_lifecycle(registry))
|
||||
self.assertIs(worker, dataflow_run_worker(registry))
|
||||
self.assertIsNone(dataflow_run_lifecycle(PlatformRegistry()))
|
||||
self.assertIsNone(dataflow_run_worker(PlatformRegistry()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user