-
Notifications
You must be signed in to change notification settings - Fork 8
feat: supports adapter high availability #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
7e7d331
docs: add adapter HA support design spec
qevolg be11224
feat: add failover implementation guide for Node.js applications usin…
qevolg 5da186d
feat: update uuid dependency to version 11.1.1
qevolg 8f24c6e
feat: enable contrib build for TDengine and update taosadapter instal…
qevolg 9c1557f
feat: update tsconfig paths to use relative paths for module resolution
qevolg 2e9aeda
feat: enhance adapter HA support with dynamic instance discovery and …
qevolg 0383996
feat: remove outdated adapter HA design specification document
qevolg ac44f11
docs: add adapter HA design spec for Node.js connector
qevolg d15273e
docs: fix adapter HA design spec per review feedback
qevolg 906bb59
docs: address round-2 review on adapter HA design
qevolg 0f37a64
feat: implement adapter HA support with cluster registry and endpoint…
qevolg d528471
feat: enhance ClusterRegistry with reset functionality and add tests …
qevolg 6674d45
feat: remove outdated failover practice documentation for Node.js on …
qevolg 713b4c5
feat: remove adapter HA design documentation for Node.js connector
qevolg 9d5b2a8
docs: add cluster type design spec
qevolg 0897e1b
docs: handle cross-cluster seeds in getOrCreateCluster
qevolg 5e35ac6
docs: add _failoverAddresses removal to cluster design
qevolg ef24bf4
docs: refine registerCluster and mergeDiscoveredEndpoints design
qevolg 4b4d9a6
docs: rename registerCluster to updateCluster, return void
qevolg f864dfb
docs: apply review feedback to cluster design spec
qevolg 11d1621
docs: update getOrCreateCluster behavior to avoid binding unmapped seeds
qevolg af87d0b
feat: implement Cluster class and enhance ClusterRegistry for improve…
qevolg 001bd4c
feat: remove Cluster type design document and related specifications
qevolg 2c25d57
refactor: improve address handling in parseDiscoveredEndpoints and up…
qevolg 4fec967
fix: remove unnecessary address mapping in createBareConnector and up…
qevolg 7a4b4b6
refactor: remove _resetForTest method and update test cases to reset …
qevolg 515a746
feat: add tests for adapter_ha functionality in WsSql and WsConsumer,…
qevolg 7049e06
feat: implement adapter_ha pooled connector tests and refactor relate…
qevolg 0ae6ccb
feat: add tests for adapter_ha pooled connector and refactor related …
qevolg 5bbd928
feat: update version to 3.5.0 in package.json and package-lock.json
qevolg aeca0ae
feat: update uuid package version to 9.0.1 and refactor Cluster class…
qevolg b4b342c
feat: add Grype configuration for vulnerability scanning of uuid package
qevolg 3d9eaed
feat: remove deprecated uuid package metadata from package-lock.json
qevolg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { Address, mergeAddresses } from "../common/dsn"; | ||
|
qevolg marked this conversation as resolved.
|
||
| import logger from "../common/log"; | ||
|
|
||
| export class ClusterRegistry { | ||
| private static _instance?: ClusterRegistry; | ||
| private endpointToCluster: Map<string, readonly Address[]> = new Map(); | ||
|
|
||
| private constructor() { } | ||
|
|
||
| public static instance(): ClusterRegistry { | ||
| if (!ClusterRegistry._instance) { | ||
| ClusterRegistry._instance = new ClusterRegistry(); | ||
| } | ||
| return ClusterRegistry._instance; | ||
| } | ||
|
|
||
| public static _resetForTest(): void { | ||
| if (ClusterRegistry._instance) { | ||
| ClusterRegistry._instance.endpointToCluster.clear(); | ||
| } | ||
| ClusterRegistry._instance = undefined; | ||
| } | ||
|
|
||
| public registerCluster(addresses: Address[]): void { | ||
| const snapshot: Address[] = addresses.map( | ||
| (address) => Object.freeze(new Address(address.host, address.port)) | ||
| ); | ||
| Object.freeze(snapshot); | ||
| for (const address of snapshot) { | ||
| this.endpointToCluster.set(`${address.host}:${address.port}`, snapshot); | ||
| } | ||
| } | ||
|
|
||
| public expandEndpoints(seeds: Address[]): Address[] { | ||
| let matchedCluster: readonly Address[] | null = null; | ||
|
|
||
| for (const seed of seeds) { | ||
| const cluster = this.endpointToCluster.get(`${seed.host}:${seed.port}`); | ||
| if (!cluster) { | ||
| continue; | ||
| } | ||
|
|
||
| if (matchedCluster === null) { | ||
| matchedCluster = cluster; | ||
| continue; | ||
| } | ||
|
|
||
| if (matchedCluster !== cluster) { | ||
| logger.warn( | ||
| "Adapter HA: seed addresses span multiple known clusters, " + | ||
| "skipping expansion. Ensure all seeds belong to the same cluster." | ||
| ); | ||
| return seeds.map((seedAddress) => | ||
| new Address(seedAddress.host, seedAddress.port) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| if (!matchedCluster) { | ||
| return seeds.map((seedAddress) => | ||
| new Address(seedAddress.host, seedAddress.port) | ||
| ); | ||
| } | ||
|
|
||
| return mergeAddresses(seeds, [...matchedCluster]); | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.