internal DefaultCircuitBreaker(CommandProperties properties, CommandMetrics metrics, IClock clock)
 {
     Contract.Requires(clock != null);
     Contract.Requires(properties != null);
     Contract.Requires(metrics != null);
     _clock = clock;
     _properties = properties;
     _metrics = metrics;
 }
        internal static ICircuitBreaker GetOrCreateInstance(string name, CommandProperties properties, CommandMetrics metrics, IClock clock)
        {
            Contract.Assert(!String.IsNullOrEmpty(name));
            Contract.Assert(properties != null);
            Contract.Assert(metrics != null);
            Contract.Assert(clock != null);

            return _metrics.GetOrAdd(name, n => new DefaultCircuitBreaker(properties, metrics, clock));
        }
        private IMetricsPublisherCommand GetOrCreatePublisherForCommand(string commandName, CommandMetrics metrics, ICircuitBreaker circuitBreaker, CommandProperties properties)
        {
            // attempt to retrieve from cache first
            IMetricsPublisherCommand publisher;
            if (_commandPublishers.TryGetValue(commandName, out publisher))
            {
                return publisher;
            }

            // it doesn't exist so we need to create it
            IMetricsPublisherCommandFactory factory;
            if (!_commandPublisherFactories.TryGetValue(commandName, out factory))
                return null;

            // attempt to store it (race other threads)
            return _commandPublishers.GetOrAdd(commandName, factory.Create(commandName, metrics, circuitBreaker, properties));
        }
 public static IMetricsPublisherCommand CreateOrRetrievePublisherForCommand(string commandName, CommandMetrics metrics, ICircuitBreaker circuitBreaker, CommandProperties properties)
 {
     return MetricsPublisherFactory.Instance.GetOrCreatePublisherForCommand(commandName, metrics, circuitBreaker, properties);
 }
 public CommandMetricsEntry(string name, CommandMetrics metrics)
 {
     CommandName = name;
     Metrics = metrics;
 }