feat: supports adapter high availability#117
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a design specification document describing how the Node.js connector would implement Adapter high availability (HA) via dynamic instance discovery (list_instances) during initial SQL connect / TMQ subscribe, and how newly discovered endpoints are merged into the DSN address pool.
Changes:
- Introduces a new spec outlining the
adapter_haDSN parameter and thelist_instancesrequest/response fields. - Describes intended code changes (DSN merge, wsClient/wsTmq message building) and a proposed test plan.
Comments suppressed due to low confidence (3)
docs/specs/2026-05-20-adapter-ha-design.md:45
- 本仓库 Node.js 实现位于
nodejs/src/...(例如nodejs/src/common/dsn.ts),这里从## 变更文件开始使用的src/...路径与实际目录结构不一致,容易误导后续实现/评审。建议将这些路径统一改为nodejs/src/...(下文的wsClient.ts/wsTmq.ts同理)。
## 变更文件
### `src/common/dsn.ts`
docs/specs/2026-05-20-adapter-ha-design.md:152
- 测试文件路径目前在仓库中是
nodejs/test/...(例如存在nodejs/test/common/),这里写的test/common/adapter-ha.test.ts与现有目录结构不一致。建议更新为实际/计划落地的路径,避免后续按文档找不到测试用例。
## 测试
### 单元测试 — `test/common/adapter-ha.test.ts`
docs/specs/2026-05-20-adapter-ha-design.md:164
test/bulkPulling/adapter-ha.test.ts目录在当前仓库中不存在(未找到bulkPulling相关测试目录)。建议改成现有测试结构下的目标位置(例如nodejs/test/...),或在实现阶段明确创建对应目录与命名规则。
- `buildSubscribeMessage()` 中 `list_instances` 字段的生成验证
### 集成测试 — `test/bulkPulling/adapter-ha.test.ts`
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request introduces a design specification for implementing Adapter High Availability (HA) in the Node.js connector, allowing for dynamic instance discovery via the list_instances protocol field. The feedback suggests enhancing the robustness of the HA support by considering a periodic refresh strategy for the instance list to handle cluster topology changes over time. Additionally, a suggestion was made to improve the clarity of the design document by avoiding non-null assertion operators in pseudo-code.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #117 +/- ##
==========================================
+ Coverage 81.67% 82.07% +0.40%
==========================================
Files 33 34 +1
Lines 3356 3515 +159
Branches 623 660 +37
==========================================
+ Hits 2741 2885 +144
- Misses 465 479 +14
- Partials 150 151 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Reference: taos-connector-jdbc PR #321 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses 6 review findings: 1. Separate _failoverAddresses from _dsn.addresses to preserve pool key invariant 2. ClusterRegistry uses deep copy + Object.freeze for immutability 3. Add discovery lifecycle and topology refresh semantics section 4. Document merge-then-register ordering and failure semantics 5. Specify endpoint format contract (IPv4/IPv6 parsing rules) 6. Add multi-discovery and cross-path test scenarios Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1. Clarify ClusterRegistry scope as per-event-loop singleton (not cross-worker) 2. Add multi-cluster seed detection with warn + reject expansion 3. Add pool key invariance test case and multi-cluster detection test case Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…for address parsing and merging
Introduce Cluster class to replace raw Address[] in ClusterRegistry, use cluster UUID as pool key for adapter HA connections. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
getOrCreateCluster returns null when seeds span multiple clusters, getPoolKey falls back to address concatenation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…date related tests
…date tsconfig to include node and jest types
…ClusterRegistry instance directly
… ensuring pooled connector reuse
Description
feat: supports adapter high availability
Issue(s)
Checklist
Please check the items in the checklist if applicable.