Skip to content

Commit

Permalink
sync comments clean
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 27, 2024
1 parent 15aaf33 commit 150fa2d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 7 additions & 2 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ local CLUSTERING_SYNC_STATUS = constants.CLUSTERING_SYNC_STATUS
local SYNC_MUTEX_OPTS = { name = "get_delta", timeout = 0, }


local pairs = pairs
local ipairs = ipairs
local fmt = string.format
local ngx_null = ngx.null
Expand All @@ -44,7 +43,8 @@ function _M:init_cp(manager)
-- CP
-- Method: kong.sync.v2.get_delta
-- Params: versions: list of current versions of the database
-- { { namespace = "default", version = 1000, }, }
--
-- example: { default = { version = 1000, }, }
local purge_delay = manager.conf.cluster_data_plane_purge_delay

local function gen_delta_result(res, wipe)
Expand Down Expand Up @@ -195,6 +195,9 @@ local function do_sync()
return true
end

-- ns_deltas should look like:
-- { default = { deltas = { ... }, wipe = true, }, }

local ns_delta = ns_deltas.default
if not ns_delta then
return nil, "default namespace does not exist inside params"
Expand Down Expand Up @@ -233,6 +236,8 @@ local function do_sync()
local crud_events = {}
local crud_events_n = 0

-- delta should look like:
-- { type = ..., row = { ... }, version = 1, ws_id = ..., }
for _, delta in ipairs(deltas) do
local delta_type = delta.type
local delta_row = delta.row
Expand Down
4 changes: 2 additions & 2 deletions kong/clustering/services/sync/strategies/postgres.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ end


function _M:get_latest_version()
local sql = "SELECT MAX(version) AS max_version FROM clustering_sync_version"
local sql = "SELECT MAX(version) FROM clustering_sync_version"

local res, err = self.connector:query(sql)
if not res then
return nil, err
end

local ver = res[1] and res[1].max_version
local ver = res[1] and res[1].max
if ver == ngx_null then
return 0
end
Expand Down
14 changes: 11 additions & 3 deletions kong/db/declarative/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,18 @@ end
-- the provided LMDB txn object, this operation is only safe
-- is the entity does not already exist inside the LMDB database
--
-- The actual item key is: <entity_name>|<ws_id>|*|<pk_string>
--
-- This function sets the following:
-- * <entity_name>|<ws_id>|*|<pk_string> => serialized item
-- * <entity_name>|<ws_id>|<unique_field_name>|sha256(field_value) => <entity_name>|<ws_id>|*|<pk_string>
-- * <entity_name>|<ws_id>|<foreign_field_name>|<foreign_key>|<pk_string> -> <entity_name>|<ws_id>|*|<pk_string>
--
-- * <entity_name>|*|*|<pk_string> => serialized item
-- * <entity_name>|<ws_id>|*|<pk_string> => actual item key
--
-- * <entity_name>|*|<unique_field_name>|sha256(field_value) => actual item key
-- * <entity_name>|<ws_id>|<unique_field_name>|sha256(field_value) => actual item key
--
-- * <entity_name>|*|<foreign_field_name>|<foreign_key>|<pk_string> => actual item key
-- * <entity_name>|<ws_id>|<foreign_field_name>|<foreign_key>|<pk_string> => actual item key
--
-- DO NOT touch `item`, or else the entity will be changed
local function insert_entity_for_txn(t, entity_name, item, options)
Expand Down

0 comments on commit 150fa2d

Please sign in to comment.