-
Notifications
You must be signed in to change notification settings - Fork 198
/
factory.go
44 lines (34 loc) · 934 Bytes
/
factory.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
package monitor
import (
"sync"
monitor_manager "github.com/eolinker/apinto/monitor-manager"
"github.com/eolinker/apinto/drivers"
"github.com/eolinker/eosc"
"github.com/eolinker/eosc/common/bean"
)
const (
Name = "monitor"
)
var (
workers eosc.IWorkers
monitorManager monitor_manager.IManager
once sync.Once
)
func Register(register eosc.IExtenderDriverRegister) {
register.RegisterExtenderDriver(Name, NewFactory())
}
type Factory struct {
eosc.IExtenderDriverFactory
}
func NewFactory() *Factory {
return &Factory{
IExtenderDriverFactory: drivers.NewFactory[Config](Create),
}
}
func (f *Factory) Create(profession string, name string, label string, desc string, params map[string]interface{}) (eosc.IExtenderDriver, error) {
once.Do(func() {
bean.Autowired(&workers)
bean.Autowired(&monitorManager)
})
return f.IExtenderDriverFactory.Create(profession, name, label, desc, params)
}