Finagle源码分析之Mux.client
2018-01-25 16:37
597 查看
Finagle 客户端实现过程,由于协议无关性,这里以Mux协议为例,Http等流程相同。
Mux.Client 的 trait 的调用时序如下:1 Mux.apply new org:Mux.Client
2 StackClient StackClient.stack
3 StackClient.stack return new StackBuilder.addModule
4 org:Parameterized , orig.configure
5 orig:Mux.Client orig.newClient6 orig:EndpointerStackClient orig.newClient7 orig:StackClient orig.endpointer8 orig:StackClient orig.copy1
9 copy1:EndpointerStackClient copy1.newTransport10 copy1:Mux.Client copy1.newTransport
11 new EndpointerModule( transport, copy1.newDispatch)
12 orig:Mux.Client copy1.stack11 StackClient StackClient.stack12 StackClient return new StackBuilder.addModule
13 (stack ++ endpointer).make14 endpointer:EndpointModule endpointer.mk
15 Module.mk
16 sf:ServiceFactory sf.apply17 sf_next:ServiceFactory sf_next.apply
18 copy1.newDispatch:EndpointStackClient19 copy1.newDispatch:Mux.client20 newRequestResponse:mux.dispatcher21 createServiceFromDispatcher
22 createServiceAsFilter
23 service.apply
24 filter.apply
25 mux.dispatch service.apply
Mux 调用apply创建新的客户端 Mux.client (步骤1),StackClient 返回需要的 Module (步骤2,3) newClient 创建 ServiceFactory,这里首先创建 endpointer(步骤7)最重要的方法1 newTrsport,2 newDispatch (步骤11), filter 嵌入 在步骤(13) endpointer 绑定到一个 transport,每次请求 service时候,调用一次 newDispath 并提供 transport。 实现这两个模版方法里可以关联不同的协议栈,实现不同类型的客户端如 Mux,http。
转自:https://github.com/mengyuetao
The core of Finagle is protocol-agnostic, meaning its internals provide an extensible RPC subsystem without defining any details of specific client-server protocols. Thus in order to provide usable APIs for clients and servers, there are a number of Finagle subprojects that implement common protocols.
Mux.Client 的 trait 的调用时序如下:1 Mux.apply new org:Mux.Client
2 StackClient StackClient.stack
3 StackClient.stack return new StackBuilder.addModule
4 org:Parameterized , orig.configure
5 orig:Mux.Client orig.newClient6 orig:EndpointerStackClient orig.newClient7 orig:StackClient orig.endpointer8 orig:StackClient orig.copy1
9 copy1:EndpointerStackClient copy1.newTransport10 copy1:Mux.Client copy1.newTransport
11 new EndpointerModule( transport, copy1.newDispatch)
12 orig:Mux.Client copy1.stack11 StackClient StackClient.stack12 StackClient return new StackBuilder.addModule
13 (stack ++ endpointer).make14 endpointer:EndpointModule endpointer.mk
15 Module.mk
16 sf:ServiceFactory sf.apply17 sf_next:ServiceFactory sf_next.apply
18 copy1.newDispatch:EndpointStackClient19 copy1.newDispatch:Mux.client20 newRequestResponse:mux.dispatcher21 createServiceFromDispatcher
22 createServiceAsFilter
23 service.apply
24 filter.apply
25 mux.dispatch service.apply
Mux 调用apply创建新的客户端 Mux.client (步骤1),StackClient 返回需要的 Module (步骤2,3) newClient 创建 ServiceFactory,这里首先创建 endpointer(步骤7)最重要的方法1 newTrsport,2 newDispatch (步骤11), filter 嵌入 在步骤(13) endpointer 绑定到一个 transport,每次请求 service时候,调用一次 newDispath 并提供 transport。 实现这两个模版方法里可以关联不同的协议栈,实现不同类型的客户端如 Mux,http。
转自:https://github.com/mengyuetao
相关文章推荐
- Finagle 源码分析之Mux.ThriftMux
- 分布式文件系统KFS源码阅读与分析(四):RPC实现机制(KfsClient端)
- 【原创】k8s源码分析-----Mux And Broadcaster
- HDFS dfsclient写文件过程 源码分析
- DDPush开源推送框架源码分析之Client到DDPush(UDP模式)
- SSO单点登录系列1:cas客户端源码分析cas-client-java-2.1.1.jar
- Hbase-0.98.6源码分析--Put写操作Client端流程
- Finagle源码分析之Stack[T]
- HDFS dfsclient写文件过程 源码分析
- HDFS dfsclient读文件过程 源码分析
- ANR源码分析之ContentProviderClient Timeout
- Hadoop源码分析HDFS Client向HDFS写入数据的过程解析
- memcache-client-forjava 源码分析之MemcachedCacheManager
- Hadoop源码分析HDFS ClientProtocol——create
- asp.net mvc源码分析-BeginForm方法 和ClientValidationEnabled 属性
- Hadoop源码分析之DFSClient对象的创建
- rocketmq-remoting源码分析NettyRemotingClient
- HDFS dfsclient写文件过程 源码分析
- Docker源码分析(二):Docker Client创建与命令执行
- Nova client源码分析---nova list命令