Documentation
¶
Index ¶
- Constants
- Variables
- func InitTable(db *gorm.DB) error
- type DoubleWriteDAO
- func (d *DoubleWriteDAO) BatchIncrReadCnt(ctx context.Context, bizs []string, bizIDs []int64) error
- func (d *DoubleWriteDAO) DeleteCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
- func (d *DoubleWriteDAO) DeleteLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) error
- func (d *DoubleWriteDAO) Get(ctx context.Context, biz string, bizID int64) (Interactive, error)
- func (d *DoubleWriteDAO) GetAll(ctx context.Context, biz string, limit int, offset int) ([]Interactive, error)
- func (d *DoubleWriteDAO) GetByIDs(ctx context.Context, biz string, ids []int64) ([]Interactive, error)
- func (d *DoubleWriteDAO) GetCollectInfo(ctx context.Context, biz string, bizID int64, uid int64) (UserCollectionBiz, error)
- func (d *DoubleWriteDAO) GetLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) (UserLikeBiz, error)
- func (d *DoubleWriteDAO) GetV1(ctx context.Context, biz string, bizID int64) (Interactive, error)
- func (d *DoubleWriteDAO) IncrReadCnt(ctx context.Context, biz string, bizID int64) error
- func (d *DoubleWriteDAO) InsertCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
- func (d *DoubleWriteDAO) InsertLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) error
- func (d *DoubleWriteDAO) MustBatchGet(ctx context.Context, biz string, bizIDs []int64) ([]Interactive, error)
- func (d *DoubleWriteDAO) UpdatePattern(pattern string)
- type GORMInteractiveDAO
- func (g *GORMInteractiveDAO) BatchIncrReadCnt(ctx context.Context, bizs []string, bizIDs []int64) error
- func (g *GORMInteractiveDAO) DeleteCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
- func (g *GORMInteractiveDAO) DeleteLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) error
- func (g *GORMInteractiveDAO) Get(ctx context.Context, biz string, bizID int64) (Interactive, error)
- func (g *GORMInteractiveDAO) GetAll(ctx context.Context, biz string, limit int, offset int) ([]Interactive, error)
- func (g *GORMInteractiveDAO) GetByIDs(ctx context.Context, biz string, ids []int64) ([]Interactive, error)
- func (g *GORMInteractiveDAO) GetCollectInfo(ctx context.Context, biz string, bizID int64, uid int64) (UserCollectionBiz, error)
- func (g *GORMInteractiveDAO) GetLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) (UserLikeBiz, error)
- func (g *GORMInteractiveDAO) IncrReadCnt(ctx context.Context, biz string, bizID int64) error
- func (g *GORMInteractiveDAO) InsertCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
- func (g *GORMInteractiveDAO) InsertLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) error
- func (g *GORMInteractiveDAO) MustBatchGet(ctx context.Context, biz string, bizIDs []int64) ([]Interactive, error)
- type Interactive
- type InteractiveDAO
- type UserCollectionBiz
- type UserLikeBiz
Constants ¶
const ( PatternSrcOnly = "src_only" PatternSrcFirst = "src_first" PatternDstFirst = "dst_first" PatternDstOnly = "dst_only" )
Variables ¶
var ErrRecordNotFound = gorm.ErrRecordNotFound
Functions ¶
Types ¶
type DoubleWriteDAO ¶
type DoubleWriteDAO struct {
// contains filtered or unexported fields
}
func (*DoubleWriteDAO) BatchIncrReadCnt ¶
func (d *DoubleWriteDAO) BatchIncrReadCnt( ctx context.Context, bizs []string, bizIDs []int64, ) error
BatchIncrReadCnt implements InteractiveDAO.
func (*DoubleWriteDAO) DeleteCollectionBiz ¶
func (d *DoubleWriteDAO) DeleteCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
DeleteCollectionBiz implements InteractiveDAO.
func (*DoubleWriteDAO) DeleteLikeInfo ¶
func (d *DoubleWriteDAO) DeleteLikeInfo( ctx context.Context, biz string, bizID int64, uid int64, ) error
DeleteLikeInfo implements InteractiveDAO.
func (*DoubleWriteDAO) Get ¶
func (d *DoubleWriteDAO) Get(ctx context.Context, biz string, bizID int64) (Interactive, error)
func (*DoubleWriteDAO) GetAll ¶
func (d *DoubleWriteDAO) GetAll( ctx context.Context, biz string, limit int, offset int, ) ([]Interactive, error)
GetAll implements InteractiveDAO.
func (*DoubleWriteDAO) GetByIDs ¶
func (d *DoubleWriteDAO) GetByIDs( ctx context.Context, biz string, ids []int64, ) ([]Interactive, error)
GetByIDs implements InteractiveDAO.
func (*DoubleWriteDAO) GetCollectInfo ¶
func (d *DoubleWriteDAO) GetCollectInfo( ctx context.Context, biz string, bizID int64, uid int64, ) (UserCollectionBiz, error)
GetCollectInfo implements InteractiveDAO.
func (*DoubleWriteDAO) GetLikeInfo ¶
func (d *DoubleWriteDAO) GetLikeInfo( ctx context.Context, biz string, bizID int64, uid int64, ) (UserLikeBiz, error)
GetLikeInfo implements InteractiveDAO.
func (*DoubleWriteDAO) GetV1 ¶
func (d *DoubleWriteDAO) GetV1(ctx context.Context, biz string, bizID int64) (Interactive, error)
NOTE: validate at the same time (not recommended, coupling)
func (*DoubleWriteDAO) IncrReadCnt ¶
IncrReadCnt implements InteractiveDAO.
func (*DoubleWriteDAO) InsertCollectionBiz ¶
func (d *DoubleWriteDAO) InsertCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
InsertCollectionBiz implements InteractiveDAO.
func (*DoubleWriteDAO) InsertLikeInfo ¶
func (d *DoubleWriteDAO) InsertLikeInfo( ctx context.Context, biz string, bizID int64, uid int64, ) error
InsertLikeInfo implements InteractiveDAO.
func (*DoubleWriteDAO) MustBatchGet ¶
func (d *DoubleWriteDAO) MustBatchGet( ctx context.Context, biz string, bizIDs []int64, ) ([]Interactive, error)
MustBatchGet implements InteractiveDAO.
func (*DoubleWriteDAO) UpdatePattern ¶
func (d *DoubleWriteDAO) UpdatePattern(pattern string)
type GORMInteractiveDAO ¶
type GORMInteractiveDAO struct {
// contains filtered or unexported fields
}
func (*GORMInteractiveDAO) BatchIncrReadCnt ¶
func (g *GORMInteractiveDAO) BatchIncrReadCnt( ctx context.Context, bizs []string, bizIDs []int64, ) error
BatchIncrReadCnt implements InteractiveDAO.
func (*GORMInteractiveDAO) DeleteCollectionBiz ¶
func (g *GORMInteractiveDAO) DeleteCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
DeleteCollectionBiz implements InteractiveDAO.
func (*GORMInteractiveDAO) DeleteLikeInfo ¶
func (g *GORMInteractiveDAO) DeleteLikeInfo( ctx context.Context, biz string, bizID int64, uid int64, ) error
DeleteLikeInfo implements InteractiveDAO.
func (*GORMInteractiveDAO) Get ¶
func (g *GORMInteractiveDAO) Get( ctx context.Context, biz string, bizID int64, ) (Interactive, error)
Get implements InteractiveDAO.
func (*GORMInteractiveDAO) GetAll ¶
func (g *GORMInteractiveDAO) GetAll( ctx context.Context, biz string, limit int, offset int, ) ([]Interactive, error)
GetAll implements InteractiveDAO.
func (*GORMInteractiveDAO) GetByIDs ¶
func (g *GORMInteractiveDAO) GetByIDs( ctx context.Context, biz string, ids []int64, ) ([]Interactive, error)
GetByIDs implements InteractiveDAO.
func (*GORMInteractiveDAO) GetCollectInfo ¶
func (g *GORMInteractiveDAO) GetCollectInfo( ctx context.Context, biz string, bizID int64, uid int64, ) (UserCollectionBiz, error)
func (*GORMInteractiveDAO) GetLikeInfo ¶
func (g *GORMInteractiveDAO) GetLikeInfo( ctx context.Context, biz string, bizID int64, uid int64, ) (UserLikeBiz, error)
GetLikeInfo implements InteractiveDAO.
func (*GORMInteractiveDAO) IncrReadCnt ¶
IncrReadCnt implements InteractiveDAO.
func (*GORMInteractiveDAO) InsertCollectionBiz ¶
func (g *GORMInteractiveDAO) InsertCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
InsertCollectionBiz implements InteractiveDAO.
func (*GORMInteractiveDAO) InsertLikeInfo ¶
func (g *GORMInteractiveDAO) InsertLikeInfo( ctx context.Context, biz string, bizID int64, uid int64, ) error
InsertLikeInfo implements InteractiveDAO.
func (*GORMInteractiveDAO) MustBatchGet ¶
func (g *GORMInteractiveDAO) MustBatchGet( ctx context.Context, biz string, bizIDs []int64, ) ([]Interactive, error)
BatchGet implements InteractiveDAO.
type Interactive ¶
type InteractiveDAO ¶
type InteractiveDAO interface {
IncrReadCnt(ctx context.Context, biz string, bizID int64) error
BatchIncrReadCnt(ctx context.Context, bizs []string, bizIDs []int64) error
InsertLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) error
DeleteLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) error
InsertCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
DeleteCollectionBiz(ctx context.Context, cb UserCollectionBiz) error
Get(ctx context.Context, biz string, bizID int64) (Interactive, error)
GetAll(ctx context.Context, biz string, limit int, offset int) ([]Interactive, error)
MustBatchGet(ctx context.Context, biz string, bizIDs []int64) ([]Interactive, error)
GetLikeInfo(ctx context.Context, biz string, bizID int64, uid int64) (UserLikeBiz, error)
GetCollectInfo(
ctx context.Context,
biz string,
bizID int64,
uid int64,
) (UserCollectionBiz, error)
GetByIDs(ctx context.Context, biz string, ids []int64) ([]Interactive, error)
}
func NewDoubleWriteDAO ¶
func NewDoubleWriteDAO(src InteractiveDAO, dst InteractiveDAO, l logger.Logger) InteractiveDAO
func NewGORMInteractiveDAO ¶
func NewGORMInteractiveDAO(db *gorm.DB) InteractiveDAO
type UserCollectionBiz ¶
type UserCollectionBiz struct {
ID int64 `gorm:"primaryKey,autoIncrement"`
// One ressource can only be put into one collection.
// Otherwise the composite index should include CID too
UID int64 `gorm:"uniqueIndex:uid_biz_type_id"`
BizID int64 `gorm:"uniqueIndex:uid_biz_type_id"`
Biz string `gorm:"uniqueIndex:uid_biz_type_id,length:128"`
// collection ID
CID int64 `gorm:"index"`
Utime int64
Ctime int64
}