Skip to content

Commit

Permalink
plugin test
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Nov 26, 2024
1 parent 089bf40 commit 97bd6b2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
6 changes: 5 additions & 1 deletion kong/db/dao/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -966,12 +966,16 @@ function _M.new(db, schema, strategy, errors)
local fk_methods = generate_foreign_key_methods(schema)
local super = setmetatable(fk_methods, DAO)

local pagination = strategy.connector and
strategy.connector.defaults.pagination or
defaults.pagination

local self = {
db = db,
schema = schema,
strategy = strategy,
errors = errors,
pagination = kong_table.shallow_copy(defaults.pagination),
pagination = kong_table.shallow_copy(pagination),
super = super,
}

Expand Down
4 changes: 0 additions & 4 deletions kong/db/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ function DB.new(kong_config, strategy)
return nil, fmt("no strategy found for schema '%s'", schema.name)
end
daos[schema.name] = DAO.new(self, schema, strategy, errors)

-- check pagination.max_page_size
assert(daos[schema.name].pagination.max_page_size ==
strategy == "off" and 2048 or 50000)
end
end

Expand Down
4 changes: 1 addition & 3 deletions kong/db/strategies/connector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ local Connector = {
pagination = {
page_size = 1000,
-- lmdb will not support huge page size
max_page_size = kong and kong.configuration and
kong.configuration.database == "off" and
2048 or 50000,
max_page_size = 50000,
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions kong/db/strategies/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ function _M.new(kong_config, database, schemas, errors)

do
local base_connector = require "kong.db.strategies.connector"

-- lmdb will not support huge page size
if database == "off" then
base_connector.defaults.pagination.max_page_size = 2048
end

local mt = getmetatable(connector)
setmetatable(mt, {
__index = function(t, k)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@ local LmdbPaginationTestHandler = {
}


local log = ngx.log
local ERR = ngx.ERR


local function test()
local db = kong.db

--assert(db.routes.pagination.max_page_size == 2048)
ngx.log(ngx.DEBUG, "xxx LmdbPaginationTestHandler ", db.routes.pagination.max_page_size)
assert(db.routes.pagination.max_page_size == 2048)
end


Expand Down

0 comments on commit 97bd6b2

Please sign in to comment.