Source code for gyoza.server.scheduler.strategies.base
"""Scheduling strategy base interface.
Defines the interface for pluggable scheduling algorithms.
"""
from typing import Protocol
from gyoza.server.op_run.repository import OpRunRepository
from gyoza.server.worker import Worker, WorkerOpRun
[docs]
class SchedulingStrategy(Protocol):
"""Protocol for scheduling strategies.
Implementations determine how to allocate pending runs to workers.
Different strategies can implement different allocation policies
(e.g., balanced load, priority-based, affinity-based).
"""
[docs]
def allocate(
self,
worker_id: str,
op_run_repo: OpRunRepository,
workers: list[Worker],
) -> list[WorkerOpRun]:
"""Select runs to allocate to the given worker.
Parameters
----------
worker_id : str
ID of the worker requesting work.
op_run_repo : OpRunRepository
Repository for querying OpRuns (pending, running, etc.).
workers : list[Worker]
List of all active workers with their current state.
Returns
-------
list[WorkerOpRun]
Op runs that should be allocated to the requesting worker.
"""
...