mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
add comments, code refactor
This commit is contained in:
@@ -5,14 +5,17 @@ import (
|
||||
"github.com/mayswind/lab/pkg/settings"
|
||||
)
|
||||
|
||||
// UuidContainer contains the current uuid generator
|
||||
type UuidContainer struct {
|
||||
Current UuidGenerator
|
||||
}
|
||||
|
||||
// Initialize a uuid container singleton instance
|
||||
var (
|
||||
Container = &UuidContainer{}
|
||||
)
|
||||
|
||||
// InitializeUuidGenerator initialized the current uuid generator according to the config
|
||||
func InitializeUuidGenerator(config *settings.Config) error {
|
||||
if config.UuidGeneratorType == settings.UUID_GENERATOR_TYPE_INTERNAL {
|
||||
generator, err := NewInternalUuidGenerator(config)
|
||||
@@ -24,6 +27,7 @@ func InitializeUuidGenerator(config *settings.Config) error {
|
||||
return errs.ErrInvalidUuidMode
|
||||
}
|
||||
|
||||
// GenerateUuid returns a new uuid by the current uuid generator
|
||||
func (u *UuidContainer) GenerateUuid(uuidType UuidType) int64 {
|
||||
return u.Current.GenerateUuid(uuidType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user