[chore #12] Modify example and readme and package name (#13)
* refactor: add license and refactor structure
* feat: add example and deploy doc
* refactor: rename project name
* feat: add example
* Delete gateway_proxy directory
* refactor: modify example structure
* Delete gateway_proxy directory
* Delete .gitignore
* refactor: modify example structure and readme and package name
Co-authored-by: shuimudongtian <2267491517@qq.com>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a08668f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,30 @@
+__pycache__/
+*.py[cod]
+
+# Distribution / packaging
+bin/
+build/
+develop-eggs/
+dist/
+eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# Unit test / coverage reports
+.tox/
+.coverage
+.cache
+nosetests.xml
+coverage.xml
+
+*.log
+*.pot
+
+# vscode
+.vscode/
\ No newline at end of file
diff --git a/README.md b/README.md
index 1f7af6c..59dc130 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,30 @@
-## proxy python service gateway request
+## Apache-ShenYu-Client
+Apache-Shenyu-Client for python client allows you to access ShenYu Gateway, it supports registory python service to ShenYu Gateway.
-### detail doc
-
-[How to access the gateway for http services in non-java languages](https://github.com/apache/incubator-shenyu-sdk/sdk-python/)
+### Requirements
+Supported python version over 3.6
+Supported ShenYu version over 2.4.3
### instructions
> 1、install
-pip3 install gateway-proxy
+pip3 install Apache-ShenYu-Client -i https://pypi.python.org/simple
> 2、usage
> 3.1、Use the decorator
```
->>import package:
-from gateway_proxy.config import GatewayConfig
-from gateway_proxy.register import register_uri, register_metadata, register_all_metadata
+>>import package:
-3.1.0、Modify the configuration according to the project situation
+from apache_shenyu_client.config import GatewayConfig
+from apache_shenyu_client.register import register_uri, register_metadata, register_all_metadata
+3.1.0、First, modify the configuration according to the project situation, If you do not configure it, you will not be able to use apache_shenyu_client.
+#### Configure shenyu gateway services and port
+GatewayConfig.test = {
+ "servers": "xx.xx.xx.xx",
+ "port": 1001
+ }
+#### Configure python services information
GatewayConfig.uri = {
"app_name": "app2", # app name
"host": "172.24.43.28", # python service host
@@ -25,18 +32,27 @@
"context_path": "/flask_test", # context_path
"environment": "test", # environment
"rpc_type": "http" # rpc type
+ }
+#### Configure to get administrator token
+GatewayConfig.register = {
+ "register_type": "http",
+ "servers": "xx.xx.xx.xx",
+ "props": {
+ "username": "admin",
+ "password": "123456"
+ }
}
-3.1.1、proxy all interfaces
+3.1.1、proxy all api
3.1.1.1、Using a decorator at the entry of a service request to register for this service: @register_uri
3.1.1.2、Using a decorator at the entry of a service request: @register_all_metadata(register_all=True)
-3.1.2、proxy some interface
+3.1.2、proxy some api
3.1.2.1、Using a decorator at the entry of a service request to register for this service: @register_uri
-3.1.2.2、use a decorator on that interface definition: @register_metadata,need param: path, as follows 3.1.2.3:
+3.1.2.2、use a decorator on that api definition: @register_metadata,need param: path, as follows 3.1.2.3:
-3.1.2.3、this is a python flask service interface, path is "/search"
+3.1.2.3、this is a python flask service api, path is "/search"
@user.route('/search', methods=['GET'])
def user_search_handler():
data = UserBusiness.search_by_nickname()
@@ -55,8 +71,8 @@
```
>>import package
-from gateway_proxy.config import GatewayConfig
-from gateway_proxy.api import GatewayProxy
+from apache_shenyu_client.config import GatewayConfig
+from apache_shenyu_client.api import GatewayProxy
gt = GatewayProxy()
3.2.1、Modify the configuration according to the project situation
diff --git a/client/client/__init__.py b/client/apache_shenyu_client/__init__.py
similarity index 96%
rename from client/client/__init__.py
rename to client/apache_shenyu_client/__init__.py
index d996748..3c604f9 100644
--- a/client/client/__init__.py
+++ b/client/apache_shenyu_client/__init__.py
@@ -18,7 +18,7 @@
*/
"""
-__project__ = "gateway-proxy"
+__project__ = "Apache-ShenYu-Client"
__author__ = "https://shenyu.apache.org"
diff --git a/client/client/api.py b/client/apache_shenyu_client/api.py
similarity index 97%
rename from client/client/api.py
rename to client/apache_shenyu_client/api.py
index e99174c..b8fb2d5 100644
--- a/client/client/api.py
+++ b/client/apache_shenyu_client/api.py
@@ -21,9 +21,8 @@
import requests
from requests.exceptions import (ReadTimeout, RequestException, ConnectTimeout)
-from client.client.config import GatewayConfig, ALL_ENV
-from client.client.exception import (EnvTypeExp, SetUpUriExp, SetUpRegisterExp,
- SetUpGatewayExp, GetRegisterTokenErr)
+from .config import GatewayConfig, ALL_ENV
+from .exception import (EnvTypeExp, SetUpUriExp, SetUpRegisterExp, SetUpGatewayExp, GetRegisterTokenErr)
class GatewayProxy(object):
diff --git a/client/client/config.py b/client/apache_shenyu_client/config.py
similarity index 100%
rename from client/client/config.py
rename to client/apache_shenyu_client/config.py
diff --git a/client/client/exception.py b/client/apache_shenyu_client/exception.py
similarity index 100%
rename from client/client/exception.py
rename to client/apache_shenyu_client/exception.py
diff --git a/client/client/main.py b/client/apache_shenyu_client/main.py
similarity index 100%
rename from client/client/main.py
rename to client/apache_shenyu_client/main.py
diff --git a/client/client/register.py b/client/apache_shenyu_client/register.py
similarity index 94%
rename from client/client/register.py
rename to client/apache_shenyu_client/register.py
index 6936e46..d2af4d1 100644
--- a/client/client/register.py
+++ b/client/apache_shenyu_client/register.py
@@ -21,8 +21,8 @@
from copy import deepcopy
from functools import wraps
-from client.client.api import GatewayProxy
-from client.client.exception import (RegisterUriExp, RegisterMetaDataExp, RegisterAllMetaDataExp)
+from .api import GatewayProxy
+from .exception import (RegisterUriExp, RegisterMetaDataExp, RegisterAllMetaDataExp)
def register_uri(func):
diff --git a/client/setup.py b/client/setup.py
index 2564e42..ed5a69b 100644
--- a/client/setup.py
+++ b/client/setup.py
@@ -18,16 +18,16 @@
*/
"""
-from setuptools import setup
+from setuptools import setup, find_packages
setup(
- name="gateway_proxy", # project name, pip3 install gateway_proxy
- version="0.1.0", # version
+ name="Apache-ShenYu-Client", # package name, pip3 install Apache-ShenYu-Client
+ version="0.2", # version
author="https://shenyu.apache.org", # author
- author_email="https://shenyu.apache.org/zh/community", # email
- url="https://github.com/mutianzero/incubator-shenyu-client-python", # project repo url
- description="shenyu python proxy service sdk", # description
- packages=["gateway_proxy"], # packages name
+ author_email="dev@shenyu.apache.org ", # email
+ url="https://github.com/apache/incubator-shenyu-client-python", # project repo url
+ description="Apache ShenYu client", # description
+ packages=find_packages(), # include packages name
install_requires=["requests>=2.25.1", "PyYAML>=5.3"], # requires third packages
python_requires=">=3.6", # python version condition
entry_points={ # console scripts
diff --git a/example/README.md b/example/README.md
index bba03bf..0b512f7 100644
--- a/example/README.md
+++ b/example/README.md
@@ -1,8 +1,8 @@
## python service gateway proxy use example
-### 1、Install gateway-proxy package
-pip install gateway-proxy
+### 1、Install Apache-ShenYu-Client package
+pip install Apache-ShenYu-Client=0.2
### 2、Config, for example the following
diff --git a/example/app.py b/example/app.py
index f0f52b3..cdaa0be 100644
--- a/example/app.py
+++ b/example/app.py
@@ -22,16 +22,16 @@
from flask import Flask, jsonify, request
-# pip install gateway-proxy
-from gateway_proxy.config import GatewayConfig
-from gateway_proxy.api import GatewayProxy
-from gateway_proxy.register import register_uri, register_all_metadata
+# pip install Apache-ShenYu-Client
+from apache_shenyu_client.config import GatewayConfig
+from apache_shenyu_client.api import GatewayProxy
+from apache_shenyu_client.register import register_uri, register_all_metadata
app = Flask(__name__)
-"""
-Configure the gateway first
+"""
+First, modify the configuration according to the project situation, If you do not configure it, you will not be able to use apache_shenyu_client.
"""
GatewayConfig.register_type = "http"
GatewayConfig.test = {
@@ -56,7 +56,7 @@
}
GatewayConfig.register = {
"register_type": "http",
- "servers": "xx.xx.xx.xx",
+ "servers": "172.12.23.10",
"props": {
"username": "admin",
"password": "123456"
diff --git a/example/requiremnets.txt b/example/requiremnets.txt
index 64e9ae3..f11c222 100644
--- a/example/requiremnets.txt
+++ b/example/requiremnets.txt
@@ -1,2 +1,2 @@
flask==2.0.3
-gateway-proxy==0.1.0
\ No newline at end of file
+Apache-ShenYu-Client=0.2
\ No newline at end of file