def get_client(eureka_hosts="127.0.0.1"):
    try:
        eureka_client.init_discovery_client(eureka_hosts)
    except AttributeError as et:
        print("Eureka connetion failed! %e".format(et.__str__()))
        return None
    else:
        return eureka_client
    def eureka_client_registration(self, application):
        if self.mock is False:
            eureka_client.init_registry_client(
                eureka_server="{}/eureka".format(
                    os.environ["localEurekaServerURL"]),
                app_name=application.config['APP_NAME'],
                instance_port=application.config['PORT'])

            eureka_client.init_discovery_client("{}/eureka".format(
                os.environ["localEurekaServerURL"]))
 async def get(self):
     username = self.get_argument('username', 'Hello')
     eureka_server_list = "http://192.168.2.64:8761/eureka/"
     eureka_client.init_discovery_client(eureka_server_list)
     res = eureka_client.do_service("python-tornado-xyweb",
                                    service="/info",
                                    return_type="string")
     print("result of other service" + res)
     return self.v2_write_json(code=MsgCode.SUCCESS,
                               msg="success",
                               data=username + ", Administrator User!")
def get_client(eureka_hosts="127.0.0.1"):
    """
            获取eureka客户端连接
            :param eureka_hosts: eureka地址
            :return:
    """
    try:
        eureka_client.init_discovery_client(eureka_hosts)
    except AttributeError as et:
        logger.error("Eureka connetion failed! %e".format(et.__str__()))
        return None
    else:
        return eureka_client
Exemple #5
0
import pandas as pd
import py_eureka_client.eureka_client as eureka_client
import pymysql
import config
import json

# 初始化
# 注册eureka_client
eureka_client.init_discovery_client(config.eureka_server)


# 从本地的excel中获取data
def load_data_from_excel():
    return pd.read_excel(config.excel_data_path)


def load_resume_from_excel():
    return pd.read_excel(config.excel_resume_path)


def load_job_from_excel():
    return pd.read_excel(config.excel_job_path)


# 通过接口获取resume
def load_resume_from_service():
    res = eureka_client.do_service("ZUUL",
                                   "/api/resumeservice/resume/getAllResume")
    resume = json.loads(res)['content']
    df = pd.DataFrame(list(resume))
    # 这边你自己把结构调成你要的frame最后return
Exemple #6
0
def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'firmwareanalyze.settings')
    try:

        # print(Sys_code_err)

        # EUREKA接口
        # 本地服务
        # eureka_server_list = "http://localhost:10100/eureka/"

        # 远程服务
        eureka_server_list = "http://172.16.60.5:10100/eureka/"

        # your_rest_server_host = "localhost"
        your_rest_server_host = "172.16.113.28"
        your_rest_server_port = 10112

        # 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="firmware-analyze",
                                           instance_host=your_rest_server_host,
                                           instance_port=your_rest_server_port)
        # 发现服务
        # you can reuse the eureka_server_list which you used in registry client
        listservice = eureka_client.init_discovery_client(eureka_server_list)

        # 调用服务
        res = eureka_client.do_service(
            "SYSTEM-CODE",
            "/sys_code/run_status",
            # 返回类型,默认为 `string`,可以传入 `json`,如果传入值是 `json`,那么该方法会返回一个 `dict` 对象
            return_type="string")
        print("result of other service" + res)

        syscode = eureka_client.do_service(
            "SYSTEM-CODE",
            "/sys_code/err_codes/all",
            # 返回类型,默认为 `string`,可以传入 `json`,如果传入值是 `json`,那么该方法会返回一个 `dict` 对象
            return_type="json")
        # string_Sys_code_err = eureka_client.do_service("SYSTEM-CODE", "/sys_code/err_codes/all",
        #                                # 返回类型,默认为 `string`,可以传入 `json`,如果传入值是 `json`,那么该方法会返回一个 `dict` 对象
        #                                return_type="string")
        settings.SYS_CODE = syscode['payload']
        # print(type(settings.SYS_CODE))

        #
        # syslog = eureka_client.do_service("SYSTEM-LOG", "/sys_log/add",
        #                                # 返回类型,默认为 `string`,可以传入 `json`,如果传入值是 `json`,那么该方法会返回一个 `dict` 对象
        #                                return_type="string")
        # print("system-log:" + syslog)

    except ZeroDivisionError as e:
        print('except:', e)

    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?") from exc
    execute_from_command_line(sys.argv)
Exemple #7
0
def init_eureka_discovery(config):
    return eureka_client.init_discovery_client(
        f"http://{socket.gethostbyname(config['hostname'])}:{config['port']}/{config['slug']}"
    )
Exemple #8
0
 def discovery_client(self):
     self.ek_cli = eureka_client.init_discovery_client(EUREKA_CLIENT_URI)