Giter Club home page Giter Club logo

python-eureka's Introduction

python-eureka

The goal of this project is to provide an easy-to-use client interface to Eureka, a middle-tier load balancer open sourced and used by Netflix.

It's fairly straight forward to use once you hve setup Eureka itself. Consider the following script (to be run on EC2):

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

python-eureka's People

Contributors

jpedro avatar kristianoellegaard avatar larsga avatar rschultheis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-eureka's Issues

Example fails with Python 3.6.6

Due to the split of urllib2 into parts (urllib.error, urllib.parse, urllib.request) the library cannot be used with python 3.6.6.

Once the client code updated to urllib another problem occurs:
../python3.6/site-packages/eureka_client/requests.py", line 46, in create
response = request.opener.open(request)
File "/usr/lib/python3.6/urllib/request.py", line 524, in open
req = meth(req)
File "/usr/lib/python3.6/urllib/request.py", line 1248, in do_request

raise TypeError(msg)
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.

On SO recommend to encode url into utf-8:
data = urllib.parse.urlencode(data)
data = data.encode('utf-8')

But then another error follows:
..lib/python3.6/site-packages/eureka_client/requests.py", line 42, in create
data = urllib.parse.urlencode(data) # I added this
File "/usr/lib/python3.6/urllib/parse.py", line 864, in urlencode
"or mapping object").with_traceback(tb)
File "/usr/lib/python3.6/urllib/parse.py", line 856, in urlencode
raise TypeError
TypeError: not a valid non-string sequence or mapping object

How to fix it?

Cannot register my instance - 404 error received

When i run the next test:

from eureka_client import EurekaClient
import logging
logging.basicConfig()
ec = EurekaClient("MyApplication",
                  eureka_url="http://localhost:8080/eureka/v2/",
                  region="eu-west-1",
                  use_dns=False,
                  data_center="asdasdasd",
                  vip_address="http://localhost:7001/",
                  health_check_url="http://localhost:7001/app1",
                  host_name="localhost",
                  port=7001,
                  eureka_port=8080)
print ec.register()

I receive the next error:

Traceback (most recent call last):
File "test.py", line 20, in
print ec.register()
File "/usr/lib/python2.7/site-packages/eureka/client.py", line 161, in register
raise EurekaRegistrationFailedException("Did not receive correct reply from any instances")
eureka.client.EurekaRegistrationFailedException: Did not receive correct reply from any instances

When i curl the next url:

http://localhost:8080/eureka/v2/apps/MyApplication
I receive 404 but when i curl the next url:

http://whclsf-teva-dev-cc-bck4:8080/eureka/v2/apps/
I receive response status code 200 which means eureka server is up and running

the issue here is:
I ran the same configuration with Prana and it worked for me. but with your module, it didn't work!
According to the error and the code, you assume that my app was registered before or already registered!
what am i doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.