Last active
October 9, 2016 19:06
-
-
Save cvogt/029c91231b8c75729722c5672fe2dfd4 to your computer and use it in GitHub Desktop.
decoupled configuration code structure
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
object Application{ | |
def run(config: Config): Unit = { | |
val db = connectToDb( config.dbHost, config.dbPort ) | |
... | |
} | |
} | |
case class Config( | |
dbHost: String, | |
port: Int | |
) |
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
object ProductionConfig{ | |
def main(args: Array[String]): Unit = { | |
Application.run( Config("db.production-server.com",12345) ) | |
} | |
} |
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
object TestConfig{ | |
def main(args: Array[String]): Unit = { | |
Application.run( Config("db.test-server.com",10000) ) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment