io.smallrye.stork.loadbalancer.requests.LeastRequestsConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stork-load-balancer-least-requests Show documentation
Show all versions of stork-load-balancer-least-requests Show documentation
SmallRye Stork Load Balancer provider picking the instance with the least inflight requests
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);
}
}