Skip to content

feat(rpc): ReconnectingTransport — 生产级自动重连与错误处理#4

Merged
Naeemo merged 1 commit into
mainfrom
feat/reconnecting-transport
Jul 8, 2026
Merged

feat(rpc): ReconnectingTransport — 生产级自动重连与错误处理#4
Naeemo merged 1 commit into
mainfrom
feat/reconnecting-transport

Conversation

@Naeemo

@Naeemo Naeemo commented Jul 8, 2026

Copy link
Copy Markdown
Owner

变更内容

为 Cap'n Proto RPC 添加 ,基于装饰器模式为任意 提供生产级自动重连能力。

核心特性

  • 指数退避重连:可配置 、、、
  • 透明挂起恢复:断链时 自动排队、 挂起,重连后自动恢复
  • 超时保护:(调用超时)、(连接超时)
  • 状态事件: 回调暴露
  • 灵活的首连策略: 控制首次连接失败时是否立即重试

测试覆盖

12 个单测全部通过:

  • ✅ 首次 send 自动触发连接
  • ✅ 断线自动重连
  • ✅ 重连期间 send 排队
  • ✅ 重连期间 receive 挂起并恢复
  • ✅ 指数退避策略
  • ✅ 最大重试次数限制
  • ✅ close 后拒绝 send / receive 返回 null
  • ✅ onError 回调代理
  • ✅ createReconnectingTransport 工厂函数
  • ✅ CompressionState 代理

兼容性

  • 保持 接口完全兼容
  • 从 导出公开 API
  • 零破坏变更

- 指数退避自动重连(可配置 maxRetries、baseDelayMs、backoffMultiplier)
- 断链时 send/receive 透明挂起,重连后自动恢复
- 调用超时保护(callTimeoutMs / connectTimeoutMs)
- 连接状态事件(onStateChange)
- retryOnInitialConnect 选项控制首次连接失败行为
- 完整单测覆盖(12 tests,全部通过)
@Naeemo Naeemo force-pushed the feat/reconnecting-transport branch from cb5a8c3 to be1c63a Compare July 8, 2026 09:53
@Naeemo Naeemo merged commit 986be3f into main Jul 8, 2026
4 of 5 checks passed
@Naeemo Naeemo deleted the feat/reconnecting-transport branch July 8, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant