On Sun, 01 Dec 2013 19:56:15 GMT, ilya-stromberg wrote:
On Sun, 01 Dec 2013 19:45:15 +0100, Sönke Ludwig wrote:
so it's useful only if there is going to be some more processing between
the lastwrite
and returning from the function to reduce latency.What should I use in this case? For example, I want to send answer for client and than save information to the log. Shall I use
flush
orfinalize
?
I think that was a bad example on my part*. To do that, the best way is to perform the logging (if it is heavyweight enough, of course) in parallel using runTask
, because even if finalize
would be used, the (keep-alive) connection would still be blocked until the function returns and would thus delay the next request.
But apart from that, finalize
would completely finish the response, so that would be the most correct call, but flush
may be enough if the client just needs all data and not necessarily the end marker.
* Needing to avoid latencies during the request is a better example, see f.ex. vibe.stream.operations.pipeRealtime