/// <summary> /// Initializes a new instance of the <see cref="HystrixThreadPoolDefault"/> class. /// </summary> /// <param name="threadPoolKey">The key of this thread pool.</param> /// <param name="setter">The default properties of this thread pool.</param> public HystrixThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter) { this.properties = HystrixPropertiesFactory.GetThreadPoolProperties(threadPoolKey, setter); this.queue = HystrixPlugins.Instance.ConcurrencyStrategy.GetBlockingQueue(this.properties.MaxQueueSize.Get()); this.threadPool = HystrixPlugins.Instance.ConcurrencyStrategy.GetThreadPool(threadPoolKey, this.properties.CoreSize, this.properties.CoreSize, this.properties.KeepAliveTime, this.queue); this.metrics = HystrixThreadPoolMetrics.GetInstance(threadPoolKey, this.threadPool, this.properties); HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForThreadPool(threadPoolKey, this.metrics, this.properties); }
public HystrixCommand(string servicePath, string opName, string serviceName, string fullServiceName, string metricPrefix /*"soa.service"*/, HystrixCommandPropertiesSetter commandPropertiesDefaults) { // op name & service name initialization if (opName == null) { throw new ArgumentNullException("opName"); } if (serviceName == null) { throw new ArgumentNullException("serviceName"); } if (metricPrefix == null) { throw new ArgumentNullException("metricPrefix"); } if (fullServiceName == null) { throw new ArgumentNullException("fullServiceName"); } CommandKey = servicePath + "." + opName; // Properties initialization commandPropertiesDefaults 只设置了 电容器的开关和方法的执行timeout 2个参数 this.properties = HystrixPropertiesFactory.GetCommandProperties(CommandKey, commandPropertiesDefaults); // Metrics initializtion this.metrics = HystrixCommandMetrics.GetInstance(CommandKey, opName, serviceName, fullServiceName, metricPrefix, this.properties); // CircuitBreaker initializtion if (this.properties.CircuitBreakerEnabled.Get()) { this.circuitBreaker = HystrixCircuitBreakerFactory.GetInstance(CommandKey, this.properties, this.metrics); } else { this.circuitBreaker = new NoOpCircuitBreaker(); } }