Skip to content

Commit

Permalink
is_rpc_ready()
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Nov 21, 2024
1 parent 01fc1ad commit 24877d8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,26 @@ function _M:init(manager, is_cp)
end


local function do_sync()
--- check rpc connection is ready
-- check if rpc connection is ready
local function is_rpc_ready()
for i = 1, 5 do
local res = kong.rpc:get_peers()

-- control_plane is ready
if res["control_plane"] then
break
return true
end

-- retry later
ngx.sleep(0.1 * i)
end
end


local function do_sync()
if not is_rpc_ready() then
return nil, "rpc is not ready"
end

local ns_deltas, err = kong.rpc:call("control_plane", "kong.sync.v2.get_delta",
{ default =
Expand Down

0 comments on commit 24877d8

Please sign in to comment.