/
pull.go
53 lines (40 loc) · 878 Bytes
/
pull.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
package scripts
import (
"sync"
"github.com/e154/smart-home/api/scripts/bind"
)
var pull *Pull
type Pull struct {
sync.Mutex
functions map[string]interface{}
structures map[string]interface{}
}
func PushStruct(name string, s interface{}) {
pull.Lock()
defer pull.Unlock()
pull.structures[name] = s
}
func PushFunctions(name string, s interface{}) {
pull.Lock()
defer pull.Unlock()
pull.functions[name] = s
}
func (p *Pull) GetStruct() map[string]interface{} {
p.Lock()
defer p.Unlock()
return p.structures
}
func (p *Pull) Getfunctions() map[string]interface{} {
p.Lock()
defer p.Unlock()
return p.functions
}
func init() {
pull = &Pull{
functions: make(map[string]interface{}),
structures: make(map[string]interface{}),
}
PushStruct("Notifr", &bind.NotifrBind{})
PushStruct("Log", &bind.LogBind{})
PushFunctions("Execute", bind.Execute)
}