Resilience4j RateLimiter, похоже, игнорирует конфигурацию

У меня проблема с Resilience4j RateLimiter

public static void main(final String[] args) throws InterruptedException {
    final ExternalService service = new ExternalService();
    final ExecutorService executorService = Executors.newFixedThreadPool(30);

    final RateLimiterConfig config = RateLimiterConfig.custom()
        .limitRefreshPeriod(Duration.ofSeconds(10))
        .limitForPeriod(3)
        .timeoutDuration(Duration.ofSeconds(12))
        .build();

    final RateLimiter rateLimiter = RateLimiter.of("RateLimiter", config);

    final Callable<Response<String>> callable = RateLimiter.decorateCallable(
        rateLimiter, () -> service.get(200, "OK")
    );

    executorService.submit(callable); //fine in first period
    executorService.submit(callable); //fine in first period
    executorService.submit(callable); //fine in first period
    executorService.submit(callable); //should wait 10 sec and fine in second period
    executorService.submit(callable); //should wait 10 sec and fine in second period
    executorService.submit(callable); //should wait 10 sec and fine in second period
    executorService.submit(callable); //should exit with timeout after 12 seconds
    executorService.submit(callable); //should exit with timeout after 12 seconds
    executorService.submit(callable); //should exit with timeout after 12 seconds


    Thread.sleep(Duration.ofSeconds(40).toMillis());
    executorService.shutdown();
}

В ExternalService у меня есть базовое ведение журнала с localTime ответов. Я думаю, что это должно работать, как я объяснил в комментариях, но мой ответ:

> Task :Main.main()
[12:24:53.5] Return standard response
[12:24:53.5] Return standard response
[12:24:53.5] Return standard response
[12:25:03.5] Return standard response
[12:25:03.5] Return standard response
[12:25:03.5] Return standard response
[12:25:03.5] Return standard response
[12:25:03.5] Return standard response

BUILD SUCCESSFUL in 40s

Таким образом, кажется, что первый цикл хорош, но после этого RateLimiter разрешает ПЯТЬ следующих потоков, а последний поток никогда не вызывается.


person ByeBye    schedule 28.01.2020    source источник
comment
Я расследую это. Я создал задачу, чтобы отследить это. github.com/resilience4j/resilience4j/issues/822   -  person Robert Winkler    schedule 29.01.2020
comment
@RobertWinkler, можете ли вы дать ответ? Я вижу, что проблема решена   -  person ByeBye    schedule 31.01.2020
comment
Да, к сожалению, это была ошибка, появившаяся в PR, который является частью выпуска 1.2.0. PR добавил возможность запрашивать несколько разрешений за звонок. Теперь ошибка исправлена.   -  person Robert Winkler    schedule 02.02.2020
comment
Пожалуйста, добавьте сюда ответ, чтобы я мог закрыть его :)   -  person ByeBye    schedule 03.02.2020


Ответы (1)


К сожалению, это была ошибка, появившаяся в PR # 672, который является частью выпуска v1.2.0. PR добавил возможность запрашивать несколько разрешений за звонок. Теперь ошибка исправлена.

person Robert Winkler    schedule 03.02.2020
comment
К сожалению, с выпуском 1.3.1 это все еще не работает. Для первых 6 вызовов он работает нормально, но остальные 3 не генерируют исключение. - person ByeBye; 07.04.2020