@@ -7,14 +7,14 @@ | |||||
package contract | package contract | ||||
type IdGeneratorOptions struct { | type IdGeneratorOptions struct { | ||||
Method uint16 // 雪花计算方法,(1-漂移算法|2-传统算法),默认1 | |||||
BaseTime int64 // 基础时间,不能超过当前系统时间 | |||||
WorkerId uint16 // 机器码,与 WorkerIdBitLength 有关系 | |||||
WorkerIdBitLength byte // 机器码位长,范围:1-21(要求:序列数位长+机器码位长不超过22) | |||||
SeqBitLength byte // 序列数位长,范围:2-21(要求:序列数位长+机器码位长不超过22) | |||||
MaxSeqNumber uint32 // 最大序列数(含),(由SeqBitLength计算的最大值) | |||||
MinSeqNumber uint32 // 最小序列数(含),默认5,不小于1,不大于MaxSeqNumber | |||||
TopOverCostCount uint // 最大漂移次数(含),默认2000,推荐范围500-10000(与计算能力有关) | |||||
Method uint16 // 雪花计算方法,(1-漂移算法|2-传统算法),默认1 | |||||
BaseTime int64 // 基础时间,不能超过当前系统时间 | |||||
WorkerId uint16 // 机器码,与 WorkerIdBitLength 有关系 | |||||
WorkerIdBitLength byte // 机器码位长,范围:1-21(要求:序列数位长+机器码位长不超过22) | |||||
SeqBitLength byte // 序列数位长,范围:2-21(要求:序列数位长+机器码位长不超过22) | |||||
MaxSeqNumber uint32 // 最大序列数(含),(由SeqBitLength计算的最大值) | |||||
MinSeqNumber uint32 // 最小序列数(含),默认5,不小于1,不大于MaxSeqNumber | |||||
TopOverCostCount uint32 // 最大漂移次数(含),默认2000,推荐范围500-10000(与计算能力有关) | |||||
} | } | ||||
func NewIdGeneratorOptions(workerId uint16) *IdGeneratorOptions { | func NewIdGeneratorOptions(workerId uint16) *IdGeneratorOptions { | ||||
@@ -7,15 +7,15 @@ | |||||
package contract | package contract | ||||
type OverCostActionArg struct { | type OverCostActionArg struct { | ||||
ActionType int | |||||
ActionType int32 | |||||
TimeTick int64 | TimeTick int64 | ||||
WorkerId int64 | |||||
OverCostCountInOneTerm int | |||||
GenCountInOneTerm int | |||||
TermIndex int | |||||
WorkerId uint16 | |||||
OverCostCountInOneTerm int32 | |||||
GenCountInOneTerm int32 | |||||
TermIndex int32 | |||||
} | } | ||||
func (ocaa OverCostActionArg) OverCostActionArg(workerId int64, timeTick int64, actionType int, overCostCountInOneTerm int, genCountWhenOverCost int, index int) { | |||||
func (ocaa OverCostActionArg) OverCostActionArg(workerId uint16, timeTick int64, actionType int32, overCostCountInOneTerm int32, genCountWhenOverCost int32, index int32) { | |||||
ocaa.ActionType = actionType | ocaa.ActionType = actionType | ||||
ocaa.TimeTick = timeTick | ocaa.TimeTick = timeTick | ||||
ocaa.WorkerId = workerId | ocaa.WorkerId = workerId | ||||
@@ -20,16 +20,16 @@ type SnowWorkerM1 struct { | |||||
SeqBitLength byte //自增序列数位长 | SeqBitLength byte //自增序列数位长 | ||||
MaxSeqNumber uint32 //最大序列数(含) | MaxSeqNumber uint32 //最大序列数(含) | ||||
MinSeqNumber uint32 //最小序列数(含) | MinSeqNumber uint32 //最小序列数(含) | ||||
TopOverCostCount uint //最大漂移次数 | |||||
TopOverCostCount uint32 //最大漂移次数 | |||||
_TimestampShift byte | _TimestampShift byte | ||||
_CurrentSeqNumber uint32 | _CurrentSeqNumber uint32 | ||||
_LastTimeTick int64 | _LastTimeTick int64 | ||||
_TurnBackTimeTick int64 | _TurnBackTimeTick int64 | ||||
_TurnBackIndex byte | _TurnBackIndex byte | ||||
_IsOverCost bool | _IsOverCost bool | ||||
_OverCostCountInOneTerm uint | |||||
_GenCountInOneTerm uint | |||||
_TermIndex uint | |||||
_OverCostCountInOneTerm uint32 | |||||
_GenCountInOneTerm uint32 | |||||
_TermIndex uint32 | |||||
sync.Mutex | sync.Mutex | ||||
} | } | ||||