Skip to main content

config service client

Project description

Build Status Maintainability codecov PyPI version

config-client

config-client package for spring cloud config.

Installing

Install and update using pip:

pip install -U config-client

Dependencies

Setup

config server url pattern:

  • http://<config_server>:<config_server_port>/configuration/<branch>/<app_name>-<profile>.json
# expected environment variables:
#
CONFIGSERVER_ADDRESS=http://configserver:8888/configuration
BRANCH=master
PROFILE=development
APP_NAME=myapp

will result in:

http://configserver:8888/configuration/master/myapp-development.json

Default values

if no value was adjusted for the environment variables below, the default value will be assumed, as:

CONFIGSERVER_ADDRESS=http://localhost:8888/configuration
BRANCH=master
PROFILE=development
APP_NAME=

Usage Example

using standard client

from config.spring import ConfigServer

config_client = ConfigServer()
config_client.config['spring']['cloud']['consul']['host']
config_client.config.get('spring').get('cloud').get('consul').get('port')

standard client with @decorator

from config import spring

@spring.config_client
def my_test(config_client):
config_client.config['spring']['cloud']['consul']['host']
config_client.config.get('spring').get('cloud').get('consul').get('port')

Integration with Flask.

from config.spring import ConfigServer
from flask import Flask


config_client = ConfigServer()
app = Flask(__name__)
app.run(host='0.0.0.0',
        port=config_client.config['app']['port']

using asyncio

client using asyncio

import asyncio
from config.spring import ConfigServer


loop = asyncio.get_event_loop()
config_client = ConfigServer()

async def service_discovery():
    await discovery_client.register(config_client.config['app']['name'],
                                    config_client.config.get('app').get('port'))

discovery_client = Consul(config_client.config['spring']['cloud']['consul']['host'],
                          config_client.config['spring']['cloud']['consul']['port'],
                          loop)
loop.run_until_complete(service_discovery)

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

config-client-0.2.1.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

config_client-0.2.1-py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page