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@172.0.0.1: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 upsert_config_to_redis, lookup_proj_config

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.1.4.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

config_redis-0.1.4-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file config-redis-0.1.4.tar.gz.

File metadata

  • Download URL: config-redis-0.1.4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for config-redis-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a517ce49aa38aec4c89998dbd5fb684985e9f530465ed8ff3ced370601f95f77
MD5 06739387ab88aa949c1e28d0d6bb0c14
BLAKE2b-256 c8c22a5216087910ab57e9c2c777ad29afaed6fadc6f2982ba1c01fd43e4c851

See more details on using hashes here.

File details

Details for the file config_redis-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: config_redis-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for config_redis-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4e85b402ddf8b81af92ce0f58b5ce744508ff6244dcd244519264da9ee097ef4
MD5 69e5290d5427f26ff622cc14d6f2abba
BLAKE2b-256 8ffa1805324f50c3922959acfc1430b7e5a9347074eb8e2ded406b503f8b59dc

See more details on using hashes here.

Supported by

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