Alanxtl commented on code in PR #1045:
URL: https://github.com/apache/dubbo-go-samples/pull/1045#discussion_r2938014362


##########
filter/hystrix/README_zh.md:
##########
@@ -0,0 +1,118 @@
+# Hystrix Filter 示例
+
+[English](README.md) | [中文](README_zh.md)
+
+## 背景
+
+本示例演示了如何在 dubbo-go 中使用 Hystrix filter 实现熔断器功能。Hystrix 
是一个延迟和容错库,用于隔离访问远程系统、服务或第三方库的访问点,防止级联故障,实现熔断器模式。
+
+## 实现方法
+
+### 1. 配置 Hystrix 命令
+
+使用 `hystrix-go` API 配置熔断器命令。资源名称格式为:
+```
+dubbo:consumer:InterfaceName:group:version:Method(param1,param2)

Review Comment:
   这里不是改成没有(param1,param2)了吗



##########
filter/hystrix/go-client/cmd/main.go:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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"
+       "fmt"
+       "time"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3/client"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+       "github.com/afex/hystrix-go/hystrix"
+
+       _ "github.com/apache/dubbo-go-extensions/filter/hystrix"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/filter/hystrix/proto"
+)
+
+func init() {
+       // Configure hystrix command for the GreetService.Greet method
+       // Resource name format: 
dubbo:consumer:InterfaceName:group:version:Method(param1,param2)
+       // For this example: 
dubbo:consumer:greet.GreetService:::Greet(*greet.GreetRequest)
+       // Note: The actual param type name is determined by dubbo-go's type 
reflection
+       cmdName := "dubbo:consumer:greet.GreetService:::Greet"
+
+       hystrix.ConfigureCommand(cmdName, hystrix.CommandConfig{
+               Timeout:                1000, // 1 second timeout
+               MaxConcurrentRequests:  10,   // Max 10 concurrent requests
+               RequestVolumeThreshold: 5,    // Minimum 5 requests before 
circuit can trip
+               SleepWindow:            5000, // 5 seconds to wait after 
circuit opens before testing
+               ErrorPercentThreshold:  50,   // 50% error rate triggers 
circuit opening
+       })
+
+       logger.Infof("Configured hystrix command: %s", cmdName)
+}
+
+func main() {
+       cli, err := client.NewClient(
+               client.WithClientURL("127.0.0.1:20000"),
+       )
+       if err != nil {
+               panic(err)
+       }
+
+       svc, err := greet.NewGreetService(cli, 
client.WithFilter("hystrix_consumer"))
+       if err != nil {
+               panic(err)
+       }
+
+       // Test 1: Normal requests
+       logger.Info("=== Test 1: Sending normal requests ===")
+       for i := 1; i <= 3; i++ {
+               resp, err := svc.Greet(context.Background(), 
&greet.GreetRequest{Name: fmt.Sprintf("request-%d", i)})
+               if err != nil {
+                       logger.Errorf("Request %d failed: %v", i, 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]

Reply via email to