Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
8bb24b34
Commit
8bb24b34
authored
Jul 10, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改介绍
parent
5aef0bdc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
17 deletions
+78
-17
README.md
+78
-17
No files found.
README.md
View file @
8bb24b34
...
@@ -384,23 +384,86 @@ Url:
...
@@ -384,23 +384,86 @@ Url:
http:
//IP:PORT/router/routes
http:
//IP:PORT/router/routes
```
```
上述操作,也可以通过集成的Swagger服务来执行,如
图1
上述操作,也可以通过集成的Swagger服务来执行,如
下图
图1


## 独立控制台
## 独立控制台
为UI提供相关接口,待实现如下功能
为UI提供相关接口,待实现如下功能
-
通过界面实现黑/白名单,版本等管理和控制
-
通过界面实现黑/白名单,版本等管理和控制
-
通过界面实现远程配置中心整合
-
通过界面实现远程配置中心整合
> PORT端口号为server.port或者management.port都可以
### 控制台接口
#### 获取服务注册中心的服务列表
```
java
Java:
@RequestMapping
(
path
=
"/console/services"
,
method
=
RequestMethod
.
GET
)
public
List
<
String
>
services
()
Url:
http:
//IP:PORT/console/services
```
#### 获取服务注册中心服务的实例列表
```
java
Java:
@RequestMapping
(
path
=
"/console/instances/{serviceId}"
,
method
=
RequestMethod
.
GET
)
public
List
<
ServiceInstance
>
instances
(
String
serviceId
)
Url:
http:
//IP:PORT/console/instances/{serviceId}
```
#### 获取服务注册中心服务的实例列表(精简数据)
```
java
Java:
@RequestMapping
(
path
=
"/console/instance-list/{serviceId}"
,
method
=
RequestMethod
.
GET
)
public
List
<
InstanceEntity
>
instanceList
(
String
serviceId
)
Url:
http:
//IP:PORT/console/instance-list/{serviceId}
```
#### 获取服务注册中心的服务和实例的Map(精简数据)
```
java
Java:
@RequestMapping
(
path
=
"/console/instance-map"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
List
<
InstanceEntity
>>
instanceMap
()
Url:
http:
//IP:PORT/console/instance-map/{serviceId}
```
#### 批量同步推送规则配置信息
```
java
Java:
@RequestMapping
(
path
=
"/console/config/send-async/{serviceId}"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
configSendAsync
(
String
serviceId
,
String
config
)
Url:
http:
//IP:PORT/console/config/send-async/{serviceId}
```
#### 批量异步推送规则配置信息
```
java
Java:
@RequestMapping
(
path
=
"/console/config/send-sync/{serviceId}"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
configSendSync
(
String
serviceId
,
String
config
)
Url:
http:
//IP:PORT/console/config/send-sync/{serviceId}
```
上述操作,也可以通过集成的Swagger服务来执行,如下图

## 扩展和自定义更多规则或者监听
## 扩展和自定义更多规则或者监听
使用者可以继承如下类
使用者可以继承如下类
-
AbstractRegisterListener,实现服务注册的扩展和监听
-
AbstractRegisterListener,实现服务注册的扩展和监听
-
AbstractDiscoveryListener,实现服务发现的扩展和监听,注意,在Consul下,同时会触发service和management两个实例的事件,需要区别判断,如
图2
-
AbstractDiscoveryListener,实现服务发现的扩展和监听,注意,在Consul下,同时会触发service和management两个实例的事件,需要区别判断,如
下图
图2,
集成了健康检查的Consul控制台
集成了健康检查的Consul控制台


## Spring Cloud引入Consul的坑
## Spring Cloud引入Consul的坑
...
@@ -410,9 +473,7 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
...
@@ -410,9 +473,7 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
## 示例演示
## 示例演示
### 场景描述
### 场景描述
本例将模拟一个较为复杂的场景,如图3
本例将模拟一个较为复杂的场景,如下图
图3


