-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(*): retain events on send failures
### Summary If there is an error with socket connection the popped event data is retained and pushed in front of the queue.
- Loading branch information
Showing
5 changed files
with
113 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# vim:set ft= ts=4 sw=4 et fdm=marker: | ||
use Test::Nginx::Socket::Lua; | ||
|
||
plan tests => repeat_each() * (blocks() * 5); | ||
|
||
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir(); | ||
|
||
check_accum_error_log(); | ||
master_on(); | ||
workers(1); | ||
run_tests(); | ||
|
||
__DATA__ | ||
|
||
=== TEST 1: queue works correctly | ||
--- config | ||
location = /test { | ||
access_by_lua_block { | ||
local queue = require("resty.events.queue").new(10240) | ||
local value, err = queue:pop() | ||
ngx.say(err) | ||
assert(queue:push_front("first")) | ||
ngx.say(queue:pop()) | ||
assert(queue:push("second")) | ||
assert(queue:push_front("first")) | ||
ngx.say(queue:pop()) | ||
ngx.say(queue:pop()) | ||
local value, err = queue:pop() | ||
ngx.say(err) | ||
assert(queue:push("first")) | ||
assert(queue:push("second")) | ||
ngx.say(queue:pop()) | ||
ngx.say(queue:pop()) | ||
assert(queue:push_front("third")) | ||
assert(queue:push_front("second")) | ||
assert(queue:push_front("first")) | ||
ngx.say(queue:pop()) | ||
ngx.say(queue:pop()) | ||
ngx.say(queue:pop()) | ||
} | ||
} | ||
--- request | ||
GET /test | ||
--- response_body | ||
timeout | ||
first | ||
first | ||
second | ||
timeout | ||
first | ||
second | ||
first | ||
second | ||
third | ||
--- no_error_log | ||
[crit] | ||
[error] | ||
[warn] |