Skip to content

Commit

Permalink
feat(doc): Update specific-id.md (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang authored May 16, 2024
1 parent 8c0c182 commit 65b5abb
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 1 deletion.
141 changes: 141 additions & 0 deletions documentation/docs/guide/specific-id.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ cosid:
group_year_biz:
group:
by: year
pattern: yyyy
converter:
type: to_string
to-string:
Expand Down Expand Up @@ -511,6 +512,146 @@ cosid:
```
:::

## group_year_month_biz

使用 _SegmentId_ 算法,要求输出的ID字符串:
- 起始序号:`0`
- 格式:`<prefix><year_month><sequence>`
- 分组:按年月分组,序号从0开始。即跨月序号需要重置为0.
- 序号位:8位数值,不足8位前补0
- 例如:`BIZ-240516-00000061`

::: code-group
```yaml {7-17} [配置]
cosid:
segment:
enabled: true
distributor:
type: redis
provider:
group_year_month_biz:
group:
by: year_month
pattern: yyyyMM
converter:
type: to_string
to-string:
pad-start: true
char-size: 8
prefix: BIZ-
group-prefix:
enabled: true
```
```json [配置信息]
{
"group_year_month_biz": {
"kind": "StringSegmentId",
"actual": {
"kind": "SegmentChainId",
"fetchTime": 1715851229,
"maxId": 110,
"offset": 90,
"sequence": 91,
"step": 20,
"isExpired": false,
"isOverflow": false,
"isAvailable": true,
"converter": {
"kind": "Radix62IdConverter",
"radix": 62,
"charSize": 11,
"padStart": true,
"maxId": 9223372036854776000
}
},
"converter": {
"kind": "PrefixIdConverter",
"prefix": "BIZ-",
"actual": {
"kind": "GroupedPrefixIdConverter",
"delimiter": "-",
"actual": {
"kind": "ToStringIdConverter",
"padStart": true,
"charSize": 8
}
}
}
}
}
```
:::

## group_year_month_day_biz

使用 _SegmentId_ 算法,要求输出的ID字符串:
- 起始序号:`0`
- 格式:`<prefix><year_month_day><sequence>`
- 分组:按日期分组,序号从0开始。即明天序号需要重置为0.
- 序号位:8位数值,不足8位前补0
- 例如:`BIZ-240516-00000001`

::: code-group
```yaml {7-17} [配置]
cosid:
segment:
enabled: true
distributor:
type: redis
provider:
group_year_month_day_biz:
group:
by: year_month_day
pattern: yyMMdd
converter:
type: to_string
to-string:
pad-start: true
char-size: 8
prefix: BIZ-
group-prefix:
enabled: true
```
```json [配置信息]
{
"group_year_month_day_biz": {
"kind": "StringSegmentId",
"actual": {
"kind": "SegmentChainId",
"fetchTime": 1715851229,
"maxId": 80,
"offset": 60,
"sequence": 60,
"step": 20,
"isExpired": false,
"isOverflow": false,
"isAvailable": true,
"converter": {
"kind": "Radix62IdConverter",
"radix": 62,
"charSize": 11,
"padStart": true,
"maxId": 9223372036854776000
}
},
"converter": {
"kind": "PrefixIdConverter",
"prefix": "BIZ-",
"actual": {
"kind": "GroupedPrefixIdConverter",
"delimiter": "-",
"actual": {
"kind": "ToStringIdConverter",
"padStart": true,
"charSize": 8
}
}
}
}
}
```
:::

## 百万级规模集群实例的全局ID

使用 _CosIdGenerator_ 算法,要求支持百万级规模集群实例的全局ID生成器。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ cosid:
group_year_month_day_biz:
group:
by: year_month_day
pattern: yyyyMMdd
pattern: yyMMdd
converter:
type: to_string
to-string:
Expand Down

0 comments on commit 65b5abb

Please sign in to comment.