Skip to content

Instantly share code, notes, and snippets.

@xerial
Last active July 15, 2018 23:53
Show Gist options
  • Save xerial/0b6b18b721c1b0b323ae85e418090bb5 to your computer and use it in GitHub Desktop.
Save xerial/0b6b18b721c1b0b323ae85e418090bb5 to your computer and use it in GitHub Desktop.
// New Services
class WebApp(webAppConfig:WebAppConfig, component:WebComponent)
class WebComponent(service:Service)
// Pack configuration set in a class
case class ConfigSet(serviceConfig:ServiceConfig, webAppConfig:WebAppConfig)
// Read configurations from a YAML file
def readConfig: ConfigSet = {
val yaml = readConfig("config.yml")
val serviceConfig = new ServiceConfig(yaml.get(...), yaml.get(..))
val webAppConfig = new WebAppConfig(...)
ConfigSet(serviceConfig, webAppConfig)
}
// Initialize services
val configSet = readConfig
val service = new Service(configSet.serviceConfig)
val webComponent = new WebComponent(service)
val webApp = new WebApp(configSet.webAppConfig, webComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment