Skip to content

Commit

Permalink
fix #135
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang committed Aug 11, 2022
1 parent 483b2ee commit b1e58eb
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 58 deletions.
1 change: 1 addition & 0 deletions document/docs/.vuepress/config/sidebar/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function getConfigSidebar(groupA): SidebarConfigArray {
collapsable: false,
children: [
'',
'machine',
'snowflake',
'segment',
'zookeeper',
Expand Down
62 changes: 62 additions & 0 deletions document/docs/config/machine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Machine 配置

> `me.ahoo.cosid.spring.boot.starter.machine.MachineProperties`
| 名称 | 数据类型 | 说明 | 默认值 |
|-----------------|------------------|----------------------|-----------|
| stable | `boolean` | 是否为稳定的实例,稳定实例将不回收机器号 | `false` |
| port | `Integer` | 端口号 | 进程ID(PID) |
| instanceId | `String` | 应用实例编号(全局唯一) | 应用IP:PID |
| machineBit | `int` | 机器位数 | `10` |
| stateStorage | `StateStorage` | 机器状态存储 | |
| distributor | `Distributor` | 机器号分发器 | |
| guarder | `Guarder` | 机器号(心跳)守护 | |
| clock-backwards | `ClockBackwards` | 时钟回拨配置 | |

### StateStorage

| 名称 | 数据类型 | 说明 | 默认值 |
|---------|----------------------|------------|--------|
| enabled | `boolean` | 是否启用状态存储 | `true` |
| local | `StateStorage.Local` | 本地机器状态存储配置 | |

#### StateStorage.Local

| 名称 | 数据类型 | 说明 | 默认值 |
|----------------|----------|--------|--------------------------|
| state-location | `String` | 状态存储位置 | `./cosid-machine-state/` |

### Distributor

| 名称 | 数据类型 | 说明 | 默认值 |
|--------|----------------------|-------------------------------------------------------------|----------|
| type | `Distributor.Type` | 机器号分配器类型:`MANUAL`/`STATEFUL_SET`/`JDBC`/`REDIS`/`ZOOKEEPER` | `MANUAL` |
| manual | `Distributor.Manual` | 手动分配器配置 | |

#### Distributor.Manual

| 名称 | 数据类型 | 说明 | 默认值 |
|-----------|-----------|-----|--------|
| machineId | `Integer` | 机器号 | `null` |

## ClockBackwards

> `me.ahoo.cosid.spring.boot.starter.machine.MachineProperties.ClockBackwards`
| 名称 | 数据类型 | 说明 | 默认值 |
|------------------|-------|----------------------------------------------|--------|
| spin-threshold | `int` | 自旋同步阈值(ms) | `10` |
| broken-threshold | `int` | 抛出异常(`ClockTooManyBackwardsException`)阈值(ms) | `2000` |

**YAML 配置样例**

```yaml
cosid:
namespace: ${spring.application.name}
machine:
enabled: true
distributor:
type: jdbc
guarder:
enabled: true
```
58 changes: 0 additions & 58 deletions document/docs/config/snowflake.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,10 @@
| enabled | `boolean` | 是否启用 | `false` |
| zone-id | `String` | 时区 | `ZoneId.systemDefault().getId()` |
| epoch | `long` | EPOCH | `CosId.COSID_EPOCH` <br> (UTC 2019-12-24 16:00) |
| clock-backwards | `ClockBackwards` | 时钟回拨配置 | |
| machine | `Machine` | 机器号分配器配置 | |
| share | `IdDefinition` | 共享ID生成器配置 ||
| provider | `Map<String, IdDefinition>` | 多ID生成器配置 | `null` |

## ClockBackwards

> `me.ahoo.cosid.spring.boot.starter.snowflake.SnowflakeIdProperties.ClockBackwards`
| 名称 | 数据类型 | 说明 | 默认值 |
|------------------|-------|----------------------------------------------|--------|
| spin-threshold | `int` | 自旋同步阈值(ms) | `10` |
| broken-threshold | `int` | 抛出异常(`ClockTooManyBackwardsException`)阈值(ms) | `2000` |

## Machine

> `me.ahoo.cosid.spring.boot.starter.snowflake.SnowflakeIdProperties.Machine`
| 名称 | 数据类型 | 说明 | 默认值 |
|--------------|------------------------|----------------------|-----------|
| stable | `boolean` | 是否为稳定的实例,稳定实例将不回收机器号 | `false` |
| port | `Integer` | 端口号 | 进程ID(PID) |
| instanceId | `String` | 应用实例编号(全局唯一) | 应用IP:PID |
| machineBit | `int` | 机器位数 | `10` |
| stateStorage | `Machine.StateStorage` | 机器状态存储 | |
| distributor | `Machine.Distributor` | 机器号分发器 | |

### Machine.StateStorage

| 名称 | 数据类型 | 说明 | 默认值 |
|---------|------------------------------|------------|--------|
| enabled | `boolean` | 是否启用状态存储 | `true` |
| local | `Machine.StateStorage.Local` | 本地机器状态存储配置 | |

#### Machine.StateStorage.Local

| 名称 | 数据类型 | 说明 | 默认值 |
|----------------|----------|--------|--------------------------|
| state-location | `String` | 状态存储位置 | `./cosid-machine-state/` |

### Machine.Distributor

| 名称 | 数据类型 | 说明 | 默认值 |
|--------|------------------------------|-------------------------------------------------------------|----------|
| type | `Machine.Distributor.Type` | 机器号分配器类型:`MANUAL`/`STATEFUL_SET`/`JDBC`/`REDIS`/`ZOOKEEPER` | `MANUAL` |
| manual | `Machine.Distributor.Manual` | 手动分配器配置 | |

#### Machine.Distributor.Manual

| 名称 | 数据类型 | 说明 | 默认值 |
|-----------|-----------|-----|--------|
| machineId | `Integer` | 机器号 | `null` |

## IdDefinition

> `me.ahoo.cosid.spring.boot.starter.snowflake.SnowflakeIdProperties.IdDefinition`
Expand All @@ -84,15 +35,6 @@ cosid:
enabled: true
zone-id: Asia/Shanghai
epoch: 1577203200000
clock-backwards:
spin-threshold: 10
broken-threshold: 2000
machine:
distributor:
type: redis
state-storage:
local:
state-location: ./cosid-machine-state/
share:
clock-sync: true
friendly: true
Expand Down

0 comments on commit b1e58eb

Please sign in to comment.