简体   繁体   English

注册,注销,从python Web服务对eureka发现执行所有操作

[英]Register, Deregister, perform all operations on eureka discovery from python web-services

I developed python web api to do some task which i need to register on spring eureka server for the discovery. 我开发了python web api来完成一些需要在spring尤里卡服务器上注册才能发现的任务。 Libraries are not available for it and available stuff of google is not helpful. 图书馆不可用,谷歌可用的东西没有帮助。

Eureka provides various restful API to perform this operation like registering, deregistering, heartbeat etc. list of RESTful API which Eureka provides. Eureka提供了各种Restful API来执行此操作,例如Eureka提供的RESTful API的注册,注销,心跳等

following is the code by which you can register your service to eureka. 以下是用于向eureka注册服务的代码。 import requests 进口要求

url = "http://<eureka ip:port>/eureka/apps/PYTHON-API/"

payload = "{\n\"instance\": {\n\"instanceId\": \"10.90.21.55:5050\",\n\"hostName\": \"10.90.21.55\",\n\"app\": \"PYTHON-api\",\n\"ipAddr\": \"10.90.21.55\",\n\"status\": \"UP\",\n\"port\": {\"$\": \"5050\", \"@enabled\": \"true\"},\n\"securePort\": {\"$\": \"443\", \"@enabled\": \"true\"},\n\"statusPageUrl\": \"http://10.90.21.55:5050/status\",\n\"homePageUrl\": \"http://10.90.21.55:5050\",\n\"dataCenterInfo\": {\n\"@class\": \"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo\", \n\"name\": \"MyOwn\"\n}\n}\n}"
headers = {
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM