知识卡片
代理对象隐藏RPC传输细节
RpcCallerDemoService持有RpcProxy(“rpc_responder_demo_service”),remote_hello(value)经代理调用响应服务hello(name)。两端name供框架绑定服务,@rpc标记可远程调用方法。图中是依赖与代理,不是两个服务类的继承;调用看似普通方法,也不能忘记远程失败与等待。
可联系[[消息代理也可承载请求响应]]理解条件与边界。
结构图:
类图:虚线三角表示实现接口,箭头表示依赖,实线菱形表示组合。
classDiagram
class RpcCallerDemoService {
+name = rpc_caller_demo_service
+remote: RpcProxy
+remote_hello(value="John Doe")
}
class RpcProxy
class RpcResponderDemoService {
+name = rpc_responder_demo_service
+hello(name)
}
RpcCallerDemoService --> RpcProxy : remote依赖
RpcProxy ..> RpcResponderDemoService : 通过服务名远程调用hello
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
remote = RpcProxy("rpc_responder_demo_service")
参考来源
- 位置:《微服务实战》第7章《构建可复用的微服务框架》(来源项目book-sources;extracted/微服务实战/_epub-src/text/part0017_split_003.html;src-180)。
- 结论依据:清单7.1保留真实类名、方法和参数,未补造返回类型或远程继承。
- 原始内容:remote = RpcProxy("rpc_responder_demo_service")