Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(clustering): dont generate event for full sync #13854

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ local function do_sync()
return nil, err
end

local crud_event_type = old_entity and "update" or "create"

-- If we will wipe lmdb, we don't need to delete it from lmdb.
if old_entity and not wipe then
local res, err = delete_entity_for_txn(t, delta_type, old_entity, opts)
Expand All @@ -277,7 +275,10 @@ local function do_sync()
", version: ", delta_version,
", type: ", delta_type)

ev = { delta_type, crud_event_type, delta_entity, old_entity, }
-- wipe the whole lmdb, should not have events
Copy link
Contributor

Choose a reason for hiding this comment

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

This is worth refactoring. Let's find a better form of the code.

if not wipe then
ev = { delta_type, old_entity and "update" or "create", delta_entity, old_entity, }
end

else
-- delete the entity
Expand All @@ -299,11 +300,17 @@ local function do_sync()
", version: ", delta_version,
", type: ", delta_type)

ev = { delta_type, "delete", old_entity, }
end
-- wipe the whole lmdb, should not have events
if not wipe then
ev = { delta_type, "delete", old_entity, }
end
end -- if delta_entity ~= nil and delta_entity ~= ngx_null

crud_events_n = crud_events_n + 1
crud_events[crud_events_n] = ev
-- wipe the whole lmdb, should not have events
if not wipe then
crud_events_n = crud_events_n + 1
crud_events[crud_events_n] = ev
end

-- delta.version should not be nil or ngx.null
assert(type(delta_version) == "number")
Expand Down
Loading