1
0
mirror of synced 2026-04-22 00:08:40 +08:00

限定TopOverCostCount范围

This commit is contained in:
yitter
2022-07-16 00:42:36 +08:00
parent 519206cdbf
commit b1b3d0cd6d
12 changed files with 165 additions and 84 deletions

View File

@@ -63,7 +63,6 @@ namespace Yitter.IdGenerator
/// </summary>
public virtual int TopOverCostCount { get; set; } = 2000;
/// <summary>
/// 数据中心ID默认0
/// </summary>

View File

@@ -118,10 +118,10 @@ namespace Yitter.IdGenerator
// 7.Others
TopOverCostCount = options.TopOverCostCount;
if (TopOverCostCount == 0)
{
TopOverCostCount = 2000;
}
//if (TopOverCostCount == 0)
//{
// TopOverCostCount = 2000;
//}
_TimestampShift = (byte)(WorkerIdBitLength + SeqBitLength);
_CurrentSeqNumber = options.MinSeqNumber;

View File

@@ -92,6 +92,12 @@ namespace Yitter.IdGenerator
throw new ApplicationException("MinSeqNumber error. (range:[5, " + maxSeqNumber + "]");
}
// 7.TopOverCostCount
if (options.TopOverCostCount < 0 || options.TopOverCostCount > 10000)
{
throw new ApplicationException("TopOverCostCount error. (range:[0, 10000]");
}
switch (options.Method)
{
case 2: