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

add conversion to FiniteDuration to zio.duration #8797

Open
domdorn opened this issue Apr 26, 2024 · 6 comments · May be fixed by #8832
Open

add conversion to FiniteDuration to zio.duration #8797

domdorn opened this issue Apr 26, 2024 · 6 comments · May be fixed by #8832

Comments

@domdorn
Copy link
Contributor

domdorn commented Apr 26, 2024

Unfortunatelly we still have a lot of akka in our codebase.
akka always requires scala.concurrent.duration.FiniteDuration instances, however I always have zio._ imported.
There's already a .asScala conversion, however that one gives me just the supertype scala.concurrent.duration.Duration when I need the subtype.

could we maybe have a .asScalaFinite or .asScalaFiniteUnsafe that would return a FiniteDuration for everything that is not infinity?

https://github.com/zio/zio/blob/series/2.x/core/shared/src/main/scala/zio/Duration.scala#L176-L181

Thanks!

@jdegoes
Copy link
Member

jdegoes commented May 8, 2024

I think asScala could be made to return FiniteDuration always, which might be the better fix.

@jdegoes
Copy link
Member

jdegoes commented May 8, 2024

/bounty $50

Copy link

algora-pbc bot commented May 8, 2024

💎 $50 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #8797 with your implementation plan
  2. Submit work: Create a pull request including /claim #8797 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @NavidJalali #8832

@NavidJalali
Copy link
Contributor

I think asScala could be made to return FiniteDuration always, which might be the better fix.

Isnt that a regression? I mean what would it return for the infinite case?

@NavidJalali NavidJalali linked a pull request May 9, 2024 that will close this issue
Copy link

algora-pbc bot commented May 12, 2024

💡 @NavidJalali submitted a pull request that claims the bounty. You can visit your bounty board to reward.

@jdegoes
Copy link
Member

jdegoes commented May 12, 2024

@NavidJalali The thing is, there is no infinite case. It's faked. It used to exist back when we used Scala duration but Duration.Inf was ported over to mean "big finite" when we adopted java.time structures.

(Unless I'm missing something...)

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

Successfully merging a pull request may close this issue.

3 participants