Skip to content

Commit

Permalink
Enable overriding the client in DiscoveryManager (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
asibross committed Aug 5, 2021
1 parent 9091ffd commit fc4e05a
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
public class DiscoveryManager {
private static final Logger logger = LoggerFactory.getLogger(DiscoveryManager.class);
private DiscoveryClient discoveryClient;
private EurekaClient clientOverride;

private EurekaInstanceConfig eurekaInstanceConfig;
private EurekaClientConfig eurekaClientConfig;
Expand All @@ -58,6 +59,10 @@ public void setDiscoveryClient(DiscoveryClient discoveryClient) {
this.discoveryClient = discoveryClient;
}

public void setClientOverride(EurekaClient eurekaClient) {
this.clientOverride = eurekaClient;
}

public void setEurekaClientConfig(EurekaClientConfig eurekaClientConfig) {
this.eurekaClientConfig = eurekaClientConfig;
}
Expand Down Expand Up @@ -107,7 +112,7 @@ public void shutdownComponent() {
}

public LookupService getLookupService() {
return discoveryClient;
return getEurekaClient();
}

/**
Expand All @@ -127,6 +132,9 @@ public DiscoveryClient getDiscoveryClient() {
* @return the client that is used to talk to eureka.
*/
public EurekaClient getEurekaClient() {
if (clientOverride != null) {
return clientOverride;
}
return discoveryClient;
}

Expand Down

0 comments on commit fc4e05a

Please sign in to comment.