jiangfucheng commented on code in PR #8790:
URL: https://github.com/apache/apisix/pull/8790#discussion_r1101530569
##########
apisix/plugins/request-id.lua:
##########
@@ -202,14 +215,28 @@ local function next_id()
return snowflake:next_id()
end
+-- generate random id
+local function get_random_id(strs, length)
+ local res = ""
+ for i = 1,length do
+ local idx = math_random(str_len(strs))
+ res = res .. str_sub(strs, idx, idx)
+ end
+ return res
+end
Review Comment:
Thansk for you suggestion, I was updated.
##########
apisix/plugins/request-id.lua:
##########
@@ -40,7 +43,17 @@ local schema = {
properties = {
header_name = {type = "string", default = "X-Request-Id"},
include_in_response = {type = "boolean", default = true},
- algorithm = {type = "string", enum = {"uuid", "snowflake", "nanoid"},
default = "uuid"}
+ algorithm = {
+ type = "string",
+ enum = {"uuid", "snowflake", "nanoid", "specified_character_id"},
+ default = "uuid"
+ },
+ specified_character_id_length = { type = "integer", minimum = 6,
default = 16 },
+ specified_character_id_strs = {
+ type = "string",
+ minLength = 6,
Review Comment:
I just want to avoid too short length that users set, too short id may
repeat.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]