Last active
October 9, 2016 19:05
-
-
Save cvogt/e29ce3c32e2b1558bf865b0b57d0306e to your computer and use it in GitHub Desktop.
configuration managed by the application
This file contains 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 main(args: Array[String]): Unit = { | |
val config = Config.get( args(0) ) | |
val db = connectToDb( config.dbHost, config.dbPort ) | |
... | |
} | |
} | |
object Config{ | |
def get(config: String) = { | |
config match { | |
case "test" => Config("db.test-server.com",10000) | |
case "production" => Config("db.production-server.com",12345) | |
case _ => throw new Exception("unknown config: "+config) | |
} | |
} | |
} | |
case class Config( | |
dbHost: String, | |
port: Int | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment