Skip to content

Implement human-readable durations in the config #4294

@0x009922

Description

@0x009922

Description

Enhance HumanDuration type to actually parse a human-readable string:

https://github.com/hyperledger/iroha/blob/964476722e2a219becaacdb3676ca058ec5748cd/config/base/src/lib.rs#L23-L27

Specification

Here is an excerpt from the configuration reference draft:

Duration is specified as a human-readable string:

value1 = "1sec"
value2 = "1hour 12min 5s"
value3 = "2years 2min 12us"
value4 = "550ms"

The duration string is a concatenation of time spans. Each time span is an
integer number and a suffix. Supported suffixes:

  • nsec, ns — nanoseconds
  • usec, us — microseconds
  • msec, ms — milliseconds
  • seconds, second, sec, s
  • minutes, minute, min, m
  • hours, hour, hr, h
  • days, day, d
  • weeks, week, w
  • months, month, M — defined as $30.44$ days
  • years, year, y — defined as $365.25$ days

I used humantime crate for reference. Maybe it can be used as is. Otherwise, it is straighforward (and quite interesting!) to write our own parser with something like winnow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or requestUISomething about the interfaceconfig-changesChanges in configuration and start up of the Irohagood first issueGood for newcomersiroha2-devThe re-implementation of a BFT hyperledger in RUSTquestionFurther information is requested

    Type

    No type

    Projects

    Status

    Roadmap

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions