com.transferwise.tasks.helpers.ErrorLoggingThrottler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-tasks-core Show documentation
Show all versions of tw-tasks-core Show documentation
Transferwise Tasks Executor - Fire and forget until Alert.
The newest version!
package com.transferwise.tasks.helpers;
import com.google.common.util.concurrent.RateLimiter;
import org.springframework.beans.factory.InitializingBean;
public class ErrorLoggingThrottler implements IErrorLoggingThrottler, InitializingBean {
private RateLimiter rateLimiter;
@Override
public void afterPropertiesSet() {
rateLimiter = RateLimiter.create(0.2);
}
@Override
public boolean canLogError() {
return rateLimiter.tryAcquire(1);
}
}