feature: optimize polaris-discovery-example/discovery-callee-service, add client-ip return.

pull/1080/head
atomzhong 2 years ago committed by Haotian Zhang
parent ca65902a7d
commit d2d66dccbe

@ -12,4 +12,5 @@
- [fix:fix NPE.](https://github.com/Tencent/spring-cloud-tencent/commit/17a9a8d75aef6ed39a0a1c7aa4b7d547f5d3d40e) - [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) - [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) - [feature:add polaris circuit breaker support](https://github.com/Tencent/spring-cloud-tencent/commit/1dffb915afc79b5d48e325fa497e94f93546a573)
- [fix:fix instance circuit breaker not working bug.]() - [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.]()

@ -35,30 +35,35 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/discovery/service/callee") @RequestMapping("/discovery/service/callee")
public class DiscoveryCalleeController { public class DiscoveryCalleeController {
private static Logger LOG = LoggerFactory.getLogger(DiscoveryCalleeController.class); private static final Logger LOG = LoggerFactory.getLogger(DiscoveryCalleeController.class);
@Value("${server.port:0}") @Value("${server.port:0}")
private int port; private int port;
@Value("${spring.cloud.client.ip-address:127.0.0.1}")
private String ip;
/** /**
* Get information of callee. * Get information of callee.
*
* @return information of callee * @return information of callee
*/ */
@GetMapping("/info") @GetMapping("/info")
public String info() { public String info() {
LOG.info("Discovery Service Callee [{}] is called.", port); LOG.info("Discovery Service Callee [{}:{}] is called.", ip, port);
return String.format("Discovery Service Callee [%s] is called.", port); return String.format("Discovery Service Callee [%s:%s] is called.", ip, port);
} }
/** /**
* Get sum of two value. * Get sum of two value.
*
* @param value1 value 1 * @param value1 value 1
* @param value2 value 2 * @param value2 value 2
* @return sum * @return sum
*/ */
@GetMapping("/sum") @GetMapping("/sum")
public int sum(@RequestParam int value1, @RequestParam int value2) { 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; return value1 + value2;
} }
} }

Loading…
Cancel
Save