Alanxtl commented on code in PR #1058: URL: https://github.com/apache/dubbo-go-samples/pull/1058#discussion_r2986304834
########## graceful_shutdown/go.mod: ########## Review Comment: 不要提交新的go.mod 使用全局go.mod ########## graceful_shutdown/README.md: ########## Review Comment: pls, refer to other samples, provide README_CN.md ########## graceful_shutdown/go-client/cmd/main.go: ########## @@ -0,0 +1,107 @@ +/* + * 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" + "flag" + "fmt" + "sync/atomic" + "time" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/client" + _ "dubbo.apache.org/dubbo-go/v3/imports" + + "github.com/dubbogo/gost/log/logger" +) + +import ( + greet "github.com/apache/dubbo-go-samples/graceful_shutdown/proto" +) + +func main() { + addr := flag.String("addr", "tri://127.0.0.1:20000", "server address") + interval := flag.Duration("interval", 200*time.Millisecond, "interval between requests for each worker") + shortConn := flag.Bool("short", false, "use short connection (create new client for each request)") + concurrency := flag.Int("concurrency", 1, "number of concurrent request loops") + requestTimeout := flag.Duration("request-timeout", 5*time.Second, "per-request timeout") + namePrefix := flag.String("name-prefix", "hello", "request name prefix") + flag.Parse() + + logger.Infof("Starting client, addr=%s short=%v concurrency=%d interval=%s request-timeout=%s", + *addr, *shortConn, *concurrency, interval.String(), requestTimeout.String()) + + var counter atomic.Int64 + for workerID := 1; workerID <= *concurrency; workerID++ { + go runWorker(workerID, *addr, *interval, *shortConn, *requestTimeout, *namePrefix, &counter) + } + + select {} +} + +func runWorker(workerID int, addr string, interval time.Duration, shortConn bool, requestTimeout time.Duration, namePrefix string, counter *atomic.Int64) { + var svc greet.GreetService + var err error + + if !shortConn { + _, svc, err = newGreetClient(addr) + if err != nil { + logger.Errorf("Worker %d failed to create long connection client: %v", workerID, err) Review Comment: 遇到问题panic出来,以使集成测试失败 -- 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]
