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 2022/08/22 07:18:02 UTC

[GitHub] [apisix] hf400159 commented on a diff in pull request #7751: docs(plugin): refactor request-id.md

hf400159 commented on code in PR #7751:
URL: https://github.com/apache/apisix/pull/7751#discussion_r951082589


##########
docs/zh/latest/plugins/request-id.md:
##########
@@ -23,28 +28,63 @@ title: request-id
 
 ## 描述
 
-`request-id` 插件通过 APISIX 为每一个请求代理添加唯一 ID(UUID),以用于追踪 API 请求。该插件在 `header_name` 已经在请求中存在时不会为请求添加新的 ID。
+`request-id` 插件通过 APISIX 为每一个请求代理添加 unique ID,以用于追踪 API 请求。
+
+:::note 注意
+
+如果请求已经有了配置好 `header_name` 属性的请求头,该插件将不会为请求添加 unique ID。

Review Comment:
   ```suggestion
   如果请求已经配置了 `header_name` 属性的请求头,该插件将不会为请求添加 unique ID。
   ```



##########
docs/zh/latest/plugins/request-id.md:
##########
@@ -23,28 +28,63 @@ title: request-id
 
 ## 描述
 
-`request-id` 插件通过 APISIX 为每一个请求代理添加唯一 ID(UUID),以用于追踪 API 请求。该插件在 `header_name` 已经在请求中存在时不会为请求添加新的 ID。
+`request-id` 插件通过 APISIX 为每一个请求代理添加 unique ID,以用于追踪 API 请求。
+
+:::note 注意
+
+如果请求已经有了配置好 `header_name` 属性的请求头,该插件将不会为请求添加 unique ID。
+
+:::
 
 ## 属性
 
 | 名称                | 类型    | 必选项   | 默认值         | 有效值 | 描述                           |
 | ------------------- | ------- | -------- | -------------- | ------ | ------------------------------ |
-| header_name         | string  | 可选 | "X-Request-Id" |                       | Request ID header name         |
-| include_in_response | boolean | 可选 | true          |                       | 是否需要在返回头中包含该唯一 ID |
-| algorithm           | string  | 可选 | "uuid"         | ["uuid", "snowflake", "nanoid"] | ID 生成算法 |
+| header_name         | string  | 否 | "X-Request-Id" |                       | unique ID 的请求头的名称。         |
+| include_in_response | boolean | 否 | true          |                       | 当设置为 `true` 时,将 unique ID 加入返回头。 |
+| algorithm           | string  | 否 | "uuid"         | ["uuid", "snowflake", "nanoid"] | 指定的 unique ID 生成算法。 |
 
-:::warning
+### 使用 snowflake 算法生成 unique ID
 
-当使用 `snowflake` 算法时,请确保 APISIX 有权限写入 etcd。
+:::caution 警告
+
+- 当使用 `snowflake` 算法时,请确保 APISIX 有权限写入 etcd。
+- 在决定使用 `snowflake` 算法时,请先阅读本文档了解一些配置细节。因为一旦启用相关配置信息,则不可随意调整,否则可能会导致生成重复的 ID。

Review Comment:
   ```suggestion
   - 在决定使用 `snowflake` 算法时,请仔细阅读本文档了解配置细节。因为一旦启用相关配置信息后,就不能随意调整,否则可能会导致生成重复的 ID。
   ```



##########
docs/zh/latest/plugins/request-id.md:
##########
@@ -23,28 +28,63 @@ title: request-id
 
 ## 描述
 
-`request-id` 插件通过 APISIX 为每一个请求代理添加唯一 ID(UUID),以用于追踪 API 请求。该插件在 `header_name` 已经在请求中存在时不会为请求添加新的 ID。
+`request-id` 插件通过 APISIX 为每一个请求代理添加 unique ID,以用于追踪 API 请求。

Review Comment:
   ```suggestion
   `request-id` 插件通过 APISIX 为每一个请求代理添加 unique ID 用于追踪 API 请求。
   ```



