Last active
April 5, 2022 07:04
-
-
Save supermanue/14823088714d5a43e8fb013040d76b7b to your computer and use it in GitHub Desktop.
Zlayer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val live: ZLayer[DBTransactor, Throwable, UserPersistence] = | |
ZLayer.fromService(new DoobiePersistenceService(_)) | |
val transactorLive: ZLayer[Has[DbConfig] with Blocking, Throwable, DBTransactor] = | |
ZLayer.fromManaged(for { | |
config <- configuration.dbConfig.toManaged_ | |
connectEC <- ZIO.descriptor.map(_.executor.asEC).toManaged_ | |
blockingEC <- blocking.blocking { ZIO.descriptor.map(_.executor.asEC) }.toManaged_ | |
transactor <- mkTransactor(config, connectEC, blockingEC) | |
} yield transactor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment