Skip to content

Commit

Permalink
fix post_hook_delete_func
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 14, 2024
1 parent 240b92a commit 62ee775
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions kong/clustering/services/sync/hooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ function _M:notify_all_nodes()
end


function _M:entity_delta_writer(row_id, row, name, options, ws_id)
function _M:entity_delta_writer(row, name, options, ws_id)
local deltas = {
{
type = name,
id = row_id,
id = row.id,
ws_id = ws_id,
row = row,
},
Expand Down Expand Up @@ -136,15 +136,38 @@ function _M:register_dao_hooks()
return row
end

return self:entity_delta_writer(row.id, row, name, options, ws_id)
return self:entity_delta_writer(row, name, options, ws_id)
end

local function post_hook_delete_func(row, name, options, ws_id, cascade_entries)
if not is_db_export(name) then
return row
end

return self:entity_delta_writer(row.id, ngx_null, name, options, ws_id)
local deltas = {
{
type = name,
id = row.id,
ws_id = ws_id,
row = ngx_null,
},
}

local res, err = self.strategy:insert_delta(deltas)
if not res then
self.strategy:cancel_txn()
return nil, err
end

res, err = self.strategy:commit_txn()
if not res then
self.strategy:cancel_txn()
return nil, err
end

self:notify_all_nodes()

return row
end

local dao_hooks = {
Expand Down

0 comments on commit 62ee775

Please sign in to comment.