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")
	ErrUserServiceResponse = errors.New("user service response error")
)
View Source
var (
	ErrFollowYourself   = errors.New("can't follow yourself")
	ErrExistRelation    = errors.New("exist relation")
	ErrNotExistRelation = errors.New("not exist relation")
)

Functions

func CreateCacheByTran

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

CreateCacheByTran 缓存创建事务

func InitDB

func InitDB(db *gorm.DB)

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

func NewMysqlConn

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

NewMysqlConn mysql数据库连接

func NewRelationRepo

func NewRelationRepo(data *Data, userConn userv1.UserServiceClient, logger log.Logger) biz.RelationRepo

Types

type CacheClient

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

CacheClient relation 服务的 Redis 缓存客户端

func NewRedisConn

func NewRedisConn(c *conf.Data, l log.Logger) (cache *CacheClient)

NewRedisConn Redis数据库连接

type Data

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

func NewData

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

type Followers

type Followers struct {
	Id         uint32 `gorm:"primary_key"`
	UserId     uint32 `gorm:"column:user_id;not null;index:idx_user_id"`
	FollowerId uint32 `gorm:"column:follower_id;not null;index:idx_follower_id"`
}

func (Followers) TableName

func (Followers) TableName() string

type KfkWriter

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

func NewKafkaWriter

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

type UserRepo

type UserRepo interface {
	GetUserInfos(ctx context.Context, userId uint32, userIds []uint32) ([]*biz.User, error)
}

func NewUserRepo

func NewUserRepo(conn pb.UserServiceClient) UserRepo

Jump to

Keyboard shortcuts

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