Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roundrobin:new() should support empty nodes, not just throw error #31

Open
stone-wind opened this issue Jul 16, 2020 · 7 comments
Open

Comments

@stone-wind
Copy link

No description provided.

@spacewander
Copy link
Member

Why?

@stone-wind
Copy link
Author

stone-wind commented Jul 16, 2020

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.

@stone-wind
Copy link
Author

stone-wind commented Jul 16, 2020

case nginx do not allow 0 server in upstream, maybe chash should throw error when get empty nodes like roundrobin

@spacewander
Copy link
Member

Pull request is welcome.

@spacewander
Copy link
Member

@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.

@stone-wind
Copy link
Author

stone-wind commented Jul 20, 2020

@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.

@spacewander
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants