Expand description
Shared human-duration parsing (#56).
One canonical parser feeds both the config layer ([slow_log] threshold) and CLI args (ferrule history --since), replacing the two
near-identical inline parsers those call sites grew independently
during the Query Telemetry Foundation sprint. It returns
chrono::Duration so each caller maps to whatever unit it needs
(milliseconds for the slow-log threshold, the raw delta for --since).
Recognised units — the union of the two original alias sets:
mss/sec/secsm/min/minsh/hr/hrsd/day/days
A unit suffix is required: a bare integer ("500") is rejected
here. Callers that assign a default unit to a bare integer (e.g.
[slow_log] threshold = "500" → 500 ms) keep that quirk in their own
thin wrapper, handled before delegating.
Out of scope, per #56 (kept here so the boundary is explicit):
- The
humantimecrate — not worth the dependency at this caller count; revisit past ~5 callers. - Fractional units (
1.5h,0.5d) — unused anywhere; YAGNI. - A byte-size parser for
[slow_log] max_size(#55) — same shape, distinct unit class; share structure, not this signature.
Functions§
- parse_
duration - Parse a human-readable duration like
250ms,30s,5m,2h, or7dinto achrono::Duration. - parse_
size - Parse a human-readable byte size like
1024,10MB, or5MiBinto a count of bytes.