{"id":16057788,"url":"https://github.com/ehsundar/pyboss","last_synced_at":"2025-03-18T04:31:15.181Z","repository":{"id":46345326,"uuid":"291155159","full_name":"ehsundar/pyboss","owner":"ehsundar","description":"Manage your app's configurations from multiple sources, e.g. Env, File, Redis, MongoDB, ...","archived":false,"fork":false,"pushed_at":"2021-10-29T18:57:55.000Z","size":30,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-24T01:04:08.386Z","etag":null,"topics":["configuration","configuration-management","kubernetes","live","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehsundar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-28T22:09:38.000Z","updated_at":"2021-10-29T18:55:10.000Z","dependencies_parsed_at":"2022-08-22T12:40:24.554Z","dependency_job_id":null,"html_url":"https://github.com/ehsundar/pyboss","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsundar%2Fpyboss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsundar%2Fpyboss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsundar%2Fpyboss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsundar%2Fpyboss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehsundar","download_url":"https://codeload.github.com/ehsundar/pyboss/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902293,"owners_count":20366260,"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","kubernetes","live","python3"],"created_at":"2024-10-09T03:04:46.908Z","updated_at":"2025-03-18T04:31:14.732Z","avatar_url":"https://github.com/ehsundar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyBoss\n\nManage your app's configurations with PyBoss! you can define several sources for aquiring configurations:\n\n* JsonFileSource\n* YamlFileSource\n* RedisSource\n* MongodbSource\n* EnvironmentSource\n* Your custom config source...\n\npass all of your sources to `Boss` then he'll take care of them. \n\n*you can partially overwrite config value by defining sources*\n\nTODO:\n* mutual lock for read and write\n* CLI for source check\n* unit tests\n\n## Quick Start\n\nfirst of all, you need to define your config sources. then pass them as a list to `Boss`. the order of the list matter,\nas it expresses which source should come on top of witch one:\n\n```python\nfrom pymongo import MongoClient\nfrom redis import Redis\n\nfrom pyboss.boss import Boss\nfrom pyboss.source import JsonFileSource, YamlFileSource, RedisSource, EnvironmentSource, MongodbSource\n\njson_source = JsonFileSource(file_path='test_data/dict_and_array.json')\nyaml_source = YamlFileSource(file_path='test_data/dict_and_array.yml')\n\nredis = Redis()\nredis_source = RedisSource(rdb=redis, config_key='Like_SVC')\n\nmongo = MongoClient(connect=False)\nmongo_source = MongodbSource(mongo, db_name='cfg', collection_name='twitter')\n\nenv_source = EnvironmentSource()\n\nb = Boss([\n    json_source,\n    yaml_source,\n    redis_source,\n    mongo_source,\n    env_source,\n], refresh_interval=120)\n```\n\nwhen an instance of `Boss` is created, all of the sources will be evaluated and merged respectively.\nwe use [jsonmerge](https://pypi.org/project/jsonmerge/) for merging output of each source, on top of\nresult of all previous sources.\n\n```python\nprint(b.like_svc.host)\nprint(b.db[1].host)\n```\n\nparameter `refresh_interval` indicates interval of reload procedure. default to `0` witch means no \nreload. this feature is intended to be used for having live configs. any failure in further reloads\n(except first time), will **not** cause your application exit. \n\n\n## In case of emergency...\n\nassume that you override some configs using MongoDB source. if your MongoDB instance is not available\nfor any reason, you can disable `MongodbSource` load by setting `PYBOSS_NO_MONGODB` environment variable.\nso that you don't need to change any line of code or rebuild. same behaviour for redis, by setting `PYBOSS_NO_REDIS`\n\n*you should pass `MongoClient(connect=False)`, so client does not attempt to connect in advance. otherwise `PYBOSS_NO_MONGODB` will have no use...*\n\n\n## Document schema for MongoDB\n\n```json\n{\n    \"_id\": {\n        \"$oid\": \"5f4a2856133f34383e3b1000\"\n    },\n    \"_version\": 1,\n    \"service_name\": \"like_svc\",\n    \"port\": 4444,\n    \"database\": [\n        {\"driver\": \"mongodb\"}\n    ]\n}\n```\n\nthe field `_version` effects which document to load. the highest version is loaded. the type must be `int32`. \n\n\n## Value schema for Redis\n\n`RedisSource(rdb=redis, config_key='Like_SVC')` the `config_key` parameter tell `RedisSource` witch key to get.\nother behaviours are just like a json file\n\n\n## Value schema for env\n\nthis source is absolutely **case sensitive**. so `boss.lev1.lev2` corresponds to `lev1__lev2` in environment.\nnote that all the configs overridden by env are typed as `str`. you're responsible to type cast. for technical reasons\nwe're not able to detect type at the moment. \n\n## MergeStrategy for sources\n\nStrategy for merge result of every source, on top of previous ones, can be specified by JsonSchema and some options.\na `Merger` instance might pass to `XSource` constructor. for further information, please read \n[this](https://github.com/avian2/jsonmerge#merge-strategies) section.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsundar%2Fpyboss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehsundar%2Fpyboss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsundar%2Fpyboss/lists"}