snowflake

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Epoch time.Time
	// contains filtered or unexported fields
}

Generator holds info needed for generating custom snowflakes

func NewGen

func NewGen(epoch time.Time) *Generator

NewGen returns a new generator

func (*Generator) Get

func (g *Generator) Get() Snowflake

Get gets a new snowflake

func (*Generator) Parse

func (g *Generator) Parse(s Snowflake) (t time.Time, err error)

Parse parses the given snowflake into a timestamp

type Snowflake

type Snowflake string

Snowflake is an ID generated by a Generator

func (Snowflake) Int

func (s Snowflake) Int() int64

Int returns the integer version of a snowflake

func (Snowflake) String

func (s Snowflake) String() string

func (Snowflake) ToTime

func (s Snowflake) ToTime(epoch time.Time) time.Time

ToTime converts the snowflake to a timestamp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL