serf编排工具的python客户端
trio_serf的Python项目详细描述
trio-serf是serf的异步python接口,serf是分散的解决方案。 用于服务发现和编排。
它使用trio<;https://github.com/python trio/trio>;作为底层 异步框架。以前的版本使用了anyio <;https://github.com/agronholm/anyio>;包装器,因此可以使用asyncio, trio,和curio,但由于问题,此操作已停止 错误处理。
安装
三个农奴需要一个运行农奴代理。有关说明,请参见Serf’s agent documentation。
要安装Trio-Serf,请运行以下命令:
$ pip install trio-serf
或者(您确实应该使用pip):
$ easy_install trio-serf
或来源:
$ python setup.py install
开始
这些示例需要运行异步循环。 trio<;建议使用https://github.com/python trio/trio>;。 asyncio也可以。
fromtrio_serfimportserf_clientasyncwithserf_client()asclient:awaitclient.event('foo','bar')
流使用:
fromtrio_serfimportserf_clientasyncwithserf_client()asclient:asyncwithclient.stream('*')asstream:asyncforrespinstream:print(resp)
开发
您可以使用以下命令运行测试:
$ serf agent --tag foo=bar &# start serf agent $ python3 -mpytest tests