@@ -98,15 +98,15 @@ type PluginMeta struct {
98
98
99
99
type FilterRule struct {
100
100
Cond condition.Condition // condition for plugin
101
- PluginList []* bfe_wasmplug.WasmPlugin
101
+ PluginList []bfe_wasmplug.WasmPlugin
102
102
}
103
103
104
104
type RuleList []FilterRule
105
- type ProductRules map [string ]* RuleList // product => list of filter rules
105
+ type ProductRules map [string ]RuleList // product => list of filter rules
106
106
107
107
func updatePluginConf (t * PluginTable , conf PluginConfFile , pluginPath string ) error {
108
108
if conf .Version != nil && * conf .Version != t .GetVersion () {
109
- pluginMapNew := make (map [string ]* bfe_wasmplug.WasmPlugin )
109
+ pluginMapNew := make (map [string ]bfe_wasmplug.WasmPlugin )
110
110
var beforeLocationRulesNew RuleList
111
111
productRulesNew := make (ProductRules )
112
112
@@ -116,16 +116,16 @@ func updatePluginConf(t *PluginTable, conf PluginConfFile, pluginPath string) er
116
116
pm := t .GetPluginMap ()
117
117
if conf .PluginMap != nil {
118
118
for pn , p := range * conf .PluginMap {
119
- plugOld := ( * pm ) [pn ]
119
+ plugOld := pm [pn ]
120
120
// check whether plugin version changed.
121
121
if plugOld != nil {
122
- configOld := ( * plugOld ) .GetConfig ()
122
+ configOld := plugOld .GetConfig ()
123
123
if configOld .WasmVersion == p .WasmVersion && configOld .ConfigVersion == p .ConfVersion {
124
124
// not change, just copy to new map
125
125
pluginMapNew [pn ] = plugOld
126
126
127
127
// ensure instance num
128
- actual := ( * plugOld ) .EnsureInstanceNum (p .InstanceNum )
128
+ actual := plugOld .EnsureInstanceNum (p .InstanceNum )
129
129
if actual != p .InstanceNum {
130
130
return fmt .Errorf ("can not EnsureInstanceNum, plugin:%s, num:%d" , pn , p .InstanceNum )
131
131
}
@@ -151,7 +151,7 @@ func updatePluginConf(t *PluginTable, conf PluginConfFile, pluginPath string) er
151
151
152
152
// plug.OnPluginStart()
153
153
154
- pluginMapNew [pn ] = & plug
154
+ pluginMapNew [pn ] = plug
155
155
}
156
156
}
157
157
@@ -194,19 +194,19 @@ func updatePluginConf(t *PluginTable, conf PluginConfFile, pluginPath string) er
194
194
}
195
195
rulelist = append (rulelist , rule )
196
196
}
197
- productRulesNew [product ] = & rulelist
197
+ productRulesNew [product ] = rulelist
198
198
}
199
199
}
200
200
201
201
// 3. update PluginTable
202
- t .Update (* conf .Version , & beforeLocationRulesNew , productRulesNew , & pluginMapNew )
202
+ t .Update (* conf .Version , beforeLocationRulesNew , productRulesNew , pluginMapNew )
203
203
204
204
// 4. stop & clear old plugins
205
- for pn , plug := range * pm {
205
+ for pn , plug := range pm {
206
206
if _ , ok := unchanged [pn ]; ! ok {
207
207
// stop plug
208
- ( * plug ) .OnPluginDestroy ()
209
- ( * plug ) .Clear ()
208
+ plug .OnPluginDestroy ()
209
+ plug .Clear ()
210
210
}
211
211
}
212
212
}
@@ -216,19 +216,19 @@ func updatePluginConf(t *PluginTable, conf PluginConfFile, pluginPath string) er
216
216
type PluginTable struct {
217
217
lock sync.RWMutex
218
218
version string
219
- beforeLocationRules * RuleList
219
+ beforeLocationRules RuleList
220
220
productRules ProductRules
221
- pluginMap * map [string ]* bfe_wasmplug.WasmPlugin
221
+ pluginMap map [string ]bfe_wasmplug.WasmPlugin
222
222
}
223
223
224
224
func NewPluginTable () * PluginTable {
225
225
t := new (PluginTable )
226
226
t .productRules = make (ProductRules )
227
- t .pluginMap = new (map [string ]* bfe_wasmplug.WasmPlugin )
227
+ t .pluginMap = make (map [string ]bfe_wasmplug.WasmPlugin )
228
228
return t
229
229
}
230
230
231
- func (t * PluginTable ) Update (version string , beforeLocationRules * RuleList , productRules ProductRules , pluginMap * map [string ]* bfe_wasmplug.WasmPlugin ) {
231
+ func (t * PluginTable ) Update (version string , beforeLocationRules RuleList , productRules ProductRules , pluginMap map [string ]bfe_wasmplug.WasmPlugin ) {
232
232
t .lock .Lock ()
233
233
234
234
t .version = version
@@ -245,19 +245,19 @@ func (t *PluginTable) GetVersion() string {
245
245
return t .version
246
246
}
247
247
248
- func (t * PluginTable ) GetPluginMap () * map [string ]* bfe_wasmplug.WasmPlugin {
248
+ func (t * PluginTable ) GetPluginMap () map [string ]bfe_wasmplug.WasmPlugin {
249
249
defer t .lock .RUnlock ()
250
250
t .lock .RLock ()
251
251
return t .pluginMap
252
252
}
253
253
254
- func (t * PluginTable ) GetBeforeLocationRules () * RuleList {
254
+ func (t * PluginTable ) GetBeforeLocationRules () RuleList {
255
255
defer t .lock .RUnlock ()
256
256
t .lock .RLock ()
257
257
return t .beforeLocationRules
258
258
}
259
259
260
- func (t * PluginTable ) Search (product string ) (* RuleList , bool ) {
260
+ func (t * PluginTable ) Search (product string ) (RuleList , bool ) {
261
261
t .lock .RLock ()
262
262
productRules := t .productRules
263
263
t .lock .RUnlock ()
0 commit comments