upgrade go chassis (#123)
* upgrade go chassis
* add dubbo protocol
diff --git a/cmd/mesher/mesher.go b/cmd/mesher/mesher.go
index 8c05b6a..06d8a85 100644
--- a/cmd/mesher/mesher.go
+++ b/cmd/mesher/mesher.go
@@ -24,6 +24,9 @@
_ "github.com/apache/servicecomb-mesher/proxy/handler"
//protocols
+ _ "github.com/apache/servicecomb-mesher/proxy/protocol/dubbo/client/chassis"
+ _ "github.com/apache/servicecomb-mesher/proxy/protocol/dubbo/server"
+ _ "github.com/apache/servicecomb-mesher/proxy/protocol/dubbo/simpleRegistry"
_ "github.com/apache/servicecomb-mesher/proxy/protocol/grpc"
_ "github.com/apache/servicecomb-mesher/proxy/protocol/http"
//ingress rule fetcher
@@ -37,9 +40,8 @@
_ "github.com/apache/servicecomb-mesher/proxy/handler/oauth2"
+ //middle wares
_ "github.com/go-chassis/go-chassis/middleware/circuit"
-
- // rate limiter handler
_ "github.com/go-chassis/go-chassis/middleware/ratelimiter"
)
diff --git a/go.mod b/go.mod
index c4ca0c0..4310b22 100644
--- a/go.mod
+++ b/go.mod
@@ -4,8 +4,8 @@
github.com/envoyproxy/go-control-plane v0.6.0
github.com/ghodss/yaml v1.0.0
github.com/go-chassis/foundation v0.1.1-0.20191113114104-2b05871e9ec4
- github.com/go-chassis/go-archaius v1.3.0
- github.com/go-chassis/go-chassis v1.8.2-0.20200505090058-f61a697f667a
+ github.com/go-chassis/go-archaius v1.3.2
+ github.com/go-chassis/go-chassis v1.8.2-0.20200728122719-5c6c673368c5
github.com/go-chassis/gohessian v0.0.0-20180702061429-e5130c25af55
github.com/go-mesh/openlogging v1.0.1
github.com/gogo/googleapis v1.3.1 // indirect
@@ -19,7 +19,6 @@
github.com/urfave/cli v1.20.1-0.20181029213200-b67dcf995b6a
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
- golang.org/x/sys v0.0.0-20191018095205-727590c5006e // indirect
google.golang.org/grpc v1.19.1
gopkg.in/yaml.v2 v2.2.4
k8s.io/apimachinery v0.17.0
diff --git a/proxy/handler/oauth2/oauth2_handler.go b/proxy/handler/oauth2/oauth2_handler.go
index 6a0963a..bc0b444 100644
--- a/proxy/handler/oauth2/oauth2_handler.go
+++ b/proxy/handler/oauth2/oauth2_handler.go
@@ -79,8 +79,8 @@
}
}
}
- chain.Next(inv, func(r *invocation.Response) error {
- return cb(r)
+ chain.Next(inv, func(r *invocation.Response) {
+ cb(r)
})
}
@@ -130,9 +130,5 @@
Err: err,
Status: status,
}
- err = cb(r)
- if err != nil {
- openlogging.Error("response error: " + err.Error())
- return
- }
+ cb(r)
}
diff --git a/proxy/handler/oauth2/oauth2_handler_test.go b/proxy/handler/oauth2/oauth2_handler_test.go
index 2259513..39548df 100644
--- a/proxy/handler/oauth2/oauth2_handler_test.go
+++ b/proxy/handler/oauth2/oauth2_handler_test.go
@@ -80,9 +80,8 @@
i.Args = req
i.SetHeader("Authorization", "Basic dGVzdDp0ZXN0")
- c.Next(i, func(r *invocation.Response) error {
+ c.Next(i, func(r *invocation.Response) {
assert.Error(t, r.Err)
- return r.Err
})
})
t.Run("null grant_type", func(t *testing.T) {
@@ -94,9 +93,8 @@
i.Args = req
i.SetHeader("Authorization", "Basic dGVzdDp0ZXN0")
- c.Next(i, func(r *invocation.Response) error {
+ c.Next(i, func(r *invocation.Response) {
assert.NoError(t, r.Err)
- return r.Err
})
})
@@ -108,9 +106,8 @@
}
i.Args = req
- c.Next(i, func(r *invocation.Response) error {
+ c.Next(i, func(r *invocation.Response) {
assert.NoError(t, r.Err)
- return r.Err
})
})
@@ -123,9 +120,8 @@
i.Args = req
i.SetHeader("Authorization", "Basic dGVzdDp0ZXN0")
- c.Next(i, func(r *invocation.Response) error {
+ c.Next(i, func(r *invocation.Response) {
assert.NoError(t, r.Err)
- return r.Err
})
})
}
diff --git a/proxy/handler/port_rewrite.go b/proxy/handler/port_rewrite.go
index e00e0eb..d157c99 100644
--- a/proxy/handler/port_rewrite.go
+++ b/proxy/handler/port_rewrite.go
@@ -46,14 +46,12 @@
Err: err,
}
- if err := cb(r); err != nil {
- openlogging.Error("Response callBack error: " + err.Error())
- }
+ cb(r)
return
}
- chain.Next(inv, func(r *invocation.Response) error {
- return cb(r)
+ chain.Next(inv, func(r *invocation.Response) {
+ cb(r)
})
}
diff --git a/proxy/handler/port_rewrite_test.go b/proxy/handler/port_rewrite_test.go
index 04265b3..eb1bcf1 100644
--- a/proxy/handler/port_rewrite_test.go
+++ b/proxy/handler/port_rewrite_test.go
@@ -44,9 +44,8 @@
Endpoint: "127.0.0.1:5555",
}
- c.Next(i, func(r *invocation.Response) error {
+ c.Next(i, func(r *invocation.Response) {
assert.NoError(t, r.Err)
- return r.Err
})
}
@@ -66,9 +65,8 @@
Endpoint: "",
}
- c.Next(i, func(r *invocation.Response) error {
+ c.Next(i, func(r *invocation.Response) {
assert.Error(t, r.Err)
- return r.Err
})
}
diff --git a/proxy/handler/skywalking_handler.go b/proxy/handler/skywalking_handler.go
index c0006d8..33dd811 100644
--- a/proxy/handler/skywalking_handler.go
+++ b/proxy/handler/skywalking_handler.go
@@ -48,8 +48,8 @@
if err != nil {
openlogging.GetLogger().Errorf("CreateEntrySpan error:%s", err.Error())
}
- chain.Next(i, func(r *invocation.Response) (err error) {
- err = cb(r)
+ chain.Next(i, func(r *invocation.Response) {
+ cb(r)
span.Tag(go2sky.TagHTTPMethod, i.Protocol)
span.Tag(go2sky.TagURL, HTTPPrefix+i.MicroServiceName+i.URLPathFormat)
span.Tag(go2sky.TagStatusCode, strconv.Itoa(r.Status))
@@ -85,8 +85,8 @@
if err != nil {
openlogging.GetLogger().Errorf("CreateExitSpan error:%s", err.Error())
}
- chain.Next(i, func(r *invocation.Response) (err error) {
- err = cb(r)
+ chain.Next(i, func(r *invocation.Response) {
+ cb(r)
span.Tag(go2sky.TagHTTPMethod, i.Protocol)
span.Tag(go2sky.TagURL, HTTPPrefix+i.MicroServiceName+i.URLPathFormat)
span.Tag(go2sky.TagStatusCode, strconv.Itoa(r.Status))
@@ -102,7 +102,6 @@
spanExit.End()
span.End()
openlogging.GetLogger().Debugf("SkyWalkingConsumerHandler end.")
- return
})
}
diff --git a/proxy/handler/skywalking_handler_test.go b/proxy/handler/skywalking_handler_test.go
index 3e7a1bf..be6ded6 100644
--- a/proxy/handler/skywalking_handler_test.go
+++ b/proxy/handler/skywalking_handler_test.go
@@ -82,9 +82,8 @@
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer = make(map[string]string)
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer["skywalking-provider"] = "skywalking-provider"
- c.Next(initInv(), func(r *invocation.Response) error {
+ c.Next(initInv(), func(r *invocation.Response) {
assert.Equal(t, r.Err, nil)
- return r.Err
})
}
@@ -113,8 +112,7 @@
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer = make(map[string]string)
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer["skywalking-consumer"] = "skywalking-consumer"
- c.Next(initInv(), func(r *invocation.Response) error {
+ c.Next(initInv(), func(r *invocation.Response) {
assert.Equal(t, r.Err, nil)
- return r.Err
})
}
diff --git a/proxy/pkg/egress/archaius/egress.go b/proxy/pkg/egress/archaius/egress.go
index 5e1487c..e77385e 100644
--- a/proxy/pkg/egress/archaius/egress.go
+++ b/proxy/pkg/egress/archaius/egress.go
@@ -52,7 +52,7 @@
configs := config.GetEgressConfig()
ok, _ := egress.ValidateEgressRule(configs.Destinations)
if !ok {
- err := fmt.Errorf("Egress rule type assertion fail, key: %s", configs.Destinations)
+ err := fmt.Errorf("egress rule type assertion fail, key: %v", configs.Destinations)
return err
}
diff --git a/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go b/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go
index 8ac6e97..9aaec2d 100755
--- a/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go
+++ b/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go
@@ -123,8 +123,8 @@
return err
}
}
- c.Next(inv, func(ir *invocation.Response) error {
- return handleDubboRequest(inv, ctx, ir)
+ c.Next(inv, func(ir *invocation.Response) {
+ handleDubboRequest(inv, ctx, ir)
})
} else { //come from other mesher
ctx.Req.SetAttachment(ProxyTag, "")
@@ -133,8 +133,8 @@
openlogging.Error("Get Provider Chain failed: " + err.Error())
return err
}
- c.Next(inv, func(ir *invocation.Response) error {
- return handleDubboRequest(inv, ctx, ir)
+ c.Next(inv, func(ir *invocation.Response) {
+ handleDubboRequest(inv, ctx, ir)
})
}
diff --git a/proxy/protocol/grpc/reverse_proxy.go b/proxy/protocol/grpc/reverse_proxy.go
index fa61aac..0b2fd92 100755
--- a/proxy/protocol/grpc/reverse_proxy.go
+++ b/proxy/protocol/grpc/reverse_proxy.go
@@ -129,13 +129,9 @@
metrics.RecordLatency(serviceLabelValues, timeTaken)
}(time.Now())
var invRsp *invocation.Response
- c.Next(inv, func(ir *invocation.Response) error {
+ c.Next(inv, func(ir *invocation.Response) {
//Send the request to the destination
invRsp = ir
- if invRsp != nil {
- return invRsp.Err
- }
- return nil
})
resp, err := handleRequest(w, r, inv, invRsp)
if err != nil {
@@ -178,13 +174,9 @@
r.Header.Set(XForwardedHost, r.Host)
}
var invRsp *invocation.Response
- c.Next(inv, func(ir *invocation.Response) error {
+ c.Next(inv, func(ir *invocation.Response) {
//Send the request to the destination
invRsp = ir
- if invRsp != nil {
- return invRsp.Err
- }
- return nil
})
if _, err = handleRequest(w, r, inv, invRsp); err != nil {
lager.Logger.Error("Handle request failed: " + err.Error())
diff --git a/proxy/protocol/http/gateway.go b/proxy/protocol/http/gateway.go
index d89dd4d..add3521 100644
--- a/proxy/protocol/http/gateway.go
+++ b/proxy/protocol/http/gateway.go
@@ -35,12 +35,8 @@
return nil, err
}
var invRsp *invocation.Response
- c.Next(inv, func(ir *invocation.Response) error {
+ c.Next(inv, func(ir *invocation.Response) {
invRsp = ir
- if invRsp != nil {
- return invRsp.Err
- }
- return nil
})
return invRsp, nil
}
@@ -91,13 +87,9 @@
return
}
var invRsp *invocation.Response
- c.Next(inv, func(ir *invocation.Response) error {
+ c.Next(inv, func(ir *invocation.Response) {
//Send the request to the destination
invRsp = ir
- if invRsp != nil {
- return invRsp.Err
- }
- return nil
})
resp, err := handleRequest(w, inv, invRsp)
if err != nil {
diff --git a/proxy/protocol/http/sidecar.go b/proxy/protocol/http/sidecar.go
index 4b3a3ad..35bff87 100755
--- a/proxy/protocol/http/sidecar.go
+++ b/proxy/protocol/http/sidecar.go
@@ -147,13 +147,9 @@
metrics.RecordLatency(serviceLabelValues, timeTaken)
}(time.Now())
var invRsp *invocation.Response
- c.Next(inv, func(ir *invocation.Response) error {
+ c.Next(inv, func(ir *invocation.Response) {
//Send the request to the destination
invRsp = ir
- if invRsp != nil {
- return invRsp.Err
- }
- return nil
})
resp, err := handleRequest(w, inv, invRsp)
if err != nil {
@@ -196,13 +192,9 @@
r.Header.Set(XForwardedHost, r.Host)
}
var invRsp *invocation.Response
- c.Next(inv, func(ir *invocation.Response) error {
+ c.Next(inv, func(ir *invocation.Response) {
//Send the request to the destination
invRsp = ir
- if invRsp != nil {
- return invRsp.Err
- }
- return nil
})
if _, err = handleRequest(w, inv, invRsp); err != nil {
lager.Logger.Error("Handle request failed: " + err.Error())