From 82a51c4b519728eed4f957fdaa547ed4abea9332 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Wed, 25 Apr 2018 17:25:13 -0700 Subject: [PATCH] chore(*) move various components out of core/ directory None of those components relate to the internal runloop of Kong. Subsequent commits will rename `core/` to `runloop/`. --- bin/busted | 2 +- kong-0.13.1-0.rockspec | 13 ++++++------- kong/api/routes/apis.lua | 2 +- kong/api/routes/plugins.lua | 2 +- kong/api/routes/routes.lua | 2 +- kong/api/routes/services.lua | 2 +- kong/{core => }/api_router.lua | 0 kong/cmd/init.lua | 2 +- kong/core/handler.lua | 6 +++--- kong/{core => }/error_handlers.lua | 0 kong/{core => }/globalpatches.lua | 0 kong/init.lua | 8 ++++---- kong/plugins/rate-limiting/policies/init.lua | 2 +- .../plugins/response-ratelimiting/policies/init.lua | 2 +- kong/{core => }/reports.lua | 0 kong/{core => }/router.lua | 0 spec-old-api/01-unit/010-router_spec.lua | 6 +++--- spec/01-unit/010-router_spec.lua | 6 +++--- spec/01-unit/013-reports_spec.lua | 6 +++--- 19 files changed, 30 insertions(+), 31 deletions(-) rename kong/{core => }/api_router.lua (100%) rename kong/{core => }/error_handlers.lua (100%) rename kong/{core => }/globalpatches.lua (100%) rename kong/{core => }/reports.lua (100%) rename kong/{core => }/router.lua (100%) diff --git a/bin/busted b/bin/busted index cc4f25f9718..85dca429048 100755 --- a/bin/busted +++ b/bin/busted @@ -61,7 +61,7 @@ end require "luarocks.loader" -require("kong.core.globalpatches")({ +require("kong.globalpatches")({ cli = true, rbusted = true }) diff --git a/kong-0.13.1-0.rockspec b/kong-0.13.1-0.rockspec index 1b9cbca57d5..881e7f0daed 100644 --- a/kong-0.13.1-0.rockspec +++ b/kong-0.13.1-0.rockspec @@ -38,16 +38,20 @@ build = { modules = { ["kong"] = "kong/init.lua", ["kong.meta"] = "kong/meta.lua", + ["kong.cache"] = "kong/cache.lua", + ["kong.router"] = "kong/router.lua", + ["kong.api_router"] = "kong/api_router.lua", + ["kong.reports"] = "kong/reports.lua", ["kong.constants"] = "kong/constants.lua", ["kong.singletons"] = "kong/singletons.lua", ["kong.conf_loader"] = "kong/conf_loader.lua", + ["kong.globalpatches"] = "kong/globalpatches.lua", + ["kong.error_handlers"] = "kong/error_handlers.lua", ["kong.cluster_events"] = "kong/cluster_events.lua", ["kong.cluster_events.strategies.cassandra"] = "kong/cluster_events/strategies/cassandra.lua", ["kong.cluster_events.strategies.postgres"] = "kong/cluster_events/strategies/postgres.lua", - ["kong.cache"] = "kong/cache.lua", - ["kong.templates.nginx"] = "kong/templates/nginx.lua", ["kong.templates.nginx_kong"] = "kong/templates/nginx_kong.lua", ["kong.templates.kong_defaults"] = "kong/templates/kong_defaults.lua", @@ -98,12 +102,7 @@ build = { ["kong.core.handler"] = "kong/core/handler.lua", ["kong.core.certificate"] = "kong/core/certificate.lua", - ["kong.core.router"] = "kong/core/router.lua", - ["kong.core.api_router"] = "kong/core/api_router.lua", ["kong.core.plugins_iterator"] = "kong/core/plugins_iterator.lua", - ["kong.core.reports"] = "kong/core/reports.lua", - ["kong.core.error_handlers"] = "kong/core/error_handlers.lua", - ["kong.core.globalpatches"] = "kong/core/globalpatches.lua", ["kong.core.balancer"] = "kong/core/balancer.lua", ["kong.dao.errors"] = "kong/dao/errors.lua", diff --git a/kong/api/routes/apis.lua b/kong/api/routes/apis.lua index 22ffc989ba7..f51e532e3e6 100644 --- a/kong/api/routes/apis.lua +++ b/kong/api/routes/apis.lua @@ -1,6 +1,6 @@ local crud = require "kong.api.crud_helpers" local utils = require "kong.tools.utils" -local reports = require "kong.core.reports" +local reports = require "kong.reports" return { ["/apis/"] = { diff --git a/kong/api/routes/plugins.lua b/kong/api/routes/plugins.lua index c2b63d2cd39..e569c82416c 100644 --- a/kong/api/routes/plugins.lua +++ b/kong/api/routes/plugins.lua @@ -1,7 +1,7 @@ local crud = require "kong.api.crud_helpers" local cjson = require "cjson" local utils = require "kong.tools.utils" -local reports = require "kong.core.reports" +local reports = require "kong.reports" local singletons = require "kong.singletons" -- Remove functions from a schema definition so that diff --git a/kong/api/routes/routes.lua b/kong/api/routes/routes.lua index c9ea437313c..f5c297f65fe 100644 --- a/kong/api/routes/routes.lua +++ b/kong/api/routes/routes.lua @@ -2,7 +2,7 @@ local api_helpers = require "kong.api.api_helpers" local singletons = require "kong.singletons" local responses = require "kong.tools.responses" local endpoints = require "kong.api.endpoints" -local reports = require "kong.core.reports" +local reports = require "kong.reports" local utils = require "kong.tools.utils" local crud = require "kong.api.crud_helpers" diff --git a/kong/api/routes/services.lua b/kong/api/routes/services.lua index 7b947b9813f..ab518b1526f 100644 --- a/kong/api/routes/services.lua +++ b/kong/api/routes/services.lua @@ -2,7 +2,7 @@ local api_helpers = require "kong.api.api_helpers" local singletons = require "kong.singletons" local responses = require "kong.tools.responses" local endpoints = require "kong.api.endpoints" -local reports = require "kong.core.reports" +local reports = require "kong.reports" local utils = require "kong.tools.utils" local crud = require "kong.api.crud_helpers" diff --git a/kong/core/api_router.lua b/kong/api_router.lua similarity index 100% rename from kong/core/api_router.lua rename to kong/api_router.lua diff --git a/kong/cmd/init.lua b/kong/cmd/init.lua index b20c7e43d47..b661e52931e 100644 --- a/kong/cmd/init.lua +++ b/kong/cmd/init.lua @@ -1,4 +1,4 @@ -require("kong.core.globalpatches")({cli = true}) +require("kong.globalpatches")({cli = true}) math.randomseed() -- Generate PRNG seed diff --git a/kong/core/handler.lua b/kong/core/handler.lua index 258e84db0de..9749266761c 100644 --- a/kong/core/handler.lua +++ b/kong/core/handler.lua @@ -8,9 +8,9 @@ -- In the `access_by_lua` phase, it is responsible for retrieving the route being proxied by -- a consumer. Then it is responsible for loading the plugins to execute on this request. local utils = require "kong.tools.utils" -local Router = require "kong.core.router" -local ApiRouter = require "kong.core.api_router" -local reports = require "kong.core.reports" +local Router = require "kong.router" +local ApiRouter = require "kong.api_router" +local reports = require "kong.reports" local balancer = require "kong.core.balancer" local constants = require "kong.constants" local responses = require "kong.tools.responses" diff --git a/kong/core/error_handlers.lua b/kong/error_handlers.lua similarity index 100% rename from kong/core/error_handlers.lua rename to kong/error_handlers.lua diff --git a/kong/core/globalpatches.lua b/kong/globalpatches.lua similarity index 100% rename from kong/core/globalpatches.lua rename to kong/globalpatches.lua diff --git a/kong/init.lua b/kong/init.lua index 4f85adbff62..88f58f32a1a 100644 --- a/kong/init.lua +++ b/kong/init.lua @@ -42,7 +42,7 @@ do end end -require("kong.core.globalpatches")() +require("kong.globalpatches")() local ip = require "kong.tools.ip" local DB = require "kong.db" @@ -58,7 +58,7 @@ local ngx_balancer = require "ngx.balancer" local plugins_iterator = require "kong.core.plugins_iterator" local balancer_execute = require("kong.core.balancer").execute local kong_cluster_events = require "kong.cluster_events" -local kong_error_handlers = require "kong.core.error_handlers" +local kong_error_handlers = require "kong.error_handlers" local ngx = ngx local header = ngx.header @@ -128,7 +128,7 @@ local function load_plugins(kong_conf, dao) -- add reports plugin if not disabled if kong_conf.anonymous_reports then - local reports = require "kong.core.reports" + local reports = require "kong.reports" local db_infos = dao:infos() reports.add_ping_value("database", kong_conf.database) @@ -184,7 +184,7 @@ function Kong.init() end function Kong.init_worker() - -- special math.randomseed from kong.core.globalpatches + -- special math.randomseed from kong.globalpatches -- not taking any argument. Must be called only once -- and in the init_worker phase, to avoid duplicated -- seeds. diff --git a/kong/plugins/rate-limiting/policies/init.lua b/kong/plugins/rate-limiting/policies/init.lua index 03f77bd1deb..501bf50af4e 100644 --- a/kong/plugins/rate-limiting/policies/init.lua +++ b/kong/plugins/rate-limiting/policies/init.lua @@ -2,7 +2,7 @@ local singletons = require "kong.singletons" local timestamp = require "kong.tools.timestamp" local redis = require "resty.redis" local policy_cluster = require "kong.plugins.rate-limiting.policies.cluster" -local reports = require "kong.core.reports" +local reports = require "kong.reports" local ngx_log = ngx.log diff --git a/kong/plugins/response-ratelimiting/policies/init.lua b/kong/plugins/response-ratelimiting/policies/init.lua index 48cac55ddc7..af9b9943044 100644 --- a/kong/plugins/response-ratelimiting/policies/init.lua +++ b/kong/plugins/response-ratelimiting/policies/init.lua @@ -2,7 +2,7 @@ local singletons = require "kong.singletons" local timestamp = require "kong.tools.timestamp" local redis = require "resty.redis" local policy_cluster = require "kong.plugins.response-ratelimiting.policies.cluster" -local reports = require "kong.core.reports" +local reports = require "kong.reports" local ngx_log = ngx.log diff --git a/kong/core/reports.lua b/kong/reports.lua similarity index 100% rename from kong/core/reports.lua rename to kong/reports.lua diff --git a/kong/core/router.lua b/kong/router.lua similarity index 100% rename from kong/core/router.lua rename to kong/router.lua diff --git a/spec-old-api/01-unit/010-router_spec.lua b/spec-old-api/01-unit/010-router_spec.lua index 5f64f203b2d..6052abb8f9e 100644 --- a/spec-old-api/01-unit/010-router_spec.lua +++ b/spec-old-api/01-unit/010-router_spec.lua @@ -1,8 +1,8 @@ -local Router = require "kong.core.api_router" +local Router = require "kong.api_router" local function reload_router() - package.loaded["kong.core.api_router"] = nil - Router = require "kong.core.api_router" + package.loaded["kong.api_router"] = nil + Router = require "kong.api_router" end local use_case = { diff --git a/spec/01-unit/010-router_spec.lua b/spec/01-unit/010-router_spec.lua index 4b6935bcf71..27db47ea4a0 100644 --- a/spec/01-unit/010-router_spec.lua +++ b/spec/01-unit/010-router_spec.lua @@ -1,8 +1,8 @@ -local Router = require "kong.core.router" +local Router = require "kong.router" local function reload_router() - package.loaded["kong.core.router"] = nil - Router = require "kong.core.router" + package.loaded["kong.router"] = nil + Router = require "kong.router" end local service = { diff --git a/spec/01-unit/013-reports_spec.lua b/spec/01-unit/013-reports_spec.lua index cd3282b1090..a816fb9fc5f 100644 --- a/spec/01-unit/013-reports_spec.lua +++ b/spec/01-unit/013-reports_spec.lua @@ -1,6 +1,6 @@ local meta = require "kong.meta" local helpers = require "spec.helpers" -local reports = require "kong.core.reports" +local reports = require "kong.reports" local cjson = require "cjson" @@ -79,8 +79,8 @@ describe("reports", function() end) before_each(function() - package.loaded["kong.core.reports"] = nil - reports = require "kong.core.reports" + package.loaded["kong.reports"] = nil + reports = require "kong.reports" reports.toggle(true) end)