Open stone-wind opened 4 years ago
chash:new() almost support empty nodes, and then it can dynamic set/delete with only one init action. it's convenient. chash's _find_id, find, next have problem when support empty nodes. it's easy to reach if we allow return nil.
case nginx do not allow 0 server in upstream, maybe chash should throw error when get empty nodes like roundrobin
Pull request is welcome.
@stone-wind
A little question: would it be better if we don't allow find
, next
call and throw error like the current behavior. A nil
server id is not valid. An empty roundrobin is allowed, but if you want to get any nodes from it, you need to fill it first.
@spacewander my server_list come from redis, weight equal 0 means don't need proxy conn to this backend. so my choose is support empty nodes and 0 weight node, and throw error when weight is less than 0 in init(reinit) func.
@stone-wind I think you can achieve this with a fake backend, without modifying the exist code? When the fake backend is chosen, you don't need to proxy.
Why?