简单记录如将tornado注册到eureka, 将tornado引入微服务体系。

使用python-eureka-client

python-eureka-client 项目地址

EUREKA_SERVER_LIST = "http://127.0.0.1:8761/eureka"
SERVER_HOST = "10.10.38.20"
SERVER_PORT = 8000


def register_eureka():
    # 配置Euraka 文档见: https://github.com/keijack/python-eureka-client/blob/master/README.zh_cn.md
    # 业务需求:仅提供对外的服务即可
    # The flowing code will register your server to eureka server and also start to send heartbeat every 30 seconds
    eureka_client.init_registry_client(eureka_server=EUREKA_SERVER_LIST,
                                       app_name="economic-model",
                                       instance_host=SERVER_HOST,
                                       instance_port=SERVER_PORT)

然后在程序的入口函数中调用该方法。

java中调用

  1. 入口函数添加注解@EnableFeignClients
  2. 调用如:
@FeignClient(name = "ECONOMIC-MODEL")
@RequestMapping(value = "/demo")
public interface ITornadoFeignService {
    @RequestMapping(value = "/get")
    Object getDepartInfo(@RequestParam("phone") String phone, @RequestParam("password") String password);
}

Ng-Alain常用命令以及简易的开发流程 tornado添加统一异常抛出、默认响应头