是否可以在 faust rpc 回复中访问 kafka 标头?这是两个浮士德代理的示例。一个 (the pow
) 调用另一个 ( mul
) 并接收一个结果作为值。但是如何知道reply topic中的kafka headers呢?
#!/usr/bin/env python
from typing import AsyncIterable
import faust
from faust import StreamT
app = faust.App('RPC99', reply_create_topic=True)
pow_topic = app.topic('RPC__pow')
mul_topic = app.topic('RPC__mul')
@app.agent(pow_topic)
async def pow(stream: StreamT[float]) -> AsyncIterable[float]:
async for value in stream:
yield await mul.ask(value=value ** 2)
# Headers for the returning result here?
@app.agent(mul_topic)
async def mul(stream: StreamT[float]) -> AsyncIterable[float]:
async for value in stream:
yield value * 100.0