Last active
October 6, 2016 23:34
-
-
Save cvogt/f1332c5501aec9a549bc9afa40e3eeab to your computer and use it in GitHub Desktop.
traditional config file code structure
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) = { | |
val reader = config_library.ConfigReader( config + “.conf” ) | |
Config( | |
reader.readString(“db.host”), | |
reader.readInt(“db.port”) | |
) | |
} | |
} | |
case class Config( | |
dbHost: String, | |
port: Int | |
) |
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
db.host = db.production-server.com | |
db.port = 12345 |
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
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