Ejemplo n.º 1
0
        public void TestBooleanGlobalDynamicOverrideOfCodeDefault()
        {
            var configSettings           = @"
            {
                'hystrix': {
                    'command': {
                        'default': {
                            'circuitBreaker': {
                                'forceClosed': true
                            }
                        }
                    }
                }

            }";
            var memStream                = GetMemoryStream(configSettings);
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.Add(new JsonStreamConfigurationSource(memStream));
            var config   = builder.Build();
            var dynamics = new HystrixDynamicOptionsDefault(config);

            HystrixCommandOptions properties = new HystrixCommandOptions(HystrixCommandKeyDefault.AsKey("TEST"), null, dynamics);

            // the global dynamic property should take precedence over the default
            Assert.True(properties.CircuitBreakerForceClosed);
        }
Ejemplo n.º 2
0
        public void TestIntegerInstanceBuilderOverrideOfGlobalDynamicOverride()
        {
            var configSettings           = @"
            {
                'hystrix': {
                    'command': {
                        'default': {
                            'metrics': {
                                'rollingStats': {
                                    'timeInMilliseconds': 3456
                                }
                            }
                        }
                    }
                }

            }";
            var memStream                = GetMemoryStream(configSettings);
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.Add(new JsonStreamConfigurationSource(memStream));
            var config   = builder.Build();
            var dynamics = new HystrixDynamicOptionsDefault(config);

            HystrixCommandOptions properties = new HystrixCommandOptions(HystrixCommandKeyDefault.AsKey("TEST"), new HystrixCommandOptions()
            {
                MetricsRollingStatisticalWindowInMilliseconds = 5000
            }, dynamics);

            // the builder injected should take precedence over the global dynamic property
            Assert.Equal(5000, properties.MetricsRollingStatisticalWindowInMilliseconds);
        }
Ejemplo n.º 3
0
        public void TestBooleanInstanceDynamicOverrideOfEverything()
        {
            var configSettings           = @"
            {
                'hystrix': {
                    'command': {
                        'default': {
                            'circuitBreaker': {
                                'forceClosed': false
                            }
                        },
                        'TEST': {
                            'circuitBreaker': {
                                'forceClosed': true
                            }
                        }
                    }
                }

            }";
            var memStream                = GetMemoryStream(configSettings);
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.Add(new JsonStreamConfigurationSource(memStream));
            var config   = builder.Build();
            var dynamics = new HystrixDynamicOptionsDefault(config);

            HystrixCommandOptions properties = new HystrixCommandOptions(HystrixCommandKeyDefault.AsKey("TEST"), new HystrixCommandOptions()
            {
                CircuitBreakerForceClosed = false
            }, dynamics);

            // the instance specific dynamic property should take precedence over everything
            Assert.True(properties.CircuitBreakerForceClosed);
        }
        public void TestIntegerGlobalDynamicOverrideOfCodeDefault()
        {
            var configSettings = @"
            {
                ""hystrix"": {
                    ""command"": {
                        ""default"": {
                            ""metrics"": {
                                ""rollingStats"": {
                                    ""timeInMilliseconds"": 1234
                                }
                            }
                        }
                    }
                }

            }";
            var memStream      = GetMemoryStream(configSettings);
            var builder        = new ConfigurationBuilder();

            builder.Add(new JsonStreamConfigurationSource(memStream));
            var config   = builder.Build();
            var dynamics = new HystrixDynamicOptionsDefault(config);

            var properties = new HystrixCommandOptions(HystrixCommandKeyDefault.AsKey("TEST"), null, dynamics);

            //// the global dynamic property should take precedence over the default
            Assert.Equal(1234, properties.MetricsRollingStatisticalWindowInMilliseconds);
        }
        public void TestBooleanInstanceBuilderOverrideOfGlobalDynamicOverride2()
        {
            var configSettings = @"
            {
                ""hystrix"": {
                    ""command"": {
                        ""default"": {
                            ""circuitBreaker"": {
                                ""forceClosed"": true
                            }
                        }
                    }
                }

            }";
            var memStream      = GetMemoryStream(configSettings);
            var builder        = new ConfigurationBuilder();

            builder.Add(new JsonStreamConfigurationSource(memStream));
            var config     = builder.Build();
            var dynamics   = new HystrixDynamicOptionsDefault(config);
            var properties = new HystrixCommandOptions(HystrixCommandKeyDefault.AsKey("TEST"), new HystrixCommandOptions()
            {
                CircuitBreakerForceClosed = false
            }, dynamics);

            // the builder injected should take precedence over the global dynamic property
            Assert.False(properties.CircuitBreakerForceClosed);
        }
        public void TestIntegerInstanceDynamicOverrideOfEverything()
        {
            var configSettings = @"
            {
                ""hystrix"": {
                    ""command"": {
                        ""default"": {
                            ""metrics"": {
                                ""rollingStats"": {
                                    ""timeInMilliseconds"": 1234
                                }
                            }
                        },
                        ""TEST"": {
                            ""metrics"": {
                                ""rollingStats"": {
                                    ""timeInMilliseconds"": 3456
                                }
                            }
                        }
                    }
                }

            }";
            var memStream      = GetMemoryStream(configSettings);
            var builder        = new ConfigurationBuilder();

            builder.Add(new JsonStreamConfigurationSource(memStream));
            var config   = builder.Build();
            var dynamics = new HystrixDynamicOptionsDefault(config);

            var properties = new HystrixCommandOptions(HystrixCommandKeyDefault.AsKey("TEST"), new HystrixCommandOptions()
            {
                MetricsRollingStatisticalWindowInMilliseconds = 5000
            }, dynamics);

            // the instance specific dynamic property should take precedence over everything
            Assert.Equal(3456, properties.MetricsRollingStatisticalWindowInMilliseconds);
        }