Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine is the abstract representation of a real single machine, the ID generated by the same machine should be monotonically increasing, but all IDs generated from all machines will be trendily increasing
func NewMachine ¶
New returns a machine that can be used to generate snowflake IDs
func (*Machine) Generate ¶
func (m *Machine) Generate() (SnowflakeID, error)
Generate creates and returns a unique snowflake ID
type SnowflakeID ¶
type SnowflakeID int64
SnowflakeID refer to https://en.wikipedia.org/wiki/Snowflake_ID +-----------------------------------------------------------------------------+ | 1 Bit Unused | 41 Bit Timestamp | 10 Bit MachineID | 12 Bit Sequence ID | +-----------------------------------------------------------------------------+
func ParseBase64 ¶
func ParseBase64(id string) (SnowflakeID, error)
func ParseBytes ¶
func ParseBytes(id []byte) (SnowflakeID, error)
func ParseInt64 ¶
func ParseInt64(id int64) SnowflakeID
func (SnowflakeID) Base64 ¶
func (f SnowflakeID) Base64() string
func (SnowflakeID) Bytes ¶
func (f SnowflakeID) Bytes() []byte
func (SnowflakeID) Int64 ¶
func (f SnowflakeID) Int64() int64
func (SnowflakeID) String ¶
func (f SnowflakeID) String() string
Click to show internal directories.
Click to hide internal directories.