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

io.smallrye.stork.loadbalancer.requests.LeastRequestsConfiguration Maven / Gradle / Ivy

Go to download

SmallRye Stork Load Balancer provider picking the instance with the least inflight requests

The newest version!
package io.smallrye.stork.loadbalancer.requests;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import io.smallrye.stork.api.config.ConfigWithType;

/**
 *  Configuration for the {@code LeastRequestsLoadBalancerProvider} LoadBalancer.
 */
 public class LeastRequestsConfiguration implements io.smallrye.stork.api.config.ConfigWithType{
   private final Map parameters;

   /**
    * Creates a new LeastRequestsConfiguration
    *
    * @param params the parameters, must not be {@code null}
    */
   public LeastRequestsConfiguration(Map params) {
      parameters = Collections.unmodifiableMap(params);
   }

   /**
    * Creates a new LeastRequestsConfiguration
    */
   public LeastRequestsConfiguration() {
      parameters = Collections.emptyMap();
   }


  /**
   * @return the type
   */
   @Override
   public String type() {
      return "least-requests";
   }


   /**
    * @return the parameters
    */
   @Override
   public Map parameters() {
      return parameters;
   }

   private LeastRequestsConfiguration extend(String key, String value) {
      Map copy = new HashMap<>(parameters);
      copy.put(key, value);
      return new LeastRequestsConfiguration(copy);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy