Skip to content

Commit

Permalink
Merge branch 'master' into feat/batchprocessor/partialconsume
Browse files Browse the repository at this point in the history
  • Loading branch information
bisakhmondal committed Jan 27, 2022
2 parents 7d00528 + 427e926 commit 7aee653
Show file tree
Hide file tree
Showing 28 changed files with 709 additions and 1,015 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ A/B testing, canary release, blue-green deployment, limit rate, defense against
- High performance: The single-core QPS reaches 18k with an average delay of fewer than 0.2 milliseconds.
- [Fault Injection](docs/en/latest/plugins/fault-injection.md)
- [REST Admin API](docs/en/latest/admin-api.md): Using the REST Admin API to control Apache APISIX, which only allows 127.0.0.1 access by default, you can modify the `allow_admin` field in `conf/config.yaml` to specify a list of IPs that are allowed to call the Admin API. Also, note that the Admin API uses key auth to verify the identity of the caller. **The `admin_key` field in `conf/config.yaml` needs to be modified before deployment to ensure security**.
- External Loggers: Export access logs to external log management tools. ([HTTP Logger](docs/en/latest/plugins/http-logger.md), [TCP Logger](docs/en/latest/plugins/tcp-logger.md), [Kafka Logger](docs/en/latest/plugins/kafka-logger.md), [UDP Logger](docs/en/latest/plugins/udp-logger.md), [RocketMQ Logger](docs/en/latest/plugins/rocketmq-logger.md), [SkyWalking Logger](docs/en/latest/plugins/skywalking-logger.md), [Alibaba Cloud Logging(SLS)](docs/en/latest/plugins/sls-logger.md), [Google Cloud Logging](docs/en/latest/plugins/google-cloud-logging.md), [Splunk HEC Logging](docs/en/latest/plugins/splunk-hec-logging.md))
- External Loggers: Export access logs to external log management tools. ([HTTP Logger](docs/en/latest/plugins/http-logger.md), [TCP Logger](docs/en/latest/plugins/tcp-logger.md), [Kafka Logger](docs/en/latest/plugins/kafka-logger.md), [UDP Logger](docs/en/latest/plugins/udp-logger.md), [RocketMQ Logger](docs/en/latest/plugins/rocketmq-logger.md), [SkyWalking Logger](docs/en/latest/plugins/skywalking-logger.md), [Alibaba Cloud Logging(SLS)](docs/en/latest/plugins/sls-logger.md), [Google Cloud Logging](docs/en/latest/plugins/google-cloud-logging.md), [Splunk HEC Logging](docs/en/latest/plugins/splunk-hec-logging.md), [File Logger](docs/en/latest/plugins/file-logger.md), [SolarWinds Loggly Logging](docs/en/latest/plugins/loggly.md))
- [Datadog](docs/en/latest/plugins/datadog.md): push custom metrics to the DogStatsD server, comes bundled with [Datadog agent](https://docs.datadoghq.com/agent/), over the UDP protocol. DogStatsD basically is an implementation of StatsD protocol which collects the custom metrics for Apache APISIX agent, aggregates it into a single data point and sends it to the configured Datadog server.
- [Helm charts](https://github.com/apache/apisix-helm-chart)
- [HashiCorp Vault](https://www.vaultproject.io/): Support secret management solution for accessing secrets from Vault secure storage backed in a low trust environment. Currently, RS256 keys (public-private key pairs) or secret keys can be linked from vault in [jwt-auth](docs/en/latest/plugins/jwt-auth.md#enable-jwt-auth-with-vault-compatibility) authentication plugin.
Expand Down
10 changes: 0 additions & 10 deletions apisix/admin/plugin_metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local error = error
local pcall = pcall
local require = require
local core = require("apisix.core")
local utils = require("apisix.admin.utils")
local api_router = require("apisix.api_router")

local injected_mark = "injected metadata_schema"
local _M = {
Expand Down Expand Up @@ -61,14 +59,6 @@ local function check_conf(plugin_name, conf)
end
local schema = plugin_object.metadata_schema

-- inject interceptors schema to each plugins
if schema.properties.interceptors
and api_router.interceptors_schema['$comment'] ~= schema.properties.interceptors['$comment']
then
error("'interceptors' can not be used as the name of metadata schema's field")
end
schema.properties.interceptors = api_router.interceptors_schema

core.log.info("schema: ", core.json.delay_encode(schema))
core.log.info("conf: ", core.json.delay_encode(conf))

Expand Down
77 changes: 4 additions & 73 deletions apisix/api_router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
--
local require = require
local router = require("apisix.utils.router")
local apisix_router = require("apisix.router")
local plugin_mod = require("apisix.plugin")
local ip_restriction = require("apisix.plugins.ip-restriction")
local core = require("apisix.core")
local ipairs = ipairs
local type = type
Expand All @@ -27,50 +25,6 @@ local type = type
local _M = {}
local match_opts = {}
local has_route_not_under_apisix
local interceptors = {
["ip-restriction"] = {
run = function (conf, ctx)
return ip_restriction.access(conf, ctx)
end,
schema = ip_restriction.schema,
}
}


_M.interceptors_schema = {
["$comment"] = "this is the mark for our interceptors schema",
type = "array",
items = {
type = "object",
minItems = 1,
properties = {
name = {
type = "string",
enum = {},
},
conf = {
type = "object",
}
},
required = {"name", "conf"},
dependencies = {
name = {
oneOf = {}
}
}
}
}
for name, attrs in pairs(interceptors) do
core.table.insert(_M.interceptors_schema.items.properties.name.enum, name)
core.table.insert(_M.interceptors_schema.items.dependencies.name.oneOf, {
properties = {
name = {
enum = {name},
},
conf = attrs.schema,
}
})
end


local fetch_api_router
Expand All @@ -84,7 +38,6 @@ function fetch_api_router()
for _, plugin in ipairs(plugin_mod.plugins) do
local api_fun = plugin.api
if api_fun then
local name = plugin.name
local api_routes = api_fun()
core.log.debug("fetched api routes: ",
core.json.delay_encode(api_routes, true))
Expand All @@ -108,30 +61,8 @@ function fetch_api_router()
core.table.insert(routes, {
methods = route.methods,
paths = route.uri,
handler = function (api_ctx, skip_global_rule)
local code, body

local metadata = plugin_mod.plugin_metadata(name)
if metadata and metadata.value.interceptors then
for _, rule in ipairs(metadata.value.interceptors) do
local f = interceptors[rule.name]
if f == nil then
core.log.error("unknown interceptor: ", rule.name)
else
code, body = f.run(rule.conf, api_ctx)
if code or body then
return core.response.exit(code, body)
end
end
end
end

if not skip_global_rule then
plugin_mod.run_global_rules(api_ctx,
apisix_router.global_rules, nil)
end

code, body = route.handler(api_ctx)
handler = function (api_ctx)
local code, body = route.handler(api_ctx)
if code or body then
core.response.exit(code, body)
end
Expand All @@ -156,7 +87,7 @@ function _M.has_route_not_under_apisix()
end


function _M.match(api_ctx, skip_global_rule)
function _M.match(api_ctx)
local api_router = core.lrucache.global("api_router", plugin_mod.load_times, fetch_api_router)
if not api_router then
core.log.error("failed to fetch valid api router")
Expand All @@ -166,7 +97,7 @@ function _M.match(api_ctx, skip_global_rule)
core.table.clear(match_opts)
match_opts.method = api_ctx.var.request_method

local ok = api_router:dispatch(api_ctx.var.uri, match_opts, api_ctx, skip_global_rule)
local ok = api_router:dispatch(api_ctx.var.uri, match_opts, api_ctx)
return ok
end

Expand Down
12 changes: 0 additions & 12 deletions apisix/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,6 @@ function _M.http_access_phase()

local route = api_ctx.matched_route
if not route then
-- whether the public API run global rules is
-- controlled by the configuration file
if router.api.has_route_not_under_apisix() or
core.string.has_prefix(uri, "/apisix/")
then
local skip = local_conf and local_conf.apisix.global_rule_skip_internal_api
local matched = router.api.match(api_ctx, skip)
if matched then
return
end
end

-- run global rule when there is no matching route
plugin.run_global_rules(api_ctx, router.global_rules, nil)

Expand Down
5 changes: 1 addition & 4 deletions apisix/plugins/public-api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ end


function _M.access(conf, ctx)
local local_conf = core.config.local_conf()

-- overwrite the uri in the ctx when the user has set the target uri
ctx.var.uri = conf.uri or ctx.var.uri
local skip = local_conf and local_conf.apisix.global_rule_skip_internal_api

-- perform route matching
if router.api.match(ctx, skip) then
if router.api.match(ctx) then
return
end

Expand Down
4 changes: 3 additions & 1 deletion ci/linux_apisix_current_luarocks_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ script() {
export_or_prefix
openresty -V

sudo rm -rf /usr/local/apisix
sudo rm -rf /usr/local/share/lua/5.1/apisix

# install APISIX with local version
sudo luarocks install rockspec/apisix-master-0.rockspec --only-deps > build.log 2>&1 || (cat build.log && exit 1)
sudo luarocks make rockspec/apisix-master-0.rockspec > build.log 2>&1 || (cat build.log && exit 1)
# ensure all files under apisix is installed
diff -rq apisix /usr/local/share/lua/5.1/apisix

mkdir cli_tmp && cd cli_tmp

Expand Down
4 changes: 1 addition & 3 deletions ci/linux_apisix_master_luarocks_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ script() {
export_or_prefix
openresty -V

sudo rm -rf /usr/local/share/lua/5.1/apisix
sudo rm -rf /usr/local/apisix

# run the test case in an empty folder
mkdir tmp && cd tmp
cp -r ../utils ./

# install APISIX by luarocks
sudo luarocks install $APISIX_MAIN > build.log 2>&1 || (cat build.log && exit 1)
# ensure all files under ../apisix is installed
diff -rq ../apisix /usr/local/share/lua/5.1/apisix || exit 1
cp ../bin/apisix /usr/local/bin/apisix

# show install files
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/latest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵
- 高性能:在单核上 QPS 可以达到 18k,同时延迟只有 0.2 毫秒。
- [故障注入](plugins/fault-injection.md)
- [REST Admin API](admin-api.md): 使用 REST Admin API 来控制 Apache APISIX,默认只允许 127.0.0.1 访问,你可以修改 `conf/config.yaml` 中的 `allow_admin` 字段,指定允许调用 Admin API 的 IP 列表。同时需要注意的是,Admin API 使用 key auth 来校验调用者身份,**在部署前需要修改 `conf/config.yaml` 中的 `admin_key` 字段,来保证安全。**
- 外部日志记录器:将访问日志导出到外部日志管理工具。([HTTP Logger](plugins/http-logger.md)[TCP Logger](plugins/tcp-logger.md)[Kafka Logger](plugins/kafka-logger.md)[UDP Logger](plugins/udp-logger.md)[RocketMQ Logger](plugins/rocketmq-logger.md)[SkyWalking Logger](plugins/skywalking-logger.md)[Alibaba Cloud Logging(SLS)](plugins/sls-logger.md)[Google Cloud Logging](plugins/google-cloud-logging.md)[Splunk HEC Logging](plugins/splunk-hec-logging.md)
- 外部日志记录器:将访问日志导出到外部日志管理工具。([HTTP Logger](plugins/http-logger.md)[TCP Logger](plugins/tcp-logger.md)[Kafka Logger](plugins/kafka-logger.md)[UDP Logger](plugins/udp-logger.md)[RocketMQ Logger](plugins/rocketmq-logger.md)[SkyWalking Logger](plugins/skywalking-logger.md)[Alibaba Cloud Logging(SLS)](plugins/sls-logger.md)[Google Cloud Logging](plugins/google-cloud-logging.md)[Splunk HEC Logging](plugins/splunk-hec-logging.md)[File Logger](plugins/file-logger.md)
- [Helm charts](https://github.com/apache/apisix-helm-chart)

- **高度可扩展**
Expand Down
Loading

0 comments on commit 7aee653

Please sign in to comment.