This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-nginx-lua.git
The following commit(s) were added to refs/heads/master by this push:
new 56e09ec fix: allow timer to restart by APISIX (#112)
56e09ec is described below
commit 56e09ec9a6577e79e9ba9f5fdaff65dd8adcfe14
Author: Shreemaan Abhishek <[email protected]>
AuthorDate: Tue Sep 24 17:56:57 2024 +0545
fix: allow timer to restart by APISIX (#112)
---
lib/skywalking/client.lua | 2 ++
t/client.t | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/lib/skywalking/client.lua b/lib/skywalking/client.lua
index 881160d..9c76b64 100644
--- a/lib/skywalking/client.lua
+++ b/lib/skywalking/client.lua
@@ -31,6 +31,7 @@ local initialized = false
-- After report instance properties successfully, it sends keep alive packages.
function Client:startBackendTimer(backend_http_uri)
initialized = true
+ self.stopped = false
local metadata_buffer = ngx.shared.tracing_buffer
-- The codes of timer setup is following the OpenResty timer doc
@@ -42,6 +43,7 @@ function Client:startBackendTimer(backend_http_uri)
check = function(premature)
if not premature and not self.stopped then
+ log(ngx.INFO, "running timer")
local instancePropertiesSubmitted =
metadata_buffer:get('instancePropertiesSubmitted')
if (instancePropertiesSubmitted == nil or
instancePropertiesSubmitted == false) then
self:reportServiceInstance(metadata_buffer, backend_http_uri)
diff --git a/t/client.t b/t/client.t
index 5149d31..33daec6 100644
--- a/t/client.t
+++ b/t/client.t
@@ -114,3 +114,37 @@ true
--- no_error_log
language: lua
Go keepAlive
+
+
+
+=== TEST 3: start backend timer then destory then restart backend timer
+--- config
+ location /t {
+ content_by_lua_block {
+ local client = require("skywalking.client")
+ client.backendTimerDelay = 0.1
+ client:startBackendTimer("http://127.0.0.1:" ..
ngx.var.server_port)
+ ngx.sleep(0.1)
+ ngx.say('ok')
+
+ local ok, err = client:destroyBackendTimer()
+ if not err then
+ ngx.say(ok)
+ else
+ ngx.say(err)
+ end
+
+ client:startBackendTimer("http://127.0.0.1:" ..
ngx.var.server_port)
+ ngx.sleep(0.1)
+ ngx.say('ok')
+ }
+ }
+--- response_body
+ok
+true
+ok
+--- grep_error_log: running timer
+--- grep_error_log_out
+running timer
+running timer
+running timer