From a5c5560279dcfea415ca04a90fa0cc9a6a4bd208 Mon Sep 17 00:00:00 2001 From: Adam Warski Date: Wed, 25 Sep 2024 08:30:04 +0200 Subject: [PATCH] Update ox to 0.4.0 (#2294) --- .gitignore | 4 +++- build.sbt | 2 +- .../sttp/client4/impl/ox/sse/OxServerSentEvents.scala | 2 +- .../scala/sttp/client4/impl/ox/ws/OxSseTest.scala | 1 - .../sttp/client4/impl/ox/ws/OxWebSocketsTest.scala | 7 +++++-- .../scala/sttp/client4/examples/WebSocketOx.scala | 11 ++++------- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index c3e7efc778..9d9dd33ac9 100644 --- a/.gitignore +++ b/.gitignore @@ -24,11 +24,13 @@ core/native/local.sbt .metals/ .bloop/ -project/metals.sbt .bsp/ .java-version +metals.sbt .vscode # scala-native lowered.hnir + +work.txt \ No newline at end of file diff --git a/build.sbt b/build.sbt index a92668fec4..a30eb8a6b6 100644 --- a/build.sbt +++ b/build.sbt @@ -150,7 +150,7 @@ val zio2Version = "2.1.9" val zio1InteropRsVersion = "1.3.12" val zio2InteropRsVersion = "2.0.2" -val oxVersion = "0.2.0" +val oxVersion = "0.4.0" val sttpModelVersion = "1.7.11" val sttpSharedVersion = "1.3.22" diff --git a/effects/ox/src/main/scala/sttp/client4/impl/ox/sse/OxServerSentEvents.scala b/effects/ox/src/main/scala/sttp/client4/impl/ox/sse/OxServerSentEvents.scala index b5b19c8270..4d595d8d5c 100644 --- a/effects/ox/src/main/scala/sttp/client4/impl/ox/sse/OxServerSentEvents.scala +++ b/effects/ox/src/main/scala/sttp/client4/impl/ox/sse/OxServerSentEvents.scala @@ -7,7 +7,7 @@ import sttp.model.sse.ServerSentEvent import java.io.InputStream object OxServerSentEvents: - def parse(is: InputStream)(using Ox, IO): Source[ServerSentEvent] = + def parse(is: InputStream)(using Ox): Source[ServerSentEvent] = Source .fromInputStream(is) .linesUtf8 diff --git a/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxSseTest.scala b/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxSseTest.scala index 1bacd78f37..a8e6af2da8 100644 --- a/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxSseTest.scala +++ b/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxSseTest.scala @@ -4,7 +4,6 @@ import org.scalatest.BeforeAndAfterAll import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import ox.* -import ox.IO.globalForTesting.given import sttp.client4.* import sttp.client4.testing.HttpTest.* import sttp.model.sse.ServerSentEvent diff --git a/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxWebSocketsTest.scala b/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxWebSocketsTest.scala index 8f8de78a77..b739f217e5 100644 --- a/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxWebSocketsTest.scala +++ b/effects/ox/src/test/scala/sttp/client4/impl/ox/ws/OxWebSocketsTest.scala @@ -164,10 +164,13 @@ class OxWebSocketTest extends AnyFlatSpec with BeforeAndAfterAll with Matchers w } def sendText(wsSink: Sink[WebSocketFrame], count: Int)(using Ox): Unit = - Source.fromIterable(1 to count).map(i => WebSocketFrame.text(s"test$i")).pipeTo(wsSink) + Source.fromIterable(1 to count).map(i => WebSocketFrame.text(s"test$i")).pipeTo(wsSink, propagateDone = true) def sendBinary(wsSink: Sink[WebSocketFrame], count: Int)(using Ox): Unit = - Source.fromIterable(1 to count).map(i => WebSocketFrame.binary(Array(i.toByte))).pipeTo(wsSink) + Source + .fromIterable(1 to count) + .map(i => WebSocketFrame.binary(Array(i.toByte))) + .pipeTo(wsSink, propagateDone = true) def receiveEchoText(wsSource: Source[WebSocketFrame], count: Int): Unit = for (i <- 1 to count) diff --git a/examples3/src/main/scala/sttp/client4/examples/WebSocketOx.scala b/examples3/src/main/scala/sttp/client4/examples/WebSocketOx.scala index 4efc367e94..452bfd6fea 100644 --- a/examples3/src/main/scala/sttp/client4/examples/WebSocketOx.scala +++ b/examples3/src/main/scala/sttp/client4/examples/WebSocketOx.scala @@ -10,16 +10,13 @@ import sttp.ws.WebSocketFrame @main def wsOxExample = def useWebSocket(ws: SyncWebSocket): Unit = - supervised { + supervised: val inputs = Source.fromValues(1, 2, 3).map(i => WebSocketFrame.text(s"Frame no $i")) val (wsSource, wsSink) = asSourceAndSink(ws) - fork { - inputs.pipeTo(wsSink) - } - wsSource.foreach { frame => + fork: + inputs.pipeTo(wsSink, propagateDone = true) + wsSource.foreach: frame => println(s"RECEIVED: $frame") - } - } val backend = DefaultSyncBackend() try