Documentation
¶
Index ¶
- Variables
- type Snowflake
- func (s Snowflake) GetNodeId() (nodeId int64)
- func (s Snowflake) GetSeq() (seq int64)
- func (s Snowflake) GetTimestampRaw() (unixMillis int64)
- func (s Snowflake) MarshalJSON() ([]byte, error)
- func (s *Snowflake) Scan(src any) error
- func (s Snowflake) String() string
- func (s *Snowflake) UnmarshalJSON(data []byte) error
- func (s Snowflake) Value() (driver.Value, error)
- type SnowflakeGenerator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TwitterEpoch int64 = 1288834974657 DiscordEpoch int64 = 1420070400000 )
presets for ease of use with other services.
View Source
var ( ErrInvalidNodeId = errors.New("node ID exceeds maximum of 10 bits") ErrGenerationClockRollback = errors.New("clock went backwards") )
View Source
var ErrInvalidSnowflake = errors.New("invalid snowflake")
Functions ¶
This section is empty.
Types ¶
type Snowflake ¶
type Snowflake int64
func ParseSnowflake ¶
func ParseStringSnowflake ¶
func (Snowflake) GetTimestampRaw ¶
Gets the raw timestamp (in unix millis) of the Snowflake You will have to manually add the timestamp offset to this value.
func (Snowflake) MarshalJSON ¶
func (*Snowflake) UnmarshalJSON ¶
type SnowflakeGenerator ¶
type SnowflakeGenerator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator(nodeId, timestampEpoch int64) (*SnowflakeGenerator, error)
func (*SnowflakeGenerator) Generate ¶
func (s *SnowflakeGenerator) Generate() (Snowflake, error)
Generates a Snowflake.
func (*SnowflakeGenerator) MustGenerate ¶
func (s *SnowflakeGenerator) MustGenerate() Snowflake
MustGenerate panics on error
Click to show internal directories.
Click to hide internal directories.