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

IdGeneratorOptions.v 854 B

4 years ago
12345678910111213
  1. module contract
  2. pub struct IdGeneratorOptions {
  3. pub mut:
  4. method u16 =1// 雪花计算方法,(1-漂移算法|2-传统算法),默认1
  5. base_time i64// 基础时间,不能超过当前系统时间
  6. worker_id u16 =1// 机器码,与 workerid_bitlength 有关系
  7. workerid_bitlength byte=6// 机器码位长,范围:1-21(要求:序列数位长+机器码位长不超过22)
  8. seq_bitlength byte=6// 序列数位长,范围:2-21(要求:序列数位长+机器码位长不超过22)
  9. max_seqnumber u32// 最大序列数(含),(由seq_bitlength计算的最大值)
  10. min_seqnumber u32// 最小序列数(含),默认5,不小于1,不大于max_seqnumber
  11. top_over_cost_count u32 =2000// 最大漂移次数(含),默认2000,推荐范围500-10000(与计算能力有关)
  12. }

雪花算法中非常好用的数字ID生成器