-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwire.go
118 lines (103 loc) · 2.33 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//go:build wireinject
// +build wireinject
package main
import (
answerclient "github.com/ddatdt12/kapo-play-ws-server/clients/answer"
gameclient "github.com/ddatdt12/kapo-play-ws-server/clients/game"
"github.com/ddatdt12/kapo-play-ws-server/infras/db"
"github.com/ddatdt12/kapo-play-ws-server/internal/protocols/http"
"github.com/ddatdt12/kapo-play-ws-server/internal/protocols/http/ws"
"github.com/ddatdt12/kapo-play-ws-server/src/handlers"
"github.com/ddatdt12/kapo-play-ws-server/src/repositories"
"github.com/ddatdt12/kapo-play-ws-server/src/services"
"github.com/google/wire"
)
var questionRepo = wire.NewSet(
repositories.NewQuestionRepository,
wire.Bind(
new(repositories.IQuestionRepository),
new(*repositories.QuestionRepository),
),
)
var questionSvc = wire.NewSet(
services.NewQuestionService,
wire.Bind(
new(services.IQuestionService),
new(*services.QuestionService),
),
)
var leaderboardSvc = wire.NewSet(
services.NewLeaderboardService,
wire.Bind(
new(services.ILeaderboardService),
new(*services.LeaderboardService),
),
)
var gameRepo = wire.NewSet(
repositories.NewGameRepository,
wire.Bind(
new(repositories.IGameRepository),
new(*repositories.GameRepository),
),
)
var gameSvc = wire.NewSet(
services.NewGameService,
wire.Bind(
new(services.IGameService),
new(*services.GameService),
),
)
var userRepo = wire.NewSet(
repositories.NewUserRepository,
wire.Bind(
new(repositories.IUserRepository),
new(*repositories.UserRepository),
),
)
var userSvc = wire.NewSet(
services.NewUserService,
wire.Bind(
new(services.IUserService),
new(*services.UserService),
),
)
var answerSvc = wire.NewSet(
services.NewAnswerService,
wire.Bind(
new(services.IAnswerService),
new(*services.AnswerService),
),
)
var answerClient = wire.NewSet(
answerclient.NewAnswerClient,
wire.Bind(
new(answerclient.IAnswerClient),
new(*answerclient.AnswerClient),
),
)
var gameClient = wire.NewSet(
gameclient.NewGameClient,
wire.Bind(
new(gameclient.IGameClient),
new(*gameclient.GameClient),
),
)
func InitHttpProtocol() *http.HttpImpl {
wire.Build(
http.NewHttpProtocol,
handlers.NewHttpHandler,
db.NewRedisClient,
ws.NewHub,
leaderboardSvc,
gameSvc,
userSvc,
answerSvc,
questionSvc,
gameRepo,
userRepo,
questionRepo,
answerClient,
gameClient,
)
return &http.HttpImpl{}
}