Skip to main content

Python client for the etcd v3 API for python >= 3.7

Project description

pyetcd

version Supported Python Versions Downloads Downloads license

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.4.tar.gz (69.1 kB view details)

Uploaded Source

Built Distribution

etcd_sdk_python-0.0.4-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file etcd-sdk-python-0.0.4.tar.gz.

File metadata

  • Download URL: etcd-sdk-python-0.0.4.tar.gz
  • Upload date:
  • Size: 69.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for etcd-sdk-python-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b79963513816cb31df30b3a531b65bdf622ec5c715f42cb6efa3f5e503c66c95
MD5 ef966115eac12f0105a3563958a43cfc
BLAKE2b-256 d50bdebbbe2408798e73ef34c8ecbd5de595032b7c9a551b52fd5d1b8a5f8d06

See more details on using hashes here.

File details

Details for the file etcd_sdk_python-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for etcd_sdk_python-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e0ddd1fa1b5dffd07b6f73b37abc52ba721a8b497e7f183c7b2cac5bfce0670a
MD5 28b84883e7577a6d42c002eb03b59f70
BLAKE2b-256 538f7cce8c9bff1c4859576da312b94be505aaed04bf70982b9670b0be1f2933

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page