kumarshantanu / ring-sse-middleware

Ring middleware to stream Server-sent Events
Eclipse Public License 1.0
19 stars 2 forks source link

Add support for sending messages only when available #3

Open kumarshantanu opened 2 years ago

kumarshantanu commented 2 years ago

Currently, only time-delay based events are generated. This is a feature request to add support for generating events only when some content is available.

TimoKramer commented 1 year ago

Is this meant to be for pushing events instead of polling? I am having an event-queue that I would like to subscribe on but currently it seems this is not possible with this middleware, right?

kumarshantanu commented 1 year ago

@TimoKramer This middleware implements https://en.wikipedia.org/wiki/Server-sent_events for server push. SSE can be done with pure HTTP without needing WebSockets - the later, however, is useful for bidirectional communication. Technically, with this middleware you can create a web-endpoint per event-queue for single consumer, or fan-out consumer endpoints per queue for multiple-consumers and consume events. For complex needs there's https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object and https://github.com/asyncapi/spec to look up.

TimoKramer commented 1 year ago

Technically, with this middleware you can create a web-endpoint per event-queue for single consumer, or fan-out consumer endpoints per queue for multiple-consumers and consume events.

That's exactly what I need. A web-endpoint per event-queue. I thought with this lib I can only poll a fn, because I understand this issue is supposed to add this feature. Am I wrong?

kumarshantanu commented 1 year ago

@TimoKramer This issue is only to stop issuing empty messages when the queue doesn't have anything. Your use-case is already doable - you just need to wrap the endpoint handlers (must be Ring-compliant) with this middleware.