Documentation
¶
Overview ¶
Package portalloc provides deterministic internal-port allocation for per-Gateway edge listeners (proposal 021 Phase 2). Each (Gateway namespace, Gateway name, listener section name) triple gets a stable internal port in the range [BasePort, BasePort+RangeSize) via FNV-1a hashing, so:
- The same triple always maps to the same port across restarts.
- Different triples are overwhelmingly likely to map to different ports (birthday-paradox collision probability is ~RangeSize² / 2 ≈ negligible at single-digit Gateway counts).
- No external state or etcd/CRD storage is required.
For production workloads with O(10) Gateways × O(4) listeners the expected collision rate is < 0.04 % per allocation, which is acceptable. Collision detection (PortSet.Assign) detects conflicts and bumps by +1 up to MaxProbes times, guaranteeing uniqueness within a single reconcile batch.
Index ¶
Constants ¶
View Source
const ( // BasePort is the first internal port in the allocation range. BasePort = uint32(18100) // RangeSize is the number of ports in the allocation range. RangeSize = uint32(900) // [18100, 18999] // MaxProbes is the maximum number of linear-probe steps on hash collision. MaxProbes = 20 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.