clyfe / config

Configure a system using YAML or EDN files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Config - Smart and flexible system configuration

Clojars Project

Config is a very small library used to handle configuration of a server; it works quite well with a system defined in terms of Stuart Sierra’s component library.

This posting provides a lot of detail on the requirements and capabilities of config.

Config reads a series of files, primarily from the classpath. The files contain contain configuration data, in either YAML or EDN format.

The files are read in a specific order, based on a set of profiles. The name of the file to read is based on the profile.

The contents of all the files are converted to Clojure maps (with keyword keys) and are deep-merged together.

Meanwhile, a set of schemas are merged together, and used to validate and coerce the data read from the individual configuration files.

The intent of profiles is that there is an approximate mapping between components and profiles. Each component will provide a schema (for validation and coercion) and profiles are used to ensure the correct configuration data is read.

But what about the 12 Factor App's guideline to store configuration only as environment variables? This is embraced by config, because the files may contain environment variable references that are expanded at runtime, before parsing of the file content.

At Aviso, we use these features in a number of ways. For example, for quick testing we combine a number of microservices (each of which has its own configuration profile and schema) together into a single system, and specify a large set of profiles. Meanwhile, in production (on AWS) we can build a smaller system with a single microservice, and single profile. We can also provide an additional configuration file that enables configuration overrides based on environment variables set by CloudFormation.

Config is easily extensible to override how configuration files are named, and to support types of configuration files (by adding new extensions and parsers).

Config is available under the terms of the Apache Software License 2.0.

About

Configure a system using YAML or EDN files

License:Apache License 2.0


Languages

Language:Clojure 100.0%