fix: complete P0 RPC correctness and lifecycle - #9
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
目标
集中完成当前 P0 级别的 RPC 正确性和资源生命周期问题,不扩展 Retry / 熔断 / Nacos 缓存等 P1/P2 功能。
1. 修复 CompletableFuture 异步返回类型
之前 JDK / ByteBuddy 代理会把
method.getReturnType()(即CompletableFuture.class)直接传给RpcClient,导致异步 RPC 无法按真正的T反序列化。本次:
RpcReturnTypeResolverCompletableFuture<User>会提取User.class作为响应反序列化类型CompletableFuture<List<User>>等当前 Serializer API 无法准确表达的嵌套参数化类型明确报错,不再静默错误反序列化2. 去除同地址并发重复建连
重构
ChannelProvider:connectingChannels,用CompletableFuture<Channel>表示正在建立的连接CountDownLatch.await(5s)同步建连等待新增确定性单元测试,不依赖真实端口。
3. 完善 Client / Server 生命周期
Client
TransportClient extends AutoCloseableRpcClient implements AutoCloseableRpcClient.close()幂等NettyTransportClient不再使用 static EventLoopGroup / BootstrapchannelInactive失败返回ProxyFactory支持 close,JDK / ByteBuddy 关闭其持有的 RpcClientRpcClientProxy.shutdown(),让静态代理入口也有应用级资源释放路径Server
RpcServer implements AutoCloseablestop()/close()幂等,统一清注册中心 + 停 TransportServerNettyTransportServer保存 listener Channel,stop()会真正 close listener,使start()阻塞线程可退出测试
新增/扩展:
ProxyAsyncReturnTypeTestRpcClientTestclose/idempotencyChannelProviderTestNettyRpcClientHandlerTestchannelInactive pending cleanupFullIntegrationTestclient/server lifecycle等待主 CI 的 Build / Unit Tests & Coverage / RPC Integration / CI Gate 全量验证。