Skip to content

Commit

Permalink
Fix js plugin not effective
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Nov 25, 2019
1 parent 6a7313b commit 59e0a2e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docker-compose.yml
Expand Up @@ -74,4 +74,5 @@ services:
- --addr-store=etcd://etcd:2379
- --metric-job=proxy
- --metric-address=pushgateway:9091
- --interval-metric-sync=5
- --interval-metric-sync=5
- --js
6 changes: 4 additions & 2 deletions pkg/plugin/engine.go
Expand Up @@ -14,15 +14,17 @@ import (
type Engine struct {
filter.BaseFilter

name string
enable bool
applied []*Runtime
lastActive time.Time
}

// NewEngine returns a plugin engine
func NewEngine(enable bool) *Engine {
func NewEngine(enable bool, name string) *Engine {
return &Engine{
enable: enable,
name: name,
}
}

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

// Name returns filter name
func (eng *Engine) Name() string {
return "JS-Plugin-Engine"
return eng.name
}

// Init returns error if init failed
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxy/dispatcher_meta.go
Expand Up @@ -625,7 +625,7 @@ func (r *dispatcher) maybeUpdateJSEngine(id uint64) error {

func (r *dispatcher) updateJSEngine() error {
var plugins []*metapb.Plugin
newEngine := plugin.NewEngine(r.cnf.Option.EnableJSPlugin)
newEngine := plugin.NewEngine(r.cnf.Option.EnableJSPlugin, FilterJSPlugin)
for _, id := range r.appliedPlugins.AppliedIDs {
p := r.plugins[id]
plugins = append(plugins, p)
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxy/proxy.go
Expand Up @@ -90,7 +90,7 @@ func NewProxy(cfg *Cfg) *Proxy {
dispatches: make([]chan *dispatchNode, cfg.Option.LimitCountDispatchWorker, cfg.Option.LimitCountDispatchWorker),
dispatchIndex: 0,
copyIndex: 0,
jsEngine: plugin.NewEngine(cfg.Option.EnableJSPlugin),
jsEngine: plugin.NewEngine(cfg.Option.EnableJSPlugin, FilterJSPlugin),
}

p.init()
Expand Down

0 comments on commit 59e0a2e

Please sign in to comment.