public sealed class PortPoolA range of UDP ports, handed out one at a time and given back when a realm stops.
Remarks
⚠ Here rather than beside a backend, because every backend needs it. Placement.Process allocates from a pool, Placement.Docker publishes one per container, and ADR-019's Kubernetes backend takes a hostPort from a per-node range — which is the same question three times. It started in Placement.Process and moved here when the second backend wanted it, rather than being copied.
The one piece of configuration Placement.Process needs, and the same shape as the node port range ADR-019 names as Kubernetes's single cluster prerequisite. A realm's endpoint has to be knowable by the orchestrator before the process exists — a client is told where to go by placement, not by the realm — so the pool allocates and the realm is told, rather than the realm binding port zero and reporting back.
⚠ A rented port is not a bound one. Something else on the machine may hold it, and the realm will fail to start. That is reported as a start failure rather than papered over with a retry loop, because on a machine where the range overlaps something else every start is a coin toss and the useful outcome is finding that out on the first one.
Fields and properties (4)
public int FirstThe first port in the range.
public int LastThe last port in the range, inclusive.
public int RentedCountHow many ports are currently out.
public int CapacityHow many ports the range holds.
Methods (4)
public PortPool(int first = 7800, int last = 7899)Takes a range.
public bool TryRent(out int port)Takes the next free port.
public void Return(int port)Gives a port back.
public override string ToString()Returns a string that represents the current object.
Used by (9)
- DockerPlacementVixen.Live.Placement.Docker
- DockerPlacementOptionsVixen.Live.Placement.Docker
- DockerPlacementTestsVixen.Live.Placement.Docker.Tests
- KubernetesPlacementVixen.Live.Placement.Kubernetes
- KubernetesPlacementOptionsVixen.Live.Placement.Kubernetes
- KubernetesPlacementTestsVixen.Live.Placement.Kubernetes.Tests
- ProcessPlacementVixen.Live.Placement.Process
- ProcessPlacementOptionsVixen.Live.Placement.Process
- ProcessPlacementTestsVixen.Live.Placement.Process.Tests