units

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

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

func ListenPort(bind string) string

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

func ParseMemoryLimit(s string) (int64, bool)

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

func ParsePortRange(s string) (first, last int, err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL