Documentation
¶
Overview ¶
Package units parses the scenario value grammar — rates, sizes, durations, and "lo..hi" ranges of each (docs/scenario-schema.md). Rates and sizes reuse github.com/BGrewell/go-conversions, which distinguishes SI decimal prefixes (K/M/G) from IEC binary prefixes (Ki/Mi/Gi); durations and ranges are parsed here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseDuration ¶
ParseDuration parses a Go duration string (e.g. "100ms", "1m30s").
func ParseRate ¶
ParseRate parses a bit-rate (e.g. "100Mbps", "1.5G", "1000") to bits/sec. SI decimal prefixes (K=1e3, M=1e6, G=1e9, e.g. "100Mbps") are distinct from IEC binary prefixes (Ki=2^10, Mi=2^20, Gi=2^30, e.g. "100Mibps"). A value that overflows int64 is rejected as out-of-range rather than returned as a poisoned (negative) rate.
func ParseSize ¶
ParseSize parses a byte size (e.g. "1000", "100K", "1.5MB") to bytes. SI decimal prefixes (K=1e3, M=1e6, G=1e9, e.g. "100MB") are distinct from IEC binary prefixes (Ki=2^10, Mi=2^20, Gi=2^30, e.g. "100MiB"); a trailing "B" is allowed. The underlying parser overflow-guards and returns a non-negative int64, which fits in the uint64 result.
Types ¶
type DurationRange ¶
DurationRange is an inclusive duration range.
func ParseDurationRange ¶
func ParseDurationRange(s string) (DurationRange, error)
ParseDurationRange parses "lo..hi" or a scalar duration.
type RateRange ¶
type RateRange struct{ Lo, Hi int64 }
RateRange, SizeRange, DurationRange are inclusive [Lo, Hi] bounds. A scalar parses to Lo == Hi.
func ParseRateRange ¶
ParseRateRange parses "lo..hi" or a scalar rate.