Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FXModule = fx.Module("ol_app_analytics", fx.Provide( NewAnalyticsCounters, NewAnalyticsViewsService, NewAnalyticsBackgroundService, ), fx.Invoke(func(srv *AnalyticsBackgroundService) {}))
Functions ¶
This section is empty.
Types ¶
type AnalyticsBackgroundService ¶
type AnalyticsBackgroundService struct {
// contains filtered or unexported fields
}
func NewAnalyticsBackgroundService ¶
func NewAnalyticsBackgroundService(analytics ViewsService, log *zap.SugaredLogger, lc fx.Lifecycle) *AnalyticsBackgroundService
func (*AnalyticsBackgroundService) Start ¶
func (s *AnalyticsBackgroundService) Start()
func (*AnalyticsBackgroundService) Stop ¶
func (s *AnalyticsBackgroundService) Stop()
type AnalyticsPeriods ¶
type AnalyticsPeriods struct {
Hour AnalyticsPeriod
Day AnalyticsPeriod
Week AnalyticsPeriod
Month AnalyticsPeriod
Year AnalyticsPeriod
}
func CurrentAnalyticsPeriods ¶
func CurrentAnalyticsPeriods(now time.Time) AnalyticsPeriods
type BookViewEntry ¶
type Counters ¶
type Counters interface {
Namespace(name string) CountersNamespace
}
func NewAnalyticsCounters ¶
func NewAnalyticsCounters(redisClient *redis.Client, log *zap.SugaredLogger) Counters
type CountersNamespace ¶
type CountersNamespace interface {
Incr(ctx context.Context, key, uniqueId string, incrBy int64, expire time.Duration) error
Get(ctx context.Context, key string) (int64, error)
Delete(ctx context.Context, key string) error
PullPendingCounters(ctx context.Context, delete bool) (map[string]int64, error)
}
type RedisCounters ¶
type RedisCounters struct {
// contains filtered or unexported fields
}
func (*RedisCounters) Namespace ¶
func (c *RedisCounters) Namespace(name string) CountersNamespace
type ViewMetadata ¶
func (ViewMetadata) UniqueID ¶
func (m ViewMetadata) UniqueID() string
type ViewsService ¶
type ViewsService interface {
IncrBookView(ctx context.Context, bookID int64, meta ViewMetadata) error
IncrChapterView(ctx context.Context, bookID, chapterID int64, meta ViewMetadata) error
GetBookViews(ctx context.Context, bookID int64) (Views, error)
GetMostViewedBooks(ctx context.Context, period AnalyticsPeriod) ([]BookViewEntry, error)
CommitPendingViewsToDB(ctx context.Context)
}
func NewAnalyticsViewsService ¶
func NewAnalyticsViewsService(db store.DBTX, counters Counters, log *zap.SugaredLogger) ViewsService
Click to show internal directories.
Click to hide internal directories.