conferer: Configuration management library

[ configuration, library, mpl ] [ Propose Tags ]

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


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.4.1.0, 0.4.1.1, 1.0.0.0, 1.0.0.1, 1.1.0.0
Dependencies base (>=4.3 && <5), bytestring (>=0.10 && <0.11), 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 2019-09-22T06:38:50Z
Distributions LTSHaskell:1.1.0.0, NixOS:1.1.0.0, Stackage:1.1.0.0
Reverse Dependencies 13 direct, 0 indirect [details]
Downloads 4541 total (53 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-09-22 [all 1 reports]

Readme for conferer-0.1.0.4

[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