From 67850e7cad13df5f9fd57d2a892bc553ecddecf2 Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Fri, 20 Oct 2017 12:40:23 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E7=94=A8python?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3=E3=80=82=20pythong?= =?UTF-8?q?=E7=9A=84web=E6=A8=A1=E6=9D=BF=E5=9C=B0=E5=9D=80=EF=BC=9A=20htt?= =?UTF-8?q?ps://gitee.com/superjery/tornado=5Fboilerplate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ace-python/pom.xml | 54 +++++++++++++++++++ ace-python/readme.md | 0 .../config/PythonServerBootstrap.java | 15 ++++++ ace-python/src/main/resources/application.yml | 12 +++++ 4 files changed, 81 insertions(+) create mode 100644 ace-python/pom.xml create mode 100644 ace-python/readme.md create mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java create mode 100644 ace-python/src/main/resources/application.yml diff --git a/ace-python/pom.xml b/ace-python/pom.xml new file mode 100644 index 00000000..cd69773f --- /dev/null +++ b/ace-python/pom.xml @@ -0,0 +1,54 @@ + + + + ace-security + com.github.wxiaoqi + 1.0-SNAPSHOT + + 4.0.0 + + ace-python + + + + org.springframework.cloud + spring-cloud-starter-config + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-netflix-sidecar + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-eureka + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/ace-python/readme.md b/ace-python/readme.md new file mode 100644 index 00000000..e69de29b diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java b/ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java new file mode 100644 index 00000000..94380736 --- /dev/null +++ b/ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java @@ -0,0 +1,15 @@ +package com.github.wxiaoqi.security.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.sidecar.EnableSidecar; +/** + * Created by ace on 2017/7/29. + */ +@EnableSidecar +@SpringBootApplication +public class PythonServerBootstrap { + public static void main(String[] args) { + SpringApplication.run(PythonServerBootstrap.class, args); + } +} diff --git a/ace-python/src/main/resources/application.yml b/ace-python/src/main/resources/application.yml new file mode 100644 index 00000000..00f0c43a --- /dev/null +++ b/ace-python/src/main/resources/application.yml @@ -0,0 +1,12 @@ +server: + port: 5688 #启动端口 + +sidecar: + port: 5680 #python接口 + health: + uri: http://localhost:${sidecar.port}/health + +spring: + application: + name: ace-python + -- Gitee From 5509b1e78d4c58e45ebb3aba40777793ea388e9c Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Sun, 22 Oct 2017 20:57:35 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=8F=90=E4=BA=A4Sidercar=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ace-python/pom.xml | 9 +++- ace-python/readme.md | 22 ++++++++ .../python/PythonServerBootstrap.java | 23 ++++++++ .../python/client/PythonFeignClient.java | 23 ++++++++ .../security/python/entity/Message.java | 28 ++++++++++ .../python/rest/PythonController.java | 31 +++++++++++ ace-python/src/main/resources/application.yml | 7 +-- ace-sidercar/pom.xml | 54 +++++++++++++++++++ ace-sidercar/readme.md | 21 ++++++++ .../security/sidercar/SidercarBootstrap.java | 7 +-- .../src/main/resources/application.yml | 12 +++++ 11 files changed, 227 insertions(+), 10 deletions(-) create mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java create mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java create mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java create mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java create mode 100644 ace-sidercar/pom.xml create mode 100644 ace-sidercar/readme.md rename ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java => ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar/SidercarBootstrap.java (68%) create mode 100644 ace-sidercar/src/main/resources/application.yml diff --git a/ace-python/pom.xml b/ace-python/pom.xml index cd69773f..bf33ac21 100644 --- a/ace-python/pom.xml +++ b/ace-python/pom.xml @@ -40,7 +40,14 @@ org.springframework.cloud spring-cloud-starter-eureka - + + org.springframework.cloud + spring-cloud-starter-eureka + + + org.springframework.cloud + spring-cloud-starter-feign + diff --git a/ace-python/readme.md b/ace-python/readme.md index e69de29b..d8779c0a 100644 --- a/ace-python/readme.md +++ b/ace-python/readme.md @@ -0,0 +1,22 @@ +Python服务端示例: +https://gitee.com/superjery/tornado_boilerplate + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +需以下根文件: + __init__.py + application.py + server.py + urls.py + +需以下根文件夹: + handlers + model + static + templates +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Python 安装 3.5 +tornado 安装 4.5 + +运行python server.py即可启动Web + diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java new file mode 100644 index 00000000..fcd7ebc7 --- /dev/null +++ b/ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java @@ -0,0 +1,23 @@ +package com.github.wxiaoqi.security.python; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.feign.EnableFeignClients; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +@SpringBootApplication +@EnableEurekaClient +@EnableDiscoveryClient +@EnableFeignClients +public class PythonServerBootstrap { + public static void main(String[] args) { + SpringApplication.run(PythonServerBootstrap.class, args); + } +} diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java new file mode 100644 index 00000000..ba5d3d63 --- /dev/null +++ b/ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java @@ -0,0 +1,23 @@ +package com.github.wxiaoqi.security.python.client; + +import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.web.bind.annotation.RequestMapping; +import com.github.wxiaoqi.security.python.entity.Message; +import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +@FeignClient(name = "ace-sidecar") +public interface PythonFeignClient { + //parse param like /message?id=12 + @RequestMapping("/message/{id}") + List getMsg(@RequestParam("id") Long id); + //parse url like /test + @RequestMapping("/test") + String getTest(); +} \ No newline at end of file diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java new file mode 100644 index 00000000..fe4f7d10 --- /dev/null +++ b/ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java @@ -0,0 +1,28 @@ +package com.github.wxiaoqi.security.python.entity; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +public class Message { + private Long id; + private String msg; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} \ No newline at end of file diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java new file mode 100644 index 00000000..d4e7e2b8 --- /dev/null +++ b/ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java @@ -0,0 +1,31 @@ +package com.github.wxiaoqi.security.python.rest; + +import com.github.wxiaoqi.security.python.entity.Message; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RestController; +import com.github.wxiaoqi.security.python.client.PythonFeignClient; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +@RestController +@RequestMapping("test") +public class PythonController { + @Autowired + private PythonFeignClient pythonFeignClient; + + @RequestMapping(value = "/test", method = RequestMethod.GET) + public String getTest() { + return pythonFeignClient.getTest(); + } + + @RequestMapping(value = "/message/{id}", method = RequestMethod.GET) + public List getMsg(@PathVariable Long id) { + return pythonFeignClient.getMsg(id); + } +} \ No newline at end of file diff --git a/ace-python/src/main/resources/application.yml b/ace-python/src/main/resources/application.yml index 00f0c43a..8aa217b8 100644 --- a/ace-python/src/main/resources/application.yml +++ b/ace-python/src/main/resources/application.yml @@ -1,10 +1,5 @@ server: - port: 5688 #启动端口 - -sidecar: - port: 5680 #python接口 - health: - uri: http://localhost:${sidecar.port}/health + port: 5689 #启动端口 spring: application: diff --git a/ace-sidercar/pom.xml b/ace-sidercar/pom.xml new file mode 100644 index 00000000..37e5fdf7 --- /dev/null +++ b/ace-sidercar/pom.xml @@ -0,0 +1,54 @@ + + + + ace-security + com.github.wxiaoqi + 1.0-SNAPSHOT + + 4.0.0 + + ace-sidercar + + + + org.springframework.cloud + spring-cloud-starter-config + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-netflix-sidecar + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-eureka + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/ace-sidercar/readme.md b/ace-sidercar/readme.md new file mode 100644 index 00000000..99eec489 --- /dev/null +++ b/ace-sidercar/readme.md @@ -0,0 +1,21 @@ +使用Sidercar代理远程Python服务,端口为Python的Web端口 +当然,换成Node的Web端口,即可代理Node的远程服务 +远程服务需要实现一个接口,返回 + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Node: +app.get('/health', (req, res) => { + res.json({ + status: 'UP' + }) +}) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Python: +class HealthHandler(tornado.web.RequestHandler): + def get(self): + self.set_header("content-type", "application/json") + self.render('health') + +health: +{"status":"UP"} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \ No newline at end of file diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java b/ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar/SidercarBootstrap.java similarity index 68% rename from ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java rename to ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar/SidercarBootstrap.java index 94380736..175d967b 100644 --- a/ace-python/src/main/java/com/github/wxiaoqi/security/config/PythonServerBootstrap.java +++ b/ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar/SidercarBootstrap.java @@ -1,15 +1,16 @@ -package com.github.wxiaoqi.security.config; +package com.github.wxiaoqi.security.sidercar; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.sidecar.EnableSidecar; + /** * Created by ace on 2017/7/29. */ @EnableSidecar @SpringBootApplication -public class PythonServerBootstrap { +public class SidercarBootstrap { public static void main(String[] args) { - SpringApplication.run(PythonServerBootstrap.class, args); + SpringApplication.run(SidercarBootstrap.class, args); } } diff --git a/ace-sidercar/src/main/resources/application.yml b/ace-sidercar/src/main/resources/application.yml new file mode 100644 index 00000000..4c273030 --- /dev/null +++ b/ace-sidercar/src/main/resources/application.yml @@ -0,0 +1,12 @@ +server: + port: 5688 #启动端口 + +sidecar: + port: 5680 #python接口 + health: + uri: http://localhost:${sidecar.port}/health + +spring: + application: + name: ace-sidercar + -- Gitee From 545ec25d6c590c3bc725a0442f2324a28a7489cb Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Sun, 22 Oct 2017 21:08:16 +0800 Subject: [PATCH 3/9] =?UTF-8?q?Sidercar=E4=BB=A3=E7=90=86Python=20Web?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=EF=BC=8C=E5=B9=B6=E8=B0=83=E7=94=A8=E4=B9=8B?= =?UTF-8?q?=E6=A1=88=E4=BE=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ace-python/readme.md | 6 ++++++ ace-sidercar/readme.md | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ace-python/readme.md b/ace-python/readme.md index d8779c0a..90da9114 100644 --- a/ace-python/readme.md +++ b/ace-python/readme.md @@ -17,6 +17,12 @@ https://gitee.com/superjery/tornado_boilerplate Python 安装 3.5 tornado 安装 4.5 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 运行python server.py即可启动Web +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +两种访问接口方式: +http://localhost:5689/ace-python/test/test +http://localhost:5689/ace-python/message/123 diff --git a/ace-sidercar/readme.md b/ace-sidercar/readme.md index 99eec489..943dc00c 100644 --- a/ace-sidercar/readme.md +++ b/ace-sidercar/readme.md @@ -18,4 +18,7 @@ class HealthHandler(tornado.web.RequestHandler): health: {"status":"UP"} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \ No newline at end of file +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +切记,通过此代理访问不到远程Python提供的服务, +需通过ace-python封装后才可访问到。 \ No newline at end of file -- Gitee From 108d615d65a19b1f6147106e28c097cfce6de0bd Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Mon, 23 Oct 2017 08:17:54 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Sidecar=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {ace-sidercar => ace-sidecar}/pom.xml | 0 {ace-sidercar => ace-sidecar}/readme.md | 2 +- .../com/github/wxiaoqi/security/sidecar}/SidercarBootstrap.java | 2 +- .../src/main/resources/application.yml | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename {ace-sidercar => ace-sidecar}/pom.xml (100%) rename {ace-sidercar => ace-sidecar}/readme.md (90%) rename {ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar => ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar}/SidercarBootstrap.java (89%) rename {ace-sidercar => ace-sidecar}/src/main/resources/application.yml (86%) diff --git a/ace-sidercar/pom.xml b/ace-sidecar/pom.xml similarity index 100% rename from ace-sidercar/pom.xml rename to ace-sidecar/pom.xml diff --git a/ace-sidercar/readme.md b/ace-sidecar/readme.md similarity index 90% rename from ace-sidercar/readme.md rename to ace-sidecar/readme.md index 943dc00c..785a7c83 100644 --- a/ace-sidercar/readme.md +++ b/ace-sidecar/readme.md @@ -1,4 +1,4 @@ -使用Sidercar代理远程Python服务,端口为Python的Web端口 +使用Sidecar代理远程Python服务,端口为Python的Web端口 当然,换成Node的Web端口,即可代理Node的远程服务 远程服务需要实现一个接口,返回 diff --git a/ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar/SidercarBootstrap.java b/ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java similarity index 89% rename from ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar/SidercarBootstrap.java rename to ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java index 175d967b..d99c807c 100644 --- a/ace-sidercar/src/main/java/com/github/wxiaoqi/security/sidercar/SidercarBootstrap.java +++ b/ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java @@ -1,4 +1,4 @@ -package com.github.wxiaoqi.security.sidercar; +package com.github.wxiaoqi.security.sidecar; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/ace-sidercar/src/main/resources/application.yml b/ace-sidecar/src/main/resources/application.yml similarity index 86% rename from ace-sidercar/src/main/resources/application.yml rename to ace-sidecar/src/main/resources/application.yml index 4c273030..3f3e3a6d 100644 --- a/ace-sidercar/src/main/resources/application.yml +++ b/ace-sidecar/src/main/resources/application.yml @@ -8,5 +8,5 @@ sidecar: spring: application: - name: ace-sidercar + name: ace-sidecar -- Gitee From f2e583e8c1dce2b53fc25975584772003abff057 Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Mon, 23 Oct 2017 09:23:39 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E8=B0=83=E6=95=B4Sidecar=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E5=88=86server=E4=B8=8Eclient=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=99=AE=E9=80=82=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ace-python/pom.xml | 61 ------------------- ace-python/readme.md | 28 --------- .../python/PythonServerBootstrap.java | 23 ------- .../python/client/PythonFeignClient.java | 23 ------- .../security/python/entity/Message.java | 28 --------- .../python/rest/PythonController.java | 31 ---------- ace-python/src/main/resources/application.yml | 7 --- ace-sidecar/pom.xml | 46 ++------------ ace-sidecar/readme.md | 24 -------- .../security/sidecar/SidercarBootstrap.java | 16 ----- .../src/main/resources/application.yml | 12 ---- pom.xml | 1 + 12 files changed, 7 insertions(+), 293 deletions(-) delete mode 100644 ace-python/pom.xml delete mode 100644 ace-python/readme.md delete mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java delete mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java delete mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java delete mode 100644 ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java delete mode 100644 ace-python/src/main/resources/application.yml delete mode 100644 ace-sidecar/readme.md delete mode 100644 ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java delete mode 100644 ace-sidecar/src/main/resources/application.yml diff --git a/ace-python/pom.xml b/ace-python/pom.xml deleted file mode 100644 index bf33ac21..00000000 --- a/ace-python/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - ace-security - com.github.wxiaoqi - 1.0-SNAPSHOT - - 4.0.0 - - ace-python - - - - org.springframework.cloud - spring-cloud-starter-config - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.cloud - spring-cloud-netflix-sidecar - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.cloud - spring-cloud-config-server - - - org.springframework.cloud - spring-cloud-starter-eureka - - - org.springframework.cloud - spring-cloud-starter-eureka - - - org.springframework.cloud - spring-cloud-starter-feign - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - \ No newline at end of file diff --git a/ace-python/readme.md b/ace-python/readme.md deleted file mode 100644 index 90da9114..00000000 --- a/ace-python/readme.md +++ /dev/null @@ -1,28 +0,0 @@ -Python服务端示例: -https://gitee.com/superjery/tornado_boilerplate - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -需以下根文件: - __init__.py - application.py - server.py - urls.py - -需以下根文件夹: - handlers - model - static - templates -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Python 安装 3.5 -tornado 安装 4.5 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -运行python server.py即可启动Web - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -两种访问接口方式: -http://localhost:5689/ace-python/test/test -http://localhost:5689/ace-python/message/123 diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java deleted file mode 100644 index fcd7ebc7..00000000 --- a/ace-python/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.github.wxiaoqi.security.python; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; - -/** - * ${DESCRIPTION} - * - * @author yangyongjie - * @create 2017-10-22 20:30 - */ -@SpringBootApplication -@EnableEurekaClient -@EnableDiscoveryClient -@EnableFeignClients -public class PythonServerBootstrap { - public static void main(String[] args) { - SpringApplication.run(PythonServerBootstrap.class, args); - } -} diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java deleted file mode 100644 index ba5d3d63..00000000 --- a/ace-python/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.github.wxiaoqi.security.python.client; - -import org.springframework.cloud.netflix.feign.FeignClient; -import org.springframework.web.bind.annotation.RequestMapping; -import com.github.wxiaoqi.security.python.entity.Message; -import org.springframework.web.bind.annotation.RequestParam; -import java.util.List; - -/** - * ${DESCRIPTION} - * - * @author yangyongjie - * @create 2017-10-22 20:30 - */ -@FeignClient(name = "ace-sidecar") -public interface PythonFeignClient { - //parse param like /message?id=12 - @RequestMapping("/message/{id}") - List getMsg(@RequestParam("id") Long id); - //parse url like /test - @RequestMapping("/test") - String getTest(); -} \ No newline at end of file diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java deleted file mode 100644 index fe4f7d10..00000000 --- a/ace-python/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.github.wxiaoqi.security.python.entity; - -/** - * ${DESCRIPTION} - * - * @author yangyongjie - * @create 2017-10-22 20:30 - */ -public class Message { - private Long id; - private String msg; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } -} \ No newline at end of file diff --git a/ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java b/ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java deleted file mode 100644 index d4e7e2b8..00000000 --- a/ace-python/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.github.wxiaoqi.security.python.rest; - -import com.github.wxiaoqi.security.python.entity.Message; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RestController; -import com.github.wxiaoqi.security.python.client.PythonFeignClient; -import org.springframework.web.bind.annotation.*; -import java.util.List; - -/** - * ${DESCRIPTION} - * - * @author yangyongjie - * @create 2017-10-22 20:30 - */ -@RestController -@RequestMapping("test") -public class PythonController { - @Autowired - private PythonFeignClient pythonFeignClient; - - @RequestMapping(value = "/test", method = RequestMethod.GET) - public String getTest() { - return pythonFeignClient.getTest(); - } - - @RequestMapping(value = "/message/{id}", method = RequestMethod.GET) - public List getMsg(@PathVariable Long id) { - return pythonFeignClient.getMsg(id); - } -} \ No newline at end of file diff --git a/ace-python/src/main/resources/application.yml b/ace-python/src/main/resources/application.yml deleted file mode 100644 index 8aa217b8..00000000 --- a/ace-python/src/main/resources/application.yml +++ /dev/null @@ -1,7 +0,0 @@ -server: - port: 5689 #启动端口 - -spring: - application: - name: ace-python - diff --git a/ace-sidecar/pom.xml b/ace-sidecar/pom.xml index 37e5fdf7..1dc3b077 100644 --- a/ace-sidecar/pom.xml +++ b/ace-sidecar/pom.xml @@ -9,46 +9,12 @@ 4.0.0 - ace-sidercar + ace-sidecar + pom - - - org.springframework.cloud - spring-cloud-starter-config - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.cloud - spring-cloud-netflix-sidecar - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.cloud - spring-cloud-config-server - - - org.springframework.cloud - spring-cloud-starter-eureka - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + ace-sidecar-server + ace-sidecar-client-demo + \ No newline at end of file diff --git a/ace-sidecar/readme.md b/ace-sidecar/readme.md deleted file mode 100644 index 785a7c83..00000000 --- a/ace-sidecar/readme.md +++ /dev/null @@ -1,24 +0,0 @@ -使用Sidecar代理远程Python服务,端口为Python的Web端口 -当然,换成Node的Web端口,即可代理Node的远程服务 -远程服务需要实现一个接口,返回 - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Node: -app.get('/health', (req, res) => { - res.json({ - status: 'UP' - }) -}) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Python: -class HealthHandler(tornado.web.RequestHandler): - def get(self): - self.set_header("content-type", "application/json") - self.render('health') - -health: -{"status":"UP"} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -切记,通过此代理访问不到远程Python提供的服务, -需通过ace-python封装后才可访问到。 \ No newline at end of file diff --git a/ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java b/ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java deleted file mode 100644 index d99c807c..00000000 --- a/ace-sidecar/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.github.wxiaoqi.security.sidecar; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.sidecar.EnableSidecar; - -/** - * Created by ace on 2017/7/29. - */ -@EnableSidecar -@SpringBootApplication -public class SidercarBootstrap { - public static void main(String[] args) { - SpringApplication.run(SidercarBootstrap.class, args); - } -} diff --git a/ace-sidecar/src/main/resources/application.yml b/ace-sidecar/src/main/resources/application.yml deleted file mode 100644 index 3f3e3a6d..00000000 --- a/ace-sidecar/src/main/resources/application.yml +++ /dev/null @@ -1,12 +0,0 @@ -server: - port: 5688 #启动端口 - -sidecar: - port: 5680 #python接口 - health: - uri: http://localhost:${sidecar.port}/health - -spring: - application: - name: ace-sidecar - diff --git a/pom.xml b/pom.xml index 44045495..2e1d5ec1 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ ace-config ace-generator ace-auth + ace-sidecar pom -- Gitee From 3e6885c1603a053c143f55a6edac9077edcd1a4b Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Mon, 23 Oct 2017 09:25:46 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E8=B0=83=E6=95=B4Sidecar=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E5=88=86server=E4=B8=8Eclient=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=99=AE=E9=80=82=E6=80=A7=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ace-sidecar/ace-sidecar-client-demo/pom.xml | 61 +++++++++++++++++++ ace-sidecar/ace-sidecar-client-demo/readme.md | 28 +++++++++ .../python/PythonServerBootstrap.java | 23 +++++++ .../python/client/PythonFeignClient.java | 23 +++++++ .../security/python/entity/Message.java | 28 +++++++++ .../python/rest/PythonController.java | 31 ++++++++++ .../src/main/resources/application.yml | 7 +++ ace-sidecar/ace-sidecar-server/pom.xml | 54 ++++++++++++++++ ace-sidecar/ace-sidecar-server/readme.md | 24 ++++++++ .../security/sidecar/SidercarBootstrap.java | 16 +++++ .../src/main/resources/application.yml | 12 ++++ 11 files changed, 307 insertions(+) create mode 100644 ace-sidecar/ace-sidecar-client-demo/pom.xml create mode 100644 ace-sidecar/ace-sidecar-client-demo/readme.md create mode 100644 ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java create mode 100644 ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java create mode 100644 ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java create mode 100644 ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java create mode 100644 ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml create mode 100644 ace-sidecar/ace-sidecar-server/pom.xml create mode 100644 ace-sidecar/ace-sidecar-server/readme.md create mode 100644 ace-sidecar/ace-sidecar-server/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java create mode 100644 ace-sidecar/ace-sidecar-server/src/main/resources/application.yml diff --git a/ace-sidecar/ace-sidecar-client-demo/pom.xml b/ace-sidecar/ace-sidecar-client-demo/pom.xml new file mode 100644 index 00000000..69a089d4 --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/pom.xml @@ -0,0 +1,61 @@ + + + + ace-python + com.github.wxiaoqi + 1.0-SNAPSHOT + + 4.0.0 + + ace-sidecar-client-demo + + + + org.springframework.cloud + spring-cloud-starter-config + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-netflix-sidecar + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-eureka + + + org.springframework.cloud + spring-cloud-starter-eureka + + + org.springframework.cloud + spring-cloud-starter-feign + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-client-demo/readme.md b/ace-sidecar/ace-sidecar-client-demo/readme.md new file mode 100644 index 00000000..90da9114 --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/readme.md @@ -0,0 +1,28 @@ +Python服务端示例: +https://gitee.com/superjery/tornado_boilerplate + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +需以下根文件: + __init__.py + application.py + server.py + urls.py + +需以下根文件夹: + handlers + model + static + templates +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Python 安装 3.5 +tornado 安装 4.5 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +运行python server.py即可启动Web + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +两种访问接口方式: +http://localhost:5689/ace-python/test/test +http://localhost:5689/ace-python/message/123 diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java new file mode 100644 index 00000000..fcd7ebc7 --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java @@ -0,0 +1,23 @@ +package com.github.wxiaoqi.security.python; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.feign.EnableFeignClients; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +@SpringBootApplication +@EnableEurekaClient +@EnableDiscoveryClient +@EnableFeignClients +public class PythonServerBootstrap { + public static void main(String[] args) { + SpringApplication.run(PythonServerBootstrap.class, args); + } +} diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java new file mode 100644 index 00000000..ba5d3d63 --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java @@ -0,0 +1,23 @@ +package com.github.wxiaoqi.security.python.client; + +import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.web.bind.annotation.RequestMapping; +import com.github.wxiaoqi.security.python.entity.Message; +import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +@FeignClient(name = "ace-sidecar") +public interface PythonFeignClient { + //parse param like /message?id=12 + @RequestMapping("/message/{id}") + List getMsg(@RequestParam("id") Long id); + //parse url like /test + @RequestMapping("/test") + String getTest(); +} \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java new file mode 100644 index 00000000..fe4f7d10 --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java @@ -0,0 +1,28 @@ +package com.github.wxiaoqi.security.python.entity; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +public class Message { + private Long id; + private String msg; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java new file mode 100644 index 00000000..d4e7e2b8 --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java @@ -0,0 +1,31 @@ +package com.github.wxiaoqi.security.python.rest; + +import com.github.wxiaoqi.security.python.entity.Message; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RestController; +import com.github.wxiaoqi.security.python.client.PythonFeignClient; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +@RestController +@RequestMapping("test") +public class PythonController { + @Autowired + private PythonFeignClient pythonFeignClient; + + @RequestMapping(value = "/test", method = RequestMethod.GET) + public String getTest() { + return pythonFeignClient.getTest(); + } + + @RequestMapping(value = "/message/{id}", method = RequestMethod.GET) + public List getMsg(@PathVariable Long id) { + return pythonFeignClient.getMsg(id); + } +} \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml b/ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml new file mode 100644 index 00000000..dace32dd --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml @@ -0,0 +1,7 @@ +server: + port: 5689 #启动端口 + +spring: + application: + name: ace-sidecar-client-demo + diff --git a/ace-sidecar/ace-sidecar-server/pom.xml b/ace-sidecar/ace-sidecar-server/pom.xml new file mode 100644 index 00000000..dce413a3 --- /dev/null +++ b/ace-sidecar/ace-sidecar-server/pom.xml @@ -0,0 +1,54 @@ + + + + ace-sidecar + com.github.wxiaoqi + 1.0-SNAPSHOT + + 4.0.0 + + ace-sidecar-server + + + + org.springframework.cloud + spring-cloud-starter-config + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-netflix-sidecar + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-eureka + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-server/readme.md b/ace-sidecar/ace-sidecar-server/readme.md new file mode 100644 index 00000000..785a7c83 --- /dev/null +++ b/ace-sidecar/ace-sidecar-server/readme.md @@ -0,0 +1,24 @@ +使用Sidecar代理远程Python服务,端口为Python的Web端口 +当然,换成Node的Web端口,即可代理Node的远程服务 +远程服务需要实现一个接口,返回 + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Node: +app.get('/health', (req, res) => { + res.json({ + status: 'UP' + }) +}) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Python: +class HealthHandler(tornado.web.RequestHandler): + def get(self): + self.set_header("content-type", "application/json") + self.render('health') + +health: +{"status":"UP"} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +切记,通过此代理访问不到远程Python提供的服务, +需通过ace-python封装后才可访问到。 \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-server/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java b/ace-sidecar/ace-sidecar-server/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java new file mode 100644 index 00000000..d99c807c --- /dev/null +++ b/ace-sidecar/ace-sidecar-server/src/main/java/com/github/wxiaoqi/security/sidecar/SidercarBootstrap.java @@ -0,0 +1,16 @@ +package com.github.wxiaoqi.security.sidecar; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.sidecar.EnableSidecar; + +/** + * Created by ace on 2017/7/29. + */ +@EnableSidecar +@SpringBootApplication +public class SidercarBootstrap { + public static void main(String[] args) { + SpringApplication.run(SidercarBootstrap.class, args); + } +} diff --git a/ace-sidecar/ace-sidecar-server/src/main/resources/application.yml b/ace-sidecar/ace-sidecar-server/src/main/resources/application.yml new file mode 100644 index 00000000..fc793e7b --- /dev/null +++ b/ace-sidecar/ace-sidecar-server/src/main/resources/application.yml @@ -0,0 +1,12 @@ +server: + port: 5688 #启动端口 + +sidecar: + port: 5680 #python接口 + health: + uri: http://localhost:${sidecar.port}/health + +spring: + application: + name: ace-sidecar-server + -- Gitee From 3f654a7200d22181a48ba601f908edf95c9b59ad Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Mon, 23 Oct 2017 09:44:27 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E8=B0=83=E6=95=B4Sidecar=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E5=88=86server=E4=B8=8Eclient=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=99=AE=E9=80=82=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ace-sidecar/ace-sidecar-client-demo/readme.md | 4 ++-- .../PythonServerBootstrap.java | 2 +- .../sidecarclient/client/NodeFeignClient.java | 23 +++++++++++++++++++ .../client/PythonFeignClient.java | 6 ++--- .../entity/Message.java | 2 +- .../rest/PythonController.java | 6 ++--- ace-sidecar/ace-sidecar-server/readme.md | 2 +- 7 files changed, 34 insertions(+), 11 deletions(-) rename ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/{python => sidecarclient}/PythonServerBootstrap.java (92%) create mode 100644 ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java rename ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/{python => sidecarclient}/client/PythonFeignClient.java (76%) rename ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/{python => sidecarclient}/entity/Message.java (86%) rename ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/{python => sidecarclient}/rest/PythonController.java (79%) diff --git a/ace-sidecar/ace-sidecar-client-demo/readme.md b/ace-sidecar/ace-sidecar-client-demo/readme.md index 90da9114..19fe23e7 100644 --- a/ace-sidecar/ace-sidecar-client-demo/readme.md +++ b/ace-sidecar/ace-sidecar-client-demo/readme.md @@ -24,5 +24,5 @@ tornado 安装 4.5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 两种访问接口方式: -http://localhost:5689/ace-python/test/test -http://localhost:5689/ace-python/message/123 +http://localhost:5689/ace-sidecar-client-demo/test/test +http://localhost:5689/ace-sidecar-client-demo/message/123 diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/PythonServerBootstrap.java similarity index 92% rename from ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java rename to ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/PythonServerBootstrap.java index fcd7ebc7..d5e5e038 100644 --- a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/PythonServerBootstrap.java +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/PythonServerBootstrap.java @@ -1,4 +1,4 @@ -package com.github.wxiaoqi.security.python; +package com.github.wxiaoqi.security.sidecarclient; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java new file mode 100644 index 00000000..b1919fd9 --- /dev/null +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java @@ -0,0 +1,23 @@ +package com.github.wxiaoqi.security.sidecarclient.client; + +import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.web.bind.annotation.RequestMapping; +import com.github.wxiaoqi.security.sidecarclient.entity.Message; +import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + +/** + * ${DESCRIPTION} + * + * @author yangyongjie + * @create 2017-10-22 20:30 + */ +@FeignClient(name = "ace-sidecar-server") +public interface NodeFeignClient { + //parse param like /message?id=12 + @RequestMapping("/message/{id}") + List getMsg(@RequestParam("id") Long id); + //parse url like /test + @RequestMapping("/test") + String getTest(); +} \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/PythonFeignClient.java similarity index 76% rename from ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java rename to ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/PythonFeignClient.java index ba5d3d63..d2741137 100644 --- a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/client/PythonFeignClient.java +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/PythonFeignClient.java @@ -1,8 +1,8 @@ -package com.github.wxiaoqi.security.python.client; +package com.github.wxiaoqi.security.sidecarclient.client; import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.web.bind.annotation.RequestMapping; -import com.github.wxiaoqi.security.python.entity.Message; +import com.github.wxiaoqi.security.sidecarclient.entity.Message; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -12,7 +12,7 @@ import java.util.List; * @author yangyongjie * @create 2017-10-22 20:30 */ -@FeignClient(name = "ace-sidecar") +@FeignClient(name = "ace-sidecar-server") public interface PythonFeignClient { //parse param like /message?id=12 @RequestMapping("/message/{id}") diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/entity/Message.java similarity index 86% rename from ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java rename to ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/entity/Message.java index fe4f7d10..6871e0cb 100644 --- a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/entity/Message.java +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/entity/Message.java @@ -1,4 +1,4 @@ -package com.github.wxiaoqi.security.python.entity; +package com.github.wxiaoqi.security.sidecarclient.entity; /** * ${DESCRIPTION} diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/rest/PythonController.java similarity index 79% rename from ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java rename to ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/rest/PythonController.java index d4e7e2b8..8cf4670c 100644 --- a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/python/rest/PythonController.java +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/rest/PythonController.java @@ -1,9 +1,9 @@ -package com.github.wxiaoqi.security.python.rest; +package com.github.wxiaoqi.security.sidecarclient.rest; -import com.github.wxiaoqi.security.python.entity.Message; +import com.github.wxiaoqi.security.sidecarclient.entity.Message; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RestController; -import com.github.wxiaoqi.security.python.client.PythonFeignClient; +import com.github.wxiaoqi.security.sidecarclient.client.PythonFeignClient; import org.springframework.web.bind.annotation.*; import java.util.List; diff --git a/ace-sidecar/ace-sidecar-server/readme.md b/ace-sidecar/ace-sidecar-server/readme.md index 785a7c83..682a7b9f 100644 --- a/ace-sidecar/ace-sidecar-server/readme.md +++ b/ace-sidecar/ace-sidecar-server/readme.md @@ -21,4 +21,4 @@ health: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 切记,通过此代理访问不到远程Python提供的服务, -需通过ace-python封装后才可访问到。 \ No newline at end of file +需通过ace-sidecar-client-demo封装后才可访问到。 \ No newline at end of file -- Gitee From 4bc7ed44d23f48f708177870a4855c893c7f16ec Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Mon, 23 Oct 2017 10:07:45 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E8=B0=83=E6=95=B4Sidecar=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E5=88=86server=E4=B8=8Eclient=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=99=AE=E9=80=82=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ace-sidecar/ace-sidecar-client-demo/pom.xml | 2 +- .../src/main/resources/application.yml | 7 +++++++ .../src/main/resources/application.yml | 15 +++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ace-sidecar/ace-sidecar-client-demo/pom.xml b/ace-sidecar/ace-sidecar-client-demo/pom.xml index 69a089d4..002d6c8f 100644 --- a/ace-sidecar/ace-sidecar-client-demo/pom.xml +++ b/ace-sidecar/ace-sidecar-client-demo/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - ace-python + ace-sidecar com.github.wxiaoqi 1.0-SNAPSHOT diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml b/ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml index dace32dd..ed9ab188 100644 --- a/ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml +++ b/ace-sidecar/ace-sidecar-client-demo/src/main/resources/application.yml @@ -5,3 +5,10 @@ spring: application: name: ace-sidecar-client-demo +eureka: + instance: + statusPageUrlPath: /info + healthCheckUrlPath: /health + client: + serviceUrl: + defaultZone: http://localhost:8761/eureka/ \ No newline at end of file diff --git a/ace-sidecar/ace-sidecar-server/src/main/resources/application.yml b/ace-sidecar/ace-sidecar-server/src/main/resources/application.yml index fc793e7b..e8deaad1 100644 --- a/ace-sidecar/ace-sidecar-server/src/main/resources/application.yml +++ b/ace-sidecar/ace-sidecar-server/src/main/resources/application.yml @@ -1,12 +1,19 @@ server: port: 5688 #启动端口 +spring: + application: + name: ace-sidecar-server + sidecar: port: 5680 #python接口 health: uri: http://localhost:${sidecar.port}/health -spring: - application: - name: ace-sidecar-server - +eureka: + instance: + statusPageUrlPath: /info + healthCheckUrlPath: /health + client: + serviceUrl: + defaultZone: http://localhost:8761/eureka/ \ No newline at end of file -- Gitee From a0ee9b950ba2cd91ba3f9ddeaaa2c88ce30b3684 Mon Sep 17 00:00:00 2001 From: superjery <9322512@qq.com> Date: Mon, 23 Oct 2017 10:35:15 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E6=96=B0=E5=A2=9Esidecar=E5=88=86=E6=94=AF?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81Node=E3=80=81Python=E3=80=81PHP?= =?UTF-8?q?=E7=AD=89=E7=AC=AC=E4=B8=89=E6=96=B9=E6=9C=8D=E5=8A=A1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidecarclient/client/NodeFeignClient.java | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java diff --git a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java b/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java deleted file mode 100644 index b1919fd9..00000000 --- a/ace-sidecar/ace-sidecar-client-demo/src/main/java/com/github/wxiaoqi/security/sidecarclient/client/NodeFeignClient.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.github.wxiaoqi.security.sidecarclient.client; - -import org.springframework.cloud.netflix.feign.FeignClient; -import org.springframework.web.bind.annotation.RequestMapping; -import com.github.wxiaoqi.security.sidecarclient.entity.Message; -import org.springframework.web.bind.annotation.RequestParam; -import java.util.List; - -/** - * ${DESCRIPTION} - * - * @author yangyongjie - * @create 2017-10-22 20:30 - */ -@FeignClient(name = "ace-sidecar-server") -public interface NodeFeignClient { - //parse param like /message?id=12 - @RequestMapping("/message/{id}") - List getMsg(@RequestParam("id") Long id); - //parse url like /test - @RequestMapping("/test") - String getTest(); -} \ No newline at end of file -- Gitee