42 ms·
Just return an io.Reader that wraps the DB cursor and outputs CSV data... I fail to see what makes this so difficult. If the "mutable" approach involves passing
by suremarc 4y ago
Just return an io.Reader that wraps the DB cursor and outputs CSV data... I fail to see what makes this so difficult. If the "mutable" approach involves passing down a mutable *http.ResponseWriter, then the dual approach of passing an io.Reader upstream is equivalent.
- int_19h 4y agoThis all is much more straightforward in languages with syntactic sugar for iterators, such as "yield" in C# and Python: https://flask.palletsprojects.com/en/2.2.x/patterns/streaming/ https://flask.palletsprojects.com/en/2.2.x/patterns/streamin...
- morelisp 4y agoLove too make those async thunks!
- morelisp 4y agoTry to write this, really. It’s such an unergonomic mess compared to for loop in the handler. It will also allocate a very complex reader that the actual version doesn’t need to.