Skip to main content

Get proj config args from redis

Project description

config-redis

config-redis is a python library for get project config from redis and don't show your config details in the project.

Installation

1.Use the package manager pip to install Proj_config.

pip install config-redis

2.Install redis-server.

3.Set environment variables from command line.

export CONF_FOR_REDISCONF="{'host': '172.0.0.1', 'port': 6379, 'db': 0, 'password': 'your_password', 'decode_responses': True}" :$CONF_FOR_REDISCONF

Usage

1.setup your config

your_proj/setting.py
from configredis.setconf import devconfig, proconfig, configs, ConfigArgs

con = ConfigArgs()

devconfig(
    disk_name="Ten",
    sentry=False,
    celery_broker="amqp://user:password@0.0.0.0:5672//",
)

proconfig(
    sentry=True,
    celery_broker="amqp://user:password@172.0.0.1:5672//",
)

config = configs()

2.Use upsert_config_to_redis func update or insert current config to redis. lookup_proj_config func to check the config in redis.

your_proj/setting.py
from configredis.setconf import ConfigUpdate, lookup_proj_config

ConfigUpdate.upsert_config_to_redis()  # update or insert current config to redis.

print(lookup_proj_config())  # show current project config

3.After write the project config to redis then your can chenge setting.py as below.

your_proj/setting.py
from configredis.setconf import devconfig, proconfig, configs, ConfigArgs

con = ConfigArgs()

devconfig(
    disk_name=con['dev']['disk_name'],
    sentry=con['dev']['sentry'],
    celery_broker=con['dev']['celery_broker'],
)

proconfig(
    sentry=con['pro']['sentry'],
    celery_broker=con['pro']['celery_broker'],
)

config = configs()

if __name__ == '__main__':
    print(config)

4.Run your project as config from command line.

python sample.py pro/dev

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the tests as appropriate.

License

MIT

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-redis-0.2.5.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

config_redis-0.2.5-py2.py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 2 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