All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.contek.invoker.commons.actor.ratelimit.SimpleRateLimitThrottleFactory Maven / Gradle / Ivy

There is a newer version: 3.8.0
Show newest version
package io.contek.invoker.commons.actor.ratelimit;

import com.google.common.collect.ImmutableList;
import io.contek.ursa.cache.LimiterManager;
import org.jetbrains.annotations.Nullable;

import javax.annotation.concurrent.ThreadSafe;
import java.net.InetAddress;
import java.util.List;

@ThreadSafe
public final class SimpleRateLimitThrottleFactory implements IRateLimitThrottleFactory {

  private final LimiterManager manager;
  private final ImmutableList interceptors;

  private SimpleRateLimitThrottleFactory(
      LimiterManager manager, ImmutableList interceptors) {
    this.manager = manager;
    this.interceptors = interceptors;
  }

  public static SimpleRateLimitThrottleFactory create(
      LimiterManager cache, List interceptors) {
    return new SimpleRateLimitThrottleFactory(cache, ImmutableList.copyOf(interceptors));
  }

  @Override
  public IRateLimitThrottle create(InetAddress boundLocalAddress, @Nullable String apiKeyId) {
    return new SimpleRateLimitThrottle(
        boundLocalAddress.getCanonicalHostName(), apiKeyId, manager, interceptors);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy