Browse Source

auto commit

tags/v1.3.1
yitter 3 years ago
parent
commit
ee97989e88
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs

+ 3
- 2
C#.NET/source/Yitter.IdGenerator/DefaultIdGenerator.cs View File

@@ -42,13 +42,14 @@ namespace Yitter.IdGenerator
}
// 2.WorkerIdBitLength
int maxLength = options.TimestampType == 0 ? 22 : 31; // (秒级时间戳时放大到31位)
if (options.WorkerIdBitLength <= 0)
{
throw new ApplicationException("WorkerIdBitLength error.(range:[1, 21])");
}
if (options.DataCenterIdBitLength + options.WorkerIdBitLength + options.SeqBitLength > 22)
if (options.DataCenterIdBitLength + options.WorkerIdBitLength + options.SeqBitLength > maxLength)
{
throw new ApplicationException("error:DataCenterIdBitLength + WorkerIdBitLength + SeqBitLength <= 22");
throw new ApplicationException("error:DataCenterIdBitLength + WorkerIdBitLength + SeqBitLength <= " + maxLength);
}
// 3.WorkerId & DataCenterId


Loading…
Cancel
Save