Skip to content

Repository files navigation

Python Microservice configuration module

CircleCI

Configuration module for microservices written on Python. Specially created for follow up corporate standards of application configuration.

Installation

pip3 install config_pkg

Usage

By default path to configuration directory and application stage loading from /configuration with defaults stage.

  1. Simple
fromconfig_pkgimportPKGpkg=PKG()
pkg.load()
all_config=pkg.get_all()
foo_bar=pkg.get('foo.bar')
  1. If u would like override default values, you can pass 2 arguments to class constructor or set up use setters.
fromconfig_pkgimportPKGpkg=PKG('/configuration', 'test')
pkg.load()
foo_bar=pkg.get('key') # full example on the top
  1. If the operating system has an env variables CONFIG_PATH and STAGE, then values for the package will be taken from there.
export CONFIG_PATH=/configuration
export STAGE=test
fromconfig_pkgimportPKGpkg=PKG()
pkg.load() # loaded files from /configuration for prod stage.foo_bar=pkg.get('key') # full example on the top
  1. If u want to see logs and see how load process working, pass you application logger to the following method:
fromconfig_pkgimportPKGpkg=PKG(logger=logger) # loggining.Logger compatible loggerpkg.load() foo_bar=pkg.get('key') # full example on the top

That all.

Depends

  • Python 3.x
  • pip for install package

License

MIT

About

Configuration module for microservices written on Python. Specially created for follow up corporate standards of application configuration.

Topics

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages