How Can I get stream one value in HTTP Request?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 12/100
- Tipo di issue
- Documentazione
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- kafka, python
- Ambito
- backend, stream-processing
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 1.9k
- Fork
- 205
- Merge medio
- 2h 2m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di faust-streaming/faust
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
faust-streaming/faust#804 ·
-
scripts/install script forces use of ./venv virtualenv, impossible to use with virtualenvwrapperAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
faust-streaming/faust#28 · 1 commento ·
-
[BUG] SASL PLAINTEXT producer initialization fails : missing sasl_plain_username/passwordForse già presa @wbarnha l’ha presa 56 giorni fa. Aperta
faust-streaming/faust#794 · 2 commenti · 1 reazione · 2 assegnatari ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
faust-streaming/faust#670 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
faust-streaming/faust#666 ·
Tutte le issue di faust-streaming/faust
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Maintainer] task area:visualizer
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
RailtownAI/railtracks#1824 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
apache/datafusion#27688 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
mloda-ai/mloda-registry#1664 ·
I maintainer di solito rispondono entro 1 giorno