Skip to content

Instantly share code, notes, and snippets.

@cvogt
Last active October 9, 2016 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvogt/e29ce3c32e2b1558bf865b0b57d0306e to your computer and use it in GitHub Desktop.
Save cvogt/e29ce3c32e2b1558bf865b0b57d0306e to your computer and use it in GitHub Desktop.
configuration managed by the application
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