Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func NewService(generator *Snowflake) api.SnowflakeServer
Types ¶
type Coordinator ¶
type Coordinator interface { GetOrCreateWorker(ctx context.Context) (*Worker, error) SyncTime(ctx context.Context) error }
func NewEtcdv3Coordinator ¶
func NewEtcdv3Coordinator() Coordinator
type Etcdv3Coordinator ¶
type Etcdv3Coordinator struct {
// contains filtered or unexported fields
}
func (*Etcdv3Coordinator) GetOrCreateWorker ¶
func (e *Etcdv3Coordinator) GetOrCreateWorker(ctx context.Context) (*Worker, error)
func (*Etcdv3Coordinator) SyncTime ¶
func (e *Etcdv3Coordinator) SyncTime(ctx context.Context) error
func (*Etcdv3Coordinator) WorkerIDKeyPrefix ¶
func (e *Etcdv3Coordinator) WorkerIDKeyPrefix() string
type Service ¶
type Service struct { api.UnimplementedSnowflakeServer // contains filtered or unexported fields }
type Snowflake ¶
func (*Snowflake) FetchNext ¶
GetUID 得到全局唯一ID int64类型 首位0(1位) + 毫秒时间戳(41位) + 数据中心标识(5位) + 工作机器标识(5位) + 自增id(12位) 时间可以保证400年不重复 数据中心和机器标识一起标识节点,最多支持1024个节点 每个节点每一毫秒能生成最多4096个id 63 62 21 16 11 0 +-------+-------------+-------------+---------+--------+ | 未使用 | 毫秒级时间戳 | 数据中心标识 | 工作机器 | 自增id | +-------+-------------+-------------+---------+--------+
Click to show internal directories.
Click to hide internal directories.