Skip to content

Commit

Permalink
Update ox to 0.4.0 (#2294)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw authored Sep 25, 2024
1 parent 838913b commit a5c5560
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions examples3/src/main/scala/sttp/client4/examples/WebSocketOx.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a5c5560

Please sign in to comment.