Code Monkey home page Code Monkey logo

aetcd3's Introduction

aetcd3

Build Status

Coverage report

Documentation

PyPI Version

Supported Python Versions

License

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.