com.taotao.boot.idgenerator.uid.config.UidGenProperties Maven / Gradle / Ivy
package com.taotao.boot.idgenerator.uid.config;
import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "taotao.boot.idgenerator.uid")
public class UidGenProperties {
@NotNull
@Length(max = 6, min = 6)
private String systemCode;
@NotNull
@Length(max = 1, min = 1)
private String dataCenterCode = "A";
/**
* 以下为可选配置, 如未指定将采用默认值(28-22-13),三个参数加起来必须等于63
*/
private int timeBits = 26;
private int workerBits = 24;
private int seqBits = 13;
private String epochStr = "2022-04-22";
/**
* RingBuffer size扩容参数, 可提高UID生成的吞吐量
*/
private int boostPower = 3;
/**
* 指定何时向RingBuffer中填充UID, 取值为百分比(0, 100), 默认为50 举例: bufferSize=1024, paddingFactor=50 ->
* threshold=1024 * 50 / 100 = 512. 当环上可用UID数量 < 512时, 将自动对RingBuffer进行填充补全
*/
private int paddingFactor = 50;
/**
* 另外一种RingBuffer填充时机, 在Schedule线程中, 周期性检查填充 默认:不配置此项, 即不实用Schedule线程. 如需使用, 请指定Schedule线程时间间隔,
* 单位:秒
*/
private Long scheduleInterval;
public int getTimeBits() {
return timeBits;
}
public void setTimeBits(int timeBits) {
this.timeBits = timeBits;
}
public int getWorkerBits() {
return workerBits;
}
public void setWorkerBits(int workerBits) {
this.workerBits = workerBits;
}
public int getSeqBits() {
return seqBits;
}
public void setSeqBits(int seqBits) {
this.seqBits = seqBits;
}
public String getEpochStr() {
return epochStr;
}
public void setEpochStr(String epochStr) {
this.epochStr = epochStr;
}
public int getBoostPower() {
return boostPower;
}
public void setBoostPower(int boostPower) {
this.boostPower = boostPower;
}
public int getPaddingFactor() {
return paddingFactor;
}
public void setPaddingFactor(int paddingFactor) {
this.paddingFactor = paddingFactor;
}
public Long getScheduleInterval() {
return scheduleInterval;
}
public void setScheduleInterval(Long scheduleInterval) {
this.scheduleInterval = scheduleInterval;
}
public String getSystemCode() {
return systemCode;
}
public void setSystemCode(String systemCode) {
this.systemCode = systemCode;
}
public String getDataCenterCode() {
return dataCenterCode;
}
public void setDataCenterCode(String dataCenterCode) {
this.dataCenterCode = dataCenterCode;
}
}