sonyflakekit

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(c *SonyFlake)

Types

type IDGenerator

type IDGenerator struct {
	// contains filtered or unexported fields
}

func NewIDGenerator

func NewIDGenerator() *IDGenerator

NewIDGenerator 创建一个ID生成器

func (*IDGenerator) BatchGenerateID

func (g *IDGenerator) BatchGenerateID(count int) ([]int64, error)

BatchGenerateID 批量生成ID

func (*IDGenerator) GenerateID

func (g *IDGenerator) GenerateID() (int64, error)

GenerateID 生成ID

func (*IDGenerator) MustGenerateID

func (g *IDGenerator) MustGenerateID() int64

noinspection all

type SonyFlake

type SonyFlake struct {
	BitsSequence  int           `json:"bits_sequence" yaml:"bits_sequence" ini:"bits_sequence"`       // 序列号位数
	BitsMachineID int           `json:"bits_machine_id" yaml:"bits_machine_id" ini:"bits_machine_id"` // 机器ID位数
	TimeUnit      time.Duration `json:"time_unit" yaml:"time_unit" ini:"time_unit"`                   // 时间单位
	StartTime     time.Time     `json:"start_time" yaml:"start_time" ini:"start_time"`                // 起始时间
}

Jump to

Keyboard shortcuts

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