membphis commented on a change in pull request #5288:
URL: https://github.com/apache/apisix/pull/5288#discussion_r732927975
##########
File path: apisix/cli/ops.lua
##########
@@ -298,7 +298,31 @@ local config_schema = {
}
}
}
- }
+ },
+ wasm = {
+ type = "object",
+ properties = {
+ plugins = {
+ type = "array",
+ minItems = 1,
+ items = {
+ type = "object",
+ properties = {
+ name = {
+ type = "string"
+ },
+ file = {
+ type = "string"
Review comment:
Ditoo
##########
File path: apisix/wasm.lua
##########
@@ -0,0 +1,120 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local core = require("apisix.core")
+local support_wasm, wasm = pcall(require, "resty.proxy-wasm")
+local concat = table.concat
+
+
+local schema = {
+ type = "object",
+ properties = {
+ conf = {
+ type = "string"
+ },
+ },
+ required = {"conf"}
+}
+local _M = {}
+
+
+local function check_schema(conf)
+ return core.schema.check(schema, conf)
+end
+
+
+local get_plugin_ctx_key
+do
+ local key_buf = {
+ nil,
+ nil,
+ }
+
+ function get_plugin_ctx_key(ctx)
+ key_buf[1] = ctx.conf_type
+ key_buf[2] = ctx.conf_id
+ return concat(key_buf, "#", 1, 2)
Review comment:
style: `ctx.conf_type .. '#' .. ctx.conf_id` is better
##########
File path: docs/en/latest/wasm.md
##########
@@ -0,0 +1,96 @@
+---
+title: WASM
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+APISIX supports WASM plugins written with [Proxy WASM
SDK](https://github.com/proxy-wasm/spec#sdks).
+
+This plugin requires APISIX to run on
[APISIX-OpenResty](../how-to-build.md#step-6-build-openresty-for-apache-apisix),
and is under construction.
+Currently, only a few APIs are implemented. Please follow
[wasm-nginx-module](https://github.com/api7/wasm-nginx-module) to know the
progress.
+
+## Programming model
+
+The plugin supports the follwing concepts from Proxy WASM:
+
+```
+ Wasm Virtual Machine
+┌────────────────────────────────────────────────────────────────┐
+│ Your Plugin │
+│ │ │
+│ │ 1: 1 │
+│ │ 1: N │
+│ VMContext ────────── PluginContext │
+│ ╲ 1: N │
+│ ╲ │
+│ ╲ HttpContext │
+│ (Http stream) │
+└────────────────────────────────────────────────────────────────┘
+```
+
+* All plugin run in the same WASM VM, like the Lua plugin in the Lua VM
Review comment:
`All plugin` -> `All plugins`
##########
File path: apisix/cli/ops.lua
##########
@@ -298,7 +298,31 @@ local config_schema = {
}
}
}
- }
+ },
+ wasm = {
+ type = "object",
+ properties = {
+ plugins = {
+ type = "array",
+ minItems = 1,
+ items = {
+ type = "object",
+ properties = {
+ name = {
+ type = "string"
Review comment:
Lack of a reasonable length range?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]