You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "mark4z (via GitHub)" <gi...@apache.org> on 2023/03/19 05:35:46 UTC

[GitHub] [dubbo-go-pixiu] mark4z commented on a diff in pull request #548: Fix triple proxy problems

mark4z commented on code in PR #548:
URL: https://github.com/apache/dubbo-go-pixiu/pull/548#discussion_r1141261139


##########
pixiu/pkg/client/triple/triple.go:
##########
@@ -68,40 +76,47 @@ func (tc *Client) MapParams(req *client.Request) (reqData interface{}, err error
 }
 
 // Close clear GenericServicePool.
-func (dc *Client) Close() error {
+func (tc *Client) Close() error {
 	return nil
 }
 
 // SingletonTripleClient singleton dubbo clent
-func SingletonTripleClient() *Client {
-	return NewTripleClient()
+func SingletonTripleClient(protoset []string) *Client {
+	return NewTripleClient(protoset)
 }
 
 // Call invoke service
-func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
+func (tc *Client) Call(req *client.Request) (res interface{}, err error) {
 	address := strings.Split(req.API.IntegrationRequest.HTTPBackendConfig.URL, ":")
-	p := proxy.NewProxy()
+	p := proxy.NewProxy(tc.protosetSource)
 	targetURL := &url.URL{
 		Scheme: address[0],
 		Opaque: address[1],
 	}
 	if err := p.Connect(context.Background(), targetURL); err != nil {
 		return "", errors.Errorf("connect triple server error = %s", err)
 	}
+
+	header := tc.forwardHeaders(req.IngressRequest.Header)
+	ctx := metadata.NewOutgoingContext(context.Background(), header)
 	meta := make(map[string][]string)
 	reqData, _ := io.ReadAll(req.IngressRequest.Body)

Review Comment:
   Do not ignore the error if the request body cannot be read, handle it or throw it.



##########
pixiu/pkg/client/triple/triple.go:
##########
@@ -68,40 +76,47 @@ func (tc *Client) MapParams(req *client.Request) (reqData interface{}, err error
 }
 
 // Close clear GenericServicePool.
-func (dc *Client) Close() error {
+func (tc *Client) Close() error {
 	return nil
 }
 
 // SingletonTripleClient singleton dubbo clent
-func SingletonTripleClient() *Client {
-	return NewTripleClient()
+func SingletonTripleClient(protoset []string) *Client {
+	return NewTripleClient(protoset)
 }
 
 // Call invoke service
-func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
+func (tc *Client) Call(req *client.Request) (res interface{}, err error) {
 	address := strings.Split(req.API.IntegrationRequest.HTTPBackendConfig.URL, ":")
-	p := proxy.NewProxy()
+	p := proxy.NewProxy(tc.protosetSource)

Review Comment:
   can we share it as a singleton



##########
pixiu/pkg/client/proxy/descriptor_source.go:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

Review Comment:
   Leave some comments or links indicating that this code was copied from grpcur



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org