Hello!
On Fri, Sep 22, 2017 at 6:25 AM, Damian Kamiński wrote:
\> According to lua nginx module documentation ngx.location.capture is
> non-blocking, but synchronous. In our case we would like to a send request
> without affecting latency therefore synchronous operation is not an option.
> We thought that maybe lua-resty-http module allows to do it, but after quick
> investigation it seems that it's using tcpsock:send which is synchronous.
>
If you do not want to add latency to the request handler, then you can
use the
ngx.timer.at() API to create a (0-delay) timer that is
detached from the current request handler context. And yeah, you'll
need to use a lua-resty-http library that is based on our cosocket
API.
But be careful when the client sends request too fast, which may
accumulate your async timers VERY quickly. So a better solution might
be use a single chain of timer and batch the tasks in a queue (could
just be a Lua table) or something. You can check
lua-resty-logger-socket library for such an example.
Regards,
Yichun