-
Notifications
You must be signed in to change notification settings - Fork 1
/
funcs.go
156 lines (146 loc) · 4.34 KB
/
funcs.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package wbgong
import (
"log"
)
var (
funcEnableMQTTDebugLog func(bool)
funcMaybeInitProfiling func(<-chan struct{})
funcNewDriverBase func(args DriverArgs) (DeviceDriver, error)
funcNewLocalDeviceArgs func() LocalDeviceArgs
funcNewControlArgs func() ControlArgs
funcNewContentTracker func() ContentTracker
funcNewDirWatcher func(string, DirWatcherClient) DirWatcher
funcNewMQTTRPCServer func(string, MQTTClient) MQTTRPCServer
)
// EnableMQTTDebugLog enables mqtt debug logging
func EnableMQTTDebugLog(useSyslog bool) {
if funcEnableMQTTDebugLog != nil {
funcEnableMQTTDebugLog(useSyslog)
return
}
funcSym, errSym := plug.Lookup("EnableMQTTDebugLog")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcEnableMQTTDebugLog, okResolve = funcSym.(func(bool))
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
funcEnableMQTTDebugLog(useSyslog)
return
}
// MaybeInitProfiling enables cpu profiling if needed
func MaybeInitProfiling(readyCh <-chan struct{}) {
if funcMaybeInitProfiling != nil {
funcMaybeInitProfiling(readyCh)
return
}
funcSym, errSym := plug.Lookup("MaybeInitProfiling")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcMaybeInitProfiling, okResolve = funcSym.(func(<-chan struct{}))
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
funcMaybeInitProfiling(readyCh)
return
}
// NewDriverBase returns new base driver
func NewDriverBase(args DriverArgs) (DeviceDriver, error) {
if funcNewDriverBase != nil {
return funcNewDriverBase(args)
}
funcSym, errSym := plug.Lookup("NewDriverBase")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcNewDriverBase, okResolve = funcSym.(func(args DriverArgs) (DeviceDriver, error))
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
return funcNewDriverBase(args)
}
// NewLocalDeviceArgs return new LocalDeviceArgs
func NewLocalDeviceArgs() LocalDeviceArgs {
if funcNewLocalDeviceArgs != nil {
return funcNewLocalDeviceArgs()
}
funcSym, errSym := plug.Lookup("NewLocalDeviceArgs")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcNewLocalDeviceArgs, okResolve = funcSym.(func() LocalDeviceArgs)
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
return funcNewLocalDeviceArgs()
}
// NewControlArgs return new ControlArgs
func NewControlArgs() ControlArgs {
if funcNewControlArgs != nil {
return funcNewControlArgs()
}
funcSym, errSym := plug.Lookup("NewControlArgs")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcNewControlArgs, okResolve = funcSym.(func() ControlArgs)
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
return funcNewControlArgs()
}
// NewContentTracker return new ContentTracker
func NewContentTracker() ContentTracker {
if funcNewContentTracker != nil {
return funcNewContentTracker()
}
funcSym, errSym := plug.Lookup("NewContentTracker")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcNewContentTracker, okResolve = funcSym.(func() ContentTracker)
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
return funcNewContentTracker()
}
// NewDirWatcher return new DirWatcher
func NewDirWatcher(pattern string, client DirWatcherClient) DirWatcher {
if funcNewDirWatcher != nil {
return funcNewDirWatcher(pattern, client)
}
funcSym, errSym := plug.Lookup("NewDirWatcher")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcNewDirWatcher, okResolve = funcSym.(func(string, DirWatcherClient) DirWatcher)
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
return funcNewDirWatcher(pattern, client)
}
// NewMQTTRPCServer return new MQTTRPCServer
func NewMQTTRPCServer(appName string, mqttClient MQTTClient) MQTTRPCServer {
if funcNewMQTTRPCServer != nil {
return funcNewMQTTRPCServer(appName, mqttClient)
}
funcSym, errSym := plug.Lookup("NewMQTTRPCServer")
if errSym != nil {
log.Fatalf("Error in lookup symbol: %s", errSym)
}
var okResolve bool
funcNewMQTTRPCServer, okResolve = funcSym.(func(string, MQTTClient) MQTTRPCServer)
if !okResolve {
log.Fatal("Wrong sign on resolving func")
}
return funcNewMQTTRPCServer(appName, mqttClient)
}