简体   繁体   中英

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. 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.

following is the code by which you can register your service to 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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