Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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())}")
```
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down