data

package
v0.0.0-...-7d1b39b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OccupyKey   = "-1"
	OccupyValue = ""
)

Variables

View Source
var (
	ErrCopy                   = errors.New("copy error")
	ErrRedisSet               = errors.New("redis set error")
	ErrRedisQuery             = errors.New("redis query error")
	ErrMysqlDelete            = errors.New("mysql delete error")
	ErrMysqlInsert            = errors.New("mysql insert error")
	ErrMysqlQuery             = errors.New("mysql query error")
	ErrRedisDelete            = errors.New("redis delete error")
	ErrRedisTransaction       = errors.New("redis transaction error")
	ErrStrconvParse           = errors.New("strconv parse error")
	ErrExistFavorite          = errors.New("exist favorite relation")
	ErrPublishServiceResponse = errors.New("publish service response error")
	ErrNotExistFavorite       = errors.New("not exist favorite relation")
)

Functions

func CreateCacheByTran

func CreateCacheByTran(ctx context.Context, cache *redis.Client, vl []uint32, userId uint32) error

CreateCacheByTran 缓存创建事务

func InitDB

func InitDB(db *gorm.DB)

InitDB 创建User数据表,并自动迁移

func NewFavoriteRepo

func NewFavoriteRepo(
	data *Data, publishConn publishv1.PublishServiceClient, logger log.Logger,
) biz.FavoriteRepo

func NewMysqlConn

func NewMysqlConn(c *conf.Data, l log.Logger) *gorm.DB

NewMysqlConn mysql数据库连接

func NewPublishRepo

func NewPublishRepo(conn pb.PublishServiceClient) biz.PublishRepo

func NewRedisConn

func NewRedisConn(c *conf.Data, l log.Logger) (cacheClient *redis.Client)

NewRedisConn Redis数据库连接, 并发开启连接提高速率

Types

type Data

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

func NewData

func NewData(db *gorm.DB, cache *redis.Client, kfk KfkWriter, logger log.Logger) (*Data, func(), error)

type Favorite

type Favorite struct {
	ID      uint32 `gorm:"column:id;primary_key;autoIncrement"`
	UserID  uint32 `gorm:"column:user_id;index:idx_user_video"`
	VideoID uint32 `gorm:"column:video_id;index:idx_user_video"`
}

func (Favorite) TableName

func (Favorite) TableName() string

type KfkWriter

type KfkWriter struct {
	Favorite *kafka.Writer
	Favored  *kafka.Writer
	// contains filtered or unexported fields
}

func NewKafkaWriter

func NewKafkaWriter(c *conf.Data, l log.Logger) KfkWriter

Jump to

Keyboard shortcuts

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