Fixes #21825: Port code to ZIO2
https://issues.rudder.io/issues/21825
As explained in the ticket, we have a very useful migration from where you copy&past things: https://zio.dev/guides/migrate/zio-2.x-migration-guide/
Main anoying/unintersting changes:
- there is a bug in zio-json (https://github.com/zio/zio-json/issues/622) that forces us to not use codec (see ExpectedReports.scala)
- lots of renaming, the most pervasive being
.effectto.attempt. Good to understand, bad for future merge. For consistency, I also renamedIOResult.effectintoIOResult.attemp - lots of others little renaming things like no more
UIO.unitbutZIO.unit,RefMintoRef.Synchronized, all.xxxMmethods into.xxxZIOmethods, etc. - A bit more involving, no more
ManagedbutZIO.scope(...).flatMap(...)and no morebracketbutZIO.acquireReleaseWith ziopackage as aSystemobject, so we need toimport zio.{System => _, _}to avoid conflict withjava.lang.System- no more
zio.duration._package, the implicits for.secondsetc are inzio._ - parallelism in traverse is not
.foreachParN(...)(N)anymore but.foreach(...).withParallelism(N) - queue method getAll etc returns
Chunkso it's simpler to use chunk elsewhere around them
More interesting:
untracedis not needed anymore: trace information are compile-time now and have almost not overhead at runtime- no need to pass
clockaround, they are now part ofZIObased effects always here. It's also much more easier to access it for sleeping (see for ex Scheduler.scala
The amazing
- they corrected https://github.com/zio/zio/issues/1275 which means that WE DON'T HAVE TO CARE ANYMORE IF THINGS BLOCK! ZIO will try to do everything non-blocking and migrate the blocking effects in a dedicated threadpool. We can advise it, but it learn by itself what methods block and what don't! So we gain:
- no more deadlock due to blocking effects that we didn't know about (rare case now for us, since by default, we told that everything was blocking -see https://github.com/Normation/rudder/pull/4507/files#diff-d4590d1d8c70916376ea07260ff5f905f68f324e53b5298c5e9038fbe913fc15R95)
- no more special case for hotpoint, like LDAPConnectionProvider.scala
- hopefully more consistant performance after a warm-up
And finally, the rewrite of CronParser.scala was kindly provided on ZIO chan.
We were lucky to not be using the IoC/Has framework which changed A LOT. Streams, too. All in all, the port is rather simple and for the hardest part, the community was extremelly helpfull.
PR updated with a new commit
PR updated with a new commit
PR updated with a new commit
PR updated with a new commit
Tested on the load platform. No obvious perf improvment or degradation; policy generation seems ~5% faster, dynamic group computation time has less variability
Tested on the load platform. No obvious perf improvment or degradation; policy generation seems ~5% faster, dynamic group computation time has less variability
amazing! (it is, because I removed all the hand-optimisation of effect/effectBlocking cherry picking, especially the one on LDAPConnection without which we were able to run rudder on the load plateform)
PR updated with a new commit
PR rebased
PR rebased
OK, merging this PR