a3consul


توضیحات

a3consul is a simple wrapper around py-consul to make it easier to use.
ویژگی مقدار
سیستم عامل OS Independent
نام فایل a3consul-0.3.0
نام a3consul
نسخه کتابخانه 0.3.0
نگهدارنده []
ایمیل نگهدارنده []
نویسنده -
ایمیل نویسنده three-kinds <3179158552@qq.com>
آدرس صفحه اصلی -
آدرس اینترنتی https://pypi.org/project/a3consul/
مجوز MIT
# a3consul English | [简体中文](README_ZH.md) `a3consul` is a simple wrapper around `py-consul` to make it easier to use. ## 1. Introduction * Provide encapsulation for `Node Discovery`. ## 2. Usage ### Install ```shell pip install a3consul ``` ### Examples: Node Discovery * Node ```python from a3consul.scene_cases.node_discovery.node import Node if __name__ == '__main__': node_conf = { "topic": "unittest", "node_path": "/nodes/", "init": { "host": "127.0.0.1", "port": 8500, }, "session": { "ttl": 10, }, "renew": { "sleep_seconds": 5, "timeout_seconds": 20, }, } node = Node(conf=node_conf) node_id = node.register_node_id() node.start_renew_thread() node.close() ``` * NodeWatcher ```python from typing import Set from a3consul.scene_cases.node_discovery.node_watcher import NodeWatcher class MyNodeWatcher(NodeWatcher): def _on_change(self, online_node_id_set: Set[str], offline_node_id_set: Set[str]): # do something pass def _handle_first_node_id_set(self, node_id_set: Set[str]): # kick or keep them or do something else pass if __name__ == '__main__': watcher_conf = { "init": { "host": "127.0.0.1", "port": 8500, }, "node_path": "/nodes/", } watcher = MyNodeWatcher(conf=watcher_conf) watcher.start() ```


نیازمندی

مقدار نام
- a3py>=0.3.0
- py-consul>=1.5.5


زبان مورد نیاز

مقدار نام
>=3.10 Python


نحوه نصب


نصب پکیج whl a3consul-0.3.0:

    pip install a3consul.whl


نصب پکیج tar.gz a3consul-0.3.0:

    pip install a3consul.tar.gz