You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/03/17 09:25:09 UTC

[GitHub] [apisix] tokers commented on a change in pull request #6614: feat: support reading configuration form shdict(mvp)

tokers commented on a change in pull request #6614:
URL: https://github.com/apache/apisix/pull/6614#discussion_r828910189



##########
File path: .github/workflows/build.yml
##########
@@ -90,6 +90,11 @@ jobs:
           sudo dpkg -i tinygo_${TINYGO_VER}_amd64.deb
           cd t/wasm && find . -type f -name "*.go" | xargs -Ip tinygo build -o p.wasm -scheduler=none -target=wasi p
 
+      - name: Build Amesh library

Review comment:
       Ditto.

##########
File path: apisix/core/config_xds.lua
##########
@@ -0,0 +1,108 @@
+--
+-- 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.
+--
+
+--- Get configuration form ngx.shared.DICT.
+--
+-- @module core.config_xds
+
+local base              = require("resty.core.base")
+local config_local      = require("apisix.core.config_local")
+local table             = table
+local error             = error
+local is_http           = ngx.config.subsystem == "http"
+local string            = string
+local io                = io
+local package           = package
+local new_tab           = base.new_tab
+local ngx_timer_at      = ngx.timer.at
+local ffi               = require ("ffi")
+local C                 = ffi.C
+local router_config     = ngx.shared["router-config"]
+
+local process
+if is_http then
+    process = require("ngx.process")
+end
+
+
+ffi.cdef[[
+extern void initial(void* router_zone_ptr);
+]]
+
+
+local _M = {
+    version = 0.1,
+    local_conf = config_local.local_conf,
+}
+
+
+-- todo: refactor this function in chash.lua and radixtree.lua
+local function load_shared_lib(lib_name)
+    local string_gmatch = string.gmatch
+    local string_match = string.match
+    local io_open = io.open
+    local io_close = io.close
+
+    local cpath = package.cpath
+    local tried_paths = new_tab(32, 0)
+    local i = 1
+
+    for k, _ in string_gmatch(cpath, "[^;]+") do

Review comment:
       Why not use `ngx.re.gmatch`?

##########
File path: apisix/core/config_xds.lua
##########
@@ -0,0 +1,108 @@
+--
+-- 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.
+--
+
+--- Get configuration form ngx.shared.DICT.
+--
+-- @module core.config_xds
+
+local base              = require("resty.core.base")
+local config_local      = require("apisix.core.config_local")
+local table             = table
+local error             = error
+local is_http           = ngx.config.subsystem == "http"
+local string            = string
+local io                = io
+local package           = package
+local new_tab           = base.new_tab
+local ngx_timer_at      = ngx.timer.at
+local ffi               = require ("ffi")
+local C                 = ffi.C
+local router_config     = ngx.shared["router-config"]
+
+local process
+if is_http then
+    process = require("ngx.process")
+end
+
+
+ffi.cdef[[
+extern void initial(void* router_zone_ptr);
+]]
+
+
+local _M = {
+    version = 0.1,
+    local_conf = config_local.local_conf,
+}
+
+
+-- todo: refactor this function in chash.lua and radixtree.lua
+local function load_shared_lib(lib_name)
+    local string_gmatch = string.gmatch
+    local string_match = string.match
+    local io_open = io.open
+    local io_close = io.close
+
+    local cpath = package.cpath
+    local tried_paths = new_tab(32, 0)
+    local i = 1
+
+    for k, _ in string_gmatch(cpath, "[^;]+") do
+        local fpath = string_match(k, "(.*/)")

Review comment:
       What about `ngx.re.match`?

##########
File path: .github/workflows/build.yml
##########
@@ -29,7 +29,7 @@ jobs:
         test_dir:
           - t/plugin
           - t/admin t/cli t/config-center-yaml t/control t/core t/debug t/discovery t/error_page t/misc
-          - t/node t/router t/script t/stream-node t/utils t/wasm
+          - t/amesh-library t/node t/router t/script t/stream-node t/utils t/wasm

Review comment:
       What is amesh?

##########
File path: apisix/init.lua
##########
@@ -110,6 +110,11 @@ function _M.http_init_worker()
     end
     require("apisix.balancer").init_worker()
     load_balancer = require("apisix.balancer")
+
+    if core.config == require("apisix.core.config_shdict") then

Review comment:
       I think we may need to unify the term, the shdict is the container, the xds is the way, I think here `config_xds` will be better.

##########
File path: apisix/core/config_xds.lua
##########
@@ -0,0 +1,108 @@
+--
+-- 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.
+--
+
+--- Get configuration form ngx.shared.DICT.
+--
+-- @module core.config_xds
+
+local base              = require("resty.core.base")
+local config_local      = require("apisix.core.config_local")
+local table             = table
+local error             = error
+local is_http           = ngx.config.subsystem == "http"
+local string            = string
+local io                = io
+local package           = package
+local new_tab           = base.new_tab
+local ngx_timer_at      = ngx.timer.at
+local ffi               = require ("ffi")
+local C                 = ffi.C
+local router_config     = ngx.shared["router-config"]
+
+local process
+if is_http then
+    process = require("ngx.process")
+end
+
+
+ffi.cdef[[
+extern void initial(void* router_zone_ptr);
+]]
+
+
+local _M = {
+    version = 0.1,
+    local_conf = config_local.local_conf,
+}
+
+
+-- todo: refactor this function in chash.lua and radixtree.lua
+local function load_shared_lib(lib_name)
+    local string_gmatch = string.gmatch
+    local string_match = string.match
+    local io_open = io.open
+    local io_close = io.close

Review comment:
       Put them to the module level?




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org