uuid

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Container = &UuidContainer{}
)

Initialize a uuid container singleton instance

Functions

func InitializeUuidGenerator

func InitializeUuidGenerator(config *settings.Config) error

InitializeUuidGenerator initializes the current uuid generator according to the config

Types

type InternalUuidGenerator

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

InternalUuidGenerator represents internal bundled uuid generator

func NewInternalUuidGenerator

func NewInternalUuidGenerator(config *settings.Config) (*InternalUuidGenerator, error)

NewInternalUuidGenerator returns a new internal uuid generator

func (*InternalUuidGenerator) GenerateUuid

func (u *InternalUuidGenerator) GenerateUuid(idType UuidType) int64

GenerateUuid generates a new uuid

func (*InternalUuidGenerator) GenerateUuids added in v0.2.0

func (u *InternalUuidGenerator) GenerateUuids(idType UuidType, count uint8) []int64

GenerateUuids generates new uuids

type InternalUuidInfo

type InternalUuidInfo struct {
	UnixTime     uint32
	UuidType     uint8
	UuidServerId uint8
	SequentialId uint32
}

InternalUuidInfo represents a struct which has all information in uuid

type UuidContainer

type UuidContainer struct {
	Current UuidGenerator
}

UuidContainer contains the current uuid generator

func (*UuidContainer) GenerateUuid

func (u *UuidContainer) GenerateUuid(uuidType UuidType) int64

GenerateUuid returns a new uuid by the current uuid generator

func (*UuidContainer) GenerateUuids added in v0.2.0

func (u *UuidContainer) GenerateUuids(uuidType UuidType, count uint8) []int64

GenerateUuids returns new uuids by the current uuid generator

type UuidGenerator

type UuidGenerator interface {
	GenerateUuid(uuidType UuidType) int64
	GenerateUuids(uuidType UuidType, count uint8) []int64
}

UuidGenerator is common uuid generator interface

type UuidType

type UuidType uint8

UuidType represents uuid type

const (
	UUID_TYPE_DEFAULT     UuidType = 0
	UUID_TYPE_USER        UuidType = 1
	UUID_TYPE_ACCOUNT     UuidType = 2
	UUID_TYPE_TRANSACTION UuidType = 3
	UUID_TYPE_CATEGORY    UuidType = 4
	UUID_TYPE_TAG         UuidType = 5
	UUID_TYPE_TAG_INDEX   UuidType = 6
)

Types of uuid

Jump to

Keyboard shortcuts

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