Skip to content

Using @decorator

Default values

For use cases where environment variables are set.

from config.spring import config_client


@config_client(app_name='myapp')
def my_test(config_client=None):
    print(config_client.config['spring']['cloud']['consul']['host'])
    print(config_client.config.get('spring').get('cloud').get('consul').get('port'))
    print(config_client.get_attribute('spring.cloud.consul.port'))

Using custom values

For use cases where environment variables are not set can you use decorator parameters, as example below:

from config.spring import config_client


@config_client(app_name='myapp', branch="dev", timeout=5.0)
def my_test(config_client=None):
    print(config_client.config['spring']['cloud']['consul']['host'])
    print(config_client.config.get('spring').get('cloud').get('consul').get('port'))
    print(config_client.get_attribute('spring.cloud.consul.port'))