auto commit
This commit is contained in:
@@ -66,8 +66,12 @@ namespace Yitter.IdGenerator
|
||||
protected int _GenCountInOneTerm = 0;
|
||||
protected int _TermIndex = 0;
|
||||
|
||||
//private static long _StartTimeTick = 0;
|
||||
//private static long _BaseTimeTick = 0;
|
||||
|
||||
public Action<OverCostActionArg> GenAction { get; set; }
|
||||
|
||||
|
||||
public SnowWorkerM1(IdGeneratorOptions options)
|
||||
{
|
||||
WorkerId = options.WorkerId;
|
||||
@@ -104,6 +108,9 @@ namespace Yitter.IdGenerator
|
||||
|
||||
_TimestampShift = (byte)(WorkerIdBitLength + SeqBitLength);
|
||||
_CurrentSeqNumber = options.MinSeqNumber;
|
||||
|
||||
//_BaseTimeTick = BaseTime.Ticks;
|
||||
//_StartTimeTick = (long)(DateTime.UtcNow.Subtract(BaseTime).TotalMilliseconds) - Environment.TickCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,6 +321,8 @@ namespace Yitter.IdGenerator
|
||||
|
||||
protected virtual long GetCurrentTimeTick()
|
||||
{
|
||||
//return (long)(DateTime.UtcNow - BaseTime).Ticks;
|
||||
//return (long)(_StartTimeTick + Environment.TickCount);
|
||||
return (long)(DateTime.UtcNow - BaseTime).TotalMilliseconds;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package contract
|
||||
|
||||
type IdGeneratorOptions struct {
|
||||
Method uint16 // 雪花计算方法,(1-漂移算法|2-传统算法),默认1
|
||||
BaseTime int64 // 基础时间,不能超过当前系统时间
|
||||
BaseTime int64 // 基础时间(ms单位),不能超过当前系统时间
|
||||
WorkerId uint16 // 机器码,与 WorkerIdBitLength 有关系
|
||||
WorkerIdBitLength byte // 机器码位长,范围:1-21(要求:序列数位长+机器码位长不超过22)
|
||||
SeqBitLength byte // 序列数位长,范围:2-21(要求:序列数位长+机器码位长不超过22)
|
||||
|
||||
@@ -17,7 +17,7 @@ public class IdGeneratorOptions {
|
||||
public short Method = 1;
|
||||
|
||||
/**
|
||||
* 基础时间
|
||||
* 基础时间(ms单位)
|
||||
* 不能超过当前系统时间
|
||||
*/
|
||||
public long BaseTime = 1582136402000L;
|
||||
|
||||
@@ -187,7 +187,7 @@ Rust:[查看示例][4]
|
||||
|
||||
QQ群:646049993
|
||||
|
||||
即将推出 C/Rust 等版本。
|
||||
即将推出 C 等版本。
|
||||
|
||||
|
||||
[1]: https://gitee.com/yitter/idgenerator/tree/master/C%23.NET
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
pub struct IdGeneratorOptions {
|
||||
/// 雪花计算方法,(1-漂移算法|2-传统算法),默认1
|
||||
pub Method: u8,
|
||||
/// 基础时间,不能超过当前系统时间
|
||||
/// 基础时间(ms单位),不能超过当前系统时间
|
||||
pub BaseTime: i64,
|
||||
/// 机器码,与 WorkerIdBitLength 有关系
|
||||
pub WorkerId: u32,
|
||||
|
||||
Reference in New Issue
Block a user