From 1ccd94fb84a9975587c387129f41b6567b614f80 Mon Sep 17 00:00:00 2001 From: Chrono Date: Tue, 5 Sep 2023 23:11:36 +0800 Subject: [PATCH] style(db/declarative): small clean for `load_into_cache()` (#11507) --- kong/db/declarative/import.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kong/db/declarative/import.lua b/kong/db/declarative/import.lua index 2ede32c984fd..e2a4a619aea9 100644 --- a/kong/db/declarative/import.lua +++ b/kong/db/declarative/import.lua @@ -16,9 +16,7 @@ local type = type local pairs = pairs local next = next local insert = table.insert -local min = math.min local null = ngx.null -local md5 = ngx.md5 local get_phase = ngx.get_phase local yield = utils.yield local sha256 = utils.sha256_hex @@ -443,6 +441,9 @@ local load_into_cache_with_events do local events = require("kong.runloop.events") + local md5 = ngx.md5 + local min = math.min + local exiting = ngx.worker.exiting local function load_into_cache_with_events_no_lock(entities, meta, hash, hashes) @@ -450,8 +451,6 @@ do return nil, "exiting" end - local reconfigure_data - local ok, err, default_ws = load_into_cache(entities, meta, hash) if not ok then if err:find("MDB_MAP_FULL", nil, true) then @@ -464,6 +463,7 @@ do local router_hash local plugins_hash local balancer_hash + if hashes then if hashes.routes ~= DECLARATIVE_EMPTY_CONFIG_HASH then router_hash = md5(hashes.services .. hashes.routes) @@ -479,13 +479,12 @@ do targets_hash ~= DECLARATIVE_EMPTY_CONFIG_HASH then balancer_hash = md5(upstreams_hash .. targets_hash) - else balancer_hash = DECLARATIVE_EMPTY_CONFIG_HASH end end - reconfigure_data = { + local reconfigure_data = { default_ws, router_hash, plugins_hash,