diff --git a/rpc/src/main/scala/RPCAsyncImplicits.scala b/rpc/src/main/scala/RPCAsyncImplicits.scala index 346ede3bd..c27640d28 100644 --- a/rpc/src/main/scala/RPCAsyncImplicits.scala +++ b/rpc/src/main/scala/RPCAsyncImplicits.scala @@ -18,7 +18,6 @@ package freestyle package rpc import cats.{~>, Comonad} -import freestyle.async.AsyncContext import freestyle.rpc.client.handlers._ import journal.Logger import monix.eval.Task @@ -33,7 +32,7 @@ trait RPCAsyncImplicits extends freestyle.async.Implicits { protected[this] val asyncLogger: Logger = Logger[this.type] protected[this] val atMostDuration: FiniteDuration = 10.seconds - implicit def futureComonad(implicit ec: ExecutionContext): Comonad[Future] = + implicit def futureComonad(implicit EC: ExecutionContext): Comonad[Future] = new Comonad[Future] { def extract[A](x: Future[A]): A = { asyncLogger.info(s"${Thread.currentThread().getName} Waiting $atMostDuration for $x...") @@ -46,6 +45,19 @@ trait RPCAsyncImplicits extends freestyle.async.Implicits { fa.map(f) } + implicit def taskComonad(implicit S: Scheduler): Comonad[Task] = + new Comonad[Task] { + def extract[A](x: Task[A]): A = { + asyncLogger.info(s"${Thread.currentThread().getName} Waiting $atMostDuration for $x...") + Await.result(x.runAsync, atMostDuration) + } + + override def coflatMap[A, B](fa: Task[A])(f: (Task[A]) => B): Task[B] = Task(f(fa)) + + override def map[A, B](fa: Task[A])(f: (A) => B): Task[B] = + fa.map(f) + } + implicit def task2Future(implicit S: Scheduler): FSHandler[Task, Future] = new TaskMHandler[Future] diff --git a/version.sbt b/version.sbt index 23a2d9bf2..5eb664c3d 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.3.4-SNAPSHOT" \ No newline at end of file +version in ThisBuild := "0.3.4" \ No newline at end of file