WIP autoscaler agent
This commit is contained in:
parent
c610a3e284
commit
28059dcedf
34 changed files with 2409 additions and 35 deletions
54
agent/nix_builder_autoscaler/providers/haproxy.py
Normal file
54
agent/nix_builder_autoscaler/providers/haproxy.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
"""HAProxy runtime socket adapter — stub for Plan 02."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
class HAProxyError(Exception):
|
||||
"""Error communicating with HAProxy runtime socket."""
|
||||
|
||||
|
||||
@dataclass
|
||||
class SlotHealth:
|
||||
"""Health status for a single HAProxy server slot."""
|
||||
|
||||
status: str
|
||||
scur: int
|
||||
qcur: int
|
||||
|
||||
|
||||
class HAProxyRuntime:
|
||||
"""HAProxy runtime CLI adapter via Unix socket.
|
||||
|
||||
Full implementation in Plan 02.
|
||||
"""
|
||||
|
||||
def __init__(self, socket_path: str, backend: str, slot_prefix: str) -> None:
|
||||
self._socket_path = socket_path
|
||||
self._backend = backend
|
||||
self._slot_prefix = slot_prefix
|
||||
|
||||
def set_slot_addr(self, slot_id: str, ip: str, port: int = 22) -> None:
|
||||
"""Update server address for a slot."""
|
||||
raise NotImplementedError
|
||||
|
||||
def enable_slot(self, slot_id: str) -> None:
|
||||
"""Enable a server slot."""
|
||||
raise NotImplementedError
|
||||
|
||||
def disable_slot(self, slot_id: str) -> None:
|
||||
"""Disable a server slot."""
|
||||
raise NotImplementedError
|
||||
|
||||
def slot_is_up(self, slot_id: str) -> bool:
|
||||
"""Return True when HAProxy health status is UP for slot."""
|
||||
raise NotImplementedError
|
||||
|
||||
def slot_session_count(self, slot_id: str) -> int:
|
||||
"""Return current active session count for slot."""
|
||||
raise NotImplementedError
|
||||
|
||||
def read_slot_health(self) -> dict[str, SlotHealth]:
|
||||
"""Return full stats snapshot for all slots."""
|
||||
raise NotImplementedError
|
||||
Loading…
Add table
Add a link
Reference in a new issue