Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
Container = &UuidContainer{}
)
Initialize a uuid container singleton instance
Functions ¶
func InitializeUuidGenerator ¶
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 uint16) []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 uint16) []int64
GenerateUuids returns new uuids by the current uuid generator
type UuidGenerator ¶
type UuidGenerator interface { GenerateUuid(uuidType UuidType) int64 GenerateUuids(uuidType UuidType, count uint16) []int64 }
UuidGenerator is common uuid generator interface
type UuidType ¶
type UuidType uint8
UuidType represents uuid type, the value of uuid type should should be from 0 to 15
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 UUID_TYPE_TEMPLATE UuidType = 7 UUID_TYPE_PICTURE UuidType = 8 )
Types of uuid