Add support for asyncio
This pull request adds the asyncio support to the lib to close #616 and #1003.
I recently took over my work started in 2021 to add asyncio support. I adapted my original version to handle the changes made since 2021, in particular those related to multi endpoint.
Unlike #1177 or #633 I dont use another gRPC lib to handle asyncio requests. I use the grpcio, this allows me to have the same interface to reuse main code. The port is not finished, there are still to do : locks, alarms and the failover.
I have re-implemented all the request's tests.
The way to use the asyncio version is very similar to the classic version :
import etcd3
etcd = await etcd3.aioclient()
foo = await etcd.get('/foo')
await etcd.put('bar', 'doot')
await etcd.delete('bar')
events_iterator, cancel = await etcd.watch("/doot/watch")
async for event in events_iterator:
print(event)
TODO
- [x] get methods
- [x] put methods
- [x] replace methods
- [x] delete methods
- [x] watch methods
- [x] transactions
- [x] lease methods
- [x] members methods
- [x] compact
- [x] Finalize merge with the
MultiEndpointEtcd3Client(some coroutine was never awaited) - [x] status
- [x] lock methods
- [x] alarm methods
- [x] defragment
- [x] snapshot
- [x] hash
- [x] failover tests
- [x] Remaining tests
Details
- For now the
Etcd3AioClientinherits from the classicMultiEndpointEtcd3Client. Do I keep that or do i implement a common abstract class ? - I don't support Python 3.6. This version is no longer active. But I could support it if it is a prerequisite with some adaptations. I tested on python 3.7, 3.8, 3.9, 3.10 (need to update dependencies), 3.11 (need to update dependencies)
- I implemented a Github Action to start tests. With the current test dependencies, tests doesn't run for ETCD v3.4+
Tests report
https://github.com/rlegonidec/python-etcd3/actions/runs/5738790855
@rlegonidec This isn't my project; but I like what you're doing here; maybe you can release something to PyPi?
As it doesn't look like @kragniz is maintaining things anymore 😞