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.
package com.transferwise.tasks.helpers;
import com.google.common.util.concurrent.RateLimiter;
import javax.annotation.PostConstruct;
public class ErrorLoggingThrottler implements IErrorLoggingThrottler {
private RateLimiter rateLimiter;
@PostConstruct
public void init() {
rateLimiter = RateLimiter.create(0.2);
}
@Override
public boolean canLogError() {
return rateLimiter.tryAcquire(1);
}
}