-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e6d1ff
commit ae1a7a2
Showing
10 changed files
with
75 additions
and
32 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
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
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
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
29 changes: 29 additions & 0 deletions
29
...ava/info/developerblog/examples/thirft/simpleclient/DiscoveryClientAutoConfiguration.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package info.developerblog.examples.thirft.simpleclient; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.web.context.WebServerInitializedEvent; | ||
import org.springframework.cloud.client.DefaultServiceInstance; | ||
import org.springframework.cloud.client.ServiceInstance; | ||
import org.springframework.cloud.client.discovery.DiscoveryClient; | ||
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration; | ||
import org.springframework.context.ApplicationListener; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@AutoConfigureAfter({ SimpleDiscoveryClientAutoConfiguration.class }) | ||
public class DiscoveryClientAutoConfiguration implements ApplicationListener<WebServerInitializedEvent> { | ||
|
||
@Autowired | ||
private DiscoveryClient simpleDiscoveryClient; | ||
|
||
@Override | ||
public void onApplicationEvent(WebServerInitializedEvent webServerInitializedEvent) { | ||
int port = webServerInitializedEvent.getWebServer().getPort(); | ||
for (String serviceId : simpleDiscoveryClient.getServices()) { | ||
for (ServiceInstance instance : simpleDiscoveryClient.getInstances(serviceId)) { | ||
((DefaultServiceInstance) instance).setPort(port); | ||
} | ||
} | ||
} | ||
} |
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
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
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,21 +1,38 @@ | ||
greeting-service: | ||
ribbon: | ||
listOfServers: localhost:${local.server.port} | ||
spring: | ||
cloud: | ||
discovery: | ||
client: | ||
simple: | ||
instances: | ||
greeting-service: | ||
- instanceId: server1 | ||
serviceId: greeting-service | ||
host: localhost | ||
port: 0 | ||
greeting-service-with-timeouts: | ||
- instanceId: server1 | ||
serviceId: greeting-service-with-timeouts | ||
host: localhost | ||
port: 0 | ||
greeting-service-with-timeouts-oneoff: | ||
- instanceId: server1 | ||
serviceId: greeting-service-with-timeouts-oneoff | ||
host: localhost | ||
port: 0 | ||
greeting-service-with-timeouts-retriable: | ||
- instanceId: server1 | ||
serviceId: greeting-service-with-timeouts-retriable | ||
host: localhost | ||
port: 0 | ||
greeting-service-with-timeouts: | ||
connectTimeout: 10 | ||
readTimeout: 100 | ||
ribbon: | ||
listOfServers: localhost:${local.server.port} | ||
greeting-service-with-timeouts-oneoff: | ||
connectTimeout: 10 | ||
readTimeout: 100 | ||
ribbon: | ||
listOfServers: localhost:${local.server.port} | ||
greeting-service-with-timeouts-retriable: | ||
connectTimeout: 10 | ||
readTimeout: 100 | ||
maxRetries: 3 | ||
ribbon: | ||
listOfServers: localhost:${local.server.port} | ||
|
||
thrift.client.max.threads: 10 |
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
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