File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ local initialized = false
3131-- After report instance properties successfully, it sends keep alive packages.
3232function Client :startBackendTimer (backend_http_uri )
3333 initialized = true
34+ self .stopped = false
3435 local metadata_buffer = ngx .shared .tracing_buffer
3536
3637 -- The codes of timer setup is following the OpenResty timer doc
@@ -42,6 +43,7 @@ function Client:startBackendTimer(backend_http_uri)
4243
4344 check = function (premature )
4445 if not premature and not self .stopped then
46+ log (ngx .INFO , " running timer" )
4547 local instancePropertiesSubmitted = metadata_buffer :get (' instancePropertiesSubmitted' )
4648 if (instancePropertiesSubmitted == nil or instancePropertiesSubmitted == false ) then
4749 self :reportServiceInstance (metadata_buffer , backend_http_uri )
Original file line number Diff line number Diff line change @@ -114,3 +114,36 @@ true
114114--- no_error_log
115115language: lua
116116Go keepAlive
117+
118+
119+
120+ === TEST 3: start backend timer then destory then restart backend timer
121+ --- config
122+ location /t {
123+ content_by_lua_block {
124+ local client = require("skywalking.client")
125+ client.backendTimerDelay = 0.1
126+ client:startBackendTimer("http://127.0.0.1:" .. ngx.var.server_port)
127+ ngx.sleep(0.1)
128+ ngx.say('ok')
129+
130+ local ok, err = client:destroyBackendTimer()
131+ if not err then
132+ ngx.say(ok)
133+ else
134+ ngx.say(err)
135+ end
136+
137+ client:startBackendTimer("http://127.0.0.1:" .. ngx.var.server_port)
138+ ngx.sleep(0.1)
139+ ngx.say('ok')
140+ }
141+ }
142+ --- response_body
143+ ok
144+ true
145+ ok
146+ --- error_log
147+ running timer
148+ running timer
149+ running timer
You can’t perform that action at this time.
0 commit comments