moonming commented on a change in pull request #10: used the nginx lua code
style.
URL:
https://github.com/apache/skywalking-nginx-lua/pull/10#discussion_r386101595
##########
File path: lib/skywalking/tracing_context_test.lua
##########
@@ -30,24 +31,24 @@ TestTracingContext = {}
end
function TestTracingContext:testInternal_NextSpanSeqID()
- local context = TC:new(1, 1)
+ local context = TC.new(1, 1)
- lu.assertEquals(context.internal:nextSpanID(), 0)
+ lu.assertEquals(TC_Internal.nextSpanID(context.internal), 0)
end
function TestTracingContext:testInternal_addActive()
- local context = TC:new(1, 1)
+ local context = TC.new(1, 1)
local mockSpan = {span_id = 0}
- context.internal:addActive(mockSpan)
+ TC_Internal.addActive(context.internal, mockSpan)
- lu.assertEquals(#(context.internal.active_spans), 1)
+ lu.assertEquals(#context.internal.active_spans, 1)
end
function TestTracingContext:testSpanStack()
- local context = TC:new(1, 1)
- local span1 = context:createEntrySpan('entry_op')
- local span2 = context:createExitSpan("exit_op", span1, "127.0.0.1")
+ local context = TC.new(1, 1)
+ local span1 = TC.createEntrySpan(context, 'entry_op')
+ local span2 = TC.createExitSpan(context, "exit_op", span1, "127.0.0.1")
Review comment:
got it. I will hide the internal context.
There are two reasons for this code style:
- In nginx lua, top level variables are shared by all requests in a worker,
so top level variables are easy to race condition, so it needs to be read-only
- There is no class in Lua, which needs to be simulated by table. Therefore,
in nginx Lua, object-oriented programming mode is generally not recommended
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services