Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 20, 2024
1 parent 2b1b167 commit 7b54b46
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
6 changes: 3 additions & 3 deletions kong/clustering/services/sync/hooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ local _MT = { __index = _M, }


local hooks = require("kong.hooks")
local constants = require("kong.constants")
--local constants = require("kong.constants")


local CLUSTERING_PING_INTERVAL = constants.CLUSTERING_PING_INTERVAL
--local CLUSTERING_PING_INTERVAL = constants.CLUSTERING_PING_INTERVAL
local ngx_log = ngx.log
local ngx_DEBUG = ngx.DEBUG
--local ngx_DEBUG = ngx.DEBUG
local ngx_ERR = ngx.ERR


Expand Down
14 changes: 11 additions & 3 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local _M = {}
local _MT = { __index = _M, }


local semaphore = require("ngx.semaphore")
local lmdb = require("resty.lmdb")
--local semaphore = require("ngx.semaphore")
--local lmdb = require("resty.lmdb")
local txn = require("resty.lmdb.transaction")
local declarative = require("kong.db.declarative")
local constants = require("kong.constants")
Expand Down Expand Up @@ -201,9 +201,13 @@ function _M:sync_once(delay)
-- upsert the entity
-- does the entity already exists?
local old_entity, err = kong.db[delta.type]:select(delta.row)
if err then
return nil, err
end

local crud_event_type = "create"

if entity then
if old_entity then
local res, err = delete_entity_for_txn(t, delta.type, old_entity, nil)
if not res then
return nil, err
Expand All @@ -223,6 +227,10 @@ function _M:sync_once(delay)
else
-- delete the entity
local old_entity, err = kong.db[delta.type]:select({ id = delta.id, }) -- TODO: composite key
if err then
return nil, err
end

if old_entity then
local res, err = delete_entity_for_txn(t, delta.type, old_entity, nil)
if not res then
Expand Down
8 changes: 4 additions & 4 deletions kong/db/declarative/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ local sha256_hex = require("kong.tools.sha256").sha256_hex
local pk_string = declarative_config.pk_string

local assert = assert
local sort = table.sort
--local sort = table.sort
local type = type
local pairs = pairs
local next = next
--local next = next
local insert = table.insert
local string_format = string.format
local null = ngx.null
Expand Down Expand Up @@ -306,7 +306,7 @@ local function insert_entity_for_txn(t, entity_name, item, options)
end

if fdata.unique_across_ws then
ws_id = default_workspace_id
ws_id = kong.default_workspace
end

local key = unique_field_key(entity_name, ws_id, fname, value)
Expand Down Expand Up @@ -364,7 +364,7 @@ local function delete_entity_for_txn(t, entity_name, item, options)
end

if fdata.unique_across_ws then
ws_id = default_workspace_id
ws_id = kong.default_workspace
end

local key = unique_field_key(entity_name, ws_id, fname, value)
Expand Down
29 changes: 16 additions & 13 deletions kong/db/strategies/off/init.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
local declarative_config = require("kong.db.schema.others.declarative_config")
local workspaces = require("kong.workspaces")
--local workspaces = require("kong.workspaces")
local lmdb = require("resty.lmdb")
local lmdb_prefix = require("resty.lmdb.prefix")
local lmdb_transaction = require("resty.lmdb.transaction")
--local lmdb_transaction = require("resty.lmdb.transaction")
local marshaller = require("kong.db.declarative.marshaller")
local yield = require("kong.tools.yield").yield
--local yield = require("kong.tools.yield").yield
local declarative = require("kong.db.declarative")

local kong = kong
local string_format = string.format
local type = type
local next = next
local sort = table.sort
local pairs = pairs
local match = string.match
--local sort = table.sort
--local pairs = pairs
--local match = string.match
local assert = assert
local tostring = tostring
local tonumber = tonumber
local encode_base64 = ngx.encode_base64
local decode_base64 = ngx.decode_base64
--local tostring = tostring
--local tonumber = tonumber
--local encode_base64 = ngx.encode_base64
--local decode_base64 = ngx.decode_base64
local null = ngx.null
local unmarshall = marshaller.unmarshall
local marshall = marshaller.marshall
--local marshall = marshaller.marshall
local lmdb_get = lmdb.get
local get_workspace_id = workspaces.get_workspace_id
--local get_workspace_id = workspaces.get_workspace_id
local pk_string = declarative_config.pk_string
local unique_field_key = declarative.unique_field_key
local item_key = declarative.item_key
local item_key_prefix = declarative.item_key_prefix
local workspace_id = declarative.workspace_id
local foreign_field_key_prefix = declarative.foreign_field_key_prefix


local PROCESS_AUTO_FIELDS_OPTS = {
Expand Down Expand Up @@ -110,7 +111,7 @@ local function page_for_prefix(self, prefix, size, offset, options, follow)

offset = offset or prefix

local list = {}
--local list = {}

local ret = {}
local ret_idx = 0
Expand Down Expand Up @@ -201,6 +202,7 @@ local function select_by_field(self, field, value, options)
end


--[[
local function remove_nulls(tbl)
for k,v in pairs(tbl) do
if v == null then
Expand All @@ -212,6 +214,7 @@ local function remove_nulls(tbl)
end
return tbl
end
--]]


do
Expand Down

0 comments on commit 7b54b46

Please sign in to comment.