Browse Source

Add flexibility to zone preference in load balancing (#1174)

pull/1182/head
Benoit Kessler 2 years ago committed by GitHub
parent
commit
9849d9b23d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilder.java

15
spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilder.java

@ -224,6 +224,21 @@ public final class ServiceInstanceListSupplierBuilder { @@ -224,6 +224,21 @@ public final class ServiceInstanceListSupplierBuilder {
return this;
}
/**
* Adds a {@link ZonePreferenceServiceInstanceListSupplier} to the
* {@link ServiceInstanceListSupplier} hierarchy.
* @param zoneName desired zone for zone preference
* @return the {@link ServiceInstanceListSupplierBuilder} object
*/
public ServiceInstanceListSupplierBuilder withZonePreference(String zoneName) {
DelegateCreator creator = (context, delegate) -> {
LoadBalancerZoneConfig zoneConfig = new LoadBalancerZoneConfig(zoneName);
return new ZonePreferenceServiceInstanceListSupplier(delegate, zoneConfig);
};
this.creators.add(creator);
return this;
}
/**
* Adds a {@link RequestBasedStickySessionServiceInstanceListSupplier} to the
* {@link ServiceInstanceListSupplier} hierarchy.

Loading…
Cancel
Save