lua-upstream-nginx-module icon indicating copy to clipboard operation
lua-upstream-nginx-module copied to clipboard

add set_peer_weight api

Open rockiee281 opened this issue 10 years ago • 10 comments

add new api for upstream module for #4 , change backen weight dynamic

rockiee281 avatar Oct 15 '14 08:10 rockiee281

@rockiee281 Thank you for looking into this! Several comments though:

  1. I think you need to (at least) update peers->total_weight, peers->weighted, and peer->current_weight fields accordingly as well.
  2. I don't see any tests for it. Will you add some corresponding test cases to the existing test suite?

Thanks!

agentzh avatar Oct 16 '14 19:10 agentzh

Hi, @agentzh ,add some commits to update peers->total_weight, peers->weighted and peer->current_weight, wish it works because I'm not so familar with nginx and C.

I'll try to add some test case later. But I cannot find any example in this project, where can I find them?

rockiee281 avatar Oct 20 '14 12:10 rockiee281

@rockiee281 It already comes with a test suite:

https://github.com/openresty/lua-upstream-nginx-module/tree/master/t

agentzh avatar Oct 20 '14 20:10 agentzh

@agentzh add some test case for this feature

rockiee281 avatar Oct 27 '14 12:10 rockiee281

@rockiee281 Thank you very much! I'll look into this as soon as I can manage :)

agentzh avatar Oct 28 '14 19:10 agentzh

There's an implement here😂 I just made an implement myself these days

jamespan avatar Nov 27 '15 16:11 jamespan

I remember there was already a PR for this feature. Check the pull request list of this repos?

agentzh avatar Nov 28 '15 04:11 agentzh

@agentzh we are talking under that PR right now. My newly post mention the functions I added to the lua upstream module. Take a look if you like.

http://blog.jamespan.me/2015/11/27/fastest-first-load-balancer-for-nginx-with-lua/

I use three functions to update weight, current weight, and effective weight respectively.

So I wander if I need to finish the test suit and push another PR.

jamespan avatar Nov 28 '15 05:11 jamespan

@JamesPan Thanks for the efforts. I will have a closer look at your PR later. Currently busy with the PRs implementing the ngx.semaphore API in ngx_lua.

agentzh avatar Nov 28 '15 09:11 agentzh

It's been almost 3 years. What are folks doing to change weights via lua? Or is there a better way/module to that?

pfischermx avatar Apr 02 '18 20:04 pfischermx