-
Notifications
You must be signed in to change notification settings - Fork 2
/
builder.go
76 lines (66 loc) · 1.9 KB
/
builder.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
package triggerhook
import (
"github.com/pvelx/triggerhook/connection"
"github.com/pvelx/triggerhook/contracts"
"github.com/pvelx/triggerhook/error_service"
"github.com/pvelx/triggerhook/monitoring_service"
"github.com/pvelx/triggerhook/preloader_service"
"github.com/pvelx/triggerhook/repository"
"github.com/pvelx/triggerhook/sender_service"
"github.com/pvelx/triggerhook/task_manager"
"github.com/pvelx/triggerhook/util"
"github.com/pvelx/triggerhook/waiting_service"
)
type Config struct {
Connection connection.Options
RepositoryOptions repository.Options
ErrorServiceOptions error_service.Options
MonitoringServiceOptions monitoring_service.Options
SenderServiceOptions sender_service.Options
WaitingServiceOptions waiting_service.Options
TaskManagerOptions task_manager.Options
PreloaderServiceOptions preloader_service.Options
}
func Build(config Config) contracts.TriggerHookInterface {
errorService := error_service.New(&config.ErrorServiceOptions)
monitoringService := monitoring_service.New(&config.MonitoringServiceOptions)
repositoryService := repository.New(
connection.New(&config.Connection),
util.NewId(),
errorService,
&config.RepositoryOptions,
)
taskManager := task_manager.New(
repositoryService,
errorService,
monitoringService,
&config.TaskManagerOptions,
)
preloaderService := preloader_service.New(
taskManager,
errorService,
monitoringService,
&config.PreloaderServiceOptions,
)
waitingService := waiting_service.New(
preloaderService.GetPreloadedChan(),
monitoringService,
taskManager,
errorService,
&config.WaitingServiceOptions,
)
senderService := sender_service.New(
taskManager,
waitingService.GetReadyToSendChan(),
errorService,
monitoringService,
&config.SenderServiceOptions,
)
return New(
errorService,
waitingService,
preloaderService,
senderService,
monitoringService,
)
}