Skip to content

Commit

Permalink
refactor(clustering): use tools.table.EMPTY to avoid overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jan 17, 2025
1 parent dbc9e8a commit 4fa071b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kong/clustering/control_plane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local compat = require("kong.clustering.compat")
local constants = require("kong.constants")
local events = require("kong.clustering.events")
local calculate_config_hash = require("kong.clustering.config_helper").calculate_config_hash
local EMPTY = require("kong.tools.table").EMPTY


local string = string
Expand Down Expand Up @@ -260,7 +261,7 @@ function _M:handle_cp_websocket(cert)
labels = data.labels,
cert_details = dp_cert_details,
-- only update rpc_capabilities if dp_id is connected
rpc_capabilities = rpc_peers and rpc_peers[dp_id] or {},
rpc_capabilities = rpc_peers and rpc_peers[dp_id] or EMPTY,
}, { ttl = purge_delay, no_broadcast_crud_event = true, })
if not ok then
ngx_log(ngx_ERR, _log_prefix, "unable to update clustering data plane status: ", err, log_suffix)
Expand Down
3 changes: 2 additions & 1 deletion kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local constants = require("kong.constants")
local concurrency = require("kong.concurrency")
local isempty = require("table.isempty")
local events = require("kong.runloop.events")
local EMPTY = require("kong.tools.table").EMPTY


local insert_entity_for_txn = declarative.insert_entity_for_txn
Expand Down Expand Up @@ -94,7 +95,7 @@ function _M:init_cp(manager)
cert_details = node_info.cert_details, -- get from rpc call
sync_status = CLUSTERING_SYNC_STATUS.NORMAL,
config_hash = default_namespace_version,
rpc_capabilities = rpc_peers and rpc_peers[node_id] or {},
rpc_capabilities = rpc_peers and rpc_peers[node_id] or EMPTY,
}, { ttl = purge_delay, no_broadcast_crud_event = true, })
if not ok then
ngx_log(ngx_ERR, "unable to update clustering data plane status: ", err)
Expand Down

0 comments on commit 4fa071b

Please sign in to comment.