...
@@ -476,16 +537,16 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
...
@@ -476,16 +537,16 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
-
通过Postman或者浏览器,执行GET
[
http://localhost:1200/instances/discovery-springcloud-example-c
](
http://localhost:1200/instances/discovery-springcloud-example-c
)
,查看当前B1服务可访问C服务的列表
-
通过Postman或者浏览器,执行GET
[
http://localhost:1200/instances/discovery-springcloud-example-c
](
http://localhost:1200/instances/discovery-springcloud-example-c
)
,查看当前B1服务可访问C服务的列表
-
通过Postman或者浏览器,执行GET
[
http://localhost:1201/instances/discovery-springcloud-example-c
](
http://localhost:1201/instances/discovery-springcloud-example-c
)
,查看当前B2服务可访问C服务的列表
-
通过Postman或者浏览器,执行GET
[
http://localhost:1201/instances/discovery-springcloud-example-c
](
http://localhost:1201/instances/discovery-springcloud-example-c
)
,查看当前B2服务可访问C服务的列表
-
灰度版本切换
-
灰度版本切换
-
通过Postman或者浏览器,执行POST
[
http://localhost:1100/routes
](
http://localhost:1100/routes
)
,填入discovery-springcloud-example-b;discovery-springcloud-example-c,查看路由路径,如图
4
,可以看到符合图3的实线调用路径
-
通过Postman或者浏览器,执行POST
[
http://localhost:1100/routes
](
http://localhost:1100/routes
)
,填入discovery-springcloud-example-b;discovery-springcloud-example-c,查看路由路径,如图
1
,可以看到符合图3的实线调用路径
-
通过Postman或者浏览器,执行POST
[
http://localhost:1100/version/send
](
http://localhost:1100/version/send
)
,填入1.1,动态把服务A的版本从1.0切换到1.1
-
通过Postman或者浏览器,执行POST
[
http://localhost:1100/version/send
](
http://localhost:1100/version/send
)
,填入1.1,动态把服务A的版本从1.0切换到1.1
-
再执行3.1步骤,如图
5
,可以看到符合图3的虚线调用路径,符合逻辑,灰度版本切换成功
-
再执行3.1步骤,如图
2
,可以看到符合图3的虚线调用路径,符合逻辑,灰度版本切换成功
-
灰度版本控制
-
灰度版本控制
-
通过Postman或者浏览器,执行POST
[
http://localhost:1200/config/send
](
http://localhost:1200/config/send
)
,发送新的规则XML(内容见下面),表示B服务的所有版本都只能访问C服务3.0版本,而本例中C服务3.0版本是不存在的,意味着B服务不能访问C服务
-
通过Postman或者浏览器,执行POST
[
http://localhost:1200/config/send
](
http://localhost:1200/config/send
)
,发送新的规则XML(内容见下面),表示B服务的所有版本都只能访问C服务3.0版本,而本例中C服务3.0版本是不存在的,意味着B服务不能访问C服务
-
访问
[
http://localhost:1201/config/send
](
http://localhost:1201/config/send
)
,重复4.1步骤
-
访问
[
http://localhost:1201/config/send
](
http://localhost:1201/config/send
)
,重复4.1步骤
-
重复3.1步骤,发现调用路径只有A服务->B服务,符合逻辑,灰度版本控制成功,如图
6
-
重复3.1步骤,发现调用路径只有A服务->B服务,符合逻辑,灰度版本控制成功,如图
3
-
负载均衡的灰度测试
-
负载均衡的灰度测试
-
通过Postman或者浏览器,执行POST
[
http://localhost:1100/invoke
](
http://localhost:1100/invoke
)
,这是example内置的单条路由实例(通过Feign实现)
-
通过Postman或者浏览器,执行POST
[
http://localhost:1100/invoke
](
http://localhost:1100/invoke
)
,这是example内置的单条路由实例(通过Feign实现)
-
重复“灰度版本切换”或者“灰度版本控制”操作,查看Ribbon负载均衡的灰度结果,如图
7
-
重复“灰度版本切换”或者“灰度版本控制”操作,查看Ribbon负载均衡的灰度结果,如图
4
-
其它更多操作,请参考“管理中心”和“路由中心”,不一一阐述了
-
其它更多操作,请参考“管理中心”和“路由中心”,不一一阐述了
新XML规则
新XML规则
...
@@ -500,19 +561,19 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
...
@@ -500,19 +561,19 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
</rule>
</rule>
```
```
图
4
图
1


图
5
图
2


图
6
图
3


图
7
图
4


...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment