lua-resty-etcd
lua-resty-etcd copied to clipboard
Move require_serializer into v3
hi @u5surf , can you show how to get the error like #126
@tzssangglass I consider that #126's user might use require("resty.etcd.v3") .new
instead of require("resty.etcd").new
like this.
location /t {
content_by_lua_block {
local cjson = require("cjson.safe")
local etcd, err = require("resty.etcd.v3").new({
timeout = 5,
http_host = "http://127.0.0.1:2379",
ttl = -1,
api_prefix = "/v3",
serializer = "raw"
})
check_res(etcd, err)
...
In this case, opt.serializer = "raw" | "json" then it had errored.
Thus I added the test case to use require("resty.etcd.v3") .new
.
So that both of require("XXX").new become to be able to select the serializer type by string which follows the docs, It should be better to select the type of serializer in lib/resty/etcd/v3.lua.
So that both of require("XXX").new become to be able to select the serializer type by string which follows the docs, It should be better to select the type of serializer in lib/resty/etcd/v3.lua.
I've thought about it for a while and I don't think this is a good change.
Reason:
- the
require_serializer
function inetcd.lua
not inv3.lua
, this is because the lib originally supported etcd's v2 protocol, sorequire_serializer
was shared byv2.lua
andv2.lua
. Although this lib is now dropping support for etcd's v2, perhaps etcd's v4 may be available in the future. -
require("resty.etcd.v3").new.
is the wrong usage and does not need to be compatible.
@tzssangglass OK, I understand what you said.
@findmark
Which the etcd
is referred on your configuration require("resty.etcd")
or require("resty.etcd.v3")
?
We could not see which it referres on your comments.
https://github.com/api7/lua-resty-etcd/issues/126#issuecomment-805406629
if there is require("resty.etcd")
, it might have another bug what we could find yet.
Else, if there is require("resty.etcd.v3")
, your configure seems to be incorrect.