lua-resty-etcd icon indicating copy to clipboard operation
lua-resty-etcd copied to clipboard

something wrong with decode json kv.value

Open findmark opened this issue 4 years ago • 4 comments

hi, I use the newest version but I got the following issue:

2021/03/24 09:25:19 [error] 6112#54059: *13 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/resty/etcd/v3.lua:487: attempt to index field 'serializer' (a nil value)

I believe serializer default is json as the doc mention in v3.md. Nvm, I set it to json manually, but I got error message instead , I believe is the same issue.

2021/03/24 09:20:19 [error] 5976#50240: *13 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/resty/etcd/v3.lua:487: attempt to call field 'deserialize' (a nil value)

Could you help look into this? Thanks in advance

findmark avatar Mar 24 '21 01:03 findmark

I just figure this out by looking into the source code, require this when new etcd instance, not sure is the correct way to handle this. image Also, the option here maybe need a little bit ajust or give a brief example would be much better.

findmark avatar Mar 24 '21 01:03 findmark

@Yiyiyimu Would you take a look at this issue? Thanks!

spacewander avatar Mar 24 '21 04:03 spacewander

Hi @findmark sorry I lost track on this issue, hope it's not too late 😬

Actually, the accepted option for serializer is json and raw. As you could find in the test code https://github.com/api7/lua-resty-etcd/blob/16a57331cb5557aa15a06a8533696606d1fcc5e6/t/v3/serializer.t#L58-L61 And yes the documentation is a bit confusing 🤦 If you got time, welcome draft a PR to refine it~

Yiyiyimu avatar Apr 12 '21 09:04 Yiyiyimu