Python client for the etcd v3 API for python >= 3.7
Project description
pyetcd
Python client for the etcd API v3, supported python >= 3.7, under active maintenance
Install
pip install etcd-sdk-python
Road maps and TODOs
Road maps
version | release date | target | status |
---|---|---|---|
0.0.1 | Apr 10,2023 | enable >= python3.7 | DONE |
0.0.2 | Jun 6,2023 | DONE | |
0.0.3 | ND | set up github actions, run pass unittests, set up merging rules, ensure quality | WIP |
TODOs for v0.0.2
functions | version | status |
---|---|---|
make ut work | 0.0.2 | BACKLOG |
make tox.ini work | 0.0.2 | BACKLOG |
enable running ut for pull requests | 0.0.2 | BACKLOG |
enable running lint for pull requests | 0.0.2 | BACKLOG |
enable publishing dev packages for merge | 0.0.2 | BACKLOG |
Add mergify to help merging PRs | 0.0.2 | BACKLOG |
Basic usage:
import pyetcd
etcd = pyetcd.client()
etcd.get('foo')
etcd.put('bar', 'doot')
etcd.delete('bar')
# locks
lock = etcd.lock('thing')
lock.acquire()
# do something
lock.release()
with etcd.lock('doot-machine') as lock:
# do something
# transactions
etcd.transaction(
compare=[
etcd.transactions.value('/doot/testing') == 'doot',
etcd.transactions.version('/doot/testing') > 0,
],
success=[
etcd.transactions.put('/doot/testing', 'success'),
],
failure=[
etcd.transactions.put('/doot/testing', 'failure'),
]
)
# watch key
watch_count = 0
events_iterator, cancel = etcd.watch("/doot/watch")
for event in events_iterator:
print(event)
watch_count += 1
if watch_count > 10:
cancel()
# watch prefix
watch_count = 0
events_iterator, cancel = etcd.watch_prefix("/doot/watch/prefix/")
for event in events_iterator:
print(event)
watch_count += 1
if watch_count > 10:
cancel()
# recieve watch events via callback function
def watch_callback(event):
print(event)
watch_id = etcd.add_watch_callback("/anotherkey", watch_callback)
# cancel watch
etcd.cancel_watch(watch_id)
# recieve watch events for a prefix via callback function
def watch_callback(event):
print(event)
watch_id = etcd.add_watch_prefix_callback("/doot/watch/prefix/", watch_callback)
# cancel watch
etcd.cancel_watch(watch_id)
Credits
Many thx to python-etcd3
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
etcd-sdk-python-0.0.3.tar.gz
(69.0 kB
view hashes)
Built Distribution
Close
Hashes for etcd_sdk_python-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39d8178b50ce6e7b2487b1d48b1796667419a1945d506b005f9570cf53797136 |
|
MD5 | e728bd299ca2e8598be177d6f8968aea |
|
BLAKE2b-256 | 14461b80f18d8159dd05ebe72966eaee31a305a79e65972a69d7118cb180391d |