Description
Hello,
I am new to lua and luv and am writing an nginx application that will accept large file uploads from many concurrent connections simultaneously, but I need to do some computation over the data as it is written to disk (think a checksum). I have experience using libuv from a different C project, so I thought to use it here since it would provide non-blocking, fast IO. I am a bit confused about how to execute the uv.run() loop. The default mode will block while the event loop is processed, there doesn't appear to be a way to hook ngx's event loop to also watch the libuv socket to emit events, and while I could do something like
co = coroutine.spawn(function ()
while not ngx.worker.is_exiting() do
luv.run("once")
coroutine.yield()
end
end)
I'm not sure of how to tell nginx to continue it at the appropriate times.
The thing that's mostly confusing me that I'm struggling to understand is if uv.run() is required at all. If I look at the filesystem examples in https://github.com/luvit/luv/blob/master/docs.md#file-system-operations, they don't call the event loop and appear to behave properly. Does this mean there's an implicit event loop happening somewhere behind my back?
Thanks for your help!