Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ox to 0.4.0 #2294

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading