A configuration is a list of key-value string pairs.
Reading configuration
Using the schema validator conformist it is easy to validate and decode configuration values. Conformist schemas can express a richer set of requirements than static types, which can be used in services to validate configurations at start time.
Validating configuration when starting services can lead to run-time exceptions, but they occur early in the app lifecycle. This minimizes the feedback loop and makes sure, that services start only with valid configuration.
val read : (unit, 'ctor, 'ty)Conformist.t->'ty
read schema returns the decoded, statically typed version of configuration t of the schema. This is used in services to declaratively define a valid configuration.
The configuration data t is merged with the environment variable and, if present, an .env file.
It fails with Exception and prints descriptive message of invalid configuration.
val read_string : string ->string option
read_string key returns the configuration value with key if present. The function is memoized, the first call caches the returned value and subsequent calls are fast.
val read_int : string ->int option
read_int key returns the configuration value with key if present. the first call caches the returned value and subsequent calls are fast.
val read_bool : string ->bool option
read_bool key returns the configuration value with key if present. the first call caches the returned value and subsequent calls are fast.
val is_testing : unit -> bool
is_testing () returns true if SIHL_ENV is set to testing.