conferer: Configuration management library

[ bsd3, configuration, library ] [ Propose Tags ]

Library to abstract the parsing of many haskell config values from different config sources


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4
Dependencies base (>=4.3 && <5), bytestring (==0.10.*), containers (>=0.5 && <0.7), directory (>=1.2 && <2.0), text (>=1.1 && <1.3) [details]
License BSD-3-Clause
Copyright MIT
Author Lucas David Traverso
Maintainer lucas6246@gmail.com
Category Configuration
Home page https://github.com/ludat/conferer#readme
Uploaded by ludat at Mon Sep 2 05:37:13 UTC 2019
Distributions NixOS:0.1.0.4
Downloads 387 total (56 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-09-02 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for conferer-0.1.0.1

[back to package description]

Conferer

what, why and a bit of how

VERY UNSTABLE DON'T USE IN PRODUCTION JUST YET

Conferer is a library that defines ways to get configuration for your Haskell application and the libraries it uses, which is at heart string keys which map to other strings.

To get this map we use Providers which define a way to get a key (eg. db.username) that may or may not exist, we then use a list of providers for getting the value for that key (position on the list defines priority). This allows adding new providers easily (for example a dhall file provider, a git repo or a etcd database)

The other side of this is that we have the FromConfig which gets some value from a Config at a certain key possibly using only keys under some namespacing key

Example (not implemented)

Let's say I want to configure warp. Let's say we wrote this program.

main = do
  -- by default gets cli parameters, envvars and json file
  config <- getDefaultConfigFor "awesomeapp"
  warpConfig :: Warp.Settings <- getKey "warp" config

  Warp.runSettings warpConfig myApp

Now I need to chage the port of the app, I can change it by either:

  • Setting cli params like ./myApp -Cwarp.port=5555
  • Setting an environment variable called AWESOMEAPP_WARP_PORT=5555
  • In a json file you can have {"warp": {"port": 5555}}

And you may also get that value from different configuration providers like redis or etc or whichever you may need.

Utilities

There are as well some utilities to change providers:

  • Conferer.Provider.Namespace: All keys must be namespaced and the namespace is striped for lookup
  • Conferer.Provider.Mapped: Using a map key to maybe key you can change the name of a key or even hiding some key
  • Conferer.Provider.Simple: Get keys from a hardcoded map key to string

Future maybe things

  • Interpolate keys with other keys: {a: "db", b: "${a}_thing"}, getting b will give "db_thing" (maybe)
  • A LOT of providers
  • A LOT of FromConfig implementations
  • Docs