public object Get(IHystrixConcurrencyStrategy concurrencyStrategy)
        {
            HystrixRequestVariableCacheKey key = new HystrixRequestVariableCacheKey(this, concurrencyStrategy);
            IHystrixRequestVariable rvInstance = requestVariableInstance.GetOrAdd(key, w =>
            {
                if (requestVariableInstance.Count > 100)
                {
                    logger.Warn("Over 100 instances of HystrixRequestVariable are being stored. This is likely the sign of a memory leak caused by using unique instances of HystrixConcurrencyStrategy instead of a single instance.");
                }

                return concurrencyStrategy.GetRequestVariable(lifeCycleMethods);
            });

            return rvInstance.Value;
        }
Example #2
0
        public object Get(IHystrixConcurrencyStrategy concurrencyStrategy)
        {
            HystrixRequestVariableCacheKey key        = new HystrixRequestVariableCacheKey(this, concurrencyStrategy);
            IHystrixRequestVariable        rvInstance = requestVariableInstance.GetOrAdd(key, w =>
            {
                if (requestVariableInstance.Count > 100)
                {
                    logger.Warn("Over 100 instances of HystrixRequestVariable are being stored. This is likely the sign of a memory leak caused by using unique instances of HystrixConcurrencyStrategy instead of a single instance.");
                }

                return(concurrencyStrategy.GetRequestVariable(lifeCycleMethods));
            });

            return(rvInstance.Value);
        }
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            HystrixRequestVariableCacheKey other = (HystrixRequestVariableCacheKey)obj;

            if (concurrencyStrategy == null)
            {
                if (other.concurrencyStrategy != null)
                {
                    return(false);
                }
            }
            else if (!concurrencyStrategy.Equals(other.concurrencyStrategy))
            {
                return(false);
            }
            if (rvHolder == null)
            {
                if (other.rvHolder != null)
                {
                    return(false);
                }
            }
            else if (!rvHolder.Equals(other.rvHolder))
            {
                return(false);
            }
            return(true);
        }