Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

You have to include the following config in our microservice if you want to register microservices with the eureka server

eureka.client.service-url.defaultZone=${DISCOVERY_URL:http://localhost:8761}/eureka/

eureka.client.service-url.instance.leaseRenewalIntervalInSeconds=1

eureka.client.service-url.instance.leaseExpirationDurationInSeconds=1

But my question is, How to create a microservice in python and how to register with the server of eureka. Anyone, please help me. 

Thank you.

1 Answer

0 votes
by (26.4k points)

You should have REST implementions which actually follows Eurela-REST-operations.

Try the below code, which is a sample implementation which follows Eureka REST in python

code:

from eureka.client import EurekaClient

import logging

logging.basicConfig()

ec = EurekaClient("MyApplication",

                  eureka_domain_name="test.yourdomain.net",

                  region="eu-west-1",

                  vip_address="http://app.yourdomain.net/",

                  port=80,

                  secure_vip_address="https://app.yourdomain.net/",

                  secure_port=443

)

print ec.get_zones_from_dns()

print ec.get_eureka_urls()

print ec.register()

print ec.update_status("UP")  # Or ec.register("UP")

print ec.heartbeat()

Searching for good python tutorial course? Come and join python online course fast!  

Browse Categories

...