refactor(schedule): move orchestrator to application/ + review fixes (stage 8)
Follow-up to the layered refactor (review-driven):
- Move scheduling/orchestrator.py -> application/orchestrator.py
(orchestrator is application-level coordination, not a cron-trigger
primitive; matches the intended target tree)
- Migrate orchestrator re-exports from scheduling/__init__.py to
application/__init__.py; scheduling/ now exposes only CronScheduler
- Rewrite imports + 5 mock.patch string targets in test_janitor.py and
the orchestrator import in test_layering.py
- Update docstring refs in application/service.py + execution/worker.py
- Add 4 runner smoke tests (test_layering.py): _limited_log under-limit /
empty-sentinel / above-MAX_LOG_BYTES truncation; execute_artifact
rejects unsupported script_type with ValueError
- infrastructure/__init__.py re-exports SchedulerStorageClient so
``from schedule.infrastructure import SchedulerStorageClient`` is a
stable top-level surface
- CLAUDE.md engineering note: extend the commit trail to 7476c27 and
note the stage-8 orchestrator placement
Zero behavior change; schedule/pyproject.toml untouched. 29 tests green.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
"""Application layer — service assembly for the scheduler.
|
||||
|
||||
Home of the old flat ``schedule/service.py``: ``SchedulerService`` plus the
|
||||
``build_object_store`` / ``build_storage_http_client`` factories.
|
||||
Houses:
|
||||
|
||||
- ``SchedulerService`` plus the ``build_object_store`` /
|
||||
``build_storage_http_client`` factories (the old flat ``schedule/service.py``).
|
||||
- ``DispatchOrchestrator`` and the cron / node event constants (the old
|
||||
``schedule/orchestrator.py`` — the outbox-polling / DAG coordinator is
|
||||
application-level glue, not a cron-trigger primitive).
|
||||
"""
|
||||
|
||||
from schedule.application.orchestrator import (
|
||||
NODE_EXECUTE_EVENT,
|
||||
NODE_FINISHED_EVENT,
|
||||
SCHEDULE_RUN_REQUESTED_EVENT,
|
||||
DispatchOrchestrator,
|
||||
)
|
||||
from schedule.application.service import (
|
||||
SchedulerService,
|
||||
build_object_store,
|
||||
@@ -14,4 +25,8 @@ __all__ = [
|
||||
"SchedulerService",
|
||||
"build_object_store",
|
||||
"build_storage_http_client",
|
||||
"DispatchOrchestrator",
|
||||
"SCHEDULE_RUN_REQUESTED_EVENT",
|
||||
"NODE_EXECUTE_EVENT",
|
||||
"NODE_FINISHED_EVENT",
|
||||
]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Composes three single-purpose components into one bootable service:
|
||||
|
||||
- :class:`schedule.scheduling.scheduler.CronScheduler` — APScheduler + cron sync loop
|
||||
- :class:`schedule.scheduling.orchestrator.DispatchOrchestrator` — Outbox polling + DAG
|
||||
- :class:`schedule.application.orchestrator.DispatchOrchestrator` — Outbox polling + DAG
|
||||
- :class:`schedule.execution.worker.NodeExecutor` — node-level execution
|
||||
|
||||
This module also exposes the factory function ``build_object_store``
|
||||
@@ -36,7 +36,7 @@ from common.storage import create_storage
|
||||
from loguru import logger
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
||||
|
||||
from schedule.scheduling.orchestrator import DispatchOrchestrator
|
||||
from schedule.application.orchestrator import DispatchOrchestrator
|
||||
from schedule.scheduling.scheduler import CronScheduler
|
||||
from schedule.execution.worker import NodeExecutor
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Node-level worker: executes one ``job.node.execute`` event.
|
||||
|
||||
The orchestrator (see ``schedule.scheduling.orchestrator``) writes a ``job.node.execute``
|
||||
The orchestrator (see ``schedule.application.orchestrator``) writes a ``job.node.execute``
|
||||
Outbox row with all the metadata needed to run the node (script type,
|
||||
artifact location, timeout, arguments ...). The polling loop picks those up
|
||||
and calls :meth:`NodeExecutor.handle_node_execute`. This module owns the
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
"""Infrastructure layer — external I/O adapters (storage API)."""
|
||||
|
||||
from schedule.infrastructure.storage import SchedulerStorageClient
|
||||
|
||||
__all__ = ["SchedulerStorageClient"]
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
"""Scheduling layer — cron trigger + DAG orchestration.
|
||||
"""Scheduling layer — cron trigger.
|
||||
|
||||
Home of the old flat ``schedule/scheduler.py`` (``CronScheduler``) and
|
||||
``schedule/orchestrator.py`` (``DispatchOrchestrator``). Classes moved
|
||||
byte-identical in the layered refactor; names unchanged.
|
||||
Home of the old flat ``schedule/scheduler.py`` (``CronScheduler``).
|
||||
The class moved byte-identical in the layered refactor; name unchanged.
|
||||
The outbox-polling orchestrator used to live here too, but it is an
|
||||
application-level coordinator — see ``schedule.application.orchestrator``.
|
||||
"""
|
||||
|
||||
from schedule.scheduling.orchestrator import (
|
||||
NODE_EXECUTE_EVENT,
|
||||
NODE_FINISHED_EVENT,
|
||||
SCHEDULE_RUN_REQUESTED_EVENT,
|
||||
DispatchOrchestrator,
|
||||
)
|
||||
from schedule.scheduling.scheduler import CronScheduler
|
||||
|
||||
__all__ = [
|
||||
"CronScheduler",
|
||||
"DispatchOrchestrator",
|
||||
"SCHEDULE_RUN_REQUESTED_EVENT",
|
||||
"NODE_EXECUTE_EVENT",
|
||||
"NODE_FINISHED_EVENT",
|
||||
]
|
||||
__all__ = ["CronScheduler"]
|
||||
|
||||
Reference in New Issue
Block a user