feat: Add support for human-readable duration formats#647
Conversation
|
In its current form, the There currently is an open issue upstream in |
|
Constant values are now possible: use stackable_operator::duration::Duration;
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(3600); |
This reworks/simplifies the `Duration` implementation. Supported units are now clearly defned by an enum and the parsing/display mechanism is now way more explicit and defined in one place. Co-authored-by: Natalie Klestrup Röijezon <teo.roijezon@stackable.de>
Co-authored-by: Natalie Klestrup Röijezon <teo.roijezon@stackable.de>
Co-authored-by: Natalie Klestrup Röijezon <teo.roijezon@stackable.de>
This commit now parses durations in the Go format. This format doesn't use whitespaces to separate each fragment. Instead, all fragments are concated without any space between. The parser needs to be a little cleverer when trying to keep it streamlined. Additionally, the error variants now contain some more context to make it easier for the user to spot the error in the provided value. Co-authored-by: Natalie Klestrup Röijezon <teo.roijezon@stackable.de>
Co-authored-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
|
Commit fe1911e breaks |
…alid character" This reverts commit fe1911e.
|
Actual change LGTM, giving it a try with trino-op graceful shutdown |
|
|
Looking at the generated |
|
@Techassi as discussed, pushed the fixes, please have a look |
|
Yes, looks good! Waiting for final feedback from @nightkr |
Fair, I should have fixed those test cases. |
…ever a valid character"" This reverts commit 2d3d32c.
… into feat/humantime
|
Awesome, thanks for working on this! |
Fixes #649. This was discussed in an arch meeting roughly two weeks ago (when this PR was opened).
It is part of the effort to unify duration formats used in our CRDs. Operators would need to use the exported
Durationtype to support human-readable duration formats. This PR adds support for human-readable durations, like2d2h20m42sor15d2m2s. TheDurationtype requirements are tracked in #649These changes are breaking, because:
numbertostringstringis already used, the parsing might be slightly different