Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jan 10, 2025
1 parent 8fb909b commit c318f77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kong/clustering/rpc/socket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,14 @@ function _M:start()

-- timeout
if not payload then
if #batch_requests > 0 then
local n = #batch_requests
if n > 0 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: ", #batch_requests)
ngx_log(ngx_DEBUG, "[rpc] sent batch RPC call: ", n)

tb_clear(batch_requests)
end
Expand Down Expand Up @@ -378,13 +379,14 @@ function _M:start()
tb_insert(batch_requests, payload)

-- send batch requests
if #batch_requests >= batch_size then
local n = #batch_requests
if n >= batch_size 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: ", #batch_requests)
ngx_log(ngx_DEBUG, "[rpc] sent batch RPC call: ", n)

tb_clear(batch_requests)
end
Expand Down
2 changes: 2 additions & 0 deletions spec/02-integration/18-hybrid_rpc/06-batch-rpc_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ for _, strategy in helpers.each_strategy() do
"kong.test.batch called: kong", true)
assert.logfile().has.line(
"kong.test.batch called: gateway", true)
assert.logfile().has.line(
"[rpc] notification has no response", true)

return true
end, 15)
Expand Down

0 comments on commit c318f77

Please sign in to comment.