This is a simple example of a realtime streaming app. When deployed, this app will be exposed as a public websocket endpoint.
The realtime handler accepts a single parameter, called event, with the event payload.
The realtime decorator is an abstraction above asgi.
This means that additional parameters in asgi, such as concurrent_requests can be used too.
app.py
from beam import realtime@realtime( cpu=1, memory="1Gi", concurrent_requests=10, # Process 10 requests at a time authorized=False, # Don't require auth to invoke )def stream(event): # Echo back the event payload sent to the websocket return {"response": event}
This app can be deployed in traditional Beam fashion: