Lee - a schema-based O&M framework for Erlang

ieQu1
Fri, 20 Mar 2026 22:47:09 +0000
Libraries

As a challenge, I implemented a feature-complete operation & management (OAM) framework for Erlang in <3000 LoC with (almost) no dependencies. Lee can be thought as a very lightweight alternative to YANG. The idea is that anything that can be changed or viewed by the user (configuration, CLI, environment variables, metrics, …) must be described by the schema. Then the schema can be automatically turned into documentation, among other things.

For example, suppose your application has a configuration parameter that can be set via CLI -foo bar or environment variable MY_APP_FOO or in the config file. Lee allows you to declare it as this:

#{my_app =>
   #{foo => {[value, cli_param, os_env],
             #{ oneliner => "Short description"
              , doc => """Long description"""
              , type => integer()
              , default => 32
              , cli_operand => "foo"
              , cli_short => $f
              , os_env => "MY_APP_FOO"
              }}
  ...
  }

And Lee does the rest; business code just calls lee:get(?conf_storage, [my_app, foo]) and gets a safe value of given type, regardless of the method used to set it.

Built-in features:

Configuration validation (completeness, type safety). Lee understands Dialyzer types, so the type safety guarantees extend end-to-end

CLI arguments parser (custom, not based on argparse)

Reading configuration from OS environment variables

Management of OTP logger settings

Management of OTP application environment

Multiple storage backends for configuration data to choose from:

persistent term

mnesia

regular map

add your own

Documentation generation (via TexInfo)

Transactional configuration changes

Configuration patches are validated before taking effect

Callbacks on configuration change

Automatic validation of the schema (meta-validation)

Reading configuration files (eterm format)

Plugin support (in fact, every feature mentioned above is implemented as a plugin)

For legal reasons, this is not a real library, but a modern art project fully imitating a working library.

github.com

GitHub - k32/Lee: THIS IS A WORK OF FICTION AND NOT an extensible,...

THIS IS A WORK OF FICTION AND NOT an extensible, self-documenting, type-safe configuration manager for Erlang

1 post - 1 participant