refactor: remove Gorse integration and implement HotRank feature
- Removed Gorse-related configurations, handlers, and dependencies from the codebase. - Introduced HotRank feature with configuration options for ranking posts based on recent activity. - Updated application structure to support HotRank processing, including new caching mechanisms and database interactions. - Cleaned up related DTOs and repository methods to reflect the removal of Gorse and the addition of HotRank functionality.
This commit is contained in:
@@ -16,13 +16,14 @@ import (
|
||||
|
||||
// App 应用程序结构体
|
||||
type App struct {
|
||||
Config *config.Config
|
||||
DB *gorm.DB
|
||||
Router *router.Router
|
||||
PushService service.PushService
|
||||
GRPCServer *runner.Server
|
||||
Server *http.Server
|
||||
Logger *zap.Logger
|
||||
Config *config.Config
|
||||
DB *gorm.DB
|
||||
Router *router.Router
|
||||
PushService service.PushService
|
||||
HotRankWorker *service.HotRankWorker
|
||||
GRPCServer *runner.Server
|
||||
Server *http.Server
|
||||
Logger *zap.Logger
|
||||
}
|
||||
|
||||
// NewApp 创建应用程序
|
||||
@@ -31,16 +32,18 @@ func NewApp(
|
||||
db *gorm.DB,
|
||||
r *router.Router,
|
||||
pushService service.PushService,
|
||||
hotRankWorker *service.HotRankWorker,
|
||||
grpcServer *runner.Server,
|
||||
logger *zap.Logger,
|
||||
) *App {
|
||||
return &App{
|
||||
Config: cfg,
|
||||
DB: db,
|
||||
Router: r,
|
||||
PushService: pushService,
|
||||
GRPCServer: grpcServer,
|
||||
Logger: logger,
|
||||
Config: cfg,
|
||||
DB: db,
|
||||
Router: r,
|
||||
PushService: pushService,
|
||||
HotRankWorker: hotRankWorker,
|
||||
GRPCServer: grpcServer,
|
||||
Logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +60,11 @@ func (a *App) Start(ctx context.Context) error {
|
||||
// 2. 启动推送 Worker
|
||||
a.PushService.StartPushWorker(ctx)
|
||||
|
||||
// 2.1 热门榜定时重算
|
||||
if a.HotRankWorker != nil {
|
||||
a.HotRankWorker.Start(ctx)
|
||||
}
|
||||
|
||||
// 3. 创建 HTTP 服务器
|
||||
addr := fmt.Sprintf("%s:%d", a.Config.Server.Host, a.Config.Server.Port)
|
||||
a.Logger.Info("Starting HTTP server",
|
||||
@@ -104,6 +112,11 @@ func (a *App) Stop(ctx context.Context) error {
|
||||
a.Logger.Info("Stopping push worker")
|
||||
a.PushService.StopPushWorker()
|
||||
|
||||
if a.HotRankWorker != nil {
|
||||
a.Logger.Info("Stopping hot rank worker")
|
||||
a.HotRankWorker.Stop()
|
||||
}
|
||||
|
||||
// 4. 关闭数据库连接
|
||||
a.Logger.Info("Closing database connection")
|
||||
sqlDB, err := a.DB.DB()
|
||||
|
||||
Reference in New Issue
Block a user