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

Implicit converter from Java Duration to Timeout #28105

Open
johanandren opened this issue Nov 1, 2019 · 3 comments
Open

Implicit converter from Java Duration to Timeout #28105

johanandren opened this issue Nov 1, 2019 · 3 comments
Labels
0 - new Ticket is unclear on it's purpose or if it is valid or not t:core

Comments

@johanandren
Copy link
Member

There is an implicit conversion from FiniteDuration to Timeout which allows this:

val myTimeout: Timeout = 4.seconds

Would be nice if there was the same for java.util.Duration so that this would work:

val myTimeout: Timeout = config.getDuration("my-app.timeout")
@johanandren johanandren added 0 - new Ticket is unclear on it's purpose or if it is valid or not t:core labels Nov 1, 2019
@patriknw
Copy link
Member

patriknw commented Nov 1, 2019

for the Timeout from config case one can use the Java API (from Scala):

implicit val timeout: Timeout =
    Timeout.create(system.settings.config.getDuration("weather.routes.ask-timeout"))

@helena
Copy link
Member

helena commented Nov 2, 2019

This duration/timeout issue has been a nit of mine for years. I can take a look when we're ready.

@helena
Copy link
Member

helena commented Nov 5, 2019

typed/untyped system:

import scala.concurrent.duration._
implicit val timeout: Timeout = system.settings.config.getDuration("key").toMillis.millis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - new Ticket is unclear on it's purpose or if it is valid or not t:core
Projects
None yet
Development

No branches or pull requests

3 participants