微服务网关

第二章 zuul基本原理

2017-04-29  本文已影响979人  原水寒

一、zuul简介

zuul使用一系列的filter实现以下功能

github地址:https://github.com/Netflix/zuul/

二、zuul filter

2.1、关键元素

Type:值可以是:pre、route、post、error、custom
Execution Order: 指定一个type中的多个filter的执行顺序
Criteria:满足该条件,filter执行
Action: filter执行的动作的具体逻辑

注意点:

2.2、filter type

1、PRE Filters执行时机: before routing to the origin.
这类filter可能做的事:权限校验、选取路由机器、限流等。

2、ROUTING Filters
这类filter可能做的事:真正的向service的一台server(这台server是pre filter选出来的)发请求。

3、POST Filters执行时机:after the request has been routed to the origin
这类filter可能做的事:adding standard HTTP headers to the response,收集统计数据、streaming the response from the origin to the client

4、ERROR Filters执行时机:其他三个阶段任一阶段发生错误时执行

5、CUSTOM Filters沿着默认的filter流,zuul允许我们创建一些自定义的Filter type,并且准确的执行他们。
例如:我们自定义一个STATIC type的filter,用于从zuul直接产生响应,而不是从后端服务获取。

三、zuul request lifecycle(filter流)

<div>



</div>
说明:对应(二)的filter type来看

四、zuul核心架构

上一篇下一篇

猜你喜欢

热点阅读