bzp2010 commented on code in PR #12604:
URL: https://github.com/apache/apisix/pull/12604#discussion_r2336287389


##########
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:
   I thought maybe we could just store `METADATA_LAST_MODIFIED` in this local 
variable.
   Then use the rule whether the shdict stored config is higher than the local 
timestamp to check if the config should be sync again.
   We only need to track last modified and no longer need to record a new 
timestamp additionally or use the difference between last sync and now to check 
if it should be changed.



-- 
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