Documentation ¶
Index ¶
- Constants
- func CnStyle(id int64) string
- func FromChStyle(v string) (int64, error)
- func IDParse(id int64) (timeMs, node, step int64)
- func IDParseEx(id int64) (t time.Time, node, step int64)
- func Setup(opts ...Option)
- func TimeBetweenID(begin time.Time, end time.Time) (min, max int64)
- func TimeIDRange(t time.Time) (min, max int64)
- type Node
- type NodeBitsMode
- type Option
Constants ¶
View Source
const ( //StepBits 步长永远设置为12 bits StepBits uint8 = 12 Node1024 NodeBitsMode = 10 Node512 NodeBitsMode = 9 Node256 NodeBitsMode = 8 //SDivMs 1 second = 1000 ms SDivMs = 1000 //MsDivNs 1 ms = 1000000 ns MsDivNs = 1000000 //TimeStrLen convert id to time style string, its length is fixed 24 TimeStrLen = 24 )
Variables ¶
This section is empty.
Functions ¶
func CnStyle ¶ added in v0.2.5
CnStyle A weird implement for chinese style 总共长度24 17位时间- 20210901 003859 000 7位NODE+STEP
func FromChStyle ¶ added in v0.2.5
FromChStyle from string to int64
func IDParse ¶ added in v0.2.5
IDParse figure out time/node/step from id Return : ms timestamp, node, step
func IDParseEx ¶ added in v0.2.5
IDParseEx figure out time/node/step from id Return : time.Time, node, step
func TimeBetweenID ¶ added in v0.3.4
TimeBetweenID figure out a specific [after time, before time] The calculation is based on second
func TimeIDRange ¶ added in v0.3.4
TimeIDRange figure out a specific time min and max id The calculation is based on second
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
A Node struct holds the basic information needed for a snowflake generator node
type NodeBitsMode ¶ added in v0.2.5
type NodeBitsMode uint8
Click to show internal directories.
Click to hide internal directories.