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 unsafeRunToTwitterFuture for twitter Future #882
Conversation
4de0e6e
to
bed5b2e
Compare
interop-twitter/jvm/src/main/scala/scalaz/zio/interop/twitter.scala
Outdated
Show resolved
Hide resolved
interop-twitter/jvm/src/main/scala/scalaz/zio/interop/twitter.scala
Outdated
Show resolved
Hide resolved
Looks good! Just a couple minor comments on efficiency. |
interop-twitter/jvm/src/main/scala/scalaz/zio/interop/twitter.scala
Outdated
Show resolved
Hide resolved
interop-twitter/jvm/src/test/scala/scalaz/zio/interop/TwitterSpec.scala
Outdated
Show resolved
Hide resolved
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.
Which test is the flaky one? Happy to help you with it!
|
The logic is not very simple, but it's possible This would be a more logical implementation to me: final def fromTwitterFuture[A](future: Task[Future[A]]): Task[A] =
Task.uninterruptibleMask(restore =>
future.flatMap { f =>
restore(Task.effectAsync { cb =>
f.respond {
case Return(a) => cb(Task.succeed(a))
case Throw(e) => cb(Task.fail(e))
}
}).onInterrupt(UIO(f.raise(new FutureCancelledException)))
)
} |
@jdegoes ah yes, I println debugged it, the promise interruption handler was never called. |
@jdegoes could you take another look? |
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 to me. Thank you for your work on this!
Allow evaluating ZIO to twitter Future. Unfortunately the only place I could add this method is the
Runtime[R]
because it needs to evaluateFiber.interrupt
when being cancelled