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
2
votes
0 answers

Data manipulation with ZIO Stream -- Compiles and runs but does not finish

I created 3 different versions of a data processing mini pipeline. One with Scala Views, one with FS2 and the one with ZIO Streams. The View and FS2 implementation both run and finishing pretty quickly (FS2 being much faster). However, my ZIO…
2
votes
1 answer

Compare ZonedDateTime in ZIO Quill

I'm getting an error trying to filter based on ZonedDateTime using >. It works with ==. I'm using scala 3.2.0 and Quill 4.6.0. It seems it should work based on the Quill Docs. What could be missing? case class Post(id: Long, createdAt:…
TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125
2
votes
1 answer

How do I suppress or redirect (e.g. to a file) Testcontainer output in Testcontainers Scala with ZIO Test?

I am using ZIO 2 and ZIO Test with plain testcontainers-scala. The test looks like this: object MongoRepositorySpec extends ZIOSpecDefault: object TestLayers: val mongoTestcontainer: ZLayer[Any, Throwable, MongoDBContainer] = …
Chris W.
  • 2,266
  • 20
  • 40
2
votes
1 answer

Scala, ZIO - how to return custom response in zio-http?

do you know how I can return custom object as zio-http response? I created simple class: final case class CustomerResponse(id: Int, name: String, age: Int) object CustomerResponse { implicit val responseCodec: Codec[CustomerResponse] =…
Developus
  • 1,400
  • 2
  • 14
  • 50
2
votes
2 answers

How to convert a Cats Effect Resource to ZIO 2 Scopes?

I am trying to use the Cats Mongo implementation (https://github.com/Kirill5k/mongo4cats) in ZIO 2. There is a chapter in ZIO 2's doc (https://zio.dev/guides/interop/with-cats-effect#converting-resource-to-zmanaged-1) how one can convert a Cats…
Chris W.
  • 2,266
  • 20
  • 40
2
votes
0 answers

How to decode this JSON with ZIO JSON?

With the following JSON, how to decode with ZIO JSON? { "substitutions": { "BRANCH_NAME": "main", "COMMIT_SHA": "e40addb0c8d8180ae3a13a470b6f3c56f2e2f29f", "REF_NAME": "main", "REPO_NAME": "data-query-service" } }
Phil
  • 46,436
  • 33
  • 110
  • 175
2
votes
2 answers

How to convert List[zio.Task[List[A]]] to zio.Task[[List[A]]

I need to process a set of Ids and return the result as zio.Task[List[RelevantReadingRow]] def getBaselinesForRequestIds(baseLineReqIds: Set[String]): Task[List[RelevantReadingRow]] = dynamoConnection .run( table.getAll("baseline_req_id"…
2
votes
3 answers

Sending zio http response from callback function

I am trying to play around with ZIO http using their simples hello world example. I have a Java-written service which does some logic, and it expecting a handler function, so it can call it when result is ready. How do I user it together with ZIO…
RB_
  • 1,195
  • 15
  • 35
2
votes
1 answer

Scala with cats exercise Data validation on Kleisli, why my code fails fast instead of accumulating errors?

I'm reading the scala-with-cats book and follow it's exercise. When I come to the case study: data validation, I encounter some problems. Here is my entire code (just the same with the book): package org.scala.ch10.final_recap import…
SkyOne
  • 188
  • 3
  • 15
2
votes
3 answers

Scala, ZIO - how to return value from Task?

I have a simple for-comprehension code: def nameFormatter(request: SomeRequest) : FormattedData = { for { config <- ZIO.fromOption(configuration.get(request.name)).orElseFail( new Exception("Unknown config")) name =…
Developus
  • 1,400
  • 2
  • 14
  • 50
2
votes
1 answer

How to implement fluent interface for scala subtypes?

I can implement nested classes with fluent interfaces in the following fashion: class Animal(name: String, props: Map[String, Any]) { def properties: Map[String, Any] = Map("name" -> name) ++ props def withAge(age: Int): Animal = new…
gurghet
  • 7,591
  • 4
  • 36
  • 63
2
votes
1 answer

ZIO scala sleep method not sleeping the thread vs. using directly Thread.sleep

In my existing Scala code I replaced Thread.sleep(10000) with ZIO.sleep(Duration.fromScala(10.seconds)) with the understanding that it won't block thread from the thread pool (performance issue). When program runs it does not wait at this line…
NKM
  • 602
  • 1
  • 6
  • 18
2
votes
2 answers

Scala, ZIO - how to convert EitherT to ZIO?

I have a simple method signature with returning type as EitherT: def run(someEither: Either[SomeException, Statement], id: String): EitherT[Future, EncodingException, ResultSet] But higher level method has a signature: def someMethod(...) :…
Developus
  • 1,400
  • 2
  • 14
  • 50
2
votes
1 answer

How to compose two Http4s routes with zio effect and different types of environment

I have two Http4s routes: val routes1:HttpRoutes[Task] = ??? val routes2:HttpRoutes[RTask] = ??? Where RTask is just a Task/RIO with a custom environment: type RTask[A] = RIO[Env,A] Composing of two routes with the same type parameters can be…
Bogdan Vakulenko
  • 3,380
  • 1
  • 10
  • 25
2
votes
1 answer

Http4s decoder how to customize error message for invalid fields

I have following code like: case req @ POST -> Root => req .decode[UserCreateRequest] { decodedRequest => my stack is http4s + zio. Ive added custom decoder for this case class where I have a line: email <-…
FrancMo
  • 2,459
  • 2
  • 19
  • 39