-
Notifications
You must be signed in to change notification settings - Fork 13
/
elorus.go
40 lines (31 loc) · 1.03 KB
/
elorus.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
package registry
import (
"errors"
"github.com/sarulabs/di"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/app"
"github.com/coretrix/hitrix/service/component/config"
"github.com/coretrix/hitrix/service/component/elorus"
)
func ServiceProviderElorus() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.ElorusService,
Build: func(ctn di.Container) (interface{}, error) {
configService := ctn.Get(service.ConfigService).(config.IConfig)
url, ok := configService.String("elorus.url")
if !ok {
return nil, errors.New("missing elorus.token key")
}
token, ok := configService.String("elorus.token")
if !ok {
return nil, errors.New("missing elorus.token key")
}
organizationID, ok := configService.String("elorus.organization_id")
if !ok {
return nil, errors.New("missing elorus.organization_id key")
}
appService := ctn.Get(service.AppService).(*app.App)
return elorus.NewElorus(url, token, organizationID, appService), nil
},
}
}