-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_deployment.go
64 lines (55 loc) · 1.32 KB
/
app_deployment.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
package logics
import (
"main/common"
"main/logics/dependency"
"main/logics/pipeline"
"main/models"
"sync"
)
type AppDeploymentService interface {
InstallApp(appName string) (err error)
UninstallApp(appName string) (err error)
ClearInvalidApps() (err error)
ListApps() (appList []string, err error)
}
var (
adSvc AppDeploymentService
adSvcOnce sync.Once
)
type appDeploymentService struct {
repo dependency.AppDeploymentRepo
eventLoop common.EventLoop
pipeline pipeline.AppDeploymentPipeline
}
func NewAppDeploymentService() AppDeploymentService {
adSvcOnce.Do(func() {
adSvc = &appDeploymentService{
repo: dependency.GetAppDeploymentRepo(),
eventLoop: common.GetEventLoop(common.Channel),
pipeline: pipeline.NewAppDeploymentPipeline(),
}
})
return adSvc
}
func (s *appDeploymentService) InstallApp(appName string) (err error) {
// ...
return
}
func (s *appDeploymentService) UninstallApp(appName string) (err error) {
// ...
return
}
func (s *appDeploymentService) ClearInvalidApps() (err error) {
// ...
invalidAppIDs := []uint64{1, 2, 3}
s.eventLoop.Trigger("clear_app", invalidAppIDs)
msg := &models.AppIDsMsg{
AppIDs: invalidAppIDs,
}
err = s.pipeline.SendClearAppMessage(msg)
return
}
func (s *appDeploymentService) ListApps() (appList []string, err error) {
// ...
return
}