diff --git a/bfe_modules/mod_wasmplug/conf_mod_wasmplug.go b/bfe_modules/mod_wasmplug/conf_mod_wasmplug.go index 4899a174..49dcf8b2 100644 --- a/bfe_modules/mod_wasmplug/conf_mod_wasmplug.go +++ b/bfe_modules/mod_wasmplug/conf_mod_wasmplug.go @@ -113,7 +113,6 @@ func updatePluginConf(t *PluginTable, conf PluginConfFile, pluginPath string) er // ensure instance num actual := (*plugOld).EnsureInstanceNum(p.InstanceNum) if actual != p.InstanceNum { - // log.DefaultLogger.Errorf("[wasm][plugin] NewWasmPlugin fail to ensure instance num, want: %v got 0", instanceNum) return fmt.Errorf("can not EnsureInstanceNum, plugin:%s, num:%d", pn, p.InstanceNum) } diff --git a/bfe_modules/mod_wasmplug/mod_wasmplug.go b/bfe_modules/mod_wasmplug/mod_wasmplug.go index 0255864b..9e2aea16 100644 --- a/bfe_modules/mod_wasmplug/mod_wasmplug.go +++ b/bfe_modules/mod_wasmplug/mod_wasmplug.go @@ -190,9 +190,6 @@ func (m *ModuleWasm) wasmRequestHandler(request *bfe_basic.Request) (int, *bfe_h // func (m *ModuleWasm) wasmResponseHandler(request *bfe_basic.Request, res *bfe_http.Response) int { - // for p := range pluginList { - // call p - // } val, ok := request.Context[ModWasmBeforeLocationKey] if ok { @@ -204,7 +201,6 @@ func (m *ModuleWasm) wasmResponseHandler(request *bfe_basic.Request, res *bfe_ht n := len(fl) for i := n-1; i >= 0; i-- { - // call pl[i] fl[i].ResponseHandler(request) fl[i].OnDestroy() } diff --git a/bfe_wasmplug/filter.go b/bfe_wasmplug/filter.go index 56063502..3165603a 100644 --- a/bfe_wasmplug/filter.go +++ b/bfe_wasmplug/filter.go @@ -32,11 +32,6 @@ import ( ) type Filter struct { - //ctx context.Context - - //factory *FilterConfigFactory - - //pluginName string plugin WasmPlugin instance common.WasmInstance abi v1Host.ContextHandler @@ -45,8 +40,6 @@ type Filter struct { rootContextID int32 contextID int32 - //receiverFilterHandler api.StreamReceiverFilterHandler - //senderFilterHandler api.StreamSenderFilterHandler request *bfe_basic.Request destroyOnce sync.Once diff --git a/bfe_wasmplug/plugin.go b/bfe_wasmplug/plugin.go index 326cc732..f0460a50 100644 --- a/bfe_wasmplug/plugin.go +++ b/bfe_wasmplug/plugin.go @@ -121,7 +121,6 @@ func NewWasmPlugin(wasmConfig WasmPluginConfig) (WasmPlugin, error) { // get wasm engine vm := GetWasmEngine() if vm == nil { - // log.DefaultLogger.Errorf("[wasm][plugin] NewWasmPlugin fail to get wasm engine: %v", wasmConfig.VmConfig.Engine) return nil, ErrEngineNotFound } @@ -149,22 +148,18 @@ func NewWasmPlugin(wasmConfig WasmPluginConfig) (WasmPlugin, error) { md5str := strings.TrimSpace(string(md5File)) if len(wasmBytes) == 0 { - // log.DefaultLogger.Errorf("[wasm][plugin] NewWasmPlugin fail to load wasm bytes, config: %v", wasmConfig) return nil, ErrWasmBytesLoad } md5Bytes := md5.Sum(wasmBytes) newMd5 := hex.EncodeToString(md5Bytes[:]) if newMd5 != md5str { - // log.DefaultLogger.Errorf("[wasm][plugin] NewWasmPlugin the hash(MD5) of wasm bytes is incorrect, config: %v, real hash: %s", - // wasmConfig, newMd5) return nil, ErrWasmBytesIncorrect } // create wasm module module := vm.NewModule(wasmBytes) if module == nil { - // log.DefaultLogger.Errorf("[wasm][plugin] NewWasmPlugin fail to create module, config: %v", wasmConfig) return nil, ErrModuleCreate } @@ -177,13 +172,9 @@ func NewWasmPlugin(wasmConfig WasmPluginConfig) (WasmPlugin, error) { rootContextID: newContextID(0), } - // plugin.SetCpuLimit(wasmConfig.VmConfig.Cpu) - // plugin.SetMemLimit(wasmConfig.VmConfig.Mem) - // ensure instance num actual := plugin.EnsureInstanceNum(wasmConfig.InstanceNum) if actual == 0 { - // log.DefaultLogger.Errorf("[wasm][plugin] NewWasmPlugin fail to ensure instance num, want: %v got 0", instanceNum) return nil, ErrInstanceCreate } @@ -220,8 +211,6 @@ func (w *wasmPluginImpl) EnsureInstanceNum(num int) int { continue } - //instance.abiList = wasmABI.GetABIList(instance) - // Instantiate any ABI needed by the guest. for _, abi := range wasmABI.GetABIList(instance) { //abi.OnInstanceCreate(instance) @@ -302,7 +291,6 @@ func (w *wasmPluginImpl) GetInstance() common.WasmInstance { atomic.AddInt32(&w.occupy, 1) return instance } - // log.DefaultLogger.Errorf("[wasm][plugin] GetInstance fail to get available instance, instance num: %v", len(w.instances)) return nil } diff --git a/conf/mod_wasm/mod_wasm.data b/conf/mod_wasm/mod_wasm.data index d76dfba9..d491ce81 100644 --- a/conf/mod_wasm/mod_wasm.data +++ b/conf/mod_wasm/mod_wasm.data @@ -1,5 +1,5 @@ { - "Version": "1", + "Version": "5", "BeforeLocationRules": [{ "Cond": "req_path_prefix_in(\"/headers\", false)", "PluginList": [ "headers" ] @@ -7,27 +7,15 @@ "ProductRules": { "local_product": [{ "Cond": "default_t()", - "PluginList": [ "auth" ] + "PluginList": [] }] }, "PluginMap": { - "http": { - "Name": "http", - "WasmVersion": "1", - "ConfVersion": "2", - "InstanceNum": 1 - }, "headers": { "Name": "headers", "WasmVersion": "3", "ConfVersion": "6", - "InstanceNum": 3 - }, - "auth": { - "Name": "auth", - "WasmVersion": "2", - "ConfVersion": "4", - "InstanceNum": 3 + "InstanceNum": 20 } } } diff --git a/conf/mod_wasm/mod_wasm.data.bak b/conf/mod_wasm/mod_wasm.data.bak deleted file mode 100644 index dc91fc64..00000000 --- a/conf/mod_wasm/mod_wasm.data.bak +++ /dev/null @@ -1,29 +0,0 @@ -{ - "Version": "3", - "BeforeLocationRules": [{ - "Cond": "default_t()", - "PluginList": [ "http", "headers" ] - }], - "ProductRules": { - }, - "PluginMap": { - "http": { - "Name": "http", - "WasmVersion": "1", - "ConfVersion": "2", - "InstanceNum": 1 - }, - "hello": { - "Name": "hello", - "WasmVersion": "1", - "ConfVersion": "2", - "InstanceNum": 1 - }, - "headers": { - "Name": "headers", - "WasmVersion": "1", - "ConfVersion": "2", - "InstanceNum": 1 - } - } -} diff --git a/conf/wasm_plugin/headers/headers.conf b/conf/wasm_plugin/headers/headers.conf new file mode 100644 index 00000000..77d8544e --- /dev/null +++ b/conf/wasm_plugin/headers/headers.conf @@ -0,0 +1,4 @@ +{ + "header": "Wasm-Header-1", + "value": "Hello WasmPlugin!" +} diff --git a/conf/wasm_plugin/headers/headers.md5 b/conf/wasm_plugin/headers/headers.md5 new file mode 100644 index 00000000..fc2ba2dd --- /dev/null +++ b/conf/wasm_plugin/headers/headers.md5 @@ -0,0 +1 @@ +82f14b56c9114d420f4624443bd76ac0 diff --git a/conf/wasm_plugin/headers/headers.wasm b/conf/wasm_plugin/headers/headers.wasm new file mode 100755 index 00000000..767910bb Binary files /dev/null and b/conf/wasm_plugin/headers/headers.wasm differ