You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/12/20 03:06:13 UTC
[apisix] branch master updated: chore(etcd): only one watching stream at most in each `core.config` object (#8523)
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new e66b69478 chore(etcd): only one watching stream at most in each `core.config` object (#8523)
e66b69478 is described below
commit e66b694787a9deb3adf2859f03dcccd77aed42b9
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Tue Dec 20 11:06:03 2022 +0800
chore(etcd): only one watching stream at most in each `core.config` object (#8523)
---
apisix/core/config_etcd.lua | 14 ++++----------
t/core/config_etcd.t | 1 -
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua
index efec28e8e..d671c6ed2 100644
--- a/apisix/core/config_etcd.lua
+++ b/apisix/core/config_etcd.lua
@@ -26,14 +26,12 @@ local log = require("apisix.core.log")
local json = require("apisix.core.json")
local etcd_apisix = require("apisix.core.etcd")
local core_str = require("apisix.core.string")
-local core_tab = require("apisix.core.table")
local new_tab = require("table.new")
local check_schema = require("apisix.core.schema").check
local exiting = ngx.worker.exiting
local insert_tab = table.insert
local type = type
local ipairs = ipairs
-local pairs = pairs
local setmetatable = setmetatable
local ngx_sleep = require("apisix.core.utils").sleep
local ngx_timer_at = ngx.timer.at
@@ -126,7 +124,7 @@ end
local function grpc_waitdir(self, etcd_cli, key, modified_index, timeout)
- local watching_stream = self.watching_streams[key]
+ local watching_stream = self.watching_stream
if not watching_stream then
local attr = {}
attr.start_revision = modified_index
@@ -141,7 +139,7 @@ local function grpc_waitdir(self, etcd_cli, key, modified_index, timeout)
log.info("create watch stream for key: ", key, ", modified_index: ", modified_index)
- self.watching_streams[key] = st
+ self.watching_stream = st
watching_stream = st
end
@@ -155,11 +153,7 @@ local function flush_watching_streams(self)
return
end
- for _, st in pairs(self.watching_streams) do
- st:close()
- end
-
- core_tab.clear(self.watching_streams)
+ self.watching_stream = nil
end
@@ -742,7 +736,7 @@ function _M.new(key, opts)
conf_version = 0,
values = nil,
need_reload = true,
- watching_streams = {},
+ watching_stream = nil,
routes_hash = nil,
prev_index = 0,
last_err = nil,
diff --git a/t/core/config_etcd.t b/t/core/config_etcd.t
index cdd99d8e3..825e0f225 100644
--- a/t/core/config_etcd.t
+++ b/t/core/config_etcd.t
@@ -337,7 +337,6 @@ qr/healthy check use round robin
config_etcd.test_automatic_fetch(false, {
running = true,
resync_delay = 1,
- watching_streams = {},
})
ngx.say("passed")
}