Skip to content

Commit

Permalink
fix: utils.has_value method always return false (#49)
Browse files Browse the repository at this point in the history
* fix: has_value method always return false

* 1. fix v3.watchdir() opts args type error (#50)
2. fix prev_kv not decode
  • Loading branch information
fengjx authored Feb 20, 2020
1 parent 4c80dd1 commit 544588b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/resty/etcd/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ end


function _M.has_value(arr, val)
for index, value in ipairs(arr) do
for key, value in pairs(arr) do
if value == val then
return index
return key
end
end

return false
end

Expand Down
11 changes: 8 additions & 3 deletions lib/resty/etcd/v3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ local function request_chunk(self, method, host, port, path, opts, timeout)
event.kv.value = decode_json(event.kv.value)
end
event.kv.key = decode_base64(event.kv.key)
if event.prev_kv then
event.prev_kv.value = decode_base64(event.prev_kv.value)
event.prev_kv.value = decode_json(event.prev_kv.value)
event.prev_kv.key = decode_base64(event.prev_kv.key)
end
end
end

Expand Down Expand Up @@ -573,7 +578,7 @@ local function watch(self, key, attr)

local prev_kv
if attr.prev_kv then
prev_kv = attr.prev_kv and 'true' or 'false'
prev_kv = attr.prev_kv and true or false
end

local start_revision
Expand All @@ -588,12 +593,12 @@ local function watch(self, key, attr)

local progress_notify
if attr.progress_notify then
progress_notify = attr.progress_notify and 'true' or 'false'
progress_notify = attr.progress_notify and true or false
end

local fragment
if attr.fragment then
fragment = attr.fragment and 'true' or 'false'
fragment = attr.fragment and true or false
end

local filters
Expand Down

0 comments on commit 544588b

Please sign in to comment.