utils

package
v0.0.0-...-9b06841 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NanosecondsInAMillisecond = 1_000_000 // 每毫秒的纳秒数
	MillisecondsInASecond     = 1000      // 每秒的毫秒数
)

Variables

This section is empty.

Functions

func CheckIfDataExpired

func CheckIfDataExpired(lastUpdate time.Time) bool

func CustomizeCheckIfDataExpired

func CustomizeCheckIfDataExpired(lastUpdate time.Time, duration time.Duration) bool

func GetDeviceID

func GetDeviceID(sid int64) (datacenterid, workerid int64)

GetDeviceID 获取数据中心ID和机器ID

func GetGenTime

func GetGenTime(sid int64) (t string)

GetGenTime 获取创建ID时的时间字符串(精度:秒)

func GetGenTimestamp

func GetGenTimestamp(sid int64) (timestamp int64)

GetGenTimestamp 获取创建ID时的时间戳

func GetMysqlDSN

func GetMysqlDSN(mysql config.MysqlConf) string

GetMysqlDSN 会拼接 Mysql 的 DSN

func GetTextFromContribution

func GetTextFromContribution(contributions []*contribution.Contribution) string

func GetTextFromLanguages

func GetTextFromLanguages(languages *analysis.Languages) string

func GetTextFromProfile

func GetTextFromProfile(profile *developer.Developer) string

func GetTimestamp

func GetTimestamp(sid int64) (timestamp int64)

GetTimestamp 获取时间戳

func GetTimestampStatus

func GetTimestampStatus() (state float64)

GetTimestampStatus 获取时间戳已使用的占比:范围(0.0 - 1.0)

func IsSuccess

func IsSuccess(baseResp *base.Base) bool

Types

type Snowflake

type Snowflake struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSnowflake

func NewSnowflake(datacenterid, workerid int64) (*Snowflake, error)

func (*Snowflake) NextVal

func (s *Snowflake) NextVal() (int64, error)

timestamp + 数据中心id + 工作节点id + 自旋id

Jump to

Keyboard shortcuts

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