Skip to content

Commit 025c572

Browse files
committed
[增加](雪花ID): 增加雪花ID的参数的配置化
1 parent da4ce0e commit 025c572

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

GameFrameX.Utility/IdGenerator.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,4 @@ public static string GetUniqueIdString()
5050
{
5151
return Guid.NewGuid().ToString("N");
5252
}
53-
54-
/// <summary>
55-
/// 静态构造函数,初始化雪花算法的ID生成器
56-
/// </summary>
57-
static IdGenerator()
58-
{
59-
// 创建ID生成器配置,WorkerId设为0
60-
var options = new IdGeneratorOptions(0);
61-
// 初始化雪花算法ID生成器
62-
YitIdHelper.SetIdGenerator(options);
63-
}
6453
}

GameFrameX.Utility/Setting/GlobalSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using GameFrameX.Foundation.Json;
22
using GameFrameX.Foundation.Logger;
33
using GameFrameX.Utility.Extensions;
4+
using Yitter.IdGenerator;
45

56
namespace GameFrameX.Utility.Setting;
67

@@ -106,6 +107,10 @@ public static void SetCurrentSetting(AppSetting setting)
106107
setting.NetWorkSendTimeOutSeconds = 5;
107108
}
108109

110+
// 创建ID生成器配置,WorkerId设为0
111+
var options = new IdGeneratorOptions(setting.WorkerId);
112+
// 初始化雪花算法ID生成器
113+
YitIdHelper.SetIdGenerator(options);
109114
CurrentSetting = setting;
110115
}
111116

0 commit comments

Comments
 (0)