protected HystrixCollapser(IHystrixCollapserKey collapserKey, RequestCollapserScope scope, ICollapserTimer timer, IHystrixCollapserOptions optionsDefault, HystrixCollapserMetrics metrics)
        {
            if (collapserKey == null || collapserKey.Name.Trim().Equals(""))
            {
                string defaultKeyName = GetDefaultNameFromClass(GetType());
                collapserKey = HystrixCollapserKeyDefault.AsKey(defaultKeyName);
            }
            IHystrixCollapserOptions options = HystrixOptionsFactory.GetCollapserOptions(collapserKey, optionsDefault);

            this.collapserFactory = new RequestCollapserFactory(collapserKey, scope, timer, options);
            this.requestCache     = HystrixRequestCache.GetInstance(collapserKey);

            if (metrics == null)
            {
                this.metrics = HystrixCollapserMetrics.GetInstance(collapserKey, options);
            }
            else
            {
                this.metrics = metrics;
            }

            HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForCollapser(collapserKey, this.metrics, options);
        }
예제 #2
0
        protected HystrixCollapser(IHystrixCollapserKey collapserKey, RequestCollapserScope scope, ICollapserTimer timer, IHystrixCollapserOptions optionsDefault, HystrixCollapserMetrics metrics)
        {
            if (collapserKey == null || string.IsNullOrWhiteSpace(collapserKey.Name))
            {
                var defaultKeyName = GetDefaultNameFromClass(GetType());
                collapserKey = HystrixCollapserKeyDefault.AsKey(defaultKeyName);
            }

            var options = HystrixOptionsFactory.GetCollapserOptions(collapserKey, optionsDefault);

            _collapserFactory = new RequestCollapserFactory(collapserKey, scope, timer, options);
            _requestCache     = HystrixRequestCache.GetInstance(collapserKey);

            if (metrics == null)
            {
                _metrics = HystrixCollapserMetrics.GetInstance(collapserKey, options);
            }
            else
            {
                _metrics = metrics;
            }

            HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForCollapser(collapserKey, _metrics, options);
        }