package app

import (
	"github.com/sony/sonyflake"
	"gofiber.study.skcks.cn/common/config"
	"gofiber.study.skcks.cn/common/logger"
	"gofiber.study.skcks.cn/common/utils"
	"gofiber.study.skcks.cn/global"
	"time"
)

const DefaultSonyFlakeStartTime = "2022-01-01"

func reloadSonyFlake(c *config.BasicConfig) {
	var s sonyflake.Settings
	s.StartTime, _ = time.Parse("2006-01-02", DefaultSonyFlakeStartTime)
	global.SonyFlake = sonyflake.NewSonyflake(s)

	if global.SonyFlake == nil {
		logger.Log.Fatalf("[x] [sonyFlake] id 生成器 初始化失败")
	}

	utils.MainAppExec(func() {
		logger.Log.Infof("[√] [sonyFlake] id 生成器 初始化 完成")
	})
}
