Skip to content

Instantly share code, notes, and snippets.

@novakov-alexey-zz
Created November 1, 2018 12:34
Show Gist options
  • Save novakov-alexey-zz/e15d4c1cde5b69a436a5f91b6cd85995 to your computer and use it in GitHub Desktop.
Save novakov-alexey-zz/e15d4c1cde5b69a436a5f91b6cd85995 to your computer and use it in GitHub Desktop.
class Module(createSchema: Boolean = true, cfg: Config = ConfigFactory.load())(
implicit system: ActorSystem,
executionContext: ExecutionContext
) extends StrictLogging {
val db = Database.forConfig("storage", cfg)
val dao = new TripDao(db)
val service = new TripService(dao)
val routes: Route = concat(QueryRoutes.routes(service), CommandRoutes.routes(service))
if (createSchema) _createSchema()
private def _createSchema(): Unit =
dao.createSchema().failed.foreach(t => logger.error(s"Failed to create schema: $t"))
def close(): Unit = db.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment