Skip to content

Instantly share code, notes, and snippets.

@cvogt
Last active October 6, 2016 23:34
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/f1332c5501aec9a549bc9afa40e3eeab to your computer and use it in GitHub Desktop.
Save cvogt/f1332c5501aec9a549bc9afa40e3eeab to your computer and use it in GitHub Desktop.
traditional config file code structure
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) = {
val reader = config_library.ConfigReader( config + “.conf” )
Config(
reader.readString(“db.host”),
reader.readInt(“db.port”)
)
}
}
case class Config(
dbHost: String,
port: Int
)
db.host = db.production-server.com
db.port = 12345
db.host = db.test-server.com
db.port = 10000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment