openresty / lua-resty-balancer

A generic consistent hash implementation for OpenResty/Lua
322 stars 77 forks source link

Is the resty.chash concurrency safe? #39

Closed zhvala closed 3 years ago

zhvala commented 3 years ago

init_master.lua

global_chash = require("resty.chash"):new(my_nodes)
ngx.timer.every( -- update nodes every 15s
        15,
        function()
            local nodes = get_my_nodes() 
            global_chash:reinit(nodes)
        end
)
location / {
      content_by_lua '
            ...
           local node = global_chash:find(my_hash_key)
            ...
      ';
    }

Is this concurrency safe here?