Skip to content

Commit

Permalink
refactor as per code suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Revolyssup committed Apr 12, 2024
1 parent dd1e3d9 commit 1bfbe6c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions apisix/core/config_etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,23 +328,23 @@ local function sync_data(self)
end

::waitdir::
-- get latest uncompacted revision
local res, err = self.etcd_cli:get('/nonexisting',{
count_only = true,
range_end = "\0"
})
if err then
log.error("failed to get latest uncompacted revision: ", err)
end
local rev
if res and res.body and res.body.header and res.body.header.revision then
rev = tonumber(res.body.header.revision)
end
local dir_res, err = waitdir(self.etcd_cli, self.key, self.prev_index + 1, self.timeout)
log.info("waitdir key: ", self.key, " prev_index: ", self.prev_index + 1)
log.info("res: ", json.delay_encode(dir_res, true))
if not dir_res then
if err == "timeout" then
-- get latest uncompacted revision
local res, err = self.etcd_cli:get('/nonexisting',{
count_only = true,
range_end = "\0"
})
if err then
log.error("failed to get latest uncompacted revision: ", err)
end
local rev
if res and res.body and res.body.header and res.body.header.revision then
rev = tonumber(res.body.header.revision)
end
log.info("updating prev_index from "..self.prev_index.." to "..rev )
if rev then
if rev == self.prev_index then
Expand Down

0 comments on commit 1bfbe6c

Please sign in to comment.