##########
docs/zh/latest/plugins/request-id.md:
##########
@@ -23,28 +28,63 @@ title: request-id
 
 ## 描述
 
-`request-id` 插件通过 APISIX 为每一个请求代理添加唯一 ID(UUID),以用于追踪 API 请求。该插件在 `header_name` 已经在请求中存在时不会为请求添加新的 ID。
+`request-id` 插件通过 APISIX 为每一个请求代理添加 unique ID,以用于追踪 API 请求。
+
+:::note 注意
+
+如果请求已经有了配置好 `header_name` 属性的请求头,该插件将不会为请求添加 unique ID。
+
+:::
 
 ## 属性
 
 | 名称                | 类型    | 必选项   | 默认值         | 有效值 | 描述                           |
 | ------------------- | ------- | -------- | -------------- | ------ | ------------------------------ |
-| header_name         | string  | 可选 | "X-Request-Id" |                       | Request ID header name         |
-| include_in_response | boolean | 可选 | true          |                       | 是否需要在返回头中包含该唯一 ID |
-| algorithm           | string  | 可选 | "uuid"         | ["uuid", "snowflake", "nanoid"] | ID 生成算法 |
+| header_name         | string  | 否 | "X-Request-Id" |                       | unique ID 的请求头的名称。         |
+| include_in_response | boolean | 否 | true          |                       | 当设置为 `true` 时,将 unique ID 加入返回头。 |
+| algorithm           | string  | 否 | "uuid"         | ["uuid", "snowflake", "nanoid"] | 指定的 unique ID 生成算法。 |
 
-:::warning
+### 使用 snowflake 算法生成 unique ID
 
-当使用 `snowflake` 算法时,请确保 APISIX 有权限写入 etcd。
+:::caution 警告
+
+- 当使用 `snowflake` 算法时,请确保 APISIX 有权限写入 etcd。
+- 在决定使用 `snowflake` 算法时,请先阅读本文档了解一些配置细节。因为一旦启用相关配置信息,则不可随意调整,否则可能会导致生成重复的 ID。
 
 :::
 
-## 如何启用
+`snowflake` 算法支持灵活配置来满足各种需求,可配置的参数如下:
+
+| 名称                | 类型    | 必选项   | 默认值         | 描述                           |
+| ------------------- | ------- | -------- | -------------- | ------------------------------ |
+| enable                     | boolean  | 否 | false          | 当设置为 `true` 时, 启用 `snowflake` 算法。      |
+| snowflake_epoc             | integer  | 否 | 1609459200000  | 起始时间戳,以毫秒为单位。默认为 `2021-01-01T00:00:00Z`, 可以支持 `69 年`到 `2090-09-07 15:47:35Z`。 |
+| data_machine_bits          | integer  | 否 | 12             | 最多支持的机器(进程)数量。 与 `snowflake` 定义中 `workerIDs` 和 `datacenterIDs` 的集合对应,插件会为每一个进程分配一个 unique ID。最大支持进程数为 `pow(2, data_machine_bits)`。即对于默认值 `12 bits`,最多支持的进程数为 `4096`。|
+| sequence_bits              | integer  | 否 | 10             | 每个节点每毫秒内最多产生的 ID 数量。 每个进程每毫秒最多产生 `1024` 个 ID。 |
+| data_machine_ttl           | integer  | 否 | 30             | etcd 中 `data_machine` 注册有效时间,以秒为单位。 |
+| data_machine_interval      | integer  | 否 | 10             | etcd 中 `data_machine` 续约间隔时间,以秒为单位。 |
 
-创建一条路由并在该路由上启用 `request-id` 插件:
+要使用 `snowflake` 算法,你必须先在配置文件 `conf/config.yaml` 中启用:

Review Comment:
   ```suggestion
   如果你需要使用 `snowflake` 算法,请务必在配置文件 `./conf/config.yaml` 中添加以下参数:
   ```



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org