refactor(hm-pipeline-ir): centralize duration-ms conversion in DurationMs#175
Closed
markovejnovic wants to merge 6 commits into
Closed
refactor(hm-pipeline-ir): centralize duration-ms conversion in DurationMs#175markovejnovic wants to merge 6 commits into
markovejnovic wants to merge 6 commits into
Conversation
…onMs
Introduce a `DurationMs(u64)` newtype in hm-pipeline-ir, carried on the wire
as a bare JSON number via `#[serde(transparent)]`, with a single saturating
`From<Duration>` conversion.
Replaces the ad-hoc `elapsed().as_millis() as u64` conversions on
`BuildEvent::{StepEnd,BuildEnd}` and `StepResultSummary`, which diverged
between lossy `as u64` (3 sites in scheduler) and saturating `try_from` (1
site in cloud watch). The conversion now has exactly one home.
u64 milliseconds stays the wire representation (~584M-year ceiling):
`serde_json` cannot round-trip `u128`, and a raw `Duration` serializes as an
awkward `{ secs, nanos }` pair non-Rust consumers must special-case. The
render side rebuilds a `Duration` via `DurationMs::as_duration()`.
- Replace the inherent `as_duration` with `impl From<DurationMs> for Duration`, mirroring the existing `From<Duration>` and reading as `Duration::from(ms)`. - Derive `Display` via `derive_more` (newtype-forwards to the inner `u64`) instead of a hand-written impl; output is unchanged.
Blanket-impl CompactDuration for any `T: Into<Duration>` instead of only `Duration`, so `DurationMs` (and any future duration newtype) gets `.compact()` for free — no dependency edge into hm-pipeline-ir, since the impl never names the concrete type. Render sites drop `Duration::from(*ms).compact()` back to `ms.compact()`.
Contributor
Author
|
Subsumed by #176, which merged this branch in — all DurationMs commits live there now. Closing to avoid double-merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated by an AI agent.