Fork me on GitHub

hello, wanted to ask if there is any interest in having an option (in byte-stream I imagine) to convert only a part of the stream to string. The use case is that I would like to limit the number of processed bytes to a specific manageable size: 1-10k and avoid processing the whole buffer. One simple application of this is that in case of errors I get a body back and I would like to print a "preview" of that buffer: first 1-2k characters. I can do it like this:

(when-let [body (-> (:body (ex-data e))
    (log/error "With body" body))
but I still get to process the WHOLE body. In theory that could be 1GB of data. What do you think? I could solve this in a number of ways. One option would be somthing like the SizeLimit InputStream . But they all fall a bit short in one way or another.


@U011NGC5FFY bs/to-string is one of the few operations that’s going to try and consume everything. I’m not sure what your source is made of, but most of the alternatives are lazier. Consider using to-reader, to-line-seq, or to-char-sequence instead. You can read only as much data as you feel like, and then convert that to a string.

👍 1

Is there a way to detect that client disconnected from websocket server?


how do you guys deal with stale websocket connections? Do you manually clear them or leave it to garbage collection?