Hello!
On Tue, Jan 22, 2013 at 8:12 AM, luis.gasca wrote:
> set_hashed_upstream $kestrel DSR_CLUSTER "12" -- 12 is just for testing
>
> content_by_lua '
>
> ngx.log(ngx.CRIT,ngx.var["backend"])
>
[...]
> In the nginx log file I am getting "DSR2" as a string. However, I want to
> access both IP and Port of the server DSR2 to use it in memc:connect() call
>
No, there's no Lua API to access the internal details of a specific
upstream. You're recommended to do the upstream hashing (or sharding
in general) completely in Lua. For example,
local servers = {
{"192.168.1.226", 22133},
{"192.168.1.227", 22133}
}
local server = hash_my_servers(servers, my_key)
local ok, err = memc:connect(server[1], server[2])
where you just need to write a simple hash_my_servers Lua function.
You can use modulo or consistent hashing or any other sharding
algorithm that you like ;)
Best regards,
-agentzh