如何将字典数组传递给Faust应用程序?

时间:2019-02-24 07:41:55

标签: python faust

  1. 如何将字典数组传递给Faust应用程序?
  2. 我们如何获取所产生事件的时间戳?

我正在尝试《浮士德》,但是对于如何读取字典数组中的数据流却有些迷茫。

示例:

[{"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}')

0 个答案:

没有答案