コード例 #1
0
        public void testBooleanCodeDefault()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");

            Assert.Equal(CommandProperties.default_circuitBreakerForceClosed, properties.CircuitBreakerForceClosed.Value);
        }
コード例 #2
0
        public void testIntegerCodeDefault()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");

            Assert.Equal(CommandProperties.default_metricsRollingStatisticalWindow, properties.MetricsRollingStatisticalWindowInMilliseconds.Value);
        }
コード例 #3
0
 public TestServiceCommand(IJellyfishContext ctx, string name, CommandPropertiesBuilder builder, IClock clock = null, TestCircuitBreaker circuitBreaker = null, CommandExecutionHook executionHook = null)
     : base(ctx ?? new JellyfishContext(), clock, name, name, null, builder, circuitBreaker, circuitBreaker?.Metrics, executionHook: executionHook)
 {
     SetFlag(ServiceCommandOptions.HasFallBack, false);
     SetFlag(ServiceCommandOptions.HasCacheKey, false);
     Id = cx++;
 }
コード例 #4
0
        public void testIntegerBuilderOverride()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                                           .WithMetricsRollingStatisticalWindowInMilliseconds(5000).Build("unitTestPrefix");

            // the builder override should take precedence over the default
            Assert.Equal(5000, properties.MetricsRollingStatisticalWindowInMilliseconds.Value);
        }
コード例 #5
0
        public void testBooleanBuilderOverride2()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                                           .WithCircuitBreakerForceClosed(false).Build("unitTestPrefix");

            // the builder override should take precedence over the default
            Assert.Equal(false, properties.CircuitBreakerForceClosed.Value);
        }
コード例 #6
0
        public void testBooleanBuilderOverride2()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                     .WithCircuitBreakerForceClosed(false).Build("unitTestPrefix");

            // the builder override should take precedence over the default
            Assert.Equal(false, properties.CircuitBreakerForceClosed.Get());
        }
コード例 #7
0
        public void testIntegerGlobalDynamicOverrideOfCodeDefault()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");

            DynamicProperties.Instance.CreateOrUpdateProperty("jellyFish.command.default.metrics.rollingStats.timeInMilliseconds", 1234);

            // the global dynamic property should take precedence over the default
            Assert.Equal(1234, properties.MetricsRollingStatisticalWindowInMilliseconds.Value);
        }
コード例 #8
0
        public void testBooleanGlobalDynamicOverrideOfCodeDefault()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");

            DynamicProperties.Instance.CreateOrUpdateProperty("jellyfish.command.default.circuitBreaker.forceClosed", true);

            // the global dynamic property should take precedence over the default
            Assert.Equal(true, properties.CircuitBreakerForceClosed.Value);
        }
コード例 #9
0
        public void testBooleanGlobalDynamicOverrideOfCodeDefault()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");
            DynamicProperties.Instance.CreateOrUpdateProperty("jellyfish.command.default.circuitBreaker.forceClosed", true);

            // the global dynamic property should take precedence over the default
            Assert.Equal(true, properties.CircuitBreakerForceClosed.Value);

        }
コード例 #10
0
        public void testBooleanInstanceBuilderOverrideOfGlobalDynamicOverride2()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                                           .WithCircuitBreakerForceClosed(false).Build("unitTestPrefix");

            DynamicProperties.Instance.CreateOrUpdateProperty("jellyFish.command.default.circuitBreaker.forceClosed", true);

            // the builder injected should take precedence over the global dynamic property
            Assert.Equal(false, properties.CircuitBreakerForceClosed.Value);
        }
コード例 #11
0
        public void testIntegerInstanceBuilderOverrideOfGlobalDynamicOverride()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                                           .WithMetricsRollingStatisticalWindowInMilliseconds(5000).Build("unitTestPrefix");

            DynamicProperties.Instance.CreateOrUpdateProperty("jellyFish.command.default.rollingStats.timeInMilliseconds", 3456);

            // the builder injected should take precedence over the global dynamic property
            Assert.Equal(5000, properties.MetricsRollingStatisticalWindowInMilliseconds.Value);
        }
