Skip to content

Commit

Permalink
chore: refactor wasm crud event-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
flrgh committed Nov 7, 2024
1 parent 7c08e55 commit d387e74
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions kong/runloop/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,25 @@ local function crud_wasm_handler(data, schema_name)
return
end

local updated = false

-- always invalidate for filter_chain entity changes
if schema_name == "filter_chains" then
updated = true

-- cache is invalidated on service/route deletion to ensure we don't
-- have oprhaned filter chain data cached
local is_delete = data.operation == "delete"
and (schema_name == "services"
or schema_name == "routes")
elseif schema_name == "services" or schema_name == "routes"
updated = data.operation == "delete"

local is_filter_plugin = false
if schema_name == "plugins" then
-- invalidate for changes to wasm filter plugin entities
elseif schema_name == "plugins" then
local new_name = data.entity.name
local old_name = data.old_entity and data.old_entity.name
is_filter_plugin = (new_name and wasm.filters_by_name[new_name]) or
(old_name and wasm.filters_by_name[old_name])
updated = (new_name and wasm.filters_by_name[new_name]) or
(old_name and wasm.filters_by_name[old_name])
end

local updated = schema_name == "filter_chains" or is_delete or is_filter_plugin


if updated then
log(DEBUG, "[events] wasm filter chains updated, invalidating cache")
core_cache:invalidate("filter_chains:version")
Expand Down

0 comments on commit d387e74

Please sign in to comment.