{"id":13494870,"url":"https://github.com/Fatal1ty/consul-options","last_synced_at":"2025-03-28T15:32:06.023Z","repository":{"id":57417547,"uuid":"83413534","full_name":"Fatal1ty/consul-options","owner":"Fatal1ty","description":"Framework for using Consul as your project options storage","archived":false,"fork":false,"pushed_at":"2017-11-08T08:11:07.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-25T21:55:50.485Z","etag":null,"topics":["configuration","configuration-management","consul","consul-kv","options","options-framework","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fatal1ty.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-28T09:22:03.000Z","updated_at":"2022-09-14T23:59:56.000Z","dependencies_parsed_at":"2022-08-30T16:43:40.969Z","dependency_job_id":null,"html_url":"https://github.com/Fatal1ty/consul-options","commit_stats":null,"previous_names":["fatal1ty/lazy-consul"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fatal1ty%2Fconsul-options","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fatal1ty%2Fconsul-options/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fatal1ty%2Fconsul-options/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fatal1ty%2Fconsul-options/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fatal1ty","download_url":"https://codeload.github.com/Fatal1ty/consul-options/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222389404,"owners_count":16976473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","configuration-management","consul","consul-kv","options","options-framework","python"],"created_at":"2024-07-31T19:01:29.005Z","updated_at":"2024-10-31T09:31:33.163Z","avatar_url":"https://github.com/Fatal1ty.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"consul-options - Define and use your project settings without pain\n===================================================================\n\n.. image:: https://travis-ci.org/Fatal1ty/consul-options.svg?branch=master\n    :target: https://travis-ci.org/Fatal1ty/consul-options\n\n.. image:: https://requires.io/github/Fatal1ty/consul-options/requirements.svg?branch=master\n    :target: https://requires.io/github/Fatal1ty/consul-options/requirements/?branch=master\n    :alt: Requirements Status\n\n.. image:: https://img.shields.io/pypi/v/consul-options.svg\n    :target: https://pypi.python.org/pypi/consul-options\n\n.. image:: https://img.shields.io/pypi/pyversions/consul-options.svg\n    :target: https://pypi.python.org/pypi/consul-options/\n\n.. image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg\n    :target: https://opensource.org/licenses/Apache-2.0\n\n\nHow often do you wonder where to store the project settings? When your project is small\nit is not a big problem. But if your big project consists of dozens of microservices\nthen there is a problem of centralized configuration management. The Сonsul have a key/value\nstorage that is ideal for this.\n\nWith **consul-options** you can define and use options in your code by a simple and elegant way.\nJust take a look at the example:\n\n.. code-block:: python\n\n    class DB(ConsulKV):\n        pass\n\n\n    class Users(DB):\n        host = '127.0.0.1'\n        port = 5432\n        user = 'postgres'\n        password = 'postgres'\n\n        dbname = 'users'\n\n\n    class Orders(DB):\n        host = '127.0.0.1'\n        port = 5432\n        user = 'postgres'\n        password = 'postgres'\n\n        dbname = 'orders'\n\nNow you can access option values in a clear way:\n\n.. code-block:: python\n\n    from consul_options import options\n\n    print options.db.users.host\n    print options.db.orders.dbname\n\n**consul-options** automagically creates folders and keys with default values defined above\nin Consul and later read them from there. So if anyone will change the value of *db/orders/host* key\nto something different in Consul then you will get that value.\n\nHow project options stored in Consul\n------------------------------------\n\nWhen you declare a new class based on **ConsulKV** default bahavior is\ncreation a *folder* in Consul key/value storage with name of your class in lowercase.\nEach class attribute you define will have mapping to key *folder/key*.\nIf you don't agree with generated folder name you are free to choose any other\nwith reserved class attribute **__key__** as shown below:\n\n.. code-block:: python\n\n    class WorkerOptions(ConsulKV):\n        __key__ = 'worker'\n\n        host = '127.0.0.1'\n        port = 80\n\nAfter that you can access to the option with \"worker\" in path:\n\n.. code-block:: python\n\n    from consul_options import options\n\n    print options.worker.host\n    print options.worker.port\n\nTo create hierarchical key structure you can take advantage of usual class hierarchy:\n\n.. code-block:: python\n\n    from consul_options import ConsulKV, options\n\n    class WorkerOptions(ConsulKV):\n        __key__ = 'worker'\n\n        host = '127.0.0.1'\n        port = 80\n\n    class DB(WorkerOptions):\n        host = '127.0.0.1'\n        port = 5432\n        user = 'postgres'\n        password = 'postgres'\n\n    print options.worker.db.host  # 'host'\n    print options.worker.db.port  # 5432\n\nIt is also possible to create keys at root level with class attribute **__root__**:\n\n.. code-block:: python\n\n    class RootOptions(ConsulKV):\n        __root__ = True\n\n        host = '127.0.0.1'\n        port = 80\n\n    print options.host\n    print options.port\n\n\nCompatibility\n-------------\n\nconsul-options is compatible with both Python 2 and Python 3.\n\n\nInstallation\n------------\n\nUse pip to install::\n\n    $ pip install consul-options\n\n\nLicense\n-------\n\nconsul-options is developed and distributed under the Apache 2.0 license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFatal1ty%2Fconsul-options","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFatal1ty%2Fconsul-options","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFatal1ty%2Fconsul-options/lists"}