Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
DefaultGenerator is a Generator with the epoch set to January 1, 2021 at 00:00 UTC
var DefaultSmallGenerator = NewSmallGen(time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC))
DefaultSmallGenerator is a SmallGenerator with the epoch set to January 1, 2021 at 00:00 UTC
Functions ¶
This section is empty.
Types ¶
type Generator ¶
Generator holds info needed for generating custom snowflakes
func (*Generator) GetFromTime ¶
GetFromTime gets a snowflake, with only the time field set, that parses as the given time
type SmallGenerator ¶ added in v2.1.0
SmallGenerator holds info needed for generating custom snowflakes
func NewSmallGen ¶ added in v2.1.0
func NewSmallGen(epoch time.Time) *SmallGenerator
NewSmallGen returns a new small generator
func (*SmallGenerator) Get ¶ added in v2.1.0
func (g *SmallGenerator) Get() SmallSnowflake
Get gets a new snowflake
func (*SmallGenerator) GetFromTime ¶ added in v2.1.0
func (g *SmallGenerator) GetFromTime(t time.Time) SmallSnowflake
GetFromTime gets a snowflake, with only the time field set, that parses as the given time
func (*SmallGenerator) Parse ¶ added in v2.1.0
func (g *SmallGenerator) Parse(s SmallSnowflake) (t time.Time, err error)
Parse parses the given snowflake into a timestamp
type SmallSnowflake ¶ added in v2.1.0
type SmallSnowflake uint32
SmallSnowflake is a uint32-sized ID
func ParseSmallSnowflake ¶ added in v2.1.0
func ParseSmallSnowflake(s string) (SmallSnowflake, error)
ParseSmallSnowflake parses a string into a small snowflake, if possible
func (SmallSnowflake) String ¶ added in v2.1.0
func (s SmallSnowflake) String() string