An eureka client written in python, you can easily intergrate your python components with spring cloud.
Project description
# python-eureka-client
## Discription
This is an eureka client written in python, you can easily intergrate your python components with spring cloud.
## Support Python Version
Python 2.7 / 3.6+ (It should also work at 3.5, not test)
## Why choose
* Register your python components to eureka server.
* Support multiple eureka server registration.
* Send heartbeat to eureka server.
* Auto unregister from eureka server when your server down.
* Discovery apps from eureka server.
* Easy to use interface to use other REST service.
* Auto try other nodes when one nodes down.
## How to use
### Install
```Shell
pip install py_eureka_client
```
### Rister your python REST server to eureka server
```python
import py_eureka_client.eureka_client as eureka_client
your_rest_server_port = 9090
# The flowing code will register your server to eureka server and also start to send heartbeat every 30 seconds
eureka_client.init_registry_client(eureka_server="http://your-eureka-server-peer1,http://your-eureka-server-peer2",
app_name="your_app_name",
instance_port=your_rest_server_port)
```
*If you do not specify your host and ip just like the example above, the client will choose one that could connect to eureka server.*
### Discover other service from eureka server
First, init the discovery client after your server starts up.
```python
import py_eureka_client.eureka_client as eureka_client
eureka_client.init_discovery_client("http://192.168.3.116:8761/eureka/, http://192.168.3.116:8762/eureka/")
```
Then, in your business code, use
```python
import py_eureka_client.eureka_client as eureka_client
cli = eureka_client.get_discovery_client()
res = cli.do_service("OTHER-SERVICE-NAME", "/service/context/path")
print("result of other service" + res)
```
*do_service method will automatically try other nodes when one node return a HTTP error, until one success or all nodes being tried.*
There are several HA strategies when using discovery client. You can specify it in `init_discovery_client`. They are:
* HA_STRATEGY_RANDOM, default strategy, find an node randamly.
* HA_STRATEGY_STICK, use one node until it going down.
* HA_STRATEGY_OTHER, always use a different node from the last time.
## Discription
This is an eureka client written in python, you can easily intergrate your python components with spring cloud.
## Support Python Version
Python 2.7 / 3.6+ (It should also work at 3.5, not test)
## Why choose
* Register your python components to eureka server.
* Support multiple eureka server registration.
* Send heartbeat to eureka server.
* Auto unregister from eureka server when your server down.
* Discovery apps from eureka server.
* Easy to use interface to use other REST service.
* Auto try other nodes when one nodes down.
## How to use
### Install
```Shell
pip install py_eureka_client
```
### Rister your python REST server to eureka server
```python
import py_eureka_client.eureka_client as eureka_client
your_rest_server_port = 9090
# The flowing code will register your server to eureka server and also start to send heartbeat every 30 seconds
eureka_client.init_registry_client(eureka_server="http://your-eureka-server-peer1,http://your-eureka-server-peer2",
app_name="your_app_name",
instance_port=your_rest_server_port)
```
*If you do not specify your host and ip just like the example above, the client will choose one that could connect to eureka server.*
### Discover other service from eureka server
First, init the discovery client after your server starts up.
```python
import py_eureka_client.eureka_client as eureka_client
eureka_client.init_discovery_client("http://192.168.3.116:8761/eureka/, http://192.168.3.116:8762/eureka/")
```
Then, in your business code, use
```python
import py_eureka_client.eureka_client as eureka_client
cli = eureka_client.get_discovery_client()
res = cli.do_service("OTHER-SERVICE-NAME", "/service/context/path")
print("result of other service" + res)
```
*do_service method will automatically try other nodes when one node return a HTTP error, until one success or all nodes being tried.*
There are several HA strategies when using discovery client. You can specify it in `init_discovery_client`. They are:
* HA_STRATEGY_RANDOM, default strategy, find an node randamly.
* HA_STRATEGY_STICK, use one node until it going down.
* HA_STRATEGY_OTHER, always use a different node from the last time.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_eureka_client-0.1.1.tar.gz
(10.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_eureka_client-0.1.1.tar.gz.
File metadata
- Download URL: py_eureka_client-0.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa17e3a03f58a4e98fc1c7be6e4dfba5a3da38c72310e60635361bf03f4a3dba
|
|
| MD5 |
134a00ef6e0c94f4f61220e988c9612d
|
|
| BLAKE2b-256 |
39960b35c76dceedb03d913eb8418b19ed0fe8e9d61db708b2e0684e2b38800b
|
File details
Details for the file py_eureka_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: py_eureka_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ef5093381dc515b24585b973dfdfde13318bd25a08bbc22e0f613a9978ab64c
|
|
| MD5 |
12f98e668ed52b1a011dd57cb5f41f29
|
|
| BLAKE2b-256 |
a8100dc385c359fba9cac300c1b4a3492e616f931e3bc24dd616d7ed4ff2a265
|