RuPeng.HystrixCore icon indicating copy to clipboard operation
RuPeng.HystrixCore copied to clipboard

Results 4 RuPeng.HystrixCore issues
Sort by recently updated
recently updated
newest added

老师您好,.net core 3.0的webapi下测试RuPeng.HystrixCore获取依赖注入的对象: 没有依赖注入的时候,可以获得Person对象是AspectCore生成的Person的动态子类对象类型: ![image](https://user-images.githubusercontent.com/58099205/69473416-3a056b80-0def-11ea-9be5-e2c830231d70.png) p的类型:AspectCore.DynamicGenerated.Person 依赖注入后,获取到的Person对象不是AspectCore生成的Person的动态子类对象类型: ![image](https://user-images.githubusercontent.com/58099205/69473448-8c468c80-0def-11ea-9cbd-cfc4a0a24c2c.png) p的类型:hystrixTest1.Person Person中的方法报异常的时候,降级没出发。 谢谢老师了。

Object fallBackResult = fallBackMethod.Invoke(context.Implementation, context.Parameters); 在这行调用方法的代码中,如果像案例中那样,在外面while调用此注解,是没有任何问题的,因为name参数是一样的,这个参数问题暴露不出来。当改变参数调用的时候,此时委托中context.parameters的context应该用aspectContext,要不然在降级的方法中使用的参数仍然是原来的那个name值。例如如下: ![image](https://user-images.githubusercontent.com/36811234/68565341-29b7cd00-048e-11ea-8f16-3c2ea892eb48.png) 如果不改,运行结果如下: ![image](https://user-images.githubusercontent.com/36811234/68565410-68e61e00-048e-11ea-94c1-2b0790329012.png) 修改后,结果如下: ![image](https://user-images.githubusercontent.com/36811234/68565484-9e8b0700-048e-11ea-842a-01ad0c45dde8.png)

``` if (policy == null) { lock (this)//因为Invoke可能是并发调用,因此要确保policy赋值的线程安全 { if (policy == null) { ... } } } ```

// 接口只定义业务方法,不公开降级方法 public interface IPerson { string SayHi(string name); } // 实现类包含降级方法 public class Person : IPerson { [HystrixCommand(nameof(SayHiFallback))] public virtual string SayHi(string name) { return $"Hi {name.ToUpper()}"; } public...