sk-matrix-project/backend/golang/matrix-middle-service/pkg/utils/sonyflake/sonyflake.go

22 lines
454 B
Go
Raw Normal View History

2023-02-26 23:25:20 +08:00
package sonyflake
import (
"github.com/sony/sonyflake"
sf "matrix-middle-service/pkg/config/sonyflake"
"matrix-middle-service/pkg/logger"
2023-02-26 23:25:20 +08:00
"time"
)
var generator *sonyflake.Sonyflake
func Init(config *sf.Config) {
logger.Log().Debug("[sonyFlake] 初始化")
2023-02-26 23:25:20 +08:00
var s sonyflake.Settings
s.StartTime, _ = time.Parse("2006-01-02", config.StartTime)
2023-02-26 23:25:20 +08:00
generator = sonyflake.NewSonyflake(s)
}
func SonyFlake() *sonyflake.Sonyflake {
return generator
}