Hello!
On Tue, Jul 29, 2014 at 9:00 AM, Lionel Duboeuf wrote:
> I've used the code snippet " local _M = { _VERSION = '0.1' } " in the module
> but didn't find any example how to use it.
>
The way you are supposed to use such version numbers is like this:
local foo = require "foo"
local ver = foo._VERSION
ngx.say("version of foo is: ", ver)
> I would like to used it like this:
>
> location ~ ^/0.1/... {
> --here load version 0.1 of module M
> }
>
> location ~ ^/0.2/... {
> --here load version 0.2 of module M
> }
>
No, selectively loading multiple versions of the same Lua module is
not supported by the standard Lua language.
>
> moreover, how can you tell in nginx that the "lua_package_path" will not be
> the same according to location ?
>
No, lua_package_path cannot be used on the "location" context. The Lua
VM is shared on the nginx http {} block level.
The only way to have multiple Lua VMs in each nginx worker process is
to define multiple http {} blocks. But the use of multiple http {}
blocks is an undocumented feature in the nginx core and is known to
have some issues in some special cases due to the imperfect isolation
of the http {} contexts in the nginx core. Be careful :)
Best regards,
-agentzh