Skip to content

Commit

Permalink
simplify the logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 24, 2023
1 parent 14c2598 commit f7a116d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions kong/tools/request_aware_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ local setmetatable = setmetatable


local get_request_id = request_id.get
local var_available = request_id.var_available


local ALLOWED_REQUEST_ID_K = "__allowed_request_id"


-- Check if access is allowed for table, based on the request ID
local function enforce_sequential_access(table)
if not var_available() then
local curr_request_id = get_request_id()

if not curr_request_id then
-- allow access and reset allowed request ID
rawset(table, ALLOWED_REQUEST_ID_K, nil)
return
end

local curr_request_id = get_request_id()
local allowed_request_id = rawget(table, ALLOWED_REQUEST_ID_K)
if not allowed_request_id then
-- first access. Set allowed request ID and allow access
Expand Down
2 changes: 0 additions & 2 deletions kong/tracing/request_id.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ end
return {
get = get,

var_available = var_available,

-- for unit testing
_get_ctx_request_id = get_ctx_request_id,
}

0 comments on commit f7a116d

Please sign in to comment.