-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwire.go
91 lines (73 loc) · 1.91 KB
/
wire.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//go:build wireinject
package main
import (
"github.com/google/wire"
article "we_book/events/article"
"we_book/interactive/events"
repository2 "we_book/interactive/repository"
cache2 "we_book/interactive/repository/cache"
dao2 "we_book/interactive/repository/dao"
service2 "we_book/interactive/service"
"we_book/internal/repository"
article2 "we_book/internal/repository/article"
"we_book/internal/repository/cache"
"we_book/internal/repository/dao"
article3 "we_book/internal/repository/dao/article"
"we_book/internal/service"
"we_book/internal/web"
ijwt "we_book/internal/web/jwt"
"we_book/ioc"
)
var interactiveSvcProvider = wire.NewSet(
service2.NewInteractiveService,
repository2.NewCacheInteractiveRepository,
dao2.NewGORMInteractiveDAO,
cache2.NewRedisInteractiveCache,
)
var rankingServerProvider = wire.NewSet(
repository.NewRankingRepository,
cache.NewRankingRedisCache,
service.NewBatchRankingService,
)
func InitWebServer() *App {
wire.Build(
// 首先引入最基本的第三方依赖
ioc.InitDB,
ioc.InitRedis,
ioc.InitLogger,
ioc.InitKafka,
interactiveSvcProvider,
rankingServerProvider,
ioc.InitRankingJob,
ioc.InitJobs,
ioc.InitRLockClient,
ioc.NewSyncProducer,
ioc.NewConsumers,
// consumer
events.NewInteractiveReadEventBatchConsumer,
article.NewKafkaProducer,
// 初始化 DAO
dao.NewUserDAO,
article3.NewGORMArticleDAO,
cache.NewUserCache,
cache.NewRedisCodeCache,
repository.NewUserRepository,
repository.NewCodeRepository,
article2.NewArticleRepository,
service.NewUserService,
service.NewCodeService,
service.NewArticleService,
// 基于内存实现存储
ioc.InitSMSService,
ioc.InitMiddlewares,
web.NewUserHandler,
web.NewArticleHandler,
web.NewOAuth2WeChatHandler,
ijwt.NewRedisJWTHandler,
ioc.InitWebServer,
ioc.InitWechatService,
ioc.NewWechatHandlerConfig,
wire.Struct(new(App), "*"),
)
return new(App)
}