Documentation ¶
Overview ¶
snowflake provides a very simple Twitter snowflake generator and parser.
Index ¶
- func NewNodeByHostname() int
- type ID
- func (f ID) Base64() string
- func (f ID) Bytes() []byte
- func (f ID) Int64() int64
- func (f ID) IntBytes() [8]byte
- func (f ID) MarshalJSON() ([]byte, error)
- func (f ID) Node() int64
- func (f ID) Step() int64
- func (f ID) String() string
- func (f ID) Time() time.Time
- func (f *ID) UnmarshalJSON(b []byte) error
- type JSONSyntaxError
- type Snowflake
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNodeByHostname ¶
func NewNodeByHostname() int
NewNodeByHostname is a convenience method which creates a new Node based off a hash of the machine's hostname.
Types ¶
type ID ¶
type ID int64
An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.
func ParseBase64 ¶
ParseBase64 converts a base64 string into a snowflake ID
func ParseBytes ¶
ParseBytes converts a byte slice into a snowflake ID
func ParseIntBytes ¶
ParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake ID
func ParseString ¶
ParseString converts a string into a snowflake ID
func (ID) IntBytes ¶
IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.
func (ID) MarshalJSON ¶
MarshalJSON returns a json byte array string of the snowflake ID.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.
type JSONSyntaxError ¶
type JSONSyntaxError struct {
// contains filtered or unexported fields
}
A JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.
func (JSONSyntaxError) Error ¶
func (j JSONSyntaxError) Error() string
type Snowflake ¶
type Snowflake struct {
// contains filtered or unexported fields
}
Snowflake service ...
func (*Snowflake) GenerateUniqueSequenceID ¶
GenerateUniqueSequenceID generates unique id ...