From d2d66dccbef4b9b858885ae365e8f90e0e5555af Mon Sep 17 00:00:00 2001 From: atomzhong <48663740+atomzhong@users.noreply.github.com> Date: Thu, 27 Apr 2023 18:04:17 +0800 Subject: [PATCH] feature: optimize polaris-discovery-example/discovery-callee-service, add client-ip return. --- CHANGELOG.md | 3 ++- .../service/callee/DiscoveryCalleeController.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76f03245..867d653f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,5 @@ - [fix:fix NPE.](https://github.com/Tencent/spring-cloud-tencent/commit/17a9a8d75aef6ed39a0a1c7aa4b7d547f5d3d40e) - [refactor:optimize sct-all.](https://github.com/Tencent/spring-cloud-tencent/commit/3859cd7eefcd93752d05113597656e584d97c38d) - [feature:add polaris circuit breaker support](https://github.com/Tencent/spring-cloud-tencent/commit/1dffb915afc79b5d48e325fa497e94f93546a573) -- [fix:fix instance circuit breaker not working bug.]() \ No newline at end of file +- [fix:fix instance circuit breaker not working bug.](https://github.com/Tencent/spring-cloud-tencent/commit/ca65902a7d65bc5e4e2ccbd68b6f7cb22a346fa9) +- [feature: optimize polaris-discovery-example/discovery-callee-service, add client-ip return.]() \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java index 7c4d8217..a1533639 100644 --- a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java +++ b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java @@ -35,30 +35,35 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/discovery/service/callee") public class DiscoveryCalleeController { - private static Logger LOG = LoggerFactory.getLogger(DiscoveryCalleeController.class); + private static final Logger LOG = LoggerFactory.getLogger(DiscoveryCalleeController.class); @Value("${server.port:0}") private int port; + @Value("${spring.cloud.client.ip-address:127.0.0.1}") + private String ip; + /** * Get information of callee. + * * @return information of callee */ @GetMapping("/info") public String info() { - LOG.info("Discovery Service Callee [{}] is called.", port); - return String.format("Discovery Service Callee [%s] is called.", port); + LOG.info("Discovery Service Callee [{}:{}] is called.", ip, port); + return String.format("Discovery Service Callee [%s:%s] is called.", ip, port); } /** * Get sum of two value. + * * @param value1 value 1 * @param value2 value 2 * @return sum */ @GetMapping("/sum") public int sum(@RequestParam int value1, @RequestParam int value2) { - LOG.info("Discovery Service Callee is called and sum is {}.", value1 + value2); + LOG.info("Discovery Service Callee [{}:{}] is called and sum is {}.", ip, port, value1 + value2); return value1 + value2; } }