Skip to content

Commit

Permalink
refactor(clustering/rpc): wait 5 seconds for non-batching rpc calls
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jan 18, 2025
1 parent 6a81453 commit fd6aae8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kong/clustering/rpc/socket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -347,22 +347,21 @@ function _M:start()
local batch_requests = {}

while not exiting() do
-- 0.5 seconds for not waiting too long
local payload, err = self.outgoing:pop(0.5)
-- 5 seconds for non-batching rpc calls
local payload, err = self.outgoing:pop(5)
if err then
return nil, err
end

-- timeout
if not payload then
local n = #batch_requests
if n > 0 then
if not isempty(batch_requests) then
local bytes, err = self.wb:send_binary(compress_payload(batch_requests))
if not bytes then
return nil, err
end

ngx_log(ngx_DEBUG, "[rpc] sent batch RPC call: ", n)
ngx_log(ngx_DEBUG, "[rpc] sent batch RPC call: ", #batch_requests)

tb_clear(batch_requests)
end
Expand Down

0 comments on commit fd6aae8

Please sign in to comment.