Eureka实现灰度发布(功能优雅下线)

@RestController
public class HelloController {
    @Autowired
    private DiscoveryClient client;
 
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String index() {
        java.util.List instances = client.getInstances("hello-service");       
        return "Hello World";
    }
    
    @RequestMapping(value = "/offline", method = RequestMethod.GET)
    public void offLine(){
    	DiscoveryManager.getInstance().shutdownComponent();
    }   
}

 

eureka客户端是是一个spring boot应用通过调用以下代码通知注册中心下线。 

DiscoveryManager.getInstance().shutdownComponent(); 

你可能感兴趣的:(Eureka实现灰度发布(功能优雅下线))