Created
June 2, 2020 13:55
-
-
Save adamw/1940e3005c501ea0d196bfb7a4ddbd47 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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", "[email protected]")) | |
} | |
.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