Skip to content

Commit

Permalink
refine due to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ProBrian committed Aug 13, 2024
1 parent 51fab9e commit dbd94d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ function Kong.init()
-- retrieve kong_config
local conf_path = pl_path.join(ngx.config.prefix(), ".kong_env")
local config = assert(conf_loader(conf_path, nil, { from_kong_env = true }))

-- The dns client has been initialized in conf_loader, so we set it directly.
-- Other modules should use 'kong.dns' to avoid reinitialization.
kong.dns = assert(package.loaded["kong.resty.dns.client"])

reset_kong_shm(config)
Expand Down
2 changes: 1 addition & 1 deletion kong/runloop/balancer/targets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ local resolve_timer_running
local queryDns

function targets_M.init()
dns_client = assert(package.loaded["kong.resty.dns.client"])
dns_client = assert(kong.dns)
if renewal_heap:size() > 0 then
renewal_heap = require("binaryheap").minUnique()
renewal_weak_cache = setmetatable({}, { __mode = "v" })
Expand Down
3 changes: 1 addition & 2 deletions kong/timing/hooks/dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ local _M = {}

local timing

local client = assert(package.loaded["kong.resty.dns.client"])

local function before_toip(qname, _port, _dnsCacheOnly, _try_list)
timing.enter_context("dns")
timing.enter_context(qname)
Expand All @@ -26,6 +24,7 @@ function _M.register_hooks(timing_module)
Here is the signature of the `toip()` function:
function toip(self, qname, port, dnsCacheOnly, try_list)
--]]
local client = assert(kong.dns)
req_dyn_hook.hook_function("timing", client, "toip", 4, {
befores = { before_toip },
afters = { after_toip },
Expand Down

0 comments on commit dbd94d8

Please sign in to comment.