ring-clojure / ring-json

Ring middleware for handling JSON
317 stars 47 forks source link

wrap response builds whole string #58

Closed pete23 closed 5 years ago

pete23 commented 5 years ago

I have a usecase where I’m returning a large amount of data from a resultset, lazily. Using wrap response attempts to build the whole string on heap.

I have a hacked fork which uses generate-stream and an InputStream response to be more parsimonious about resources.

Is this something you’d be interested in a PR for? If so I may clean what I have up and fix tests etc.

weavejester commented 5 years ago

That sounds fine, as long as it happens transparently. I assume you're just checking for a lazy seq?

pete23 commented 5 years ago

I haven’t bothered even doing that tbh, I just always stream. I guess there’s overhead to setting up the writer/stream machinery that we might want to avoid for the general case? If so the laziness of the seq might be a reasonable guess for whether we want streaming maybe? Hmmm. I’ll clean up and submit a first cut and maybe it’ll be more obvious to me then.

pete23 commented 5 years ago

PR in the hopper. Let me know if you need any further work on it.

pete23 commented 5 years ago

Hi, any plans to cut a release? I’m quite keen to throw my hacked versions away! :-)

weavejester commented 5 years ago

Released 0.5.0.