package com.qianwen.mdc.collect.config;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
|
import com.hy.properties.IdGeneratorOptions;
|
|
/**
|
* 漂移雪花算法的option生成配置
|
*/
|
@Configuration
|
public class WFGIdGeneratorConfig {
|
|
@Autowired
|
private WfgProperties wftProperties;
|
|
@Bean(name="idGeneratorOptions") //bean的name必须为该值!!!
|
public IdGeneratorOptions buildOptions() {
|
IdGeneratorOptions options = new IdGeneratorOptions();
|
options.setBaseTime(wftProperties.getBaseTime());
|
|
options.setWorkerId(wftProperties.getWorkerId());
|
options.setDataCenterId((short)wftProperties.getDataCenterId());
|
options.setDataCenterIdBitLength(wftProperties.getDataCenterIdBitLength());
|
options.setMaxSeqNumber(wftProperties.getMaxSeqNumber());
|
options.setMethod(wftProperties.getMethod());
|
options.setMinSeqNumber(wftProperties.getMinSeqNumber());
|
options.setSeqBitLength(wftProperties.getSeqBitLength());
|
options.setTopOverCostCount(wftProperties.getTopOverCostCount());
|
options.setWorkerIdBitLength(wftProperties.getWorkerIdBitLength());
|
return options;
|
}
|
}
|