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
27
votes
1 answer

Making sense of Scala FP Libraries

Just for the sake of quick clarity for someone who wants to start working with Scala FP library, on a journey to become better at pure FP. Would someone clarify the difference/relation between Cats and Cats-Effect, Cats-Effects IO? On top of that,…
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
11
votes
7 answers

How to test an exception case with zio-test

I have the following function, that I want to test: def people(id: Int): RIO[R, People] This function returns People if there is one for that id, resp. fails if not, like: IO.fail(ServiceException(s"No People with id $id")) The happy case works,…
pme
  • 14,156
  • 3
  • 52
  • 95
9
votes
1 answer

Experiencing deadlocks when using the Hikari transactor for Doobie with ZIO

I'm using Doobie in a ZIO application, and sometimes I get deadlocks (total freeze of the application). That can happen if I run my app on only one core, or if I reach the number of maximum parallel connections to the database. My code looks…
fanf42
  • 1,828
  • 15
  • 22
8
votes
1 answer

Validation and capturing errors using an algebra

I came across this article on medium: https://medium.com/@odomontois/tagless-unions-in-scala-2-12-55ab0100c2ff. There is a piece of code that I have a hard time understanding. The full source code for the article can be found here:…
boggy
  • 3,674
  • 3
  • 33
  • 56
7
votes
1 answer

How to enforce to run ZIO Tests sequentially

I want to run two integration tests sequentially. How can this be achieved in ZIO Test? Here is the Suite: suite("Undeploy a Package")( testM("There is a Package") { PackageDeployer.deploy(pckg) *> // first deploy …
pme
  • 14,156
  • 3
  • 52
  • 95
6
votes
1 answer

Difference in deflate function between Java and C#

I have 2 deflate functions written in C# and Scala, when running with the same input, the returned byte array has a difference in leading bytes and trailing bytes (the difference between the bytes in the middle is expected by the unsigned/signed…
Cypherius
  • 521
  • 2
  • 14
6
votes
1 answer

Is there a way to add a descriptive Assert message in a Boolean ZIO Test

I have a couple of Booleans I want to test, like assert(g8Exists, equalTo(true)) && assert(projectExists, equalTo(true)) && assert(testenvExists, equalTo(true)) ... If one fails, all I get is: false did not satisfy equalTo(true) No clue which line…
pme
  • 14,156
  • 3
  • 52
  • 95
6
votes
2 answers

ZIO: How to join Fibers for Processes that run forever

I have the following ZIO program with two processes that both run forever: for { .. numberProvider <- numberProvider(queue).fork // runs forever numberService <- numberService(queue) // runs forever .. }…
pme
  • 14,156
  • 3
  • 52
  • 95
6
votes
4 answers

How to elegantly perform multiple effects in parallel with ZIO

I know that I can use import zio.Task def zip3Par[A, B, C](a: Task[A], b: Task[B], c: Task[C]): Task[(A, B, C)] = a.zipPar(b).zipWithPar(c) { case ((a, b), c) => (a, b, c) } def zip4Par[A, B, C, D](a: Task[A], b: Task[B], c: Task[C], d:…
Matthias Langer
  • 994
  • 8
  • 22
5
votes
2 answers

Delegate to a more specific Context Bound (additional implicit parameter)

I am trying to create an example of a ZIO Module, that has two implementations: Using YAML with circe-yaml Using HOCON with pureConfig My general Interface looks like this: trait Service[R] { def load[T <: Component](ref: CompRef): RIO[R,…
pme
  • 14,156
  • 3
  • 52
  • 95
5
votes
2 answers

ZIO Fiber orElse generate exception messages

I want to use the combinator orElse on ZIO Fibers. From docs: If the first fiber succeeds, the composed fiber will succeed with its result; otherwise, the composed fiber will complete with the exit value of the second fiber (whether success or…
Aleksey N Yakushev
  • 443
  • 1
  • 3
  • 11
5
votes
3 answers

ZIO Environment construction

I started experimenting with ZIO, and was trying to run the following highly sophisticated program: import logger.{Logger, _} import zio.console._ import zio.{system, _} object MyApp extends App { override def run(args: List[String]): ZIO[ZEnv,…
haspok_adv
  • 53
  • 1
  • 5
5
votes
1 answer

How to share a ZIO Queue between ZIO Tasks via the ZIO Environment

I'm somewhat new to Scala and ZIO and have run into something of an odd puzzle. I would like to setup a ZIO Environment containing a ZIO Queue and later have different ZIO Tasks offer and take from this shared Queue. I tried defining my…
jq170727
  • 13,159
  • 3
  • 46
  • 56
5
votes
0 answers

ZIO interop with Cats on parallel operations

ZIO is not dependent on Cats, so it has its own methods to perform sequence operations: ZIO.sequencePar and ZIO.sequence. I tried to use sequence provided by interop with Cats and it works the same way as ZIO.sequence: import zio._ import…
Bogdan Vakulenko
  • 3,380
  • 1
  • 10
  • 25
5
votes
2 answers

What is the right way to send JSON response in http4s?

Not so long time ago I switched from akka-http to http4s. One of the basic things which I wanted to do correctly — JSON handling, in particular sending a JSON response. I decided to use http4s with ZIO instead of cats, so here is how an http route…
Alex Fruzenshtein
  • 2,846
  • 6
  • 32
  • 53
1
2 3
16 17