-
-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
Problem
Cask has no configuration management. Every app manually reads environment variables with no validation, type safety, or profiles.
// Current - scattered, unsafe, unvalidated
val port = sys.env.getOrElse("PORT", "8080").toInt
val dbUrl = sys.env.getOrElse("DATABASE_URL", "jdbc:sqlite:./app.db")
val secret = sys.env("SECRET_KEY") // Runtime crash if missingSolution
Auto-load application.conf (HOCON) at startup with Lightbend Config.
# application.conf (auto-loaded)
app {
name = "my-app"
server.port = 8080
database.url = ${?DATABASE_URL} # Env override
}// Type-safe, validated at startup
override def port = cask.config.getInt("app.server.port")
val dbUrl = cask.config.getString("app.database.url")Must have
application.confauto-loads at startup- Environment variables override config (
${?VAR}) - Profile loading works (
CASK_ENV=prod) // Show dev/prod profiles - Database examples use config for URLs
- Missing required config fails at startup
- API:
config.getString(),config.getInt(), etc.
Dependency libraries:
com.typesafe:config:1.4.3(~300KB)
Question: Is that fine? or should we use Properties Files (Java built-in) - this comes with lot of limitations: No nesting , All values are strings
References
- Lightbend Config: https://github.com/lightbend/config
- HOCON spec: https://github.com/lightbend/config/blob/main/HOCON.md
Metadata
Metadata
Assignees
Labels
No labels