### Set up local development environment Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Install the project in a virtual environment using `setup.py develop` for local development. ```bash mkvirtualenv etcd3 cd etcd3/ python setup.py develop ``` -------------------------------- ### Install project with development and testing requirements Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Install the project in editable mode along with development and testing dependencies. ```bash pip install -Ue . -r requirements/dev.txt ``` -------------------------------- ### Basic etcd Operations Source: https://github.com/hron/etcd3aio/blob/master/README.md Demonstrates basic get, put, and delete operations on etcd keys. Requires an initialized etcd client. ```python import etcd3aio etcd = etcd3aio.client() await etcd.get('foo') await etcd.put('bar', 'doot') await etcd.delete('bar') ``` -------------------------------- ### Clone the repository Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Clone your forked repository locally to begin development. ```bash git clone git@github.com:your_name_here/python-etcd3.git ``` -------------------------------- ### Synchronize virtual environment with requirements Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Ensure the virtual environment exactly matches the packages listed in `requirements/dev.txt`, uninstalling any extra packages. ```bash pip-sync requirements/dev.txt ``` -------------------------------- ### Watch Prefix Changes Source: https://github.com/hron/etcd3aio/blob/master/README.md Shows how to watch for changes on all keys under a specific prefix. The watch can be cancelled similarly to watching a single key. ```python # 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() ``` -------------------------------- ### Copy protobuf stubs Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Copy protobuf files from the etcd server package to the local proto directory. ```bash cp etcd/etcdserver/etcdserverpb/*.proto python-etcd3/etcd3/proto/ ``` -------------------------------- ### Generate protobuf stubs Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Generate protobuf stubs within the python-etcd3 project directory using tox. ```bash cd python-etcd3 tox -e genproto ``` -------------------------------- ### Commit and push changes Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Stage, commit, and push your changes to your fork on GitHub. ```bash git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature ``` -------------------------------- ### Run linters and tests Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Ensure code quality and test suite pass before committing. Includes linting with flake8 and running tests with `tox` for multiple Python versions. ```bash flake8 etcd3 tests python setup.py test or py.test tox ``` -------------------------------- ### Etcd Lock Management Source: https://github.com/hron/etcd3aio/blob/master/README.md Shows how to acquire and release locks using etcd3aio, including context manager usage. Ensure the lock name is unique for your operation. ```python # locks lock = etcd.lock('thing') await lock.acquire() # do something await lock.release() ``` ```python async with etcd.lock('doot-machine') as lock: # do something ``` -------------------------------- ### Create a new branch Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Create a dedicated branch for your bugfix or new feature. ```bash git checkout -b name-of-your-bugfix-or-feature ``` -------------------------------- ### Watch Key Changes Source: https://github.com/hron/etcd3aio/blob/master/README.md Demonstrates how to watch for changes on a specific key and cancel the watch after a certain number of events. The iterator yields event objects. ```python # 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() ``` -------------------------------- ### Add Watch Prefix Callback Source: https://github.com/hron/etcd3aio/blob/master/README.md Registers a callback function to receive watch events for all keys under a given prefix. This is useful for monitoring multiple related keys. ```python # receive watch events for a prefix via callback function def watch_callback(event): print(event) ``` -------------------------------- ### Push tags Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Push all local tags to the remote repository to ensure release tags are available. ```bash git push --tags ``` -------------------------------- ### Etcd Transactions Source: https://github.com/hron/etcd3aio/blob/master/README.md Illustrates how to perform atomic transactions with etcd, including conditional operations and success/failure branches. Conditions can check value, version, or modification time. ```python # 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'), ] ) ``` -------------------------------- ### Add Watch Callback Source: https://github.com/hron/etcd3aio/blob/master/README.md Registers a callback function to receive watch events for a specific key. The callback is executed asynchronously when events occur. ```python # receive watch events via callback function def watch_callback(event): print(event) watch_id = await etcd.add_watch_callback("/anotherkey", watch_callback) ``` -------------------------------- ### Bump version Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Increment the project version using `bumpversion`, specifying 'major', 'minor', or 'patch' according to semantic versioning rules. ```bash bumpversion patch ``` -------------------------------- ### View commit history Source: https://github.com/hron/etcd3aio/blob/master/CONTRIBUTING.rst Check changes made since the last tagged release using `git log`. ```bash git log $(git describe --tags --abbrev=0)..HEAD --oneline ``` -------------------------------- ### Cancel Watch Source: https://github.com/hron/etcd3aio/blob/master/README.md Demonstrates how to cancel an active watch using its ID. This stops further event notifications for that watch. ```python # cancel watch await etcd.cancel_watch(watch_id) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.