-
Couldn't load subscription status.
- Fork 1.4k
Implement ZIO#timeoutFork #1856
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
Conversation
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.
Looks good!
| */ | ||
| final def timeoutFork(d: Duration): ZIO[R with Clock, E, Either[Fiber[E, A], A]] = | ||
| raceWith(ZIO.sleep(d))( | ||
| (exit, fiber) => ZIO.done(exit).map(Right(_)) <* fiber.interrupt, |
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.
IMO could be a bit more readable if fiber is renamed to timeoutFiber.
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.
Done.
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.
Still LGTM :)
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.
Excellent work. Should make small work of the other PR!
|
Oops, a few conflicts to resolve.., |
|
Conflicts resolved. |
* implement Cause.Meta * fix access levels * make case class final * address review comments * migrate tests to ZIO Test * address review comments * fix type * fix another typo * pass `Data` in from above * implement flatMap * implement flatten * implement unsandbox via flatten * apply nonFlaky only on JVM * use jvm test aspect more * try ignoring tests * start reenabling tests * remove unused import * reenable more tests * Add ZSchedule.elapsed example to docs (#1871) * Add ZSchedule.elapsed example to docs * ignore flaky supervision test (#1874) * CircleCI improvements (#1859) * CircleCI improvements * CircleCI improvements, yaml fix * CircleCI improvements, yaml fix 2 * CircleCI improvements, yaml fix 3 * Implement ZIO#timeoutFork (#1856) * implement timeoutFork * address review comments
* implement timeoutFork * address review comments
* implement Cause.Meta * fix access levels * make case class final * address review comments * migrate tests to ZIO Test * address review comments * fix type * fix another typo * pass `Data` in from above * implement flatMap * implement flatten * implement unsandbox via flatten * apply nonFlaky only on JVM * use jvm test aspect more * try ignoring tests * start reenabling tests * remove unused import * reenable more tests * Add ZSchedule.elapsed example to docs (zio#1871) * Add ZSchedule.elapsed example to docs * ignore flaky supervision test (zio#1874) * CircleCI improvements (zio#1859) * CircleCI improvements * CircleCI improvements, yaml fix * CircleCI improvements, yaml fix 2 * CircleCI improvements, yaml fix 3 * Implement ZIO#timeoutFork (zio#1856) * implement timeoutFork * address review comments
Following up on discussion in #1824, adds a
timeoutForkmethod on ZIO that attempts to timeout an effect, but does not wait for the running effect to terminate. If the running effect does not complete before the timeout elapses a reference to the interrupting fiber will be returned, allowing the user to decide what further action to take (e.g. ignore it, wait a certain amount of time for it to succeed or else do something else).This can be useful when the effect is potentially uninterruptible to avoid waiting indefinitely on the effect to complete and possible apply further logic in that case.