Questions tagged [zio]

ZIO is a zero-dependency Scala library for asynchronous and concurrent programming with similar features as Cats IO or Monix.

ZIO — A type-safe, zero-dependency library for asynchronous and concurrent programming in Scala.

Homepage: https://zio.dev/

241 questions
5
votes
1 answer

Zio run blocking backwardscompatible code

(Hopefully) simple question on Scalaz Zio. I have some old code that I refactored to Zio. I want one path of that code to keep behaving exactly as it was: synchronous blocking on the current thread (this is a hard requirement) How can I run an…
Lodewijk Bogaards
  • 19,777
  • 3
  • 28
  • 52
5
votes
2 answers

Scalajs & scala ZIO

Does scala.js work with scala ZIO? I'm looking to use scala ZIO with scala.js I only know how to use scala ZIO in normal apps does anyone know how to use it with scala.js?
NaseemMahasneh
  • 485
  • 5
  • 19
4
votes
2 answers

zio-http (ZIO 2.x) application not starting with Scala 3

I have this simple application: import zhttp.http.* import zhttp.http.Method.GET import zhttp.service.Server import zio.* object HexAppApplication extends ZIOAppDefault { // Create HTTP route val app: HttpApp[Any, Nothing] =…
codependent
  • 23,193
  • 31
  • 166
  • 308
4
votes
0 answers

How can i build batch the request and understand the response with help ZStream (ZIO)?

I have api that gets such request: case class UsersRequest(ids: List[Long]) and returns such response: case class UsersInfoResponse(info: List[Info]) case class Info(userId: Long, info: String) also, i have methods that send this request and…
Vlad
  • 41
  • 1
4
votes
2 answers

How do I assert that an Option contains something in zio-test?

I tried assert(anOption)(contains("x")) But that only works for Iterables such as List or Seq.
Thilo
  • 257,207
  • 101
  • 511
  • 656
4
votes
2 answers

Integration testing an HTTP server with ZIO test suite

I am trying to figure out the idiom for writing an integration test for an Http4s app that supports two end points. I'm starting the Main app class in a ZManaged by forking it on a new fiber and then doing interruptFork on release of the ZManaged. I…
arinray
  • 178
  • 1
  • 12
4
votes
1 answer

Building a ZIO and http4s app, works with sbt, fails with Bazel: missing an implicit

I'm attempting to build a service that integrates ZIO and http4s. The starting point is this example (it uses zio 1.0.1, http4s 0.21.3, scala 2.12.11) I was able to build the code below without any problems using sbt, but am running into trouble…
Shastick
  • 1,218
  • 1
  • 12
  • 29
4
votes
1 answer

What do parameters to throttleShape mean?

zio-streams provides throttleShape which /** * Delays the chunks of this stream according to the given bandwidth parameters using the token bucket * algorithm. Allows for burst in the processing of elements by allowing the token bucket to…
Mario Galic
  • 47,285
  • 6
  • 56
  • 98
4
votes
1 answer

How to ignore a Suite or a Test in ZIO Test?

I could not find anything on how to ignore a Suite or a Test with ZIO Test. Whether in an example nor in the documentation (https://zio.dev/docs/usecases/usecases_testing) There is an ignored in the test package object: /** * Creates an ignored…
pme
  • 14,156
  • 3
  • 52
  • 95
4
votes
2 answers

How can I implement loops that don't use potentially very large amounts of heapspace in ZIO

I know that ZIO is maintains its own stack, namely zio.internal.FiberContext#stack, which protects recursive functions like def getNameFromUser(askForName: UIO[String]): UIO[String] = for { resp <- askForName name <- if (resp.isEmpty)…
Matthias Langer
  • 994
  • 8
  • 22
4
votes
1 answer

Scala ZIO.bracket: handling errors of releasing resource

I want to create a directory, then do something with the directory and finally delete it. I'm using a bracket idiom for that. val fs: FileSystem = ??? val path = ??? ZIO.bracket[Any, Throwable, Path, Unit]( acquire = ZIO{fs.mkdirs(path); path}, …
simpadjo
  • 3,947
  • 1
  • 13
  • 38
4
votes
2 answers

ZIO : How to compute only once?

I am using ZIO: https://github.com/zio/zio in my build.sbt: "dev.zio" %% "zio" % "1.0.0-RC9" No matter what I tried, my results are always being computed each time I need them: val t = Task { println(s"Compute") 12 } val r = unsafeRun(for…
Wonay
  • 1,160
  • 13
  • 35
3
votes
0 answers

How to merge two stream and sort them in zio streams

Like akka-stream's mergeSorted. It's very useful when process history data and keep the time order. What's the replacement in zio-streams?
Lin Lee
  • 213
  • 2
  • 8
3
votes
2 answers

Collect all of the successes and failures of a sequence of ZIOs together?

I have a bunch of IOs, all of which may have either succeeded or failed: val result: Seq[IO[MyFailure, MySuccess]] = ... I need to summarize the results such that I can examine all the failures and all the successes together: case class…
Cory Klein
  • 51,188
  • 43
  • 183
  • 243
3
votes
2 answers

How can I encode None to missing json field using zio-json instead of null?

Let's say I have a case class with the optional field nickName and codec like this: final case class Person(name: String, nickName: Option[String]) object Person { implicit val personCodec: JsonCodec[Person] = DeriveJsonCodec.gen } I want to…
mkUltra
  • 2,828
  • 1
  • 22
  • 47
1
2
3
16 17