Namespace containing the shared code for each adapter.
It contains helpers for working with [[OutputStreams]] and assembling SSE sending function using several strategies and managing exceptions in the adapters.
The main concept here is what we call "write profiles". A write profile is a map of 3 keys:
With these 3 keys we can control buffering aspects of our SSE connection and compression functionality.
Here is an example profile which uses gzip and temporary buffers to concatenate SSE event text:
(def gzip-profile
{wrap-output-stream (fn [^OutputStream os] (-> os ->gzip-os ->os-writer))
content-encoding gzip-content-encoding
write! (->write-with-temp-buffer!)})
The wrap-output-stream
function will use a [[GZIPOutputStream]] and an
[[OutputStreamWriter]] constructed with the ->gzip-os
and ->os-writer
helpers.
To go with this we use a write!
function constructed with
->write-with-temp-buffer!
.
If we wanted specific buffer sizes we could do:
(def gzip-profile
{wrap-output-stream (fn[^OutputStream os]
(-> os
(->gzip-os 1024)
->os-writer))
content-encoding gzip-content-encoding
write! (->write-with-temp-buffer! 4096)})
The output stream wrapping helpers are:
The write function helper to go with them are:
See the rest of the docstrings for more details.
Namespace containing the shared code for each adapter. It contains helpers for working with [[OutputStreams]] and assembling SSE sending function using several strategies and managing exceptions in the adapters. The main concept here is what we call "write profiles". A write profile is a map of 3 keys: - [[wrap-output-stream]] - [[write!]] - [[content-encoding]] With these 3 keys we can control buffering aspects of our SSE connection and compression functionality. Here is an example profile which uses gzip and temporary buffers to concatenate SSE event text: ```clojure (def gzip-profile {wrap-output-stream (fn [^OutputStream os] (-> os ->gzip-os ->os-writer)) content-encoding gzip-content-encoding write! (->write-with-temp-buffer!)}) ``` The `wrap-output-stream` function will use a [[GZIPOutputStream]] and an [[OutputStreamWriter]] constructed with the [[->gzip-os]] and [[->os-writer]] helpers. To go with this we use a `write!` function constructed with [[->write-with-temp-buffer!]]. If we wanted specific buffer sizes we could do: ```clojure (def gzip-profile {wrap-output-stream (fn[^OutputStream os] (-> os (->gzip-os 1024) ->os-writer)) content-encoding gzip-content-encoding write! (->write-with-temp-buffer! 4096)}) ``` The output stream wrapping helpers are: - [[->gzip-os]] - [[->os-writer]] - [[->buffered-writer]] The write function helper to go with them are: - [[->write-with-temp-buffer!]] - [[write-to-buffered-writer!]] See the rest of the docstrings for more details.
Utilities providing a test SSEGenerator and a mock ->sse-response
function.
Utilities providing a test SSEGenerator and a mock `->sse-response` function.
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 |