FaustPython 流處理
Faust 是一個(gè)流處理庫(kù),將想法從 Kafka Streams 移植到 Python。
它在 Robinhood 用于構(gòu)建高性能的分布式系統(tǒng)和實(shí)時(shí)數(shù)據(jù)管道,每天處理數(shù)十億個(gè)事件。
Faust 提供流處理和事件處理,與 Kafka Streams,Apache Spark / Storm / Samza / Flink 等工具共享相似性,
它不使用 DSL,它只是 Python!這意味著您可以在流處理時(shí)使用所有您喜歡的 Python 庫(kù):NumPy,PyTorch,Pandas,NLTK,Django,F(xiàn)lask,SQLAlchemy,++
Faust 需要 Python 3.6 或更高版本才能使用新的 async / await 語法和變量類型注釋。
特性:
- 簡(jiǎn)單易使用
- 高度可用
- 快速
- 靈活性
以下是處理傳入訂單流的示例:
# Python Streams ?(???)?
# Forever scalable event processing & in-memory durable K/V store;
# w/ asyncio & static typing.
import faust
app = faust.App('myapp', broker='kafka://localhost')
# Models describe how messages are serialized:
# {"account_id": "3fae-...", amount": 3}
class Order(faust.Record):
account_id: str
amount: int
@app.agent(value_type=Order)
async def order(orders):
async for order in orders:
# process infinite stream of orders.
print(f'Order for {order.account_id}: {order.amount}')
評(píng)論
圖片
表情
