utils

package
v0.0.0-...-816873c Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenToken

func GenToken(userId int64) (string, error)

func GetDeviceID

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

获取数据中心ID和机器ID

func GetGenTime

func GetGenTime(sid int64) (t string)

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

func GetGenTimestamp

func GetGenTimestamp(sid int64) (timestamp int64)

获取创建ID时的时间戳

func GetMQUrl

func GetMQUrl() string

func GetMysqlDSN

func GetMysqlDSN() string

func GetTimestamp

func GetTimestamp(sid int64) (timestamp int64)

获取时间戳

func GetTimestampStatus

func GetTimestampStatus() (state float64)

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

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

type UserClaim

type UserClaim struct {
	UserId int64 `json:"user_id"`
	jwt.RegisteredClaims
}

func VerifyToken

func VerifyToken(token string) (*UserClaim, error)

Jump to

Keyboard shortcuts

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