pub struct IdGeneratorOptions {
pub method: u8,
pub base_time: i64,
pub worker_id: u32,
pub worker_id_bit_length: u8,
pub seq_bit_length: u8,
pub max_seq_number: u32,
pub min_seq_number: u32,
pub top_over_cost_count: u32,
pub seq_step: u8,
}Fields§
§method: u8雪花计算方法,(1-漂移算法|2-传统算法),默认1
base_time: i64基础时间(ms单位),不能超过当前系统时间
worker_id: u32必须由外部设定,最大值 2^WorkerIdBitLength-1
worker_id_bit_length: u8默认值6,取值范围 [1, 15](要求:序列数位长+机器码位长不超过22)
seq_bit_length: u8默认值6,取值范围 [3, 21](要求:序列数位长+机器码位长不超过22)
max_seq_number: u32设置范围 [MinSeqNumber, 2^SeqBitLength-1],默认值0,表示最大序列数取最大值(2^SeqBitLength-1])
min_seq_number: u32默认值5,取值范围 [5, MaxSeqNumber],每毫秒的前5个序列数对应编号0-4是保留位,其中1-4是时间回拨相应预留位,0是手工新值预留位
top_over_cost_count: u32最大漂移次数(含),默认2000,推荐范围 500-20000(与计算能力有关)
seq_step: u8生成流水序列之间的步长,默认为1。
Implementations§
Source§impl IdGeneratorOptions
impl IdGeneratorOptions
Sourcepub fn new(worker_id: u32) -> IdGeneratorOptions
pub fn new(worker_id: u32) -> IdGeneratorOptions
Auto Trait Implementations§
impl Freeze for IdGeneratorOptions
impl RefUnwindSafe for IdGeneratorOptions
impl Send for IdGeneratorOptions
impl Sync for IdGeneratorOptions
impl Unpin for IdGeneratorOptions
impl UnwindSafe for IdGeneratorOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more