You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/02/20 07:17:08 UTC

[skywalking-nginx-lua] branch master updated: Set up the basic project structure

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 495cceb  Set up the basic project structure
495cceb is described below

commit 495ccebe4fb730ef01b5879d564f8487546fc4fd
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Thu Feb 20 15:16:57 2020 +0800

    Set up the basic project structure
---
 .github/workflows/ci.yaml                          |  6 ++--
 lib/skywalking/{agent.lua => id_generator.lua}     | 13 ++++++++
 .../{agent.lua => id_generator_test.lua}           | 15 +++++++++
 lib/skywalking/span.lua                            |  0
 lib/skywalking/{agent.lua => tracer.lua}           | 12 +++++++
 lib/skywalking/{agent.lua => tracing_context.lua}  | 23 ++++++++++++++
 .../{agent.lua => tracing_context_test.lua}        | 17 ++++++++++
 test/test.lua                                      | 37 ----------------------
 8 files changed, 84 insertions(+), 39 deletions(-)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 90f976f..4ca9dad 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -45,10 +45,12 @@ jobs:
           cd luarocks-3.3.0
           ./configure && make && sudo make install
           cd ..
-      - name: 'install LuaUnit'
+      - name: 'install dependencies'
         run: |
           sudo luarocks install luaunit
+          sudo luarocks install luasocket
       - name: 'test'
         run: |
           cd test
-          lua test.lua 
\ No newline at end of file
+          lua id_generator_test.lua
+          lua tracing_context_test.lua 
\ No newline at end of file
diff --git a/lib/skywalking/agent.lua b/lib/skywalking/id_generator.lua
similarity index 75%
copy from lib/skywalking/agent.lua
copy to lib/skywalking/id_generator.lua
index 6245b76..3054774 100644
--- a/lib/skywalking/agent.lua
+++ b/lib/skywalking/id_generator.lua
@@ -15,3 +15,16 @@
 -- limitations under the License.
 -- 
 
+socket=require'socket'
+
+IDGenerator = {}
+MAX_ID_PART2 = 1000000000
+MAX_ID_PART3 = 100000
+SEQ = 1
+
+function IDGenerator:newID()
+    SEQ = SEQ + 1
+    return {socket.gettime(), math.random( 0, MAX_ID_PART2), math.random( 0, MAX_ID_PART3) + SEQ}
+end
+
+return IDGenerator
\ No newline at end of file
diff --git a/lib/skywalking/agent.lua b/lib/skywalking/id_generator_test.lua
similarity index 72%
copy from lib/skywalking/agent.lua
copy to lib/skywalking/id_generator_test.lua
index 6245b76..a536bed 100644
--- a/lib/skywalking/agent.lua
+++ b/lib/skywalking/id_generator_test.lua
@@ -15,3 +15,18 @@
 -- limitations under the License.
 -- 
 
+local lu = require('luaunit')
+local idGen = require('id_generator')
+
+TestIDGenerator = {}
+    function TestIDGenerator:test()
+        local id = idGen.newID()
+
+        lu.assertNotNil(id[1])
+        lu.assertNotNil(id[2])
+        lu.assertNotNil(id[3])
+    end
+-- end TestIDGenerator
+
+
+os.exit( lu.LuaUnit.run() )
\ No newline at end of file
diff --git a/lib/skywalking/span.lua b/lib/skywalking/span.lua
new file mode 100644
index 0000000..e69de29
diff --git a/lib/skywalking/agent.lua b/lib/skywalking/tracer.lua
similarity index 84%
copy from lib/skywalking/agent.lua
copy to lib/skywalking/tracer.lua
index 6245b76..2d8c3a8 100644
--- a/lib/skywalking/agent.lua
+++ b/lib/skywalking/tracer.lua
@@ -15,3 +15,15 @@
 -- limitations under the License.
 -- 
 
+local Tracer = {}
+
+function Tracer.new()
+    
+end
+
+
+function Tracer.createEntrySpan(context, operationName, sw6_header_value)
+    
+end
+
+return Tracer
\ No newline at end of file
diff --git a/lib/skywalking/agent.lua b/lib/skywalking/tracing_context.lua
similarity index 67%
copy from lib/skywalking/agent.lua
copy to lib/skywalking/tracing_context.lua
index 6245b76..fa42f9a 100644
--- a/lib/skywalking/agent.lua
+++ b/lib/skywalking/tracing_context.lua
@@ -15,3 +15,26 @@
 -- limitations under the License.
 -- 
 
+local idGen = require('id_generator')
+
+TracingContext = {
+    span_id_seq = 0,
+    trace_id,
+    segment_id,
+    -- Linked Lists
+    finished_spans = nil,
+}
+
+function TracingContext:new(o)
+    o = o or {} 
+    setmetatable(o, self)
+
+    o.trace_id = idGen.newID();
+    o.segment_id = o.trace_id
+    return o
+end
+
+function TracingContext:createEntrySpan(operationName)
+end
+
+return TracingContext
\ No newline at end of file
diff --git a/lib/skywalking/agent.lua b/lib/skywalking/tracing_context_test.lua
similarity index 64%
rename from lib/skywalking/agent.lua
rename to lib/skywalking/tracing_context_test.lua
index 6245b76..9de8c7d 100644
--- a/lib/skywalking/agent.lua
+++ b/lib/skywalking/tracing_context_test.lua
@@ -15,3 +15,20 @@
 -- limitations under the License.
 -- 
 
+local lu = require('luaunit')
+local tc = require('tracing_context')
+
+TestTracingContext = {}
+    function TestTracingContext:testNew()
+        local context = tc.new()
+
+        lu.assertNotNil(context.segment_id[1])
+        lu.assertNotNil(context.segment_id[2])
+        lu.assertNotNil(context.segment_id[3])
+
+        lu.assertEquals(context.trace_id, context.segment_id)
+    end
+-- end TestTracingContext
+
+
+os.exit( lu.LuaUnit.run() )
diff --git a/test/test.lua b/test/test.lua
deleted file mode 100644
index 5282eb4..0000000
--- a/test/test.lua
+++ /dev/null
@@ -1,37 +0,0 @@
-local lu = require('luaunit')
-
-local function range(start, stop)
-    -- return list of { start ... stop }
-    local i 
-    local ret = {}
-    i=start
-    while i <= stop do
-        table.insert(ret, i)
-        i = i + 1
-    end
-    return ret
-end
-
-
-TestListCompare = {}
-
-    function TestListCompare:test1()
-        local A = { 121221, 122211, 121221, 122211, 121221, 122212, 121212, 122112, 122121, 121212, 122121 } 
-        local B = { 121221, 122211, 121221, 122211, 121221, 122212, 121212, 122112, 121221, 121212, 122121 }
-        lu.assertEquals( A, B )
-    end
--- end TestListCompare
-
---[[
-TestDictCompare = {}
-    function XTestDictCompare:test1()
-        lu.assertEquals( {one=1,two=2, three=3}, {one=1,two=1, three=3} )
-    end
-    function XTestDictCompare:test2()
-        lu.assertEquals( {one=1,two=2, three=3, four=4, five=5}, {one=1,two=1, three=3, four=4, five=5} )
-    end
--- end TestDictCompare
-]]
-
-
-os.exit( lu.LuaUnit.run() )