├── .gitattributes
├── .github
├── stale.yml
└── workflows
│ └── maven.yml
├── .gitignore
├── LICENSE
├── README.md
├── discovery-guide-console
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── nepxion
│ │ └── discovery
│ │ └── guide
│ │ └── console
│ │ └── DiscoveryGuideConsole.java
│ └── resources
│ ├── bootstrap.properties
│ └── logback.xml
├── discovery-guide-gateway
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── nepxion
│ │ └── discovery
│ │ └── guide
│ │ └── gateway
│ │ └── DiscoveryGuideGateway.java
│ └── resources
│ ├── bootstrap.properties
│ └── logback.xml
├── discovery-guide-service
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── nepxion
│ │ └── discovery
│ │ └── guide
│ │ └── service
│ │ ├── DiscoveryGuideServiceA1.java
│ │ ├── DiscoveryGuideServiceA2.java
│ │ ├── DiscoveryGuideServiceB1.java
│ │ ├── DiscoveryGuideServiceB2.java
│ │ ├── core
│ │ └── CoreImpl.java
│ │ ├── feign
│ │ ├── AFeign.java
│ │ ├── AFeignImpl.java
│ │ ├── BFeign.java
│ │ └── BFeignImpl.java
│ │ └── rest
│ │ ├── ARestImpl.java
│ │ └── BRestImpl.java
│ └── resources
│ ├── application-a1.properties
│ ├── application-a2.properties
│ ├── application-b1.properties
│ ├── application-b2.properties
│ ├── bootstrap.properties
│ └── logback.xml
├── discovery-guide-zuul
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── nepxion
│ │ └── discovery
│ │ └── guide
│ │ └── zuul
│ │ └── DiscoveryGuideZuul.java
│ └── resources
│ ├── bootstrap.properties
│ └── logback.xml
├── pmd.xml
├── pom.xml
└── postman.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Declare files that will always have UNIX line endings on checkout.
2 | *.sh text eol=lf
--------------------------------------------------------------------------------
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # General configuration
2 | # Number of days of inactivity before an issue becomes stale
3 | daysUntilStale: 60
4 | # Issues with these labels will never be considered stale
5 | exemptLabels:
6 | - good first issue
7 | - contribution welcome
8 | - bug
9 | - discussion
10 | - enhancement
11 | - feature
12 | - feature request
13 | - help wanted
14 | - info
15 | - need investigation
16 | - tips
17 |
18 | # Set to true to ignore issues in a project (defaults to false)
19 | exemptProjects: true
20 | # Set to true to ignore issues in a milestone (defaults to false)
21 | exemptMilestones: true
22 | # Set to true to ignore issues with an assignee (defaults to false)
23 | exemptAssignees: true
24 | # Label to use when marking an issue as stale
25 | staleLabel: stale
26 |
27 | # Pull request specific configuration
28 | pulls:
29 | # Number of days of inactivity before a stale Issue or Pull Request is closed.
30 | # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
31 | daysUntilClose: 30
32 | # Comment to post when marking as stale. Set to `false` to disable
33 | markComment: >
34 | This pull request has been automatically marked as stale because it has not had activity
35 | in the last 90 days. It will be closed in 30 days if no further activity occurs. Please
36 | feel free to give a status update now, ping for review, or re-open when it's ready.
37 | Thank you for your contributions!
38 | # Comment to post when closing a stale Issue or Pull Request.
39 | closeComment: >
40 | This pull request has been automatically closed because it has not had
41 | activity in the last 30 days. Please feel free to give a status update now, ping for review, or re-open when it's ready.
42 | Thank you for your contributions!
43 | # Limit the number of actions per hour, from 1-30. Default is 30
44 | limitPerRun: 1
45 |
46 | # Issue specific configuration
47 | issues:
48 | # Number of days of inactivity before a stale Issue or Pull Request is closed.
49 | daysUntilClose: 14
50 | # Comment to post when marking as stale. Set to `false` to disable
51 | markComment: >
52 | This issue has been automatically marked as stale because it has not had activity in the
53 | last 90 days. It will be closed in 14 days unless it is tagged "help wanted" or other activity
54 | occurs. Thank you for your contributions.
55 | # Comment to post when closing a stale Issue or Pull Request.
56 | closeComment: >
57 | This issue has been automatically closed because it has not had activity in the
58 | last 14 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted".
59 | Thank you for your contributions.
60 | # Limit the number of actions per hour, from 1-30. Default is 30
61 | limitPerRun: 1
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: build
5 |
6 | on:
7 | push:
8 | branches: [ 6.x.x-simple ]
9 | pull_request:
10 | branches: [ 6.x.x-simple ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK 8
20 | uses: actions/setup-java@v2
21 | with:
22 | java-version: '8'
23 | distribution: 'adopt'
24 | - name: Build with Maven
25 | run: mvn -B package --file pom.xml
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 | .classpath
4 | .springBeans
5 | .factorypath
6 | # Mobile Tools for Java (J2ME)
7 | .mtj.tmp/
8 |
9 | *.class
10 | *.classpath
11 | *.project
12 | *.springBeans
13 | bin/
14 | log/
15 | test-output/
16 |
17 | # Package Files #
18 | *.jar
19 | *.war
20 | *.ear
21 | *.zip
22 | *.tar.gz
23 | *.rar
24 | *.swp
25 | *.log
26 | *.ctxt
27 | # nodejs local modules
28 | .tags*
29 | .idea/
30 | *.iml
31 | .gradle/
32 | .settings/
33 | target/
34 | hs_err_pid*
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Discovery【探索】云原生微服务解决方案
4 |  [](https://github.com/Nepxion/Discovery/blob/6.x.x/LICENSE) [](https://search.maven.org/artifact/com.nepxion/discovery) [](http://www.javadoc.io/doc/com.nepxion/discovery-plugin-framework-starter) [](https://github.com/Nepxion/Discovery/actions) [](https://www.codacy.com/gh/Nepxion/Discovery/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Nepxion/Discovery&utm_campaign=Badge_Grade) [](https://github.com/Nepxion/Discovery/stargazers) [](https://gitee.com/Nepxion/Discovery/stargazers)
5 |
6 | [](https://github.com/Nepxion/Discovery/wiki) [](https://gitee.com/nepxion/Discovery/wikis/pages?sort_id=3993615&doc_id=1124387) [](https://nepxion.github.io/Discovery/docs/link-doc/discovery-ppt.html) [](https://nepxion.github.io/Discovery/) [](https://nepxion.github.io/DiscoveryPlatform) [](https://nepxion.github.io/DiscoveryDesktop) [](https://polaris-paas.github.io/polaris-wiki)
7 |
8 |
9 |
10 | 如果您觉得本框架具有一定的参考价值和借鉴意义,请帮忙在页面右上角 [**Star**]
11 |
12 | ## 入门必读
13 | 本文只介绍入门Discovery【探索】最基础的功能和用法,更多资料请参考相关文档
14 |
15 | ### 快速上手
16 | [如何快速搭建和运行示例](https://github.com/Nepxion/Discovery/wiki/如何快速搭建和运行示例)
17 |
18 | ### 解决方案
19 | 配置较简单,灵活性不强,适用于DevOps运维能力较弱的公司
20 | [如何执行全链路简单蓝绿发布](https://github.com/Nepxion/Discovery/wiki/如何执行全链路简单蓝绿发布)
21 | [如何执行全链路简单灰度发布](https://github.com/Nepxion/Discovery/wiki/如何执行全链路简单灰度发布)
22 | 配置较复杂,灵活性较强,适用于DevOps运维能力较弱的公司
23 | [如何执行全链路高级蓝绿发布](https://github.com/Nepxion/Discovery/wiki/如何执行全链路高级蓝绿发布)
24 | [如何执行全链路高级灰度发布](https://github.com/Nepxion/Discovery/wiki/如何执行全链路高级灰度发布)
25 | 配置很简单,灵活性较弱,适用于DevOps运维能力较弱的公司
26 | [如何执行全链路无编排高级蓝绿灰度发布](https://github.com/Nepxion/Discovery/wiki/如何执行全链路无编排高级蓝绿灰度发布)
27 | 界面驱动,配置很简单,灵活性很强,流程化管理,落地成本较高,需自行研发界面整合到DevOps运维系统中,适用于DevOps运维能力较强的公司
28 | [如何执行全链路智能编排高级蓝绿灰度发布](https://github.com/Nepxion/Discovery/wiki/如何执行全链路智能编排高级蓝绿灰度发布)
29 | [如何设计全链路智能编排高级蓝绿灰度发布界面](https://github.com/Nepxion/Discovery/wiki/如何设计全链路智能编排高级蓝绿灰度发布界面)
30 |
31 | ### 快速集成
32 | [如何快速集成框架](https://github.com/Nepxion/Discovery/wiki/如何快速集成框架)
33 |
34 | ### 流量染色
35 | 通过增加启动参数`-Dmetadata.version=1.0`进行染色
36 | [如何设置元数据标签](https://github.com/Nepxion/Discovery/wiki/如何设置元数据标签)
37 | 通过`git-commit-id-plugin`插件代替启动参数进行染色
38 | [如何基于Git插件自动创建版本号](https://github.com/Nepxion/Discovery/wiki/如何基于Git插件自动创建版本号)
39 | 通过截取统一规范的服务名前缀进行组染色
40 | [如何基于服务名前缀自动创建组名](https://github.com/Nepxion/Discovery/wiki/如何基于服务名前缀自动创建组名)
41 |
42 | ### 故障定位
43 | 开启Debug模式,通过增加启动参数`-Dstrategy.debug=true`启动所有的网关和服务
44 | [如何解决蓝绿灰度发布失效问题](https://github.com/Nepxion/Discovery/wiki/如何解决蓝绿灰度发布失效问题)
45 |
46 | ### 异步探针
47 | 开启异步探针,通过增加启动参数`-javaagent:C:/opt/discovery-agent/discovery-agent-starter-1.3.0.jar`启动所有的网关和服务,`C:/opt`需要变更为具体使用场景下的目录。Spring Cloud 2020及以上版本必须引入异步探针
48 | [如何在异步场景下使用探针Agent](https://github.com/Nepxion/Discovery/wiki/如何在异步场景下使用探针Agent)
49 |
50 | ### 自动化测试
51 | 开发环境和测试环境下的全方位自动化测试
52 | [如何执行全链路自动化模拟流程测试](https://github.com/Nepxion/Discovery/wiki/如何执行全链路自动化模拟流程测试)
53 | 生产环境下的自动化测试
54 | [如何执行全链路自动化流量侦测测试](https://github.com/Nepxion/Discovery/wiki/如何执行全链路自动化流量侦测测试)
55 |
56 | ## 请联系我
57 | 微信、钉钉、公众号和文档
58 |
59 | 
60 |
61 | ## Star走势图
62 | [](https://starchart.cc/Nepxion/Discovery)
--------------------------------------------------------------------------------
/discovery-guide-console/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.boot.builder.SpringApplicationBuilder; 14 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 15 | 16 | @SpringBootApplication 17 | @EnableDiscoveryClient 18 | public class DiscoveryGuideConsole { 19 | public static void main(String[] args) { 20 | new SpringApplicationBuilder(DiscoveryGuideConsole.class).run(args); 21 | } 22 | } -------------------------------------------------------------------------------- /discovery-guide-console/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | # Spring cloud config 2 | spring.application.name=discovery-guide-console 3 | server.port=6001 4 | 5 | # Nacos config for discovery 6 | spring.cloud.nacos.discovery.server-addr=localhost:8848 7 | 8 | # Nacos config for rule 9 | spring.cloud.nacos.config.server-addr=localhost:8848 10 | 11 | # Ribbon config 12 | ribbon.ServerListRefreshInterval=5000 13 | ribbon.ConnectTimeout=60000 14 | ribbon.ReadTimeout=60000 15 | ribbon.maxAutoRetries=3 16 | ribbon.maxAutoRetriesNextServer=3 17 | ribbon.okToRetryOnAllOperations=true 18 | 19 | # 精简教程,请访问 20 | # https://github.com/Nepxion/Discovery/wiki 21 | # https://gitee.com/nepxion/Discovery/wikis 22 | # 详细教程,请访问 23 | # http://nepxion.com/discovery/ 24 | -------------------------------------------------------------------------------- /discovery-guide-console/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 |Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.boot.builder.SpringApplicationBuilder; 14 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 15 | 16 | @SpringBootApplication 17 | @EnableDiscoveryClient 18 | public class DiscoveryGuideGateway { 19 | public static void main(String[] args) { 20 | new SpringApplicationBuilder(DiscoveryGuideGateway.class).run(args); 21 | } 22 | } -------------------------------------------------------------------------------- /discovery-guide-gateway/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | # Spring cloud config 2 | spring.application.name=discovery-guide-gateway 3 | server.port=5001 4 | 5 | # Nacos config for discovery 6 | spring.cloud.nacos.discovery.server-addr=localhost:8848 7 | 8 | # Nacos config for rule 9 | spring.cloud.nacos.config.server-addr=localhost:8848 10 | 11 | # Spring cloud discovery metadata config 12 | spring.cloud.discovery.metadata.group=discovery-guide-group 13 | 14 | # Nepxion discovery config 15 | # 当外界传值Header的时候,网关也设置并传递同名的Header,需要决定哪个Header传递到后边的服务去。如果下面开关为true,以网关设置为优先,否则以外界传值为优先。缺失则默认为true 16 | spring.application.strategy.gateway.header.priority=false 17 | # 当以网关设置为优先的时候,网关未配置Header,而外界配置了Header,仍旧忽略外界的Header。缺失则默认为true 18 | # spring.application.strategy.gateway.original.header.ignored=true 19 | # 开启和关闭网关订阅配置中心的动态路由策略。缺失则默认为false 20 | spring.application.strategy.gateway.dynamic.route.enabled=true 21 | 22 | # Ribbon config 23 | ribbon.ServerListRefreshInterval=5000 24 | ribbon.ConnectTimeout=60000 25 | ribbon.ReadTimeout=60000 26 | ribbon.maxAutoRetries=3 27 | ribbon.maxAutoRetriesNextServer=3 28 | ribbon.okToRetryOnAllOperations=true 29 | 30 | # Spring cloud gateway config 31 | # 手工配置路由 32 | spring.cloud.gateway.routes[0].id=route0 33 | spring.cloud.gateway.routes[0].predicates[0]=Path=/discovery-guide-service-a/** 34 | spring.cloud.gateway.routes[0].filters[0]=StripPrefix=1 35 | spring.cloud.gateway.routes[0].uri=lb://discovery-guide-service-a 36 | 37 | # 注册发现自动路由 38 | # 开启和关闭自动路由。缺失则默认关闭自动路由 39 | # spring.cloud.gateway.discovery.locator.enabled=true 40 | # 当启动自动路由(locator.enabled=true)时候,必须关闭reactive模式,否则无法执行蓝绿灰度发布。只有H版需要该配置 41 | # spring.cloud.discovery.reactive.enabled=false 42 | 43 | # 精简教程,请访问 44 | # https://github.com/Nepxion/Discovery/wiki 45 | # https://gitee.com/nepxion/Discovery/wikis 46 | # 详细教程,请访问 47 | # http://nepxion.com/discovery/ 48 | -------------------------------------------------------------------------------- /discovery-guide-gateway/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 |Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.boot.builder.SpringApplicationBuilder; 14 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 15 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 16 | import org.springframework.cloud.openfeign.EnableFeignClients; 17 | import org.springframework.context.annotation.Bean; 18 | import org.springframework.web.client.RestTemplate; 19 | 20 | @SpringBootApplication 21 | @EnableDiscoveryClient 22 | @EnableFeignClients 23 | public class DiscoveryGuideServiceA1 { 24 | public static void main(String[] args) { 25 | System.setProperty("spring.profiles.active", "a1"); 26 | 27 | new SpringApplicationBuilder(DiscoveryGuideServiceA1.class).run(args); 28 | } 29 | 30 | @Bean 31 | @LoadBalanced 32 | public RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/DiscoveryGuideServiceA2.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.boot.builder.SpringApplicationBuilder; 14 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 15 | import org.springframework.cloud.openfeign.EnableFeignClients; 16 | 17 | @SpringBootApplication 18 | @EnableDiscoveryClient 19 | @EnableFeignClients 20 | public class DiscoveryGuideServiceA2 { 21 | public static void main(String[] args) { 22 | System.setProperty("spring.profiles.active", "a2"); 23 | 24 | new SpringApplicationBuilder(DiscoveryGuideServiceA2.class).run(args); 25 | } 26 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/DiscoveryGuideServiceB1.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.boot.builder.SpringApplicationBuilder; 14 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 15 | import org.springframework.cloud.openfeign.EnableFeignClients; 16 | 17 | @SpringBootApplication 18 | @EnableDiscoveryClient 19 | @EnableFeignClients 20 | public class DiscoveryGuideServiceB1 { 21 | public static void main(String[] args) { 22 | System.setProperty("spring.profiles.active", "b1"); 23 | 24 | new SpringApplicationBuilder(DiscoveryGuideServiceB1.class).run(args); 25 | } 26 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/DiscoveryGuideServiceB2.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.boot.builder.SpringApplicationBuilder; 14 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 15 | import org.springframework.cloud.openfeign.EnableFeignClients; 16 | 17 | @SpringBootApplication 18 | @EnableDiscoveryClient 19 | @EnableFeignClients 20 | public class DiscoveryGuideServiceB2 { 21 | public static void main(String[] args) { 22 | System.setProperty("spring.profiles.active", "b2"); 23 | 24 | new SpringApplicationBuilder(DiscoveryGuideServiceB2.class).run(args); 25 | } 26 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/core/CoreImpl.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service.core; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | 14 | import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter; 15 | 16 | public class CoreImpl { 17 | @Autowired 18 | private PluginAdapter pluginAdapter; 19 | 20 | public String getPluginInfo(String value) { 21 | return pluginAdapter.getPluginInfo(value); 22 | } 23 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/feign/AFeign.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service.feign; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.cloud.openfeign.FeignClient; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.PathVariable; 15 | 16 | @FeignClient(value = "discovery-guide-service-a") 17 | public interface AFeign { 18 | @GetMapping(path = "/invoke/{value}") 19 | String invoke(@PathVariable(value = "value") String value); 20 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/feign/AFeignImpl.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service.feign; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.nepxion.discovery.common.constant.DiscoveryConstant; 20 | import com.nepxion.discovery.guide.service.core.CoreImpl; 21 | 22 | @RestController 23 | @ConditionalOnProperty(name = DiscoveryConstant.SPRING_APPLICATION_NAME, havingValue = "discovery-guide-service-a") 24 | public class AFeignImpl extends CoreImpl implements AFeign { 25 | private static final Logger LOG = LoggerFactory.getLogger(AFeignImpl.class); 26 | 27 | @Autowired 28 | private BFeign bFeign; 29 | 30 | @Override 31 | public String invoke(@PathVariable(value = "value") String value) { 32 | value = getPluginInfo(value); 33 | value = bFeign.invoke(value); 34 | 35 | LOG.info("调用路径:{}", value); 36 | 37 | return value; 38 | } 39 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/feign/BFeign.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service.feign; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.cloud.openfeign.FeignClient; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.PathVariable; 15 | 16 | @FeignClient(value = "discovery-guide-service-b") 17 | public interface BFeign { 18 | @GetMapping(path = "/invoke/{value}") 19 | String invoke(@PathVariable(value = "value") String value); 20 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/feign/BFeignImpl.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service.feign; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 15 | import org.springframework.web.bind.annotation.PathVariable; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.nepxion.discovery.common.constant.DiscoveryConstant; 19 | import com.nepxion.discovery.guide.service.core.CoreImpl; 20 | 21 | @RestController 22 | @ConditionalOnProperty(name = DiscoveryConstant.SPRING_APPLICATION_NAME, havingValue = "discovery-guide-service-b") 23 | public class BFeignImpl extends CoreImpl implements BFeign { 24 | private static final Logger LOG = LoggerFactory.getLogger(BFeignImpl.class); 25 | 26 | @Override 27 | public String invoke(@PathVariable(value = "value") String value) { 28 | value = getPluginInfo(value); 29 | 30 | LOG.info("调用路径:{}", value); 31 | 32 | return value; 33 | } 34 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/rest/ARestImpl.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service.rest; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 16 | import org.springframework.web.bind.annotation.GetMapping; 17 | import org.springframework.web.bind.annotation.PathVariable; 18 | import org.springframework.web.bind.annotation.RestController; 19 | import org.springframework.web.client.RestTemplate; 20 | 21 | import com.nepxion.discovery.common.constant.DiscoveryConstant; 22 | import com.nepxion.discovery.guide.service.core.CoreImpl; 23 | 24 | @RestController 25 | @ConditionalOnProperty(name = DiscoveryConstant.SPRING_APPLICATION_NAME, havingValue = "discovery-guide-service-a") 26 | public class ARestImpl extends CoreImpl { 27 | private static final Logger LOG = LoggerFactory.getLogger(ARestImpl.class); 28 | 29 | @Autowired 30 | private RestTemplate restTemplate; 31 | 32 | @GetMapping(path = "/rest/{value}") 33 | public String rest(@PathVariable(value = "value") String value) { 34 | value = getPluginInfo(value); 35 | value = restTemplate.getForEntity("http://discovery-guide-service-b/rest/" + value, String.class).getBody(); 36 | 37 | LOG.info("调用路径:{}", value); 38 | 39 | return value; 40 | } 41 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/java/com/nepxion/discovery/guide/service/rest/BRestImpl.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.discovery.guide.service.rest; 2 | 3 | /** 4 | *Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.nepxion.discovery.common.constant.DiscoveryConstant; 20 | import com.nepxion.discovery.guide.service.core.CoreImpl; 21 | 22 | @RestController 23 | @ConditionalOnProperty(name = DiscoveryConstant.SPRING_APPLICATION_NAME, havingValue = "discovery-guide-service-b") 24 | public class BRestImpl extends CoreImpl { 25 | private static final Logger LOG = LoggerFactory.getLogger(BRestImpl.class); 26 | 27 | @GetMapping(path = "/rest/{value}") 28 | public String rest(@PathVariable(value = "value") String value) { 29 | value = getPluginInfo(value); 30 | 31 | LOG.info("调用路径:{}", value); 32 | 33 | return value; 34 | } 35 | } -------------------------------------------------------------------------------- /discovery-guide-service/src/main/resources/application-a1.properties: -------------------------------------------------------------------------------- 1 | # Spring cloud config 2 | spring.application.name=discovery-guide-service-a 3 | server.port=3001 4 | 5 | # Spring cloud discovery metadata config 6 | spring.cloud.discovery.metadata.group=discovery-guide-group 7 | spring.cloud.discovery.metadata.version=1.0 8 | spring.cloud.discovery.metadata.region=dev 9 | spring.cloud.discovery.metadata.env=env1 10 | spring.cloud.discovery.metadata.zone=zone1 -------------------------------------------------------------------------------- /discovery-guide-service/src/main/resources/application-a2.properties: -------------------------------------------------------------------------------- 1 | # Spring cloud config 2 | spring.application.name=discovery-guide-service-a 3 | server.port=3002 4 | 5 | # Spring cloud discovery metadata config 6 | spring.cloud.discovery.metadata.group=discovery-guide-group 7 | spring.cloud.discovery.metadata.version=1.1 8 | spring.cloud.discovery.metadata.region=qa 9 | spring.cloud.discovery.metadata.env=common 10 | spring.cloud.discovery.metadata.zone=zone2 -------------------------------------------------------------------------------- /discovery-guide-service/src/main/resources/application-b1.properties: -------------------------------------------------------------------------------- 1 | # Spring cloud config 2 | spring.application.name=discovery-guide-service-b 3 | server.port=4001 4 | 5 | # Spring cloud discovery metadata config 6 | spring.cloud.discovery.metadata.group=discovery-guide-group 7 | spring.cloud.discovery.metadata.version=1.0 8 | spring.cloud.discovery.metadata.region=qa 9 | spring.cloud.discovery.metadata.env=env1 10 | spring.cloud.discovery.metadata.zone=zone1 -------------------------------------------------------------------------------- /discovery-guide-service/src/main/resources/application-b2.properties: -------------------------------------------------------------------------------- 1 | # Spring cloud config 2 | spring.application.name=discovery-guide-service-b 3 | server.port=4002 4 | 5 | # Spring cloud discovery metadata config 6 | spring.cloud.discovery.metadata.group=discovery-guide-group 7 | spring.cloud.discovery.metadata.version=1.1 8 | spring.cloud.discovery.metadata.region=dev 9 | spring.cloud.discovery.metadata.env=common 10 | spring.cloud.discovery.metadata.zone=zone2 -------------------------------------------------------------------------------- /discovery-guide-service/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | # Nacos config for discovery 2 | spring.cloud.nacos.discovery.server-addr=localhost:8848 3 | 4 | # Nacos config for rule 5 | spring.cloud.nacos.config.server-addr=localhost:8848 6 | 7 | # Feign config 8 | spring.main.allow-bean-definition-overriding=true 9 | 10 | # Nepxion discovery config 11 | # 当外界传值Header的时候,服务也设置并传递同名的Header,需要决定哪个Header传递到后边的服务去。如果下面开关为true,以服务设置为优先,否则以外界传值为优先。缺失则默认为true 12 | # spring.application.strategy.service.header.priority=true 13 | 14 | # Ribbon config 15 | ribbon.ServerListRefreshInterval=5000 16 | ribbon.ConnectTimeout=60000 17 | ribbon.ReadTimeout=60000 18 | ribbon.maxAutoRetries=3 19 | ribbon.maxAutoRetriesNextServer=3 20 | ribbon.okToRetryOnAllOperations=true 21 | 22 | # 精简教程,请访问 23 | # https://github.com/Nepxion/Discovery/wiki 24 | # https://gitee.com/nepxion/Discovery/wikis 25 | # 详细教程,请访问 26 | # http://nepxion.com/discovery/ 27 | -------------------------------------------------------------------------------- /discovery-guide-service/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 |Title: Nepxion Discovery
5 | *Description: Nepxion Discovery
6 | *Copyright: Copyright (c) 2017-2050
7 | *Company: Nepxion
8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.boot.builder.SpringApplicationBuilder; 14 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 15 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 16 | 17 | @SpringBootApplication 18 | @EnableDiscoveryClient 19 | @EnableZuulProxy 20 | public class DiscoveryGuideZuul { 21 | public static void main(String[] args) { 22 | new SpringApplicationBuilder(DiscoveryGuideZuul.class).run(args); 23 | } 24 | } -------------------------------------------------------------------------------- /discovery-guide-zuul/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | # Spring cloud config 2 | spring.application.name=discovery-guide-zuul 3 | server.port=5002 4 | 5 | # Nacos config for discovery 6 | spring.cloud.nacos.discovery.server-addr=localhost:8848 7 | 8 | # Nacos config for rule 9 | spring.cloud.nacos.config.server-addr=localhost:8848 10 | 11 | # Spring cloud discovery metadata config 12 | spring.cloud.discovery.metadata.group=discovery-guide-group 13 | 14 | # Nepxion discovery config 15 | # 当外界传值Header的时候,网关也设置并传递同名的Header,需要决定哪个Header传递到后边的服务去。如果下面开关为true,以网关设置为优先,否则以外界传值为优先。缺失则默认为true 16 | spring.application.strategy.zuul.header.priority=false 17 | # 当以网关设置为优先的时候,网关未配置Header,而外界配置了Header,仍旧忽略外界的Header。缺失则默认为true 18 | # spring.application.strategy.zuul.original.header.ignored=true 19 | # 开启和关闭网关订阅配置中心的动态路由策略。缺失则默认为false 20 | spring.application.strategy.zuul.dynamic.route.enabled=true 21 | 22 | # Ribbon config 23 | ribbon.ServerListRefreshInterval=5000 24 | ribbon.ConnectTimeout=60000 25 | ribbon.ReadTimeout=60000 26 | ribbon.maxAutoRetries=3 27 | ribbon.maxAutoRetriesNextServer=3 28 | ribbon.okToRetryOnAllOperations=true 29 | 30 | # Zuul config 31 | zuul.host.max-per-route-connections=1000 32 | zuul.host.max-total-connections=1000 33 | zuul.semaphore.max-semaphores=5000 34 | 35 | # 手工配置路由 36 | zuul.routes.route0.path=/discovery-guide-service-a/** 37 | zuul.routes.route0.serviceId=discovery-guide-service-a 38 | 39 | # 注册发现自动路由 40 | # 开启和关闭自动路由。缺失则默认开启自动路由 41 | zuul.ignoredServices=* 42 | 43 | # 精简教程,请访问 44 | # https://github.com/Nepxion/Discovery/wiki 45 | # https://gitee.com/nepxion/Discovery/wikis 46 | # 详细教程,请访问 47 | # http://nepxion.com/discovery/ 48 | -------------------------------------------------------------------------------- /discovery-guide-zuul/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 |