Install using clojars deps coordinates:
This library already depends on the core SDK lib.
Datastar SDK adapter for ring. It is currently tested only with ring-jetty-adapter.
This SDK adapter is based on the ring.core.protocols/StreamableResponseBody
protocol.
Any ring adapter using this protocol should work with this library.
With the ring-jetty-adapter,
sending events on a closed connection will fail at some point throwing an
IOException
. By default the SSE-Gen will catch this exception, close itself
then call the on-close
callback.
[!Note] At this moment, when using the ring adapter and Jetty, our SSE-Gen needs to send 2 small events or 1 big event to detect a closed connection. There must be some buffering happening independent of our implementation.
|Api| connection lifetime| |-|--| |Ring sync| same as the thread carrying the initial response| |Ring async| alive until the client or the server closes it|
important
This is standard behavior as specified in the Ring spec. It implies that you can't keep a SSE connection opened beyond the lifetime of the thread making the initial response when using the synchronous API.
In other words, the barebones broadcast example from the docs will work with the ring asynchronous API, not the synchronous one when using this library.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |