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 3184364 fix: raw http bytes data
new 63637b1 Merge pull request #311 from
LaurenceLiZhixin/fix/raw-http-bytes-data
3184364 is described below
commit 31843645f1f1fb651d47c6207469eee8d0ad11da
Author: LaurenceLiZhixin <[email protected]>
AuthorDate: Wed Dec 1 20:36:06 2021 +0800
fix: raw http bytes data
---
pkg/adapter/dubboregistry/registrycenter.go | 8 ++++++++
pkg/client/mq/kafka_facade.go | 7 ++++---
pkg/client/mq/mq.go | 8 ++++----
pkg/client/triple/triple.go | 2 +-
pkg/common/constant/env.go | 5 +++++
pkg/common/router/router_test.go | 2 +-
pkg/common/router/trie/trie_test.go | 5 ++++-
pkg/common/util/stringutil/stringutil.go | 5 ++++-
pkg/filter/response/response.go | 4 ++++
samples/dubbogo/simple/triple/pixiu/conf.yaml | 3 +--
10 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/pkg/adapter/dubboregistry/registrycenter.go
b/pkg/adapter/dubboregistry/registrycenter.go
index 7a9aebf..e7387eb 100644
--- a/pkg/adapter/dubboregistry/registrycenter.go
+++ b/pkg/adapter/dubboregistry/registrycenter.go
@@ -18,6 +18,10 @@
package dubboregistry
import (
+ "os"
+)
+
+import (
"github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
"github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
)
@@ -93,8 +97,12 @@ func (a *Adapter) Stop() {
// Apply inits the registries according to the configuration
func (a *Adapter) Apply() error {
// create registry per config
+ nacosAddrFromEnv :=
os.Getenv(constant.EnvDubbogoPixiuNacosRegistryAddress)
for k, registryConfig := range a.cfg.Registries {
var err error
+ if nacosAddrFromEnv != "" && registryConfig.Protocol ==
constant.Nacos {
+ registryConfig.Address = nacosAddrFromEnv
+ }
a.registries[k], err = registry.GetRegistry(k, registryConfig,
a)
if err != nil {
return err
diff --git a/pkg/client/mq/kafka_facade.go b/pkg/client/mq/kafka_facade.go
index 8e05896..591d82e 100644
--- a/pkg/client/mq/kafka_facade.go
+++ b/pkg/client/mq/kafka_facade.go
@@ -29,12 +29,13 @@ import (
)
import (
- "github.com/apache/dubbo-go-pixiu/pkg/logger"
+ "github.com/Shopify/sarama"
+
+ perrors "github.com/pkg/errors"
)
import (
- "github.com/Shopify/sarama"
- perrors "github.com/pkg/errors"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
)
type kafkaErrors struct {
diff --git a/pkg/client/mq/mq.go b/pkg/client/mq/mq.go
index d6cb1ca..f08e6e8 100644
--- a/pkg/client/mq/mq.go
+++ b/pkg/client/mq/mq.go
@@ -26,13 +26,13 @@ import (
)
import (
- "github.com/apache/dubbo-go-pixiu/pkg/client"
- "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
- "github.com/apache/dubbo-go-pixiu/pkg/logger"
+ perrors "github.com/pkg/errors"
)
import (
- perrors "github.com/pkg/errors"
+ "github.com/apache/dubbo-go-pixiu/pkg/client"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
)
var (
diff --git a/pkg/client/triple/triple.go b/pkg/client/triple/triple.go
index dff3799..d540fed 100644
--- a/pkg/client/triple/triple.go
+++ b/pkg/client/triple/triple.go
@@ -93,5 +93,5 @@ func (dc *Client) Call(req *client.Request) (res interface{},
err error) {
if err != nil {
return "", errors.Errorf("call triple server error = %s", err)
}
- return string(call), nil
+ return call, nil
}
diff --git a/pkg/common/constant/env.go b/pkg/common/constant/env.go
index d51e889..8c5f360 100644
--- a/pkg/common/constant/env.go
+++ b/pkg/common/constant/env.go
@@ -31,3 +31,8 @@ const (
EnvDubbogoPixiuLogFormat = "DUBBOGO_PIXIU_LOG_FORMAT"
EnvDubbogoPixiuLimitCpus = "DUBBOGO_PIXIU_LIMIT_CPUS"
)
+
+// registry configuration
+const (
+ EnvDubbogoPixiuNacosRegistryAddress = "NACOS_ADDRESS"
+)
diff --git a/pkg/common/router/router_test.go b/pkg/common/router/router_test.go
index fb3e42f..697a293 100644
--- a/pkg/common/router/router_test.go
+++ b/pkg/common/router/router_test.go
@@ -19,7 +19,6 @@ package router
import (
"bytes"
- "github.com/apache/dubbo-go-pixiu/pkg/common/router/trie"
"net/http"
"testing"
)
@@ -29,6 +28,7 @@ import (
)
import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/router/trie"
"github.com/apache/dubbo-go-pixiu/pkg/context/mock"
"github.com/apache/dubbo-go-pixiu/pkg/model"
)
diff --git a/pkg/common/router/trie/trie_test.go
b/pkg/common/router/trie/trie_test.go
index 0585734..ee53f11 100644
--- a/pkg/common/router/trie/trie_test.go
+++ b/pkg/common/router/trie/trie_test.go
@@ -18,10 +18,13 @@
package trie
import (
- "github.com/stretchr/testify/assert"
"testing"
)
+import (
+ "github.com/stretchr/testify/assert"
+)
+
func TestTrie_Put(t *testing.T) {
trie := NewTrie()
ret, _ := trie.Put("/path1/:pathvarible1/path2/:pathvarible2", "")
diff --git a/pkg/common/util/stringutil/stringutil.go
b/pkg/common/util/stringutil/stringutil.go
index 3e0f635..355365f 100644
--- a/pkg/common/util/stringutil/stringutil.go
+++ b/pkg/common/util/stringutil/stringutil.go
@@ -18,10 +18,13 @@
package stringutil
import (
- "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
"strings"
)
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+)
+
// StrInSlice returns whether the string is in the slice.
func StrInSlice(str string, slice []string) bool {
for _, s := range slice {
diff --git a/pkg/filter/response/response.go b/pkg/filter/response/response.go
index c5c3d59..3db7223 100644
--- a/pkg/filter/response/response.go
+++ b/pkg/filter/response/response.go
@@ -163,6 +163,10 @@ func dealResp(in interface{}, HumpToLine bool)
(interface{}, error) {
return inm, nil
}
case reflect.Slice:
+ if data, ok := in.([]byte); ok {
+ // raw bytes data should return directly
+ return data, nil
+ }
value := reflect.ValueOf(in)
newTemps := make([]interface{}, 0, value.Len())
for i := 0; i < value.Len(); i++ {
diff --git a/samples/dubbogo/simple/triple/pixiu/conf.yaml
b/samples/dubbogo/simple/triple/pixiu/conf.yaml
index 901bb88..476428e 100644
--- a/samples/dubbogo/simple/triple/pixiu/conf.yaml
+++ b/samples/dubbogo/simple/triple/pixiu/conf.yaml
@@ -43,7 +43,6 @@ static_resources:
- name: dgp.filter.http.dubboproxy
- name: dgp.filter.http.response
config:
- server_name: "test_http_dubbo"
generate_request_id: false
config:
idle_timeout: 5s
@@ -63,4 +62,4 @@ static_resources:
registries:
nacos:
protocol: nacos
- address: mse-be245cc0-p.nacos-ans.mse.aliyuncs.com:8848
\ No newline at end of file
+ address: dubbo-go-nacos:8848
\ No newline at end of file