Questions tagged «faust»

2
如何使用Faust Python软件包将kafka主题与Web端点连接?
我有一个简单的应用程序,具有两个功能,一个用于收听主题,另一个用于Web端点。我想创建服务器端事件流(SSE),即文本/事件流,以便在客户端可以使用EventSource收听它。 我现在有以下代码,其中每个功能都在执行其特定的工作: import faust from faust.web import Response app = faust.App("app1", broker="kafka://localhost:29092", value_serializer="raw") test_topic = app.topic("test") @app.agent(test_topic) async def test_topic_agent(stream): async for value in stream: print(f"test_topic_agent RECEIVED -- {value!r}") yield value @app.page("/") async def index(self, request): return self.text("yey") 现在,我要在索引中输入类似以下代码的内容,但是使用费力: import asyncio from aiohttp import web from aiohttp.web import Response from …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.