美文网首页
分布式id

分布式id

作者: 杜子龙 | 来源:发表于2021-02-10 09:54 被阅读0次
// 42位时间戳 + 1位 + 9位工作节点 + 12位序列号
type UuidService struct {
    Pilot   int64 //标记位 轮训使用 服务启动时会有多个node节点 每次调用时轮训使用其中的一个node节点
    Nodes   []*Node //一台服务上可以有多个节点
}
type Node struct {
    mu         sync.Mutex
    node       int64 //节点id
    step       int64 //序号
    timeId     int64 //时间线序号
    backoffMap map[int64]int64 //两条时间线对应的时间戳
}

相关文章

网友评论

      本文标题:分布式id

      本文链接:https://www.haomeiwen.com/subject/deqcxltx.html