Documentation ¶
Overview ¶
idgenerator id generator,id生成器
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct { Config *IDConfig //Structure of custom id. 自定义id的结构 CustomIntervalNumber uint64 //Business area, used to distinguish the id generated by different services. 业务区间,用来区分不同服务生成的id SerialNumber uint64 //Self-increasing serial number. 自增序列号 IDRecorder recorder.Recorder //id recorder, customizable implementation interface. id记录器,可自定义实现接口 // contains filtered or unexported fields }
Generator Implementation of the generator. 生成器的实现
func NewCachedIdGenerator ¶
func NewCachedIdGenerator(config *IDConfig, custominterval uint64, r recorder.Recorder) (*Generator, error)
NewCachedIdGenerator Get a generator with customizable buffer size. 获得可自定义缓冲大小的生成器
type IDConfig ¶
type IDConfig struct { CustomIntervalBits uint16 //The size of the CustomInterval. 业务区间的占位大小 SerialBits uint16 //The size of the self-incrementing serial number. 自增序列号的占位大小 BufferSize int //缓冲区大小 }
IDConfig id生成器的配置
func NewIDConfig ¶
func NewIDConfig() *IDConfig
NewIDConfig Get a default configuration. 获取一个默认配置
return &IDConfig{ CustomIntervalBits: 10, SerialBits: 53, BufferSize: 4096, }
Click to show internal directories.
Click to hide internal directories.