From d9897da2a4a7a16c3cf34a1f26fa87be3580f735 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 25 Sep 2024 08:14:10 +0200 Subject: [PATCH 1/2] Update ox --- .gitignore | 4 +++- build.sbt | 2 +- .../sttp/client4/impl/ox/sse/OxServerSentEvents.scala | 2 +- .../src/test/scala/sttp/client4/impl/ox/ws/OxSseTest.scala | 1 - .../scala/sttp/client4/impl/ox/ws/OxWebSocketsTest.scala | 7 +++++-- 5 files changed, 10 insertions(+), 6 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 fd3eebec09..e1525f68df 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) From a67939bbfd8161f4e54c8f4fe26672275885bce5 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 25 Sep 2024 08:17:59 +0200 Subject: [PATCH 2/2] Update example --- .../scala/sttp/client4/examples/WebSocketOx.scala | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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