Python asyncio based client for the etcd API v3
Project description
Installation
$ python3 -m pip install aetcd3
Basic usage
import aetcd3
etcd = aetcd3.client()
await etcd.get('foo')
await etcd.put('bar', 'doot')
await etcd.delete('bar')
# locks
lock = etcd.lock('thing')
await lock.acquire()
# do something
await lock.release()
async with etcd.lock('doot-machine') as lock:
# do something
# transactions
await 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 = await etcd.watch("/doot/watch")
async for event in events_iterator:
print(event)
watch_count += 1
if watch_count > 10:
await cancel()
# watch prefix
watch_count = 0
events_iterator, cancel = await etcd.watch_prefix("/doot/watch/prefix/")
async for event in events_iterator:
print(event)
watch_count += 1
if watch_count > 10:
await cancel()
# receive watch events via callback function
def watch_callback(event):
print(event)
watch_id = await etcd.add_watch_callback("/anotherkey", watch_callback)
# cancel watch
await etcd.cancel_watch(watch_id)
# receive watch events for a prefix via callback function
def watch_callback(event):
print(event)
Acknowledgements
This project is a fork of etcd3aio, which itself is a fork of python-etcd3. python-etcd3 was originally written by kragniz. asyncio suppport was contributed by hron and based on the previous work by gjcarneiro. Kudos to all the people involved in the projects.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aetcd3-0.1.0a4.tar.gz
(65.2 kB
view details)
Built Distribution
aetcd3-0.1.0a4-py3-none-any.whl
(50.4 kB
view details)
File details
Details for the file aetcd3-0.1.0a4.tar.gz
.
File metadata
- Download URL: aetcd3-0.1.0a4.tar.gz
- Upload date:
- Size: 65.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e84a928557514c369a5d98c2730e9bc19c18e8c9f06e3730239047e64e090dac |
|
MD5 | cc30f6b7f2e52f2b93b4204f1c8bebaf |
|
BLAKE2b-256 | bf91c55ca7037bc83dca633c4510026691602fe21454836033760a27bee35f16 |
File details
Details for the file aetcd3-0.1.0a4-py3-none-any.whl
.
File metadata
- Download URL: aetcd3-0.1.0a4-py3-none-any.whl
- Upload date:
- Size: 50.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92f1f8b9bb587a45d5754853a076bf3575398b6ad8f75b4e411d43b0c525e744 |
|
MD5 | 1463f03e094f6c1bc060a6c61e68aad2 |
|
BLAKE2b-256 | 91654c4e0ed7a6a29dc77ae19f188e70268ab844b3aae795a234d02ac312b752 |