@Test public void changeLimitForPeriod() throws Exception { setup(Duration.ZERO); RateLimiterConfig rateLimiterConfig = rateLimiter.getRateLimiterConfig(); then(rateLimiterConfig.getTimeoutDuration()).isEqualTo(Duration.ZERO); then(rateLimiterConfig.getLimitForPeriod()).isEqualTo(PERMISSIONS_RER_CYCLE); then(rateLimiterConfig.getLimitRefreshPeriod()).isEqualTo(Duration.ofNanos(CYCLE_IN_NANOS)); rateLimiter.changeLimitForPeriod(35); then(rateLimiterConfig != rateLimiter.getRateLimiterConfig()).isTrue(); rateLimiterConfig = rateLimiter.getRateLimiterConfig(); then(rateLimiterConfig.getTimeoutDuration()).isEqualTo(Duration.ZERO); then(rateLimiterConfig.getLimitForPeriod()).isEqualTo(35); then(rateLimiterConfig.getLimitRefreshPeriod()).isEqualTo(Duration.ofNanos(CYCLE_IN_NANOS)); }
@Override public void changeLimitForPeriod(final int limitForPeriod) { RateLimiterConfig newConfig = RateLimiterConfig.from(state.get().config) .limitForPeriod(limitForPeriod) .build(); state.updateAndGet(currentState -> new State( newConfig, currentState.activeCycle, currentState.activePermissions, currentState.nanosToWait )); }
AtomicRateLimiter implements RateLimiter { @Override public void changeLimitForPeriod(final int limitForPeriod) { RateLimiterConfig newConfig = RateLimiterConfig.from(state.get().config) .limitForPeriod(limitForPeriod) .build(); state.updateAndGet(currentState -> new State( newConfig, currentState.activeCycle, currentState.activePermissions, currentState.nanosToWait )); } }
AtomicRateLimiter implements RateLimiter { @Override public void changeLimitForPeriod(final int limitForPeriod) { RateLimiterConfig newConfig = RateLimiterConfig.from(state.get().config) .limitForPeriod(limitForPeriod) .build(); state.updateAndGet(currentState -> new State( newConfig, currentState.activeCycle, currentState.activePermissions, currentState.nanosToWait )); } AtomicRateLimiter(String name, RateLimiterConfig rateLimiterConfig);  AtomicRateLimiter(String name, RateLimiterConfig rateLimiterConfig,
                             Map<String, String> tags); }
AtomicRateLimiter implements RateLimiter { @Override public void changeLimitForPeriod(final int limitForPeriod) { RateLimiterConfig newConfig = RateLimiterConfig.from(state.get().config) .limitForPeriod(limitForPeriod) .build(); state.updateAndGet(currentState -> new State( newConfig, currentState.activeCycle, currentState.activePermissions, currentState.nanosToWait )); } AtomicRateLimiter(String name, RateLimiterConfig rateLimiterConfig);  AtomicRateLimiter(String name, RateLimiterConfig rateLimiterConfig,
                             Map<String, String> tags); @Override void changeTimeoutDuration(final Duration timeoutDuration); @Override void changeLimitForPeriod(final int limitForPeriod); @Override boolean acquirePermission(final int permits); @Override long reservePermission(final int permits); @Override String getName(); @Override RateLimiterConfig getRateLimiterConfig(); @Override Map<String, String> getTags(); @Override Metrics getMetrics(); @Override EventPublisher getEventPublisher(); @Override String toString(); AtomicRateLimiterMetrics getDetailedMetrics(); }
AtomicRateLimiter implements RateLimiter { @Override public void changeLimitForPeriod(final int limitForPeriod) { RateLimiterConfig newConfig = RateLimiterConfig.from(state.get().config) .limitForPeriod(limitForPeriod) .build(); state.updateAndGet(currentState -> new State( newConfig, currentState.activeCycle, currentState.activePermissions, currentState.nanosToWait )); } AtomicRateLimiter(String name, RateLimiterConfig rateLimiterConfig);  AtomicRateLimiter(String name, RateLimiterConfig rateLimiterConfig,
                             Map<String, String> tags); @Override void changeTimeoutDuration(final Duration timeoutDuration); @Override void changeLimitForPeriod(final int limitForPeriod); @Override boolean acquirePermission(final int permits); @Override long reservePermission(final int permits); @Override String getName(); @Override RateLimiterConfig getRateLimiterConfig(); @Override Map<String, String> getTags(); @Override Metrics getMetrics(); @Override EventPublisher getEventPublisher(); @Override String toString(); AtomicRateLimiterMetrics getDetailedMetrics();  }