You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ma...@apache.org on 2022/11/21 05:42:56 UTC

[dubbo-go-pixiu] branch develop updated: Add GracefulShutdown Signal For Windows (#522)

This is an automated email from the ASF dual-hosted git repository.

mark4z pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7c573671 Add GracefulShutdown Signal For Windows (#522)
7c573671 is described below

commit 7c573671c94849cc8b20c78c46ddb688d0367822
Author: Nanno <64...@users.noreply.github.com>
AuthorDate: Mon Nov 21 13:42:51 2022 +0800

    Add GracefulShutdown Signal For Windows (#522)
    
    * Add GracefulShutdown Signal
    
    * fix format
    
    * update shutdown signal & close wasm for windows
    
    Co-authored-by: mark4z <ma...@apache.org>
---
 ...ignal.go => graceful_shutdown_signal_darwin.go} |  1 +
 ...signal.go => graceful_shutdown_signal_linux.go} |  1 +
 ...gnal.go => graceful_shutdown_signal_windows.go} | 10 ++--
 pixiu/pkg/filter/http/proxywasm/filter.go          |  2 +
 .../proxywasm/{filter.go => filter_windows.go}     | 53 ++--------------------
 5 files changed, 11 insertions(+), 56 deletions(-)

diff --git a/pixiu/pkg/common/shutdown/shutdown_signal.go b/pixiu/pkg/common/shutdown/graceful_shutdown_signal_darwin.go
similarity index 99%
copy from pixiu/pkg/common/shutdown/shutdown_signal.go
copy to pixiu/pkg/common/shutdown/graceful_shutdown_signal_darwin.go
index 6aca490e..e52b1c14 100644
--- a/pixiu/pkg/common/shutdown/shutdown_signal.go
+++ b/pixiu/pkg/common/shutdown/graceful_shutdown_signal_darwin.go
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package shutdown
 
 import (
diff --git a/pixiu/pkg/common/shutdown/shutdown_signal.go b/pixiu/pkg/common/shutdown/graceful_shutdown_signal_linux.go
similarity index 99%
copy from pixiu/pkg/common/shutdown/shutdown_signal.go
copy to pixiu/pkg/common/shutdown/graceful_shutdown_signal_linux.go
index 6aca490e..e52b1c14 100644
--- a/pixiu/pkg/common/shutdown/shutdown_signal.go
+++ b/pixiu/pkg/common/shutdown/graceful_shutdown_signal_linux.go
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package shutdown
 
 import (
diff --git a/pixiu/pkg/common/shutdown/shutdown_signal.go b/pixiu/pkg/common/shutdown/graceful_shutdown_signal_windows.go
similarity index 82%
rename from pixiu/pkg/common/shutdown/shutdown_signal.go
rename to pixiu/pkg/common/shutdown/graceful_shutdown_signal_windows.go
index 6aca490e..08ce9f59 100644
--- a/pixiu/pkg/common/shutdown/shutdown_signal.go
+++ b/pixiu/pkg/common/shutdown/graceful_shutdown_signal_windows.go
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package shutdown
 
 import (
@@ -24,14 +25,11 @@ import (
 var (
 	// ShutdownSignals receives shutdown signals to process
 	ShutdownSignals = []os.Signal{
-		os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP,
+		os.Interrupt, os.Kill, syscall.SIGKILL,
 		syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP,
-		syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM,
+		syscall.SIGABRT, syscall.SIGTERM,
 	}
 
 	// DumpHeapShutdownSignals receives shutdown signals to process
-	DumpHeapShutdownSignals = []os.Signal{
-		syscall.SIGQUIT, syscall.SIGILL,
-		syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS,
-	}
+	DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT}
 )
diff --git a/pixiu/pkg/filter/http/proxywasm/filter.go b/pixiu/pkg/filter/http/proxywasm/filter.go
index 79c207c3..fb13f46b 100644
--- a/pixiu/pkg/filter/http/proxywasm/filter.go
+++ b/pixiu/pkg/filter/http/proxywasm/filter.go
@@ -1,3 +1,5 @@
+//go:build !windows
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
diff --git a/pixiu/pkg/filter/http/proxywasm/filter.go b/pixiu/pkg/filter/http/proxywasm/filter_windows.go
similarity index 50%
copy from pixiu/pkg/filter/http/proxywasm/filter.go
copy to pixiu/pkg/filter/http/proxywasm/filter_windows.go
index 79c207c3..41721d36 100644
--- a/pixiu/pkg/filter/http/proxywasm/filter.go
+++ b/pixiu/pkg/filter/http/proxywasm/filter_windows.go
@@ -1,3 +1,5 @@
+//go:build windows
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -22,7 +24,6 @@ import (
 	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/common/extension/filter"
 	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/context/http"
 	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
-	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/wasm"
 )
 
 func init() {
@@ -38,56 +39,17 @@ type (
 	}
 
 	WasmFilter struct {
-		abiContextWrappers map[string]*wasm.ABIContextWrapper
 	}
 
 	Config struct {
-		WasmServices []*Service `yaml:"wasm_services" json:"wasm_services" mapstructure:"wasm_services"`
-	}
-
-	Service struct {
-		Name string `yaml:"name" json:"name" mapstructure:"name"`
 	}
 )
 
 func (w *WasmFilter) Decode(ctx *http.HttpContext) filter.FilterStatus {
-
-	// sample: display http header
-	if wrapper := w.abiContextWrappers[wasm.HeaderLevel]; wrapper != nil {
-		wrapper.Context.Instance.Lock(wrapper.Context)
-		defer wrapper.Context.Instance.Unlock()
-
-		err := wrapper.Context.GetExports().ProxyOnContextCreate(wrapper.ContextID, wasm.GetServiceRootID(wasm.HeaderLevel))
-		if err != nil {
-			logger.Warnf("[dubbo-go-pixiu] wasmFilter call ProxyOnContextCreate failed: %v", err)
-			return filter.Continue
-		}
-
-		_, err = wrapper.Context.GetExports().ProxyOnRequestHeaders(wrapper.ContextID, int32(len(ctx.Request.Header)), 1)
-		if err != nil {
-			logger.Warnf("[dubbo-go-pixiu] wasmFilter call ProxyOnRequestHeaders failed: %v", err)
-		}
-
-		err = wrapper.Context.GetExports().ProxyOnDelete(wrapper.ContextID)
-		if err != nil {
-			logger.Warnf("[dubbo-go-pixiu] wasmFilter call ProxyOnDelete failed: %v", err)
-		}
-	}
 	return filter.Continue
 }
 
 func (w *WasmFilter) Encode(ctx *http.HttpContext) filter.FilterStatus {
-	for _, wrapper := range w.abiContextWrappers {
-		if err := wasm.ContextDone(wrapper); err != nil {
-			logger.Warnf("[dubbo-go-pixiu] wasmFilter call contextDone failed: %v", err)
-		}
-	}
-
-	if val := ctx.GetHeader("go-wasm-header"); val != "" {
-		if _, err := ctx.Writer.Write([]byte(val)); err != nil {
-			logger.Errorf("write response error: %s", err)
-		}
-	}
 	return filter.Continue
 }
 
@@ -100,16 +62,7 @@ func (factory *WasmFilterFactory) Apply() error {
 }
 
 func (factory *WasmFilterFactory) PrepareFilterChain(ctx *http.HttpContext, chain filter.FilterChain) error {
-	filter := &WasmFilter{
-		abiContextWrappers: make(map[string]*wasm.ABIContextWrapper),
-	}
-	for _, service := range factory.cfg.WasmServices {
-		if abiContext := wasm.CreateABIContextByName(service.Name, ctx); abiContext != nil {
-			filter.abiContextWrappers[service.Name] = abiContext
-		}
-	}
-	chain.AppendDecodeFilters(filter)
-	chain.AppendEncodeFilters(filter)
+	logger.Warnf("Wasm not support on windows now")
 	return nil
 }