Skip to content

Commit

Permalink
refactor(clustering): use tools.table.EMPTY to avoid overhead (#14180)
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw authored Jan 20, 2025
1 parent 7fd7f04 commit 122810c
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

1 comment on commit 122810c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong-dev:122810c04c44413749bd425a6813172ccf456586
Artifacts available https://github.com/Kong/kong/actions/runs/12863747159

Please sign in to comment.