diff --git a/README.md b/README.md index 63fb5d5..b7d10d9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,49 @@ -## httpetcd +# httpetcd -Etcd client over HTTP +## Usage -Some code is borrowed from `etcd3gw` package (but mostly is written from scratch): -* https://pypi.org/project/etcd3gw/ -* https://opendev.org/openstack/etcd3gw +Etcd client over HTTP allows you to interact with an etcd cluster using HTTP requests. + +### Installation + +First, install the package via pip: + +```sh +pip install httpetcd +``` + +### Basic Usage + +```python +import time + +from httpetcd import clients + + +client = clients.get_wrapped_client( + endpoints=["http://localhost:2379/"], + namespace='ns1', + timeout=100, +) + +# KV locks +lock = client.kvlock.acquire(key_name="my-lock", ttl=10) +lock.refresh() +print(f"Lock ttl: {lock.ttl()}") +print(f"Lock is alive: {lock.alive()}") +lock.release() +print(f"Lock is alive (after release): {lock.alive()}") + +client.kvlock.acquire(key_name="another/lock", ttl=10) +lock = list(client.kvlock.list())[0] +lock.release() + +# Lease & KV +lease = client.lease.grant(ttl=5) +client.kv.new(key_name="expiring-key", value="expiring-value", lease=lease) +print(f"KV items: {list(client.kv.items())}") +client.kv.new(key_name="my-key", value="my-value") +print(f"KV items: {list(client.kv.items())}") +time.sleep(6) +print(f"KV items (after expire): {list(client.kv.items())}") +``` diff --git a/setup.cfg b/setup.cfg index 565d44f..605714c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,9 +3,10 @@ name = httpetcd summary = Etcd client over HTTP description-file = README.md -author = Mail.ru Cloud Solutions -author-email = mcs-iaas@we.mail.ru -home-page = http://infra.pages.gitlab.corp.mail.ru/iaas/libraries/httpetcd3 +long_description_content_type = text/markdown +author = VK Tech +author-email = digital.tech@corp.mail.ru +home-page = https://github.com/vktechdev/httpetcd classifier = Intended Audience :: Developers License :: OSI Approved :: Apache Software License