()
| 5688 | } |
| 5689 | |
| 5690 | public void initRestRateLimiter() |
| 5691 | { |
| 5692 | if (Helpers.isTrue(Helpers.isTrue(Helpers.isEqual(this.rateLimit, null)) || Helpers.isTrue((Helpers.isTrue(!Helpers.isEqual(this.id, null)) && Helpers.isTrue(Helpers.isEqual(this.rateLimit, Helpers.opNeg(1))))))) |
| 5693 | { |
| 5694 | throw new ExchangeError((String)Helpers.add(this.id, ".rateLimit property is not configured")) ; |
| 5695 | } |
| 5696 | Object refillRate = this.MAX_VALUE; |
| 5697 | if (Helpers.isTrue(Helpers.isGreaterThan(this.rateLimit, 0))) |
| 5698 | { |
| 5699 | refillRate = Helpers.divide(1, this.rateLimit); |
| 5700 | } |
| 5701 | Object useLeaky = Helpers.isTrue((Helpers.isEqual(this.rollingWindowSize, 0))) || Helpers.isTrue((Helpers.isEqual(this.rateLimiterAlgorithm, "leakyBucket"))); |
| 5702 | Object algorithm = ((Helpers.isTrue(useLeaky))) ? "leakyBucket" : "rollingWindow"; |
| 5703 | final Object finalRefillRate = refillRate; |
| 5704 | Object defaultBucket = new java.util.HashMap<String, Object>() {{ |
| 5705 | put( "delay", 0.001 ); |
| 5706 | put( "capacity", 1 ); |
| 5707 | put( "cost", 1 ); |
| 5708 | put( "refillRate", finalRefillRate ); |
| 5709 | put( "algorithm", algorithm ); |
| 5710 | put( "windowSize", Exchange.this.rollingWindowSize ); |
| 5711 | put( "rateLimit", Exchange.this.rateLimit ); |
| 5712 | }}; |
| 5713 | Object existingBucket = ((Helpers.isTrue((Helpers.isEqual(this.tokenBucket, null))))) ? new java.util.HashMap<String, Object>() {{}} : this.tokenBucket; |
| 5714 | this.tokenBucket = this.extend(defaultBucket, existingBucket); |
| 5715 | this.initThrottler(); |
| 5716 | } |
| 5717 | |
| 5718 | public void featuresGenerator() |
| 5719 | { |
no test coverage detected