id

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MaxSequence maximum allowed value
	MaxSequence uint32 = math.MaxUint32 >> 4 // 268435455
)

Variables

View Source
var ErrSequenceOverflow = fmt.Errorf("sequence over the max limition of %d", MaxSequence)

ErrSequenceOverflow oveflow error

Functions

func A20RID

func A20RID(prefix Prefix) string

A20RID a 18len decimal random id with 2len prefix

Types

type Generator

type Generator interface {
	New(prefix Prefix) (string, error)
	Parse(id string) (Prefix, time.Time, error)
}

Generator genarate a 18len decimal id with 2len prefix

func NewGenerator

func NewGenerator(sequence Sequence) Generator

NewGenerator create a new generator

type Prefix

type Prefix [2]byte

Prefix two visible ASCII

func (Prefix) String

func (p Prefix) String() string

type Sequence

type Sequence interface {
	Next() (uint32, error)
}

Sequence number generator

Jump to

Keyboard shortcuts

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