diff --git a/build.sbt b/build.sbt index a2db86c782..109f23e4ec 100644 --- a/build.sbt +++ b/build.sbt @@ -618,7 +618,7 @@ lazy val httpClientFs2Backend = .dependsOn(fs2 % compileAndTest) lazy val httpClientZioBackend = - httpClientBackendProject("zio", includeDotty = true) + httpClientBackendProject("zio", includeDotty = false) .settings( libraryDependencies ++= Seq( diff --git a/docs/backends/summary.md b/docs/backends/summary.md index 00ae009e0d..953cf0d16b 100644 --- a/docs/backends/summary.md +++ b/docs/backends/summary.md @@ -24,7 +24,7 @@ Class Effect type Supported stre ==================================== ============================ ================================================= ========================== =================== ``HttpURLConnectionBackend`` None (``Identity``) n/a no no ``TryHttpURLConnectionBackend`` ``scala.util.Try`` n/a no no -``AkkaHttpBackend`` ``scala.concurrent.Future`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming) no +``AkkaHttpBackend`` ``scala.concurrent.Future`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming) yes ``AsyncHttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) no ``AsyncHttpClientScalazBackend`` ``scalaz.concurrent.Task`` n/a yes (regular) no ``AsyncHttpClientZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` yes (regular & streaming) no @@ -39,9 +39,9 @@ Class Effect type Supported stre ``HttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) no ``HttpClientMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) no ``HttpClientFs2Backend`` ``F[_]: cats.effect.Async`` ``fs2.Stream[F, Byte]`` yes (regular & streaming) yes -``HttpClientZioBackend`` ``zio.RIO[Blocking, *]`` ``zio.stream.ZStream[Blocking, Throwable, Byte]`` yes (regular & streaming) yes +``HttpClientZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` yes (regular & streaming) yes ``FinagleBackend`` ``com.twitter.util.Future`` n/a no no -==================================== ============================ ================================================= ========================== +==================================== ============================ ================================================= ========================== =================== ``` The backends work with Scala 2.11, 2.12 and 2.13 (with some exceptions for 2.11). Moreover, `HttpURLConnectionBackend`, `AsyncHttpClientFutureBackend`, `AsyncHttpClientZioBackend`, `HttpClientSyncBackend`, `HttpClientFutureBackend` and `HttpClientZioBackend` are additionally built with Dotty (Scala 3). diff --git a/docs/backends/zio.md b/docs/backends/zio.md index a465a14f58..0b85300c2d 100644 --- a/docs/backends/zio.md +++ b/docs/backends/zio.md @@ -85,7 +85,7 @@ type SttpClient = Has[SttpBackend[Task, ZioStreams with WebSockets]] // or, when using Java 11 & HttpClient package sttp.client3.httpclient.zio -type SttpClient = Has[SttpBackend[BlockingTask, BlockingZioStreams with WebSockets]] +type SttpClient = Has[SttpBackend[Task, ZioStreams with WebSockets]] ``` The lifecycle of the `SttpClient` service is described by `ZLayer`s, which can be created using the `.layer`/`.layerUsingConfig`/... methods on `AsyncHttpClientZioBackend` / `HttpClientZioBackend`. diff --git a/generated-docs/out/backends/summary.md b/generated-docs/out/backends/summary.md index c2c4a6a2a4..953cf0d16b 100644 --- a/generated-docs/out/backends/summary.md +++ b/generated-docs/out/backends/summary.md @@ -19,28 +19,29 @@ Each backend has two type parameters: Below is a summary of all the JVM backends; see the sections on individual backend implementations for more information: ```eval_rst -==================================== ============================ ================================================= ========================== -Class Effect type Supported stream type Supports websockets -==================================== ============================ ================================================= ========================== -``HttpURLConnectionBackend`` None (``Identity``) n/a no -``TryHttpURLConnectionBackend`` ``scala.util.Try`` n/a no -``AkkaHttpBackend`` ``scala.concurrent.Future`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming) -``AsyncHttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) -``AsyncHttpClientScalazBackend`` ``scalaz.concurrent.Task`` n/a yes (regular) -``AsyncHttpClientZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` yes (regular & streaming) -``AsyncHttpClientMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) -``AsyncHttpClientCatsBackend`` ``F[_]: cats.effect.Async`` n/a no -``AsyncHttpClientFs2Backend`` ``F[_]: cats.effect.Async`` ``fs2.Stream[F, Byte]`` yes (regular & streaming) -``OkHttpSyncBackend`` None (``Identity``) n/a yes (regular) -``OkHttpFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) -``OkHttpMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) -``Http4sBackend`` ``F[_]: cats.effect.Effect`` ``fs2.Stream[F, Byte]`` no -``HttpClientSyncBackend`` None (``Identity``) n/a no -``HttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) -``HttpClientMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) -``HttpClientZioBackend`` ``zio.RIO[Blocking, *]`` ``zio.stream.ZStream[Blocking, Throwable, Byte]`` yes (regular & streaming) -``FinagleBackend`` ``com.twitter.util.Future`` n/a no -==================================== ============================ ================================================= ========================== +==================================== ============================ ================================================= ========================== =================== +Class Effect type Supported stream type Supports websockets Fully non-blocking +==================================== ============================ ================================================= ========================== =================== +``HttpURLConnectionBackend`` None (``Identity``) n/a no no +``TryHttpURLConnectionBackend`` ``scala.util.Try`` n/a no no +``AkkaHttpBackend`` ``scala.concurrent.Future`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming) yes +``AsyncHttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) no +``AsyncHttpClientScalazBackend`` ``scalaz.concurrent.Task`` n/a yes (regular) no +``AsyncHttpClientZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` yes (regular & streaming) no +``AsyncHttpClientMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) no +``AsyncHttpClientCatsBackend`` ``F[_]: cats.effect.Async`` n/a no no +``AsyncHttpClientFs2Backend`` ``F[_]: cats.effect.Async`` ``fs2.Stream[F, Byte]`` yes (regular & streaming) no +``OkHttpSyncBackend`` None (``Identity``) n/a yes (regular) no +``OkHttpFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) no +``OkHttpMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) no +``Http4sBackend`` ``F[_]: cats.effect.Effect`` ``fs2.Stream[F, Byte]`` no no +``HttpClientSyncBackend`` None (``Identity``) n/a no no +``HttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) no +``HttpClientMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) no +``HttpClientFs2Backend`` ``F[_]: cats.effect.Async`` ``fs2.Stream[F, Byte]`` yes (regular & streaming) yes +``HttpClientZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` yes (regular & streaming) yes +``FinagleBackend`` ``com.twitter.util.Future`` n/a no no +==================================== ============================ ================================================= ========================== =================== ``` The backends work with Scala 2.11, 2.12 and 2.13 (with some exceptions for 2.11). Moreover, `HttpURLConnectionBackend`, `AsyncHttpClientFutureBackend`, `AsyncHttpClientZioBackend`, `HttpClientSyncBackend`, `HttpClientFutureBackend` and `HttpClientZioBackend` are additionally built with Dotty (Scala 3). diff --git a/generated-docs/out/backends/zio.md b/generated-docs/out/backends/zio.md index ca9f42a2eb..7e3a374aec 100644 --- a/generated-docs/out/backends/zio.md +++ b/generated-docs/out/backends/zio.md @@ -85,7 +85,7 @@ type SttpClient = Has[SttpBackend[Task, ZioStreams with WebSockets]] // or, when using Java 11 & HttpClient package sttp.client3.httpclient.zio -type SttpClient = Has[SttpBackend[BlockingTask, BlockingZioStreams with WebSockets]] +type SttpClient = Has[SttpBackend[Task, ZioStreams with WebSockets]] ``` The lifecycle of the `SttpClient` service is described by `ZLayer`s, which can be created using the `.layer`/`.layerUsingConfig`/... methods on `AsyncHttpClientZioBackend` / `HttpClientZioBackend`. diff --git a/httpclient-backend/zio/src/test/scala/sttp/client3/httpclient/zio/HttpClientZioHttpTest.scala b/httpclient-backend/zio/src/test/scala/sttp/client3/httpclient/zio/HttpClientZioHttpTest.scala index a38a325fb5..fb334853d7 100644 --- a/httpclient-backend/zio/src/test/scala/sttp/client3/httpclient/zio/HttpClientZioHttpTest.scala +++ b/httpclient-backend/zio/src/test/scala/sttp/client3/httpclient/zio/HttpClientZioHttpTest.scala @@ -12,9 +12,8 @@ class HttpClientZioHttpTest extends HttpTest[Task] with ZioTestBase { "compile" - { "SttpClient usage" in { - import _root_.zio.blocking._ val request = basicRequest.post(uri"http://example.com").body("hello") - send(request).provideLayer(Blocking.live >+> HttpClientZioBackend.layer()) + send(request).provideLayer(HttpClientZioBackend.layer()) succeed } } diff --git a/implementations/zio/src/test/scala/sttp/client3/impl/zio/ZioTestBase.scala b/implementations/zio/src/test/scala/sttp/client3/impl/zio/ZioTestBase.scala index 785b30f1f1..9839869b41 100644 --- a/implementations/zio/src/test/scala/sttp/client3/impl/zio/ZioTestBase.scala +++ b/implementations/zio/src/test/scala/sttp/client3/impl/zio/ZioTestBase.scala @@ -1,8 +1,7 @@ package sttp.client3.impl.zio import sttp.client3.testing.ConvertToFuture -import zio.{Exit, Runtime, Task, ZEnv, ZIO} -import zio.blocking.Blocking +import zio.{Exit, Runtime, Task, ZEnv} import scala.concurrent.{Future, Promise} import scala.util.{Failure, Success} @@ -10,8 +9,6 @@ import scala.util.{Failure, Success} trait ZioTestBase { val runtime: Runtime[ZEnv] = Runtime.default - type BlockingTask[A] = ZIO[Blocking, Throwable, A] - val convertZioTaskToFuture: ConvertToFuture[Task] = new ConvertToFuture[Task] { override def toFuture[T](value: Task[T]): Future[T] = { val p = Promise[T]() @@ -29,22 +26,4 @@ trait ZioTestBase { p.future } } - - val convertZioBlockingTaskToFuture: ConvertToFuture[BlockingTask] = new ConvertToFuture[BlockingTask] { - override def toFuture[T](value: BlockingTask[T]): Future[T] = { - val p = Promise[T]() - - runtime.unsafeRunSync(value) match { - case Exit.Failure(c) => - p.complete( - Failure( - c.failures.headOption.orElse(c.defects.headOption).getOrElse(new RuntimeException(s"Unknown cause: $c")) - ) - ) - case Exit.Success(v) => p.complete(Success(v)) - } - - p.future - } - } }