ring-sse-middleware icon indicating copy to clipboard operation
ring-sse-middleware copied to clipboard

Add support for sending messages only when available

Open kumarshantanu opened this issue 3 years ago • 4 comments
trafficstars

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.

kumarshantanu avatar Aug 23 '22 12:08 kumarshantanu

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?

TimoKramer avatar Mar 14 '23 11:03 TimoKramer

@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.

kumarshantanu avatar Mar 14 '23 12:03 kumarshantanu

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?

TimoKramer avatar Mar 15 '23 13:03 TimoKramer

@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.

kumarshantanu avatar Mar 15 '23 14:03 kumarshantanu