You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/09 09:22:56 UTC
[GitHub] [apisix] tokers commented on a change in pull request #3003: fix: avoid duplicate auto-generated id
tokers commented on a change in pull request #3003:
URL: https://github.com/apache/apisix/pull/3003#discussion_r539140752
##########
File path: apisix/core/etcd.lua
##########
@@ -269,12 +269,15 @@ end
function _M.push(key, value, ttl)
- local etcd_cli, prefix, err = new()
+ local etcd_cli, _, err = new()
if not etcd_cli then
return nil, err
end
- local res, err = etcd_cli:readdir(prefix .. key)
+ -- It will be better if we use snowflake algorithm like manager-api,
+ -- but we haven't found a good library. It costs too much to write
+ -- our own one as the admin-api will be replaced by manager-api finally.
+ local res, err = set("/gen_id", 1)
Review comment:
I think we should add more comments here to explain why we need extra write operation here, it's not easy to understand if readers are out of the context of #2950 .
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org