Hello!
On Thu, Aug 8, 2013 at 8:03 PM, Daniel Rios wrote:
> Thanks a lot for the explanation , was very concise. But as I understand lua
> can call c modules an libs, so it is possible to use this lib ?
No, you need to integrate all the network I/O into the Nginx event
loop, otherwise your Lua code will surely block the (single-threaded)
Nginx worker processes, and ruin the performance of everything. You
surely don't want your Nginx downgrade to an Apache httpd with its
prefork mpm.
See how ngx_drizzle integrates libdrizzle's nonblocking API for MySQL
into the nginx event model,
https://github.com/chaoslawful/drizzle-nginx-module
and also how ngx_postgres integrates libpq's nonblocking API for PostgreSQL:
https://github.com/FRiCKLE/ngx_postgres
Basically, you need to hook your C library's nonblocking API into the
Nginx event model, normally as an Nginx upstream module.
Alternatively, you can re-implement the wire protocol atop ngx_lua's
nonblocking cosocket API with pure Lua:
http://wiki.nginx.org/HttpLuaModule#ngx.socket.tcp
Such examples are the lua-resty-mysql and lua-resty-memcached libraries:
https://github.com/agentzh/lua-resty-mysql
https://github.com/agentzh/lua-resty-memcached
But the Oracle wire protocol is not open AFAIK, so it could be hard to
take this pure Lua approach.
Regards,
-agentzh
P.S. I'm cc'ing the openresty-en mailing list:
https://groups.google.com/group/openresty-en