Documentation
¶
Overview ¶
Data storage
Index ¶
- Variables
- type ArticleAuthorRepository
- type ArticleReaderRepository
- type ArticleRepository
- type AsyncSMSRepository
- type CachedArticleAuthorRepository
- type CachedArticleReaderRepository
- type CachedArticleRepository
- func (c *CachedArticleRepository) Create(ctx context.Context, article domain.Article) (int64, error)
- func (c *CachedArticleRepository) GetByAuthor(ctx context.Context, uid int64, offset int, limit int) ([]domain.Article, error)
- func (c *CachedArticleRepository) GetByID(ctx context.Context, id int64) (domain.Article, error)
- func (c *CachedArticleRepository) GetPubByID(ctx context.Context, id int64) (domain.Article, error)
- func (c *CachedArticleRepository) Sync(ctx context.Context, article domain.Article) (int64, error)
- func (c *CachedArticleRepository) SyncStatus(ctx context.Context, userID int64, articleID int64, ...) error
- func (c *CachedArticleRepository) SyncV0(ctx context.Context, article domain.Article) (int64, error)
- func (c *CachedArticleRepository) SyncV1(ctx context.Context, article domain.Article) (int64, error)
- func (c *CachedArticleRepository) SyncV2(ctx context.Context, article domain.Article) (int64, error)
- func (c *CachedArticleRepository) Update(ctx context.Context, article domain.Article) error
- type CachedCodeRepository
- type CachedInteractiveRepository
- func (c *CachedInteractiveRepository) AddCollectionItem(ctx context.Context, biz string, id int64, cid int64, uid int64) error
- func (c *CachedInteractiveRepository) Collected(ctx context.Context, biz string, bizID int64, uid int64) (bool, error)
- func (c *CachedInteractiveRepository) DecrLike(ctx context.Context, biz string, id int64, uid int64) error
- func (c *CachedInteractiveRepository) DeleteCollectionItem(ctx context.Context, biz string, id int64, cid int64, uid int64) error
- func (c *CachedInteractiveRepository) Get(ctx context.Context, biz string, bizID int64) (domain.Interactive, error)
- func (c *CachedInteractiveRepository) IncrLike(ctx context.Context, biz string, id int64, uid int64) error
- func (c *CachedInteractiveRepository) IncrReadCnt(ctx context.Context, biz string, bizID int64) error
- func (c *CachedInteractiveRepository) Liked(ctx context.Context, biz string, bizID int64, uid int64) (bool, error)
- type CachedUserRepository
- func (repo *CachedUserRepository) Create(ctx context.Context, u domain.User) (domain.User, error)
- func (repo *CachedUserRepository) FindByEmail(ctx context.Context, email string) (domain.User, error)
- func (repo *CachedUserRepository) FindByID(ctx context.Context, userID int64) (domain.User, error)
- func (repo *CachedUserRepository) FindByIdV1(ctx context.Context, userID int64) (domain.User, error)
- func (repo *CachedUserRepository) FindByPhone(ctx context.Context, phone string) (domain.User, error)
- func (repo *CachedUserRepository) UpdateProfile(ctx context.Context, user *domain.User) error
- type CodeRepository
- type InteractiveRepository
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCodeVerifyTooMany = cache.ErrCodeVerifyTooMany ErrCodeSendTooMany = cache.ErrCodeSendTooMany )
View Source
var ( ErrDuplicatedUser = dao.ErrDuplicatedUser // NOTE: Strongly related to the service ErrUserNotFound = dao.ErrRecordNotFound )
View Source
var ErrArticleNotFound = dao.ErrArticleNotFound
Functions ¶
This section is empty.
Types ¶
type ArticleAuthorRepository ¶
type ArticleAuthorRepository interface { Create(ctx context.Context, article domain.Article) (int64, error) Update(ctx context.Context, article domain.Article) error }
func NewArticleAuthorRepository ¶
func NewArticleAuthorRepository(dao dao.ArticleDAO) ArticleAuthorRepository
type ArticleReaderRepository ¶
type ArticleReaderRepository interface { // Insert or Update Save(ctx context.Context, article domain.Article) error }
func NewArticleReaderRepository ¶
func NewArticleReaderRepository(dao dao.ArticleDAO) ArticleReaderRepository
type ArticleRepository ¶
type ArticleRepository interface { Create(ctx context.Context, article domain.Article) (int64, error) Update(ctx context.Context, article domain.Article) error Sync(ctx context.Context, article domain.Article) (int64, error) SyncStatus( ctx context.Context, userID int64, articleID int64, status domain.ArticleStatus, ) error GetByAuthor(ctx context.Context, uid int64, offset int, limit int) ([]domain.Article, error) GetByID(ctx context.Context, id int64) (domain.Article, error) GetPubByID(ctx context.Context, id int64) (domain.Article, error) }
func NewArticleRepository ¶
func NewArticleRepository( l logger.Logger, dao dao.ArticleDAO, cache cache.ArticleCache, userRepo UserRepository, ) ArticleRepository
type AsyncSMSRepository ¶
type AsyncSMSRepository interface { AddSMS(ctx context.Context, toNb string, body string, args string) error TrySend( ctx context.Context, f func(ctx context.Context, toNb string, body string, args ...string) error, maxRetry int, ) }
func NewAsyncSMSRepository ¶
func NewAsyncSMSRepository(dao dao.AsyncSMSDAO, db *gorm.DB) AsyncSMSRepository
type CachedArticleAuthorRepository ¶
type CachedArticleAuthorRepository struct {
// contains filtered or unexported fields
}
type CachedArticleReaderRepository ¶
type CachedArticleReaderRepository struct {
// contains filtered or unexported fields
}
type CachedArticleRepository ¶
type CachedArticleRepository struct {
// contains filtered or unexported fields
}
func NewArticleRepositoryV2 ¶
func NewArticleRepositoryV2( readerDAO dao.ArticleReaderDAO, authorDAO dao.ArticleAuthorDAO, ) *CachedArticleRepository
func (*CachedArticleRepository) GetByAuthor ¶
func (c *CachedArticleRepository) GetByAuthor( ctx context.Context, uid int64, offset int, limit int, ) ([]domain.Article, error)
GetByAuthor implements ArticleRepository.
func (*CachedArticleRepository) GetPubByID ¶
func (c *CachedArticleRepository) GetPubByID( ctx context.Context, id int64, ) (domain.Article, error)
GetPubByID implements ArticleRepository.
func (*CachedArticleRepository) SyncStatus ¶
func (c *CachedArticleRepository) SyncStatus( ctx context.Context, userID int64, articleID int64, status domain.ArticleStatus, ) error
type CachedCodeRepository ¶
type CachedCodeRepository struct {
// contains filtered or unexported fields
}
type CachedInteractiveRepository ¶
type CachedInteractiveRepository struct {
// contains filtered or unexported fields
}
func (*CachedInteractiveRepository) AddCollectionItem ¶
func (c *CachedInteractiveRepository) AddCollectionItem( ctx context.Context, biz string, id int64, cid int64, uid int64, ) error
AddCollectionItem implements InteractiveRepository.
func (*CachedInteractiveRepository) Collected ¶
func (c *CachedInteractiveRepository) Collected( ctx context.Context, biz string, bizID int64, uid int64, ) (bool, error)
Collected implements InteractiveRepository.
func (*CachedInteractiveRepository) DeleteCollectionItem ¶
func (c *CachedInteractiveRepository) DeleteCollectionItem( ctx context.Context, biz string, id int64, cid int64, uid int64, ) error
DeleteCollectionItem implements InteractiveRepository.
func (*CachedInteractiveRepository) Get ¶
func (c *CachedInteractiveRepository) Get( ctx context.Context, biz string, bizID int64, ) (domain.Interactive, error)
Get implements InteractiveRepository.
func (*CachedInteractiveRepository) IncrReadCnt ¶
func (c *CachedInteractiveRepository) IncrReadCnt( ctx context.Context, biz string, bizID int64, ) error
IncrReadCnt implements InteractiveRepository.
type CachedUserRepository ¶
type CachedUserRepository struct {
// contains filtered or unexported fields
}
func (*CachedUserRepository) FindByEmail ¶
func (*CachedUserRepository) FindByID ¶
NOTE: Ok for normal case. But if cache penetration happens, the DB can be crashed by queries
func (*CachedUserRepository) FindByIdV1 ¶
func (repo *CachedUserRepository) FindByIdV1( ctx context.Context, userID int64, ) (domain.User, error)
NOTE: Conservative method, for tasks with low priority. This helps keep the database working for other services.
func (*CachedUserRepository) FindByPhone ¶
func (*CachedUserRepository) UpdateProfile ¶
type CodeRepository ¶
type CodeRepository interface { Set(ctx context.Context, biz, phone, code string) error Verify(ctx context.Context, biz, phone, code string) (bool, error) }
func NewCodeRepository ¶
func NewCodeRepository(cc cache.CodeCache) CodeRepository
type InteractiveRepository ¶
type InteractiveRepository interface { IncrReadCnt(ctx context.Context, biz string, bizID int64) error IncrLike(ctx context.Context, biz string, id int64, uid int64) error DecrLike(ctx context.Context, biz string, id int64, uid int64) error AddCollectionItem(ctx context.Context, biz string, id int64, cid int64, uid int64) error DeleteCollectionItem(ctx context.Context, biz string, id int64, cid int64, uid int64) error Get(ctx context.Context, biz string, bizID int64) (domain.Interactive, error) Liked(ctx context.Context, biz string, bizID int64, uid int64) (bool, error) Collected(ctx context.Context, biz string, bizID int64, uid int64) (bool, error) }
func NewCachedInteractiveRepository ¶
func NewCachedInteractiveRepository( l logger.Logger, dao dao.InteractiveDAO, cache cache.InteractiveCache, ) InteractiveRepository
type UserRepository ¶
type UserRepository interface { Create(ctx context.Context, u domain.User) (domain.User, error) FindByEmail(ctx context.Context, email string) (domain.User, error) FindByPhone(ctx context.Context, phone string) (domain.User, error) UpdateProfile(ctx context.Context, user *domain.User) error FindByID(ctx context.Context, userID int64) (domain.User, error) }
func NewUserRepository ¶
func NewUserRepository(dao dao.UserDAO, cache cache.UserCache) UserRepository
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Cache access
|
Cache access |
mocks
Package cachemocks is a generated GoMock package.
|
Package cachemocks is a generated GoMock package. |
rediscache/mocks
Package redismock is a generated GoMock package.
|
Package redismock is a generated GoMock package. |
Database access
|
Database access |
mocks
Package daomocks is a generated GoMock package.
|
Package daomocks is a generated GoMock package. |
Package repomocks is a generated GoMock package.
|
Package repomocks is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.