Skip to content

Commit

Permalink
fix(clustering): still decoding with cjson
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Aug 1, 2024
1 parent cffc4a9 commit de3dec2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kong/clustering/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local ws_client = require("resty.websocket.client")
local ws_server = require("resty.websocket.server")
local parse_url = require("socket.url").parse
local process_type = require("ngx.process").type
local cjson = require("cjson.safe")

local type = type
local table_insert = table.insert
Expand Down Expand Up @@ -169,12 +170,12 @@ end
-- encode/decode json with cjson or simdjson
local ok, simdjson_dec = pcall(require, "resty.simdjson.decoder")
if not ok or kong.configuration.cluster_cjson then
local cjson = require("cjson.safe")

_M.json_decode = cjson.decode
_M.json_encode = cjson.encode

else
_M.json_decode = cjson.decode
--[[ TODO: fix the behavior of simdjson encoding
_M.json_decode = function(str)
-- enable yield and not reentrant for decode
local dec = simdjson_dec.new(true)
Expand All @@ -184,6 +185,7 @@ else
return res, err
end
--]]

-- enable yield and reentrant for encode
local enc = require("resty.simdjson.encoder").new(true)
Expand Down

0 comments on commit de3dec2

Please sign in to comment.