我正在尝试《浮士德》,但是对于如何读取字典数组中的数据流却有些迷茫。
示例:
[{"product_id": "p1", "name": "pen"}, {"product_id": "p2", "name": "eraser"}]
class Products(faust.Record, coercions={UUID: UUID}):
id: UUID
product_id: str
name: str
app = faust.App('prdapp', broker='kafka://localhost:9092')
prd_topic = app.topic('products', key_type=str, value_type=Order)
@app.agent(prd_topic)
async def process_product(prds):
async for p in prds:
print(f'product_id with uuid - {p.id}, ID is {p.product_id} and name is {p.name}')