Serf编排工具的Python客户端
项目描述
AioSerf是Serf的异步Python接口,Serf是一种去中心化的服务发现和编排解决方案。
它使用anyio <https://github.com/agronholm/anyio>,因此应该与asyncio、trio和curio兼容。希望如此。
安装
aioserf需要一个正在运行的Serf代理。有关说明,请参阅Serf代理文档。
要安装aioserf,请运行以下命令
$ pip install aioserf
或者(尽管您应该使用pip)
$ easy_install aioserf
或者从源安装
$ python setup.py install
入门指南
以下示例需要运行的异步循环。Trio <https://github.com/python-trio/trio>推荐,但asyncio也可以。
from aioserf import serf_client
async with serf_client() as client:
await client.event('foo', 'bar')
流使用
from aioserf import serf_client
async with serf_client() as client:
async with client.stream('*') as stream:
async for resp in stream:
print(resp)
开发
aioserf需要一个正在运行的Serf代理。有关说明,请参阅Serf代理文档。
您可以使用以下命令运行测试
$ serf agent --tag foo=bar & # start serf agent
$ python3 -mpytest tests