Skip to content

Commit

Permalink
fix(clustering): encode using lua-cjson instead of `lua-resty-simdj…
Browse files Browse the repository at this point in the history
…son` (#13441)

In #13421, we introduced lua-resty-simdjson, but the behavior of encoding has some differences with cjson, this PR disabled simdjson encoding temporarily.

KAG-5061

Related PR: Kong/lua-resty-simdjson#38
  • Loading branch information
chronolaw authored Aug 1, 2024
1 parent 5fd6e3f commit 6ab6b73
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,8 +170,6 @@ 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

Expand All @@ -185,12 +184,15 @@ else
return res, err
end

_M.json_encode = cjson.encode
--[[ TODO: make simdjson encoding more compatible with cjson
-- enable yield and reentrant for encode
local enc = require("resty.simdjson.encoder").new(true)
_M.json_encode = function(obj)
return enc:process(obj)
end
--]]
end


Expand Down

1 comment on commit 6ab6b73

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Bazel Build

Docker image available kong/kong:6ab6b730adc415a62b6bfa568499430b6008866a
Artifacts available https://github.com/Kong/kong/actions/runs/10196185953

Please sign in to comment.