-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.go
59 lines (47 loc) · 1.2 KB
/
main.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
package main
import (
"context"
"time"
"github.com/sarulabs/di"
"github.com/coretrix/hitrix"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/app"
"github.com/coretrix/hitrix/service/registry"
)
type testScript struct {
description string
unique bool
}
func (script *testScript) Run(_ context.Context, _ app.IExit) {
}
func (script *testScript) Unique() bool {
return script.unique
}
func (script *testScript) Description() string {
return script.description
}
func (script *testScript) Active() bool {
return true
}
func (script *testScript) Interval() time.Duration {
return 3 * time.Second
}
func main() {
r := hitrix.New("test_script", "secret")
r.RegisterDIGlobalService(&service.DefinitionGlobal{
Name: "aa",
Script: true,
Build: func(ctn di.Container) (interface{}, error) {
return &testScript{"takie tam", false}, nil
},
})
r.RegisterDIGlobalService(&service.DefinitionGlobal{
Name: "bb",
Script: true,
Build: func(ctn di.Container) (interface{}, error) {
return &testScript{"takie tam dwa", true}, nil
},
})
r.RegisterDIGlobalService(registry.ServiceProviderConfigDirectory("../config"))
r.RegisterDIGlobalService().Build()
}