chore: load the base64 in `utils`, different ENV use different way. (#46)
diff --git a/lib/skywalking/correlation_context.lua b/lib/skywalking/correlation_context.lua
index 353ad02..09e65d7 100644
--- a/lib/skywalking/correlation_context.lua
+++ b/lib/skywalking/correlation_context.lua
@@ -20,14 +20,8 @@
local VALUE_MAX_LENGTH = 128
local Util = require('skywalking.util')
-local Base64 = require('skywalking.dependencies.base64')
-local encode_base64 = Base64.encode
-local decode_base64 = Base64.decode
-
-if Util.is_ngx_lua then
- encode_base64 = ngx.encode_base64
- decode_base64 = ngx.decode_base64
-end
+local encode_base64 = Util.encode_base64
+local decode_base64 = Util.decode_base64
local _M = {}
diff --git a/lib/skywalking/segment_ref.lua b/lib/skywalking/segment_ref.lua
index 61feea6..d3917fb 100644
--- a/lib/skywalking/segment_ref.lua
+++ b/lib/skywalking/segment_ref.lua
@@ -15,14 +15,8 @@
-- limitations under the License.
--
local Util = require('skywalking.util')
-local Base64 = require('skywalking.dependencies.base64')
-local encode_base64 = Base64.encode
-local decode_base64 = Base64.decode
-
-if Util.is_ngx_lua then
- encode_base64 = ngx.encode_base64
- decode_base64 = ngx.decode_base64
-end
+local encode_base64 = Util.encode_base64
+local decode_base64 = Util.decode_base64
local _M = {}
-- local SegmentRef = {
diff --git a/lib/skywalking/util.lua b/lib/skywalking/util.lua
index 79580db..459e384 100644
--- a/lib/skywalking/util.lua
+++ b/lib/skywalking/util.lua
@@ -14,6 +14,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
+
local _M = {}
-- for pure Lua
@@ -47,13 +48,16 @@
end
end
+
_M.split = split
_M.timestamp = timestamp
_M.is_ngx_lua = ok
+
local MAX_ID_PART2 = 1000000000
local MAX_ID_PART3 = 100000
+
local random_seed = function ()
local seed
local frandom = io.open("/dev/urandom", "rb")
@@ -100,6 +104,19 @@
end
end
+
_M.newID = newID
+
+if _M.is_ngx_lua then
+ _M.encode_base64 = ngx.encode_base64
+ _M.decode_base64 = ngx.decode_base64
+
+else
+ local Base64 = require('skywalking.dependencies.base64')
+ _M.encode_base64 = Base64.encode
+ _M.decode_base64 = Base64.decode
+end
+
+
return _M
diff --git a/rockspec/skywalking-nginx-lua-master-0.rockspec b/rockspec/skywalking-nginx-lua-master-0.rockspec
new file mode 100644
index 0000000..1461369
--- /dev/null
+++ b/rockspec/skywalking-nginx-lua-master-0.rockspec
@@ -0,0 +1,31 @@
+package = "skywalking-nginx-lua"
+version = "master-0"
+source = {
+ url = "git://github.com/apache/skywalking-nginx-lua",
+ branch = "master",
+}
+
+description = {
+ summary = "The Nginx Lua agent for Apache SkyWalking",
+ homepage = "https://github.com/apache/skywalking-nginx-lua",
+ license = "Apache License 2.0"
+}
+
+dependencies = {
+ "lua-resty-http > 0.15",
+ "lua-resty-jit-uuid > 0.0.7"
+}
+
+build = {
+ type = "builtin",
+ modules = {
+ ["skywalking.management"] = "lib/skywalking/management.lua",
+ ["skywalking.segment_ref"] = "lib/skywalking/segment_ref.lua",
+ ["skywalking.segment"] = "lib/skywalking/segment.lua",
+ ["skywalking.span_layer"] = "lib/skywalking/span_layer.lua",
+ ["skywalking.span"] = "lib/skywalking/span.lua",
+ ["skywalking.tracing_context"] = "lib/skywalking/tracing_context.lua",
+ ["skywalking.util"] = "lib/skywalking/util.lua",
+ ["skywalking.correlation_context"] = "lib/skywalking/correlation_context.lua",
+ }
+}