繁体   English   中英

如何在我的 eureka 服务器上注册 python 微服务(spring boot)

[英]How to register python microservices with my eureka server (spring boot)

为了向 eureka 服务器注册微服务,我们需要在我们的微服务中添加以下配置

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

但是我需要在 python 中创建微服务并在 eureka 服务器上注册。 那么我应该如何实现呢?

提前致谢

需要遵循Eureka-REST-operations 的REST 实现。 下面是在 Python 中遵循 Eureka REST 的示例实现。

请参阅Netflix Eureka 的 Python 客户端的完整文档

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()

@AzizSM 推荐的 github 项目已经四年没有更新了。 最近的一个项目是https://github.com/keijack/python-eureka-client 它最后一次更新是在 2019 年 11 月。

暂无
暂无

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

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