Skip to content

Commit 59e0a2e

Browse files
Fix js plugin not effective
1 parent 6a7313b commit 59e0a2e

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

docker-compose.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ services:
7474
- --addr-store=etcd://etcd:2379
7575
- --metric-job=proxy
7676
- --metric-address=pushgateway:9091
77-
- --interval-metric-sync=5
77+
- --interval-metric-sync=5
78+
- --js

pkg/plugin/engine.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import (
1414
type Engine struct {
1515
filter.BaseFilter
1616

17+
name string
1718
enable bool
1819
applied []*Runtime
1920
lastActive time.Time
2021
}
2122

2223
// NewEngine returns a plugin engine
23-
func NewEngine(enable bool) *Engine {
24+
func NewEngine(enable bool, name string) *Engine {
2425
return &Engine{
2526
enable: enable,
27+
name: name,
2628
}
2729
}
2830

@@ -84,7 +86,7 @@ func (eng *Engine) ApplyPlugins(plugins ...*metapb.Plugin) error {
8486

8587
// Name returns filter name
8688
func (eng *Engine) Name() string {
87-
return "JS-Plugin-Engine"
89+
return eng.name
8890
}
8991

9092
// Init returns error if init failed

pkg/proxy/dispatcher_meta.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ func (r *dispatcher) maybeUpdateJSEngine(id uint64) error {
625625

626626
func (r *dispatcher) updateJSEngine() error {
627627
var plugins []*metapb.Plugin
628-
newEngine := plugin.NewEngine(r.cnf.Option.EnableJSPlugin)
628+
newEngine := plugin.NewEngine(r.cnf.Option.EnableJSPlugin, FilterJSPlugin)
629629
for _, id := range r.appliedPlugins.AppliedIDs {
630630
p := r.plugins[id]
631631
plugins = append(plugins, p)

pkg/proxy/proxy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func NewProxy(cfg *Cfg) *Proxy {
9090
dispatches: make([]chan *dispatchNode, cfg.Option.LimitCountDispatchWorker, cfg.Option.LimitCountDispatchWorker),
9191
dispatchIndex: 0,
9292
copyIndex: 0,
93-
jsEngine: plugin.NewEngine(cfg.Option.EnableJSPlugin),
93+
jsEngine: plugin.NewEngine(cfg.Option.EnableJSPlugin, FilterJSPlugin),
9494
}
9595

9696
p.init()

0 commit comments

Comments
 (0)