public static void AddHystrixCollapser <TService>(this IServiceCollection services, string collapserKey, IConfiguration config) where TService : class
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (string.IsNullOrEmpty(collapserKey))
            {
                throw new ArgumentNullException(nameof(collapserKey));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            AddHystrixCollapser <TService>(services, HystrixCollapserKeyDefault.AsKey(collapserKey), config);
        }
        public static void RegisterHystrixCollapser <TService>(this ContainerBuilder container, string collapserKey, RequestCollapserScope scope, IConfiguration config)
            where TService : class
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            if (string.IsNullOrEmpty(collapserKey))
            {
                throw new ArgumentNullException(nameof(collapserKey));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            RegisterHystrixCollapser <TService>(container, HystrixCollapserKeyDefault.AsKey(collapserKey), scope, config);
        }
        public static void AddHystrixCollapser <TService, TImplementation>(this IServiceCollection services, string collapserKey, RequestCollapserScope scope, IConfiguration config)
            where TService : class
            where TImplementation : class, TService
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (string.IsNullOrEmpty(collapserKey))
            {
                throw new ArgumentNullException(nameof(collapserKey));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            AddHystrixCollapser <TService, TImplementation>(services, HystrixCollapserKeyDefault.AsKey(collapserKey), scope, config);
        }
        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);
        }
Exemplo n.º 5
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);
        }