コード例 #12
0
        public void testBooleanInstanceDynamicOverrideOfEverything()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                                           .WithCircuitBreakerForceClosed(false).Build("TEST");

            DynamicProperties.Instance.CreateOrUpdateProperty("jellyFish.command.default.circuitBreaker.forceClosed", false);
            DynamicProperties.Instance.CreateOrUpdateProperty("jellyFish.command.TEST.circuitBreaker.forceClosed", true);

            // the instance specific dynamic property should take precedence over everything
            Assert.Equal(true, properties.CircuitBreakerForceClosed.Value);
        }
コード例 #13
0
        public void testIntegerInstanceDynamicOverrideOfEverything()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                                           .WithMetricsRollingStatisticalWindowInMilliseconds(5000).Build("TEST");

            DynamicProperties.Instance.CreateOrUpdateProperty("jellyFish.command.default.metrics.rollingStats.timeInMilliseconds", 1234);
            DynamicProperties.Instance.CreateOrUpdateProperty("jellyFish.command.TEST.metrics.rollingStats.timeInMilliseconds", 3456);

            // the instance specific dynamic property should take precedence over everything
            Assert.Equal(3456, properties.MetricsRollingStatisticalWindowInMilliseconds.Value);
        }
コード例 #14
0
        internal static CommandState PrepareInternal(Type commandType, IJellyfishContext context, string commandGroup, string commandName, CommandPropertiesBuilder propertiesBuilder=null, IClock clock = null, CommandMetrics metrics = null, ICircuitBreaker circuitBreaker = null)
        {
            var state = new CommandState();

            state.CommandName = commandName ?? commandType.FullName;
            state.CommandGroup = commandGroup ?? state.CommandName;

            clock = clock ?? Clock.GetInstance();
            var properties = propertiesBuilder?.Build( state.CommandName ) ?? new CommandProperties( state.CommandName );
            metrics = metrics ?? CommandMetricsFactory.GetInstance( state.CommandName, state.CommandGroup, properties, clock );
            circuitBreaker = circuitBreaker ?? ( properties.CircuitBreakerEnabled.Value ? CircuitBreakerFactory.GetOrCreateInstance( state.CommandName, properties, metrics, clock ) : new NoOpCircuitBreaker() );
            context.MetricsPublisher.CreateOrRetrievePublisherForCommand( state.CommandGroup, metrics, circuitBreaker );

            ServiceCommandOptions flags = ServiceCommandOptions.None;
            if(IsMethodImplemented( commandType, "GetFallback" ))
                flags |= ServiceCommandOptions.HasFallBack;
            if(IsMethodImplemented( commandType, "GetCacheKey" ))
                flags |= ServiceCommandOptions.HasCacheKey;
            state.Flags = flags;
            return state;
        }
コード例 #15
0
        public void testBooleanInstanceBuilderOverrideOfGlobalDynamicOverride1()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                     .WithCircuitBreakerForceClosed(true).Build("unitTestPrefix");
            DynamicProperties.Instance.SetProperty("jellyFish.command.default.circuitBreaker.forceClosed", false);

            // the builder injected should take precedence over the global dynamic property
            Assert.Equal(true, properties.CircuitBreakerForceClosed.Get());

            // cleanup 
            DynamicProperties.Instance.RemoveProperty("jellyFish.command.default.circuitBreaker.forceClosed");
        }
コード例 #16
0
 public void testBooleanCodeDefault()
 {
     DynamicProperties.Instance.Reset();
     CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");
     Assert.Equal(CommandProperties.default_circuitBreakerForceClosed, properties.CircuitBreakerForceClosed.Get());
 }
