Example #1
0
        public IHystrixCommandFactory CreateFactory()
        {
            var configSection = ConfigurationManager.GetSection("hystrix.dotnet/hystrix") as HystrixConfigSection;

            var translator = new HystrixConfigSectionTranslator();

            return(new HystrixCommandFactory(
                       configSection == null ? HystrixOptions.CreateDefault() : translator.TranslateToOptions(configSection)));
        }
        public static void AddHystrix(this IServiceCollection serviceCollection)
        {
            serviceCollection.AddSingleton(s =>
            {
                var options = s.GetService <IOptions <HystrixOptions> >();

                return(options?.Value ?? HystrixOptions.CreateDefault());
            });
            serviceCollection.AddSingleton <IHystrixCommandFactory, HystrixCommandFactory>();
            serviceCollection.AddSingleton <IHystrixMetricsStreamEndpoint, HystrixMetricsStreamEndpoint>();
        }
 public HystrixMetricsStreamEndpoint(IHystrixCommandFactory commandFactory, HystrixOptions options) :
     this(commandFactory, options?.MetricsStreamPollIntervalInMilliseconds ?? 500)
 {
 }