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

decouple from frees-async #297

Merged
merged 2 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 20 additions & 3 deletions modules/internal/src/main/scala/client/monixCalls.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package internal
package client

import cats.effect.{Async, LiftIO}
import freestyle.async.guava.implicits._
import freestyle.async.catsEffect.implicits._
import io.grpc.{CallOptions, Channel, MethodDescriptor}
import com.google.common.util.concurrent._
import io.grpc.stub.{ClientCalls, StreamObserver}
import io.grpc.{CallOptions, Channel, MethodDescriptor}
import java.util.concurrent.{Executor => JavaExecutor}
import monix.execution.Scheduler
import monix.reactive.Observable
import scala.concurrent.ExecutionContext

object monixCalls {

Expand Down Expand Up @@ -79,4 +80,20 @@ object monixCalls {
outputObserver
))
)

private[this] def listenableFuture2Async[F[_], A](
fa: => ListenableFuture[A])(implicit F: Async[F], E: ExecutionContext): F[A] =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed teh AsyncContext[F] requirement with an Async[F] requirement, which is the same idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can restrict the implicit req to the Effect typeclass?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect is an Async, so it would be widening. Also, we're not using runAsync on the F, so we don't need Effect, right?

F.async { cb =>
Futures.addCallback(
fa,
new FutureCallback[A] {
override def onSuccess(result: A): Unit = cb(Right(result))

override def onFailure(t: Throwable): Unit = cb(Left(t))
},
new JavaExecutor {
override def execute(command: Runnable): Unit = E.execute(command)
}
)
}
}
1 change: 0 additions & 1 deletion project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ object ProjectPlugin extends AutoPlugin {
lazy val internalSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("frees-async-cats-effect", V.frees),
%%("frees-async-guava", V.frees) exclude ("com.google.guava", "guava"),
%("grpc-stub", V.grpc),
%%("monix"),
%%("fs2-reactive-streams", V.fs2ReactiveStreams),
Expand Down