-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "fix(*): prevent queues from growing without bounds (#…
- Loading branch information
1 parent
2350ba2
commit 0cff934
Showing
5 changed files
with
103 additions
and
35 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,33 @@ | ||
|
||
local BatchQueue = require "kong.tools.batch_queue" | ||
local helpers = require "spec.helpers" | ||
|
||
describe("batch queue", function() | ||
|
||
it("observes the limit parameter", function() | ||
local count = 0 | ||
local last | ||
local function process(entries) | ||
count = count + #entries | ||
last = entries[#entries] | ||
return true | ||
end | ||
|
||
local q = BatchQueue.new("batch-queue-unit-test", process, {max_queued_batches=2, batch_max_size=100, process_delay=0}) | ||
|
||
q:add(1) | ||
q:flush() | ||
q:add(2) | ||
q:flush() | ||
q:add(3) | ||
q:flush() | ||
|
||
helpers.wait_until(function() | ||
ngx.sleep(.1) | ||
return #q.batch_queue == 0 | ||
end, 1) | ||
|
||
assert.equal(2, count) | ||
assert.equal(3, last) | ||
end) | ||
end) |