How Can I get stream one value in HTTP Request?

オープン
#637 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
12/100
issue の種類
ドキュメント
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
kafka, python

調査の方向性

Start from the get_data page view and process_events in the snippet: get_data creates data from agent.stream() but never reads it, and process_events reads stream.current_event inside stream.events(). Check how Faust agent streams are consumed from a web handler and what the Faust docs say about sharing a stream with an HTTP request. Done means the question has a working pattern or a documented answer. The issue has been inactive for about 18 months and needs a maintainer to confirm the approach.

索引モデルが issue の本文から書いたものです。

説明

from faust import App, Record
from faust.web import Request, Response, View
import asyncio

app = App('ness', broker='kafka://localhost')

data_queues = {}

async def process_message(stream):
async for record in stream:
yield record

async def process_events(stream):
async for event in stream.events():
event = stream.current_event
message = event.message
topic = event.message.topic
print(f"Received message {message} from topic {topic}")

agents = {}
topics = {}
for i in ['test-30']:
agents[i] = app.agent(channel=i, name=app.topic(i))(process_message)
topics[i] = app.topic(i)

app.start()

@app.page('/get_data/{topic_name}')
async def get_data(self, request: Request, topic_name) -> Response:
print(topic_name)
if topic_name not in agents:
return self.json({'error': 'Topic not found'}, status=404)

agent = agents[topic_name]
data = process_events(agent.stream())

return self.json({'topic_name': topic_name, 'message': 'data'})

if name == 'main':
import sys
if len(sys.argv) < 2:
sys.argv.extend(['worker', '-l', 'info'])
app.main()

Versions

  • Python version: 3.11
  • Faust version: faust-streaming 0.11.1
  • Operating system macOS
  • Kafka version 2.8
  • RocksDB version (if applicable) None
主要言語
Python
スター
1.9k
フォーク
205
平均マージ
2時間 2分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

faust-streaming/faust のほかの issue

faust-streaming/faust の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。