Skip to content

Instantly share code, notes, and snippets.

@adamw
Created June 2, 2020 13:55
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 adamw/1940e3005c501ea0d196bfb7a4ddbd47 to your computer and use it in GitHub Desktop.
Save adamw/1940e3005c501ea0d196bfb7a4ddbd47 to your computer and use it in GitHub Desktop.
import zio._
object Main extends App {
override def run(args: List[String]): ZIO[zio.ZEnv, Nothing, ExitCode] = {
ConnectionPoolIntegration
.managedConnectionPool(DBConfig("jdbc://localhost"))
.use { cp =>
lazy val db = new RelationalDB(cp)
lazy val userModel = new DefaultUserModel(db)
lazy val userRegistration = new UserRegistration(DefaultUserNotifier, userModel)
userRegistration.register(User("adam", "adam@hello.world"))
}
.catchAll(t => ZIO.succeed(t.printStackTrace()).map(_ => ExitCode.failure))
.map { u =>
println(s"Registered user: $u (constructors)")
ExitCode.success
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment