Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.
/ aetcd3 Public archive
forked from martyanov/aetcd

Python asyncio based client for the etcd API v3

License

Notifications You must be signed in to change notification settings

aquarist-labs/aetcd3

 
 

Repository files navigation

aetcd3 for Project Aquarium

Documentation

Supported Python Versions

License

Note Before

This is a forked repository from aetcd3 by @martyanov.

At Aquarist Labs we found it necessary to fork and maintain some patches we need for the development of Aquarium, simply because our development pace may at times overtake the time it would take to merge patches into the original repository.

We deeply believe in cooperating with the upstreams of the projects we use, and thus we intend to contribute our efforts to aetcd3 as much as possible, should they be welcome.

At this point in time, we have no plans to provide a PyPI package based on our fork.

Installation

$ python3 -m pip install git+https://github.com/aquarist-labs/aetcd3/@aquarium#egg=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.

About

Python asyncio based client for the etcd API v3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.1%
  • Makefile 1.9%