We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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)
if name == 'main':
import sys
if len(sys.argv) < 2:
sys.argv.extend(['worker', '-l', 'info'])
app.main()
Versions
The text was updated successfully, but these errors were encountered: