fix: harden service startup and discovery lifecycle - #10
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.
目标
继续完成 P1 级别的工程化完善,集中处理服务启动顺序、Spring Boot 生命周期和 Nacos 服务发现缓存正确性。
1. bind 成功后再发布服务
之前
RpcServer.register()会立即写注册中心,而底层 Netty 端口可能尚未 bind,存在“注册中心可见但端口未 ready”的窗口。本次调整生命周期语义:
TransportServer.start()只负责启动并在监听端口 bind 成功后返回TransportServer.awaitTermination()RpcServer.register()在启动前只登记本地服务,不再提前发布RpcServer.start()严格执行:transport bind -> publish servicesProviderApp显式start()后调用awaitTermination()新增
RpcServerLifecycleTest固定验证 bind/publish 顺序。2. Spring Boot 使用 SmartLifecycle
移除原先:
CommandLineRunner改为
SmartLifecycle:RpcServer.close()新增 Starter 生命周期单测,并将
rpc-spring-boot-starter纳入主 CI unit-test job。3. 修复 Nacos stale cache
NacosServiceDiscovery由 static 全局缓存改为实例级状态:close()会幂等取消订阅、清缓存并关闭 NamingServiceServiceDiscovery增加 AutoCloseable 契约RpcClient.close()同时释放 TransportClient 和 ServiceDiscovery测试覆盖:
CI
主 Unit Tests 现在覆盖:
等待 Build / Unit Tests & Coverage / RPC Integration / CI Gate 全量验证。