Skip to content

Commit

Permalink
refactor(pubsub): simpify the get_cmd implementation (#8608)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander authored Jan 29, 2023
1 parent 9c899b8 commit 3fdbbaa
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions apisix/core/pubsub.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ local pb = require("pb")
local ngx = ngx
local setmetatable = setmetatable
local pcall = pcall
local pairs = pairs


local _M = { version = 0.1 }
Expand Down Expand Up @@ -57,15 +56,10 @@ end

-- parse command name and parameters from client message
local function get_cmd(data)
for key, value in pairs(data) do
-- There are sequence and command properties in the data,
-- select the handler according to the command value.
if key ~= "sequence" and key ~= "req" then
-- new version of lua-protobuf will add a new field 'oneof_name = oneof_type'
-- so we also need to filter it out (in this case, the 'req' key)
return key, value
end
end
-- There are sequence and command properties in the data,
-- select the handler according to the command value.
local key = data.req
return key, data[key]
end


Expand Down

0 comments on commit 3fdbbaa

Please sign in to comment.