Alanxtl commented on code in PR #993: URL: https://github.com/apache/dubbo-go-samples/pull/993#discussion_r2609353595
########## http3/go-client/cmd/main.go: ########## @@ -0,0 +1,79 @@ +/* + * 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. + */ + +package main + +import ( + "context" + "time" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/client" + _ "dubbo.apache.org/dubbo-go/v3/imports" + "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/triple" + "dubbo.apache.org/dubbo-go/v3/tls" + + "github.com/dubbogo/gost/log/logger" +) + +import ( + greet "github.com/apache/dubbo-go-samples/http3/proto" +) + +func main() { + logger.SetLoggerLevel("debug") + + cli, err := client.NewClient( + client.WithClientURL("127.0.0.1:20000"), + client.WithClientTLSOption( + tls.WithCACertFile("../../x509/server_ca_cert.pem"), + tls.WithCertFile("../../x509/server2_cert.pem"), + tls.WithKeyFile("../../x509/server2_key_pkcs8.pem"), + tls.WithServerName("dubbogo.test.example.com"), + ), + // Enable HTTP/3 support on client side + // This configures the client to use dualTransport which supports + // both HTTP/2 and HTTP/3 with Alt-Svc negotiation + client.WithClientProtocol(protocol.WithTriple(triple.Http3Enable())), + ) + if err != nil { + logger.Fatalf("failed to create client: %v", err) + return + } + + svc, err := greet.NewGreetService(cli) + if err != nil { + logger.Fatalf("failed to create greet service: %v", err) + } + + for i := 0; i < 3; i += 1 { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + + resp, err := svc.Greet(ctx, &greet.GreetRequest{Name: "Go Client"}) + if err != nil { + logger.Errorf("failed to greet: %v", err) Review Comment: This repo also serves as the intergration test for dubbo, we need to check the result for go server and client. Checking whether it works as we want. So we need to panic when test fails. For example, we should panic here, which means test doesn't work as we want -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
