nic-6443 commented on code in PR #12604:
URL: https://github.com/apache/apisix/pull/12604#discussion_r2347787968


##########
apisix/admin/standalone.lua:
##########
@@ -420,6 +430,29 @@ function _M.init_worker()
     end
     events:register(update_config, EVENT_UPDATE, EVENT_UPDATE)
 
+    -- due to the event module can not broadcast events between http and 
stream subsystems,
+    -- we need to poll the shared dict to keep the config in sync
+    local last_sync_time = ngx_time()
+    local function sync_config()
+        local now = ngx_time()
+        if now - last_sync_time < 1 then
+            return
+        end
+
+        local config, err = get_config()
+        if not config then
+            if err ~= NOT_FOUND_ERR then
+                core.log.error("failed to get config: ", err)
+            end
+        else
+            if config[METADATA_LAST_MODIFIED] > last_sync_time then
+                update_config(config)
+            end
+        end
+        last_sync_time = now

Review Comment:
   got it, `ngx.timer.every` is a good idea, applied your suggestion, please 
review again



-- 
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-unsubscr...@apisix.apache.org

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

Reply via email to