Documentation ¶
Index ¶
- func GetDataCenterIDMax() int64
- func GetDeviceID(sid int64) (datacenterid, workerid int64)
- func GetGenTime(sid int64, layout string) (t string)
- func GetGenTimestamp(sid int64) (timestamp int64)
- func GetTimestamp(sid int64) (timestamp int64)
- func GetTimestampStatus() (state float64)
- func GetWorkerIDMax() int64
- func NewUUID4() (uuid4 string)
- type IDGenerator
- type Snowflake
- func (s *Snowflake) GetDeviceID(sid int64) (datacenterid, workerid int64)
- func (s *Snowflake) GetGenTime(sid int64, layout string) (t string)
- func (s *Snowflake) GetGenTimestamp(sid int64) (timestamp int64)
- func (s *Snowflake) GetTimestamp(sid int64) (timestamp int64)
- func (s *Snowflake) GetTimestampStatus() (state float64)
- func (s *Snowflake) NextID() (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDataCenterIDMax ¶
func GetDataCenterIDMax() int64
func GetDeviceID ¶
GetDeviceID 获取数据中心ID和机器ID.
func GetGenTime ¶
GetGenTime 获取创建ID时的时间字符串(精度:秒)
func GetGenTimestamp ¶
GetGenTimestamp 获取创建ID时的时间戳
func GetTimestampStatus ¶
func GetTimestampStatus() (state float64)
GetTimestampStatus 获取时间戳已使用的占比:范围(0.0 - 1.0)
func GetWorkerIDMax ¶
func GetWorkerIDMax() int64
Types ¶
type IDGenerator ¶
type IDGenerator interface { NextID() (int64, error) GetDeviceID(sid int64) (datacenterid, workerid int64) GetTimestamp(sid int64) (timestamp int64) GetGenTimestamp(sid int64) (timestamp int64) GetGenTime(sid int64, layout string) (t string) GetTimestampStatus() (state float64) }
func Default ¶
func Default() IDGenerator
func NewSnowflake ¶
func NewSnowflake(datacenterid, workerid int64) (IDGenerator, error)
type Snowflake ¶
func (*Snowflake) GetDeviceID ¶
GetDeviceID 获取数据中心ID和机器ID.
func (*Snowflake) GetGenTime ¶
GetGenTime 获取创建ID时的时间字符串(精度:秒).
func (*Snowflake) GetGenTimestamp ¶
GetGenTimestamp 获取创建ID时的时间戳.
func (*Snowflake) GetTimestamp ¶
GetTimestamp 获取时间戳.
func (*Snowflake) GetTimestampStatus ¶
GetTimestampStatus 获取时间戳已使用的占比:范围(0.0 - 1.0.
Click to show internal directories.
Click to hide internal directories.