Skip to content

Instantly share code, notes, and snippets.

@supermanue
Last active April 5, 2022 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermanue/14823088714d5a43e8fb013040d76b7b to your computer and use it in GitHub Desktop.
Save supermanue/14823088714d5a43e8fb013040d76b7b to your computer and use it in GitHub Desktop.
Zlayer
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