-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwire.go
More file actions
68 lines (57 loc) · 1.68 KB
/
wire.go
File metadata and controls
68 lines (57 loc) · 1.68 KB
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
//go:build wireinject
package main
import (
"github.com/google/wire"
"github.com/heliannuuthus/helios/aegis"
"github.com/heliannuuthus/helios/aegis/adapter"
"github.com/heliannuuthus/helios/chaos"
"github.com/heliannuuthus/helios/hermes"
hermesconfig "github.com/heliannuuthus/helios/hermes/config"
"github.com/heliannuuthus/helios/iris"
"github.com/heliannuuthus/helios/zwei"
zweiconfig "github.com/heliannuuthus/helios/zwei/config"
)
var ProviderSet = wire.NewSet(
provideZwei,
provideHermesService,
provideHermesHandler,
provideAegisHandler,
provideChaosHandler,
)
type App struct {
Zwei *zwei.Zwei
AegisHandler *aegis.Handler
HermesHandler *hermes.Handler
ChaosHandler *chaos.Handler
}
func InitializeApp() (*App, error) {
wire.Build(
ProviderSet,
wire.Struct(new(App), "*"),
)
return nil, nil
}
func provideZwei() *zwei.Zwei {
return zwei.New(zweiconfig.InitDB())
}
func provideHermesService() *hermes.Service {
return hermes.NewService(hermesconfig.InitDB())
}
func provideAegisHandler(hermesService *hermes.Service) (*aegis.Handler, error) {
hermesAdapter := adapter.NewHermesAdapter(hermesService)
userAdapter := adapter.NewUserAdapter(hermesService)
credentialStore := adapter.NewCredentialStoreAdapter(hermesService)
credentialSvc := iris.NewCredentialService(credentialStore)
return aegis.Initialize(hermesAdapter, userAdapter, credentialSvc)
}
func provideHermesHandler(hermesService *hermes.Service) *hermes.Handler {
return hermes.NewHandler(hermesService)
}
func provideChaosHandler() (*chaos.Handler, error) {
db := hermesconfig.InitDB()
chaosModule, err := chaos.New(db)
if err != nil {
return nil, err
}
return chaosModule.Handler(), nil
}