Code Monkey home page Code Monkey logo

toml_config's Introduction

TOML Config Provider

Build Status Coverage Status Hex.pm

A config provider to read TOML configuration files that works with Elixir (1.9+) releases.

Note: If you are building releases with Distillery, you can use the config provider from the toml-elixir library.

Prerequisites

  • Elixir >= 1.9

Installation

The package can be installed by adding toml_config to your list of dependencies in mix.exs:

def deps do
  [
    {:toml_config, "~> 0.1", only: :prod}
  ]
end

Usage

Update the release configuration in your mix.exs file:

You can either give a fully qualified pathname to the config file.

releases: [
  my_app: [
    config_providers: [
      {TomlConfigProvider, path: "/absolute/path/to/my/config.toml"}
    ],
    ...
  ]
]

Or you can read the config directory or path from a specified environment variable. Booting the application fails if the specified environment variable is undefined.

releases: [
  my_app: [
    config_providers: [
      {TomlConfigProvider,
       path: {:system, "RELEASE_CONFIG_DIR", "my_app.toml"}}
    ],
    ...
  ]
]

Or:

releases: [
  my_app: [
    config_providers: [
      {TomlConfigProvider, path: {:system, "RELEASE_CONFIG_PATH"}}
    ],
    ...
  ]
]

All config provider options except :path are forwarded to Toml.decode_file/2 from the toml-elixir library. Thus, you can also provide custom transforms.

config_providers: [
  {TomlConfigProvider,
   path: "path/to/my/config.toml",
   transforms: [UrlTransform, TupleTransform]}
]

Other Implementations

toml Config Provider

The toml package brings it's own config provider that unfortunately only works with distellery releases at the moment.

toml_config_provider

Unlike toml_config_provider, this library allows specifying the location of the config file through environment variables. This is quite useful when you have multiple (slightly different) instances of a release running on the same machine, such as staging and production environments. Additionally, we allow custom transform modules.

Docs

Documentation can be generated with ExDoc and is published on HexDocs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.