spacewander commented on a change in pull request #4559:
URL: https://github.com/apache/apisix/pull/4559#discussion_r666608780
##########
File path: apisix/plugins/request-id.lua
##########
@@ -14,36 +14,163 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-local core = require("apisix.core")
-local plugin_name = "request-id"
-local ngx = ngx
-local uuid = require("resty.jit-uuid")
+
+local ngx = ngx
+local bit = require("bit")
+local core = require("apisix.core")
+local snowflake = require("snowflake")
+local uuid = require("resty.jit-uuid")
+local process = require("ngx.process")
+local tostring = tostring
+local math_pow = math.pow
+
+local plugin_name = "request-id"
+
+local worker_number = nil
+local snowflake_init = nil
+
+local attr = nil
local schema = {
type = "object",
properties = {
header_name = {type = "string", default = "X-Request-Id"},
- include_in_response = {type = "boolean", default = true}
+ include_in_response = {type = "boolean", default = true},
+ algorithm = {type = "string", enum = {"uuid", "snowflake"}, default =
"uuid"}
}
}
+local attr_schema = {
+ type = "object",
+ properties = {
+ snowflake = {
+ type = "object",
+ properties = {
+ enable = {type = "boolean"},
+ snowflake_epoc = {type = "integer", minimum = 1, default =
1609459200000},
+ node_id_bits = {type = "integer", minimum = 1, default = 5},
+ sequence_bits = {type = "integer", minimum = 1, default = 10},
+ datacenter_id_bits = {type = "integer", minimum = 1, default =
5},
Review comment:
~~Better to use a user-friendly name, like max_worker_number or
ids_per_second~~
The current name is fine. But we should clarify in the doc that the xxx_bits
are for snowflake. There is nothing relative to node or datacenter.
--
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]