public void testBooleanCodeDefault() { DynamicProperties.Instance.Reset(); CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix"); Assert.Equal(CommandProperties.default_circuitBreakerForceClosed, properties.CircuitBreakerForceClosed.Value); }
public void testIntegerCodeDefault() { DynamicProperties.Instance.Reset(); CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix"); Assert.Equal(CommandProperties.default_metricsRollingStatisticalWindow, properties.MetricsRollingStatisticalWindowInMilliseconds.Value); }
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++; }
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); }
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); }
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()); }
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); }
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); }
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); }
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); }
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); }
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); }
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; }
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"); }
public void testBooleanCodeDefault() { DynamicProperties.Instance.Reset(); CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix"); Assert.Equal(CommandProperties.default_circuitBreakerForceClosed, properties.CircuitBreakerForceClosed.Get()); }
private static ICircuitBreaker getCircuitBreaker(string key, string commandGroup, CommandMetrics metrics, CommandPropertiesBuilder properties, IClock clock) { return(new DefaultCircuitBreaker(properties.Build(key), metrics, clock)); }
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"); }
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"); }
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"); }
public void testIntegerCodeDefault() { DynamicProperties.Instance.Reset(); CommandProperties properties = new CommandPropertiesBuilder().Build("unitTestPrefix"); Assert.Equal(CommandProperties.default_metricsRollingStatisticalWindow, properties.MetricsRollingStatisticalWindowInMilliseconds.Get()); }
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()); }
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"); }
internal static CommandMetrics getMetrics(CommandPropertiesBuilder properties, IClock clock) { return(new CommandMetrics("KEY_ONE", "GROUP_ONE", properties.Build("KEY_ONE"), clock)); }