You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

24 lines
586 B

using Yitter.IdGenerator;
namespace Easy.Snowflakes;
public class DriftingSnowflakeIdGenerator : ISnowflakeIdGenerator
{
private readonly IIdGenerator Generator;
public DriftingSnowflakeIdGenerator(ushort workerId)
{
Generator = new DefaultIdGenerator(new IdGeneratorOptions()
{
WorkerId = workerId,
BaseTime = DateTime.Parse("2022-01-01 00:00:00")
});
}
/// <summary>
/// 生成新的Id
/// </summary>
/// <returns></returns>
public long Create()
{
return Generator.NewLong();
}
}