utils

package
v0.0.0-...-bdd2a71 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VideoFavoriteExchange       = "douyin_video_favorite_exchange"
	VideoFavoriteDeadExchange   = "douyin_video_favorite_exchange_dead"
	VideoFavoriteQueue          = "douyin_video_favorite"
	VideoFavoriteDeadQueue      = "douyin_video_favorite_dead"
	VideoFavoriteRoutingKey     = "douyin_vf_routing"
	VideoFavoriteDeadRoutingKey = "douyin_vf_dead_routing"
	VideoFavoriteTTL            = 10000
)
View Source
const (
	UserLogged        = "user:logged:"
	UserFollow        = "user:follow:"
	UserFan           = "user:fan:"
	UserMessageFlag   = "user:message:"
	VideoFavorite     = "video:favorite:"
	VideoFavoriteCnt  = "video:favorite:count:"
	VideoFavoriteLock = "video:favorite:lock:"
)

Variables

View Source
var MQUrl string
View Source
var UserServiceRedis *redis.Client // 供每个服务使用的

Functions

func GenErrorResp

func GenErrorResp(msg string) map[string]interface{}

func GenOkResp

func GenOkResp() map[string]interface{}

func GenToken

func GenToken(user *model.UserInfo) (string, error)

func InitMongo

func InitMongo(mc MongoConf) *mongo.Client

func InitRabbitMQ

func InitRabbitMQ(rc RabbitMQConf) (*amqp.Connection, *amqp.Channel)

func InitRedis

func InitRedis(rc RedisConf) *redis.Client

func InitXorm

func InitXorm(dbtype string, mc MysqlConf) *xorm.Engine

func UserServiceInit

func UserServiceInit(ctx context.Context, client *redis.Client)

Types

type DistributedLock

type DistributedLock struct {
	// contains filtered or unexported fields
}

func NewDistributedLock

func NewDistributedLock(ctx context.Context, rc *redis.Client, Key string) *DistributedLock

func (*DistributedLock) AcquireLock

func (l *DistributedLock) AcquireLock(ttl time.Duration) (bool, error)

func (*DistributedLock) ReleaseLock

func (l *DistributedLock) ReleaseLock() error

func (*DistributedLock) WatchDog

func (l *DistributedLock) WatchDog(ctx context.Context, ttl time.Duration)

type DouyinTiktokClaims

type DouyinTiktokClaims struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
	jwt.RegisteredClaims
}

func ParseToken

func ParseToken(token string) (*DouyinTiktokClaims, error)

type JwtUser

type JwtUser struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
}

type MongoConf

type MongoConf struct {
	Url string
}

type MysqlConf

type MysqlConf struct {
	Dsn string
}

type RabbitMQ

type RabbitMQ struct {
	Conn      *amqp.Connection
	Channel   *amqp.Channel
	QueueName string // 队列名称
	Exchange  string // 交换机名称
	Key       string // bind Key 名称
	MQUrl     string // 连接信息
}

RabbitMQ rabbitMQ结构体

func NewRabbitMQ

func NewRabbitMQ(queueName string, exchange string, key string, conn *amqp.Connection, channel *amqp.Channel) *RabbitMQ

NewRabbitMQ 创建结构体实例

func (*RabbitMQ) PublishTopic

func (r *RabbitMQ) PublishTopic(message string) error

PublishTopic 话题模式发送消息

type RabbitMQConf

type RabbitMQConf struct {
	RmqUrl string
}

RabbitMQConf rabbitMQ配置

type RabbitmqCore

type RabbitmqCore struct {
	Conn    *amqp.Connection
	Channel *amqp.Channel
}

type RedisConf

type RedisConf struct {
	Addr     string
	Password string
	Db       int
}

type VFMessage

type VFMessage struct {
	Time     int64 `json:"time"`
	UserId   int64 `json:"userId"`
	VideoId  int64 `json:"videoId"`
	IsCancel int8  `json:"isCancel"`
}

Jump to

Keyboard shortcuts

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