mirror of
https://github.com/thousmile/molly-multi-tenant.git
synced 2025-12-30 04:32:26 +00:00
1.IdUtils添加日志输出,workerId
This commit is contained in:
@@ -3,6 +3,7 @@ package com.xaaef.molly.common.util;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.github.yitter.contract.IdGeneratorOptions;
|
||||
import com.github.yitter.idgen.YitIdHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,11 +17,13 @@ import com.github.yitter.idgen.YitIdHelper;
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class IdUtils {
|
||||
|
||||
static {
|
||||
// workerId 范围 1~63。
|
||||
var workerId = (short) RandomUtil.randomInt(1, 63);
|
||||
log.info("IdUtils random workerId: {}", workerId);
|
||||
var options = new IdGeneratorOptions(workerId);
|
||||
YitIdHelper.setIdGenerator(options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user