1. Zuul1
总体架构:
Zuul Servlet源码:
调用流程:
2.Zuul2
总体架构:
调用流程:
refer link: zuul-2-the-netflix-journey-to-asynchronous-non-blocking-systems
时序图:
以下是 zuul inbound 和 zuul outbound 中任意
filter needsBodyBuffered方法 returntrue
时的时序图
图片过大,点击原图查看
zuul inbound 和 outbound 中所有
filter needsBodyBuffered方法 returnfalse
时
接收请求:
ProxyEndpoint writeClientRequestToOrigin方法在netty lister成功时被调用(这时zuulRequest,bodyChunks有值)或先被调用(这时zuulRequest,bodyChunks为空),
ZuulFilterChainHandler channelRead方法循环
读 HttpContent,
ZuulFilterChainRunner filter方法里 limit >= filters.length invokeNextStage(inMesg, chunk),
ZuulEndPointRunner filter(zuulReq, chunk)方法里 endpoint.processContentChunk(zuulReq, chunk) 用originConn的channel(netty client)写HttpContent,zuulReq.bufferBodyContents(newChunk)里缓存 HttpContent
origin发送:
ClientResponseWriter chnnelRead方法里,先发送 zuulResponse,再循环
写 HttpContent
源码:
Netty Server:
Http handler &Zuul pipeline:
GATEWAY SERVER PIPELINE:
0 = "IdleStateHandler#0"
1 = "CloseOnIdleStateHandler#0"
2 = "SourceAddressChannelHandler#0"
3 = "channelMetrics"
4 = "PerEventLoopMetricsChannelHandler$Connections#0"
5 = "ElbProxyProtocolChannelHandler"
6 = "MaxInboundConnectionsHandler#0"
7 = "codec"
8 = "Http1ConnectionCloseHandler#0"
9 = "conn_expiry_handler"
10 = "PassportStateHttpServerHandler#0"
11 = "http_request_read_timeout_handler"
12 = "HttpServerLifecycleChannelHandler#0"
13 = "ClientResponseHttpContentLimitHandler#0"
14 = "HttpBodySizeRecordingChannelHandler#0"
15 = "HttpMetricsChannelHandler#0"
16 = "PerEventLoopMetricsChannelHandler$HttpRequests#0"
17 = "AccessLogChannelHandler#0"
18 = "ServerStatusHeaderHandler#0"
19 = "StripUntrustedProxyHeadersHandler#0"
20 = "logger"
21 = "ClientRequestReceiver#0"
22 = "ClientRequestHttpContentLimitHandler#0"
23 = "ZuulFilterChainHandler#0"
24 = "ClientResponseWriter#0"
25 = "DefaultChannelPipeline$TailContext#0"
Netty Client:
GATEWAY CLIENT PIPELINE:
0 = "PassportStateOriginHandler#0"
1 = "codec"
2 = "PassportStateHttpClientHandler"
3 = "readTimeoutHandler"
4 = "originNettyLogger"
5 = "HttpMetricsChannelHandler#0"
6 = "httpLifecycle"
7 = "ClientTimeoutHandler#0"
8 = "_origin_response_receiver"
9 = "connectionPoolHandler"
10 = "DefaultChannelPipeline$TailContext#0"