Skip to content

Application configuration management #183

@vim89

Description

@vim89

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 missing

Solution

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.conf auto-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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions