Replies: 2 comments
-
|
I would recommend using some kind of message broker for this, e.g. Redis pub/sub interface (or maybe your database has some event system?). So connecting to an SSE endpoint will subscribe to a redis pub/sub channel and start listening. When other endpoints are called you can publish message to the channel and the listener on SSE endpoint will emit what you want. Having this system in a separate service outside FastAPI is preferred since you want a single source of truth and FastAPI could run in many processes/containers, so you want it to be stateless. |
Beta Was this translation helpful? Give feedback.
-
|
@havardthom: This makes sense! Is there a message broker that can be easily integrated with FastAPI? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does FastAPI have some kind of event/hook system for entity creation?
E.g. a new comment entity is inserted (using POST). A SSE event should be emitted when this happens.
Beta Was this translation helpful? Give feedback.
All reactions