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

How to get the response status in case of entity not found. #62

Closed benlocum closed 2 years ago

benlocum commented 2 years ago

I am trying to catch "entity not found" responses. According to the examples, this code should do that:

try: res = eureka_client.do_service(app_name, service) except urllib.request.HTTPError as e: print("error code {}".format(e.code))

But instead of an HTTPError I always get a URLError. Looking at EurekaClient.walk_nodes(), it seems to always raise a URLError. How can I see the response status?

keijack commented 2 years ago

At moment, any response with the status code which is not 200, will be considered as failed and will do a retry, And after all nodes return a failure result, a unique URLError will be raised.

If you want a response with the status code witch is not 200 and want to take it as a success response, I think I have give another configuration to do this.

keijack commented 2 years ago

At 0.10.5 in init method, you can set strict_service_error_policy to False, by doing so, the HTTPError will be raise when do_service raise that.

keijack commented 2 years ago

Close for the long time silence.

If you have any problem, please re-open this issue.

benlocum commented 2 years ago

Works great! Thank you!