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 methods to get finite duration from duration #8832
base: series/2.x
Are you sure you want to change the base?
Conversation
@NavidJalali just FYI, you'll need to add |
💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe/Alipay. |
case _ => Some(ScalaFiniteDuration(duration.toNanos, TimeUnit.NANOSECONDS)) | ||
} | ||
|
||
def asFiniteDurationUnsafe: ScalaFiniteDuration = duration match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary to throw, because if you look at "Infinity", it's just a "really big" (biggest possible) finite duration. So I think this can and should be a total function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw I would also consider simply changing def asScala: ScalaDuration
to def asScala: ScalaFiniteDuration
. This way no new methods are necessary and it should be backward compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
…ite duration instead
867c862
to
63a44b4
Compare
@@ -154,7 +154,7 @@ object DurationSpec extends ZIOBaseSpec { | |||
assert(Duration.Infinity.isZero)(equalTo(false)) | |||
}, | |||
test("It converts into the infinite s.c.d.Duration") { | |||
assert(Duration.Infinity.asScala)(equalTo(ScalaDuration.Inf: ScalaDuration)) | |||
assert(Duration.Infinity.asScala)(equalTo(ScalaFiniteDuration(Long.MaxValue, TimeUnit.NANOSECONDS))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will note this is likely not preferable if users are using APIs which special case for Duration.Inf
...
Fix #8797
/claim #8797