dickens7 commented on a change in pull request #4559:
URL: https://github.com/apache/apisix/pull/4559#discussion_r684299882



##########
File path: docs/en/latest/plugins/request-id.md
##########
@@ -72,6 +73,60 @@ X-Request-Id: fe32076a-d0a5-49a6-a361-6c244c1df956
 ......
 ```
 
+### Use the snowflake algorithm to generate an ID
+
+> supports using the Snowflake algorithm to generate ID.
+> read the documentation first before deciding to use snowflake. Because once 
the configuration information is enabled, you can not arbitrarily adjust the 
configuration information. Failure to do so may result in duplicate ID being 
generated.
+
+The Snowflake algorithm is not enabled by default and needs to be configured 
in 'conf/config.yaml'.
+
+```yaml
+plugin_attr:
+  request-id:
+    snowflake:
+      enable: true
+      snowflake_epoc: 1609459200000
+      data_machine_bits: 12
+      sequence_bits: 10
+      data_machine_ttl: 30
+      data_machine_interval: 10
+```
+
+#### Configuration parameters
+
+| Name                | Type    | Requirement   | Default        |  Valid  | 
Description                    |
+| ------------------- | ------- | ------------- | -------------- | ------- | 
------------------------------ |
+| enable                     | boolean  | optional   | false          |  | 
When set it to true, enable the snowflake algorithm.  |
+| snowflake_epoc             | integer  | optional   | 1609459200000  |  | 
Start timestamp (in milliseconds)       |
+| data_machine_bits          | integer  | optional   | 12             |  | 
Maximum number of supported machines (processes) `1 << data_machine_bits` |
+| sequence_bits              | integer  | optional   | 10             |  | 
Maximum number of generated ID per millisecond per node `1 << sequence_bits` |
+| data_machine_ttl           | integer  | optional   | 30             |  | 
Valid time of registration of 'data_machine' in 'etcd' (unit: seconds) |
+| data_machine_interval      | integer  | optional   | 10             |  | 
Time between 'data_machine' renewal in 'etcd' (unit: seconds) |
+
+- `snowflake_epoc` default start time is  `2021-01-01T00:00:00Z`, and it can 
support `69 year` approximately to `2090-09-0715:47:35Z` according to the 
default configuration
+- `data_machine_bits` corresponds to the set of workIDs and datacEnteridd in 
the snowflake definition. The plug-in aslocates a unique ID to each process. 
Maximum number of supported processes is `pow(2, data_machine_bits)`. The 
default number of `12 bits` is up to `4096`.
+- `sequence_bits` defaults to `10 bits` and each process generates up to 
`1024` ID per second

Review comment:
       This is the definition of two parts of the snowflake algorithm. 
Millisecond is the definition of the timestamp part, which means that the 
timestamp part is in milliseconds. Second is the definition of the sequence 
number part, which means that the number of id can be generated per second
   




-- 
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]


Reply via email to