コード例 #17
0
 private static ICircuitBreaker getCircuitBreaker(string key, string commandGroup, CommandMetrics metrics, CommandPropertiesBuilder properties, IClock clock)
 {
     return(new DefaultCircuitBreaker(properties.Build(key), metrics, clock));
 }
コード例 #18
0
        public void testIntegerInstanceDynamicOverrideOfEverything()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                     .WithMetricsRollingStatisticalWindowInMilliseconds(5000).Build("TEST");
            DynamicProperties.Instance.SetProperty("jellyFish.command.default.metrics.rollingStats.timeInMilliseconds", 1234);
            DynamicProperties.Instance.SetProperty("jellyFish.command.TEST.metrics.rollingStats.timeInMilliseconds", 3456);

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

            // cleanup 
            DynamicProperties.Instance.RemoveProperty("jellyFish.command.default.metrics.rollingStats.timeInMilliseconds");
            DynamicProperties.Instance.RemoveProperty("jellyFish.command.TEST.metrics.rollingStats.timeInMilliseconds");
        }
コード例 #19
0
        public void testIntegerInstanceBuilderOverrideOfGlobalDynamicOverride()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                     .WithMetricsRollingStatisticalWindowInMilliseconds(5000).Build("unitTestPrefix");
            DynamicProperties.Instance.SetProperty("jellyFish.command.default.rollingStats.timeInMilliseconds", 3456);

            // the builder injected should take precedence over the global dynamic property
            Assert.Equal(5000, properties.MetricsRollingStatisticalWindowInMilliseconds.Get());

            // cleanup 
            DynamicProperties.Instance.RemoveProperty("jellyFish.command.default.rollingStats.timeInMilliseconds");
        }
コード例 #20
0
        public void testIntegerGlobalDynamicOverrideOfCodeDefault()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");
            DynamicProperties.Instance.SetProperty("jellyFish.command.default.metrics.rollingStats.timeInMilliseconds", 1234);

            // the global dynamic property should take precedence over the default
            Assert.Equal(1234, properties.MetricsRollingStatisticalWindowInMilliseconds.Get());

            // cleanup 
            DynamicProperties.Instance.RemoveProperty("jellyFish.command.default.metrics.rollingStats.timeInMilliseconds");
        }
コード例 #21
0
 public void testIntegerCodeDefault()
 {
     DynamicProperties.Instance.Reset();
     CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix");
     Assert.Equal(CommandProperties.default_metricsRollingStatisticalWindow, properties.MetricsRollingStatisticalWindowInMilliseconds.Get());
 }
コード例 #22
0
        public void testIntegerBuilderOverride()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                     .WithMetricsRollingStatisticalWindowInMilliseconds(5000).Build("unitTestPrefix");

            // the builder override should take precedence over the default
            Assert.Equal(5000, properties.MetricsRollingStatisticalWindowInMilliseconds.Get());
        }
コード例 #23
0
        public void testBooleanInstanceDynamicOverrideOfEverything()
        {
            DynamicProperties.Instance.Reset();
            CommandProperties properties = new CommandPropertiesBuilder()
                     .WithCircuitBreakerForceClosed(false).Build("TEST");
            DynamicProperties.Instance.SetProperty("jellyFish.command.default.circuitBreaker.forceClosed", false);
            DynamicProperties.Instance.SetProperty("jellyFish.command.TEST.circuitBreaker.forceClosed", true);

            // the instance specific dynamic property should take precedence over everything
            Assert.Equal(true, properties.CircuitBreakerForceClosed.Get());

            // cleanup 
            DynamicProperties.Instance.RemoveProperty("jellyFish.command.default.circuitBreaker.forceClosed");
            DynamicProperties.Instance.RemoveProperty("jellyFish.command.TEST.circuitBreaker.forceClosed");
        }
コード例 #24
0
 internal static CommandMetrics getMetrics(CommandPropertiesBuilder properties, IClock clock)
 {
     return(new CommandMetrics("KEY_ONE", "GROUP_ONE", properties.Build("KEY_ONE"), clock));
 }