refactor(worker): 删除冗余的 SocialWorker

服务层已经写库。SocialWorker 再写一次是重复。因此删除它。

cmd/worker 不再构造 social 仓储,也不再声明 social 主队列拓扑。

验证:go build ./... 通过,go test -count=1 ./internal/worker/... 全绿。
This commit is contained in:
2026-11-11 16:18:59 +08:00
parent f658b7e76e
commit 52213c1d83
2 changed files with 0 additions and 78 deletions

View File

@@ -9,7 +9,6 @@ import (
mqrabbit "feedsystem_video_go/internal/middleware/rabbitmq"
rediscache "feedsystem_video_go/internal/middleware/redis"
"feedsystem_video_go/internal/observability"
"feedsystem_video_go/internal/social"
"feedsystem_video_go/internal/video"
"feedsystem_video_go/internal/worker"
"log"
@@ -110,13 +109,11 @@ func main() {
// 登记拓扑:每一代连接都会重放。名字一律取自 rabbitmq 包的导出常量。
rmqMgr.RegisterTopology(
mqrabbit.Topology{Exchange: mqrabbit.SocialExchange, Queue: mqrabbit.SocialQueue, BindingKey: mqrabbit.SocialBindingKey},
mqrabbit.Topology{Exchange: mqrabbit.LikeExchange, Queue: mqrabbit.LikeQueue, BindingKey: mqrabbit.LikeBindingKey},
mqrabbit.Topology{Exchange: mqrabbit.CommentExchange, Queue: mqrabbit.CommentQueue, BindingKey: mqrabbit.CommentBindingKey},
)
// 准备 repo
socialRepo := social.NewSocialRepository(sqlDB)
videoRepo := video.NewVideoRepository(sqlDB)
likeRepo := video.NewLikeRepository(sqlDB)
commentRepo := video.NewCommentRepository(sqlDB)
@@ -170,11 +167,6 @@ func main() {
return worker.NewFailedEventWorker(ch, failedEventRepo, mqrabbit.ParkedQueue).Run(ctx)
})
})
run(func() {
mqrabbit.RunConsumer(ctx, rmqMgr, "SocialWorker", 50, func(ch *amqp.Channel) error {
return worker.NewSocialWorker(ch, rmqMgr, socialRepo, mqrabbit.SocialQueue).Run(ctx)
})
})
run(func() {
mqrabbit.RunConsumer(ctx, rmqMgr, "LikeWorker", 50, func(ch *amqp.Channel) error {
return worker.NewLikeWorker(ch, rmqMgr, likeRepo, videoRepo, cache, mqrabbit.LikeQueue).Run(ctx)