File tree Expand file tree Collapse file tree 2 files changed +51
-8
lines changed
Expand file tree Collapse file tree 2 files changed +51
-8
lines changed Original file line number Diff line number Diff line change 1- ## httpetcd
1+ # httpetcd
22
3- Etcd client over HTTP
3+ ## Usage
44
5- Some code is borrowed from ` etcd3gw ` package (but mostly is written from scratch):
6- * https://pypi.org/project/etcd3gw/
7- * https://opendev.org/openstack/etcd3gw
5+ Etcd client over HTTP allows you to interact with an etcd cluster using HTTP requests.
6+
7+ ### Installation
8+
9+ First, install the package via pip:
10+
11+ ``` sh
12+ pip install httpetcd
13+ ```
14+
15+ ### Basic Usage
16+
17+ ``` python
18+ import time
19+
20+ from httpetcd import clients
21+
22+
23+ client = clients.get_wrapped_client(
24+ endpoints = [" http://localhost:2379/" ],
25+ namespace = ' ns1' ,
26+ timeout = 100 ,
27+ )
28+
29+ # KV locks
30+ lock = client.kvlock.acquire(key_name = " my-lock" , ttl = 10 )
31+ lock.refresh()
32+ print (f " Lock ttl: { lock.ttl()} " )
33+ print (f " Lock is alive: { lock.alive()} " )
34+ lock.release()
35+ print (f " Lock is alive (after release): { lock.alive()} " )
36+
37+ client.kvlock.acquire(key_name = " another/lock" , ttl = 10 )
38+ lock = list (client.kvlock.list())[0 ]
39+ lock.release()
40+
41+ # Lease & KV
42+ lease = client.lease.grant(ttl = 5 )
43+ client.kv.new(key_name = " expiring-key" , value = " expiring-value" , lease = lease)
44+ print (f " KV items: { list (client.kv.items())} " )
45+ client.kv.new(key_name = " my-key" , value = " my-value" )
46+ print (f " KV items: { list (client.kv.items())} " )
47+ time.sleep(6 )
48+ print (f " KV items (after expire): { list (client.kv.items())} " )
49+ ```
Original file line number Diff line number Diff line change @@ -3,9 +3,10 @@ name = httpetcd
33summary = Etcd client over HTTP
44description-file =
55 README.md
6- author = Mail.ru Cloud Solutions
7- author-email = mcs-iaas@we.mail.ru
8- home-page = http://infra.pages.gitlab.corp.mail.ru/iaas/libraries/httpetcd3
6+ long_description_content_type = text/markdown
7+ author = VK Tech
8+ author-email = digital.tech@corp.mail.ru
9+ home-page = https://github.com/vktechdev/httpetcd
910classifier =
1011 Intended Audience :: Developers
1112 License :: OSI Approved :: Apache Software License
You can’t perform that action at this time.
0 commit comments