Skip to main content

Default Configs

Default Configs is the set of all possible configuration keys of your application along with their default values. One may think of default configs as the best assumption we can make about our configs.

Every default config is defined by two properties:

  • Schema - the type of the config value enforced by JSONSchema
  • Default value - the base value for the config key

Default Configs

Configuration keys with type safety and default values

per_km_rate
type
{ "type": "number" }
default value
10
surge_factor
type
{ "type": "number", "minimum": 1.0 }
default value
1.0
payment_url
type
{ "type": "string", "pattern": "^https://" }
default value
"https://pay.juspay.io"

Type schema validates every config change before it goes live

Let us use a simple cab ride-hailing application that operates in different cities and capture some attributes that we might need configurable at a per city level.

  1. per_distance_unit_rate
  2. surge_factor

CAC supports configurations written using the TOML format. This section and the following sections will use the TOML format to illustrate each abstraction.

[default-configs]
per_km_rate = { "value" = 20.0, "schema" = { "type" = "number" } }
surge_factor = { "value" = 0.0, "schema" = { "type" = "number" } }

Correctness with Functions

Two functions that can be linked with default configs to ensure correctness:

  • Value Validation
  • Value Compute

To learn more about these, check out functions