keijack / python-eureka-client

A eureka client written in python. Support registering your python component to Eureka Server, as well as calling remote services by pulling the the Eureka registry.
MIT License
183 stars 43 forks source link

New optional parameter instance_ip_network to force autodetect correct network #48

Closed uwohlfeil closed 3 years ago

uwohlfeil commented 3 years ago

I had the situation, that my first non loopback device was a openvpn adapter. In this case, the auto guess function selects the wrong IP address. Maybe it is useful, to have the possibility to define a correct network IP range for auto detection. For example, if all microservices receives the configuration via Spring Cloud Config, the correct (docker) network IP range can be via this parameter.

Of cause, it is already possible, to to this like you documented it in the README.md:

import py_eureka_client.netint_utils as netint_utils

ip, host = netint_utils.get_ip_and_host("192.168.10.0/24")

# you can get the ip only
ip = netint_utils.get_first_non_loopback_ip("192.168.10.0/24")
host = "my-py-component.mydomian.com"

eureka_client.init(eureka_server="your-eureka-server-peer1,your-eureka-server-peer2",
                eureka_protocol="https",
                eureka_basic_auth_user="keijack",
                eureka_basic_auth_password="kjauthpass",
                eureka_context="/eureka/v2",
                app_name="python_module_1", 
                instance_ip=ip,
                instance_host=host,
                instance_port=9090)

So this change is just a comfort improvement :)

sonarcloud[bot] commented 3 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

keijack commented 3 years ago

Thanks for you code, a new version 0.9.6 is released.