etcd3 package used in hippo
Project description
Python client for the etcd API v3, supported under python 2.7, 3.4 and 3.5.
Warning: the API is mostly stable, but may change in the future
If you’re interested in using this library, please get involved.
Free software: Apache Software License 2.0
Documentation: https://python-etcd3.readthedocs.io.
Basic usage:
import etcd3
etcd = etcd3.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)
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
hippo_etcd3-0.12.0.tar.gz
(41.4 kB
view details)
Built Distribution
File details
Details for the file hippo_etcd3-0.12.0.tar.gz
.
File metadata
- Download URL: hippo_etcd3-0.12.0.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3531721b0c3bbab45fa2d42feb9e8001df483967a7c37cf47823090c97fff3f |
|
MD5 | cc17bd0b8390b651ae905534b4f5a183 |
|
BLAKE2b-256 | fb899c426f32dada6ebed43dcce8886f1e52cf7d7e12e88522d5adffd59297df |
File details
Details for the file hippo_etcd3-0.12.0-py3-none-any.whl
.
File metadata
- Download URL: hippo_etcd3-0.12.0-py3-none-any.whl
- Upload date:
- Size: 47.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e19c31641bc08b2da8143bed4bd009c7a5343b2e10b87504464a43d6a08599b5 |
|
MD5 | 519f1119ed5cf91c043d24eb50d98b9d |
|
BLAKE2b-256 | 21978963eee50a2950906ed99e1d765ce102ce32016b8ab1be1298838a749792 |