main
py 37 lines 1.05 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Abstract base classes for the EC control plane.
4
5 ControlConnection wraps a single peer channel (one DEALER socket).
6 """
7
8 from abc import ABC, abstractmethod
9
10
11 class ControlConnection(ABC):
12 """Bidirectional message channel to a single remote peer.
13
14 All I/O is non-blocking: send enqueues without blocking; recv drains
15 all buffered inbound messages since the last call.
16 """
17
18 @property
19 @abstractmethod
20 def alive(self) -> bool:
21 """True if the connection is still usable."""
22
23 @abstractmethod
24 def send(self, msg: bytes) -> None:
25 """Enqueue msg for delivery. Must not block."""
26
27 @abstractmethod
28 def recv(self) -> list[bytes]:
29 """Drain and return all buffered inbound messages."""
30
31 @abstractmethod
32 def mark_dead(self) -> None:
33 """Signal that the peer disconnected. Sets alive to False."""
34
35 @abstractmethod
36 def close(self) -> None:
37 """Release all resources. Idempotent."""