Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more flexible Duration parsing #11078

Closed
philwebb opened this issue Nov 19, 2017 · 9 comments
Closed

Allow more flexible Duration parsing #11078

philwebb opened this issue Nov 19, 2017 · 9 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@philwebb
Copy link
Member

Binding to Duration is currently cumbersome. It would be nice if we could parse simpler formats like 10s, 10m etc.

@philwebb
Copy link
Member Author

Originally part of PR #11071 but we should have a consistent solution that's the same for all binding, not just micrometer.

@philwebb philwebb added this to the 2.0.0.M7 milestone Nov 19, 2017
@snicoll
Copy link
Member

snicoll commented Nov 19, 2017

@philwebb this support is quite awesome. There are a bunch of places where we use a long to express a value in milliseconds. Would it be possible to support that as well? If we did somehow that would be a great migration path for users then: they could keep the raw value (e.g. 10000) or migrate to the new format (10s).

@wilkinsona
Copy link
Member

If the converter could treat no unit as milliseconds, perhaps we could then change a millisecond property that’s a long to be a Duration instead?

@snicoll
Copy link
Member

snicoll commented Nov 19, 2017

That's the exact reason why I am asking for that support.

@philwebb philwebb reopened this Nov 19, 2017
@philwebb
Copy link
Member Author

Adding a no suffix == milliseconds should be easy and I like the idea of converting longs to Duration

@snicoll
Copy link
Member

snicoll commented Nov 20, 2017

That's awesome. There are a couple of comments on the commit, reopening to make sure they're not missed.

@jkschneider
Copy link
Contributor

This is fantastic folks. Results in beautiful config.

@b0c1
Copy link

b0c1 commented Dec 16, 2017

What do you tihink about the HOCON (typesafe config) duration format?
https://github.com/lightbend/config/blob/eeb95825bf3763959ddd073d20b11045d2c01131/HOCON.md#duration-format

@philwebb
Copy link
Member Author

@b0c1 Looks like they were way ahead of us :) I like it, but I think I prefer to limit the number of choices for now. At least until someone complains that they'd rather type 10seconds rather than 10s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants