-
Notifications
You must be signed in to change notification settings - Fork 275
feature: add the balancer.recreate_request
function, which allows user to recreate request buffer in balancer phase.
#302
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1bdcc26
feature: add the `balancer.recreate_request` function, which allows user
dndx 5858696
temp to make tests pass
dndx 1e749c8
fixed styling according to @thibaultcha's comments
dndx 0f621fe
fix according to @agentzh's comments
dndx 4349f7b
ci: changed to use the master branch.
doujiang24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ use t::TestCore; | |
|
||
repeat_each(2); | ||
|
||
plan tests => repeat_each() * (blocks() * 4 + 5); | ||
plan tests => repeat_each() * (blocks() * 4 + 6); | ||
|
||
$ENV{TEST_NGINX_LUA_PACKAGE_PATH} = "$t::TestCore::lua_package_path"; | ||
|
||
|
@@ -834,3 +834,51 @@ GET /t | |
[lua] log_by_lua(nginx.conf:59):2: ngx.var.upstream_addr is 127.0.0.3:12345, 127.0.0.3:12346 | ||
--- no_error_log | ||
[alert] | ||
|
||
|
||
|
||
=== TEST 19: recreate upstream module requests with header change | ||
--- http_config | ||
lua_package_path "$TEST_NGINX_LUA_PACKAGE_PATH"; | ||
|
||
upstream backend { | ||
server 0.0.0.1; | ||
|
||
balancer_by_lua_block { | ||
print("here") | ||
local b = require "ngx.balancer" | ||
|
||
if ngx.ctx.balancer_ran then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
assert(b.set_current_peer("127.0.0.1", tonumber(ngx.var.server_port))) | ||
ngx.var.test = "second" | ||
assert(b.recreate_request()) | ||
|
||
else | ||
ngx.ctx.balancer_ran = true | ||
assert(b.set_current_peer("127.0.0.3", 12345)) | ||
assert(b.set_more_tries(1)) | ||
end | ||
} | ||
} | ||
--- config | ||
location = /t { | ||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_404; | ||
proxy_next_upstream_tries 2; | ||
|
||
set $test "first"; | ||
|
||
proxy_set_header X-Test $test; | ||
proxy_pass http://backend/upstream; | ||
} | ||
|
||
location = /upstream { | ||
return 200 "value is: $http_x_test"; | ||
} | ||
--- request | ||
GET /t | ||
--- response_body: value is: second | ||
--- error_log | ||
connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1 | ||
--- no_error_log | ||
[warn] | ||
[crit] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to
0.1.20
.