-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored ConsulServiceLocator to retrieve all healthy services from…
… catalog endpoint
- Loading branch information
pawel.wlodarczyk
committed
Oct 26, 2020
1 parent
30463fa
commit db24c14
Showing
4 changed files
with
73 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 19 additions & 5 deletions
24
judge-d-agent/src/main/java/com/hltech/judged/agent/consul/ConsulBeanFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
package com.hltech.judged.agent.consul; | ||
|
||
import com.ecwid.consul.v1.ConsulClient; | ||
import com.ecwid.consul.v1.catalog.CatalogClient; | ||
import com.ecwid.consul.v1.catalog.CatalogConsulClient; | ||
import com.ecwid.consul.v1.health.HealthClient; | ||
import com.ecwid.consul.v1.health.HealthConsulClient; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
@Configuration | ||
@Profile("consul") | ||
@RequiredArgsConstructor | ||
public class ConsulBeanFactory { | ||
|
||
@Value("${hltech.contracts.judge-d.consul-host}") | ||
private String consulUrl; | ||
|
||
@Bean | ||
CatalogClient catalogConsulClient() { | ||
return new CatalogConsulClient(consulUrl); | ||
} | ||
|
||
@Bean | ||
ConsulClient consulAgentClient(@Value("${hltech.contracts.judge-d.consul-host}") String consulUrl) { | ||
return new ConsulClient(consulUrl); | ||
HealthClient healthConsulClient() { | ||
return new HealthConsulClient(consulUrl); | ||
} | ||
|
||
@Bean | ||
ConsulTagBasedServiceLocator consulServiceLocator(ConsulClient discoveryClient) { | ||
return new ConsulTagBasedServiceLocator(discoveryClient); | ||
ConsulTagBasedServiceLocator consulServiceLocator(CatalogClient catalogConsulClient, | ||
HealthClient healthConsulClient) { | ||
return new ConsulTagBasedServiceLocator(catalogConsulClient, healthConsulClient); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 33 additions & 32 deletions
65
...gent/src/test/groovy/com/hltech/judged/agent/consul/ConsulTagBasedServiceLocatorUT.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters