Using Guice as a dependency injection library in ZIO App

122 Views Asked by At

We are working on migrating our Play! application to ZIO. As a first step, we are checking if we can use the Google Guice as a dependency injection library in ZIO, so that changes could be minimal. It is mentioned here, but I didn't find any resource in the internet which describes the steps in detail with some example.

Any guide/reference would be much appreciated.

1

There are 1 best solutions below

0
On

You can use Guice just as you were before. You will end up with interfaces that will return ZIO effects instead of Futures.

The problem is if you are planning to use ZIO HTTP and other related ZIO libraries, you'll find that they expose their functionality via ZLayers (like ZIO HTTP's server) so you'll end up juggling both layers and Guice modules. I highly recommend formulating ZLayers from your existing Guice modules before migrating to ZIO HTTP.

I recommend having a look at https://www.youtube.com/watch?v=9fr4pWIG-Tw from DevInsideYou for some inspiration - he showcases how you can get ZIO to work with Play which is a good intermediate step.