Skip to content

Conversation

clemyan
Copy link
Member

@clemyan clemyan commented Oct 14, 2025

What's the problem this PR addresses?

There are a number of configurations that represent a duration of time (e.g. httpTimeout). Currently those use the NUMBER settings type with a predefined unit (e.g. milliseconds for httpTimeout). But:

  1. Each setting uses a different unit so users need to context switch to the docs to read/write those config
  2. Because YAML doesn't support arithmetic expressions, unit conversions need to be done beforehand in order to properly set those settings.

How did you fix it?

Create a new DURATION settings type that allows specifying the duration as a string in the following format:

  1. An integer or decimal value
  2. Optionally a unit among ms, s, m, h, d, w

For backward compatibility, a DURATION is parsed to a number using the existing predefined unit for that setting. That unit is also used if one is not specified.

I have only implemented units that the exactly convertible to each other* to avoid something like having to convert 1 month to an exact number of days.

(* not entirely true since 1 day is not always 24 hours)

In the future, maybe we can use a proper duration data structure to do proper date calculations. (So that, for example, setting a DURATION to 1 month actually means "1 calendar month" instead of an approximate number of seconds)

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant