Created
November 1, 2018 12:34
-
-
Save novakov-alexey-zz/e15d4c1cde5b69a436a5f91b6cd85995 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
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