File tree 2 files changed +13
-13
lines changed 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,6 @@ local pcall = pcall
6
6
local _M = {version = 0.9 }
7
7
8
8
9
- local function require_serializer (serializer_name )
10
- if serializer_name then
11
- local ok , module = pcall (require , " resty.etcd.serializers." .. serializer_name )
12
- if ok then
13
- return module
14
- end
15
- end
16
-
17
- return require (" resty.etcd.serializers.json" )
18
- end
19
-
20
9
function _M .new (opts )
21
10
opts = opts or {}
22
11
if not typeof .table (opts ) then
@@ -33,7 +22,7 @@ function _M.new(opts)
33
22
opts .ttl = opts .ttl or - 1
34
23
35
24
local serializer_name = typeof .string (opts .serializer ) and opts .serializer
36
- opts .serializer = require_serializer ( serializer_name )
25
+ opts .serializer = serializer_name
37
26
opts .api_prefix = " /v3"
38
27
39
28
return etcdv3 .new (opts )
Original file line number Diff line number Diff line change @@ -265,6 +265,17 @@ local function serialize_and_encode_base64(serialize_fn, data)
265
265
return encode_base64 (data )
266
266
end
267
267
268
+ local function require_serializer (serializer_name )
269
+ if serializer_name then
270
+ local ok , module = pcall (require , " resty.etcd.serializers." .. serializer_name )
271
+ if ok then
272
+ return module
273
+ end
274
+ end
275
+
276
+ return require (" resty.etcd.serializers.json" )
277
+ end
278
+
268
279
269
280
function _M .new (opts )
270
281
local timeout = opts .timeout
@@ -278,7 +289,7 @@ function _M.new(opts)
278
289
if ssl_verify == nil then
279
290
ssl_verify = true
280
291
end
281
- local serializer = opts .serializer
292
+ local serializer = require_serializer ( opts .serializer )
282
293
local extra_headers = opts .extra_headers
283
294
local sni = opts .sni
284
295
local unix_socket_proxy = opts .unix_socket_proxy
You can’t perform that action at this time.
0 commit comments