Skip to content

wangfenjin/python-etcd3

 
 

Repository files navigation

python-etcd3

Documentation Status Updates https://codecov.io/github/kragniz/python-etcd3/coverage.svg?branch=master

Python client for the etcd API v3.

Warning: this is a work in progress, many basic features do not have a stable API.

If you're interested in using this library, please get involved.

Basic usage:

import etcd3

etcd = etcd3.client()

etcd.get('foo')
etcd.put('bar', 'doot')
etcd.delete('bar')

# locks
lock = etcd.lock('thing')
# 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
for (event, cancel) in etcd.watch("/doot/watch"):
    print event
    watch_count += 1
    if watch_count > 10:
        cancel()

# watch prefix
watch_count = 0
for (event, cancel) in etcd.watch_prefix("/doot/watch/prefix/"):
    print event
    watch_count += 1
    if watch_count > 10:
        cancel()

About

Python client for the etcd API v3

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 61.5%
  • Protocol Buffer 38.5%