config service client
Project description
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')
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
- License: Apache License
- Code: https://github.com/amenezes/config-client
- Issue tracker: https://github.com/amenezes/config-client/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size config_client-0.1.0-py3-none-any.whl (7.3 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size config-client-0.1.0.tar.gz (3.0 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for config_client-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a6b8e2cbf4ad2776e529b7618e856ebfeb62bb092828d92d17d3f29e76f9efb |
|
MD5 | e795254ae776771e786e970dd7318af8 |
|
BLAKE2-256 | 91bdb098c41c04fa4a4e639d8f79f91a0a7305e0581cd885d2af8eb1f520f33e |