Hello!
On Fri, Mar 7, 2014 at 9:20 AM, Yaroslav Rodionov wrote:
> How openresty and redis/0mq pubsub can be integrated best way?
>
What exactly do you want to do? There is a lua-resty-redis library
that you can use the Redis Pub/Sub API nonblockingly.
>
> I assume something like semi-endless while cycle doing
> resty.redis:read_reply() + lua-resty-lock
>
I'm not sure how lua-resty-lock is used here though.
> Or lua-resty-upstream-healthcheck'like approach using ngx.timer.at
>
the healthcheck library uses timer for periodic backend checks and
inter-process state synchronization (with shared dict).
> Much better (i think so :)) will be a module which sets nginx directives to
> define events and desired actions (internal requests) for them, but i can't
> imagine this perfectly.
>
In ngx_lua, we try to make underlying events implicit rather than
explicit to save the Lua programmers' burden.
For application level user defined events, it is better to use shm
dictionaries or external services like Redis to exchange data at least
for now.
In the near future I'd introduce a semaphore API for ngx_lua's "light
threads". Waiting on such a semaphore will not block NGINX workers nor
introduce unnecessary extra delays within the same worker process.
lua-resty-lock will still be the way for inter-process synchronization
though.
> Actually i believe entire app can be based on openresty solely and i can
> remove helping daemons/timers/cron stuff/etc
>
Yes sure! And we do have timers in ngx_lua already where you can
create cronjob-like threads in the background within the NGINX server
;)
Best regards,
-agentzh