Documentation
¶
Overview ¶
Package units provides parsers for human-readable input units (e.g. memory sizes) used by the API and the backends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenPort ¶
ListenPort extracts the port from a Go bind address like "host:port" or "[::1]:port". Falls back to "8080" when the string contains no colon at all — a defensive path for malformed input, not a real configuration mode (operators go through config validation before reaching this helper).
Shared between cmd/blockyard (passes a closure into NewDockerFactory) and internal/orchestrator tests so both sides exercise the same parsing. The orchestrator package intentionally does not depend on config, so this lives in internal/units where both callers can reach it without introducing a cycle.
func ParseMemoryLimit ¶
ParseMemoryLimit converts human-readable memory strings like "512m", "1g", "256mb" to bytes. Returns (bytes, true) on success, (0, false) on parse error or empty input. Suffixes are case-insensitive; bare numbers are treated as bytes.
func ParsePortRange ¶
ParsePortRange parses a "start-end" port range string into its two integer endpoints. Both endpoints are inclusive. Returns an error for malformed input, out-of-range values (0 or > 65535), or reversed ordering (start > end).
Used by the process orchestrator for the update.alt_bind_range config field. The worker port range on ProcessConfig stays as two int fields because its long-lived bitset allocator has different lifetime requirements and operators already configure it as separate start/end fields.
Types ¶
This section is empty.