feat(nodejs): protocol version option, binary protocol for doubles#49
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for protocol version negotiation and binary serialization of double values in the QuestDB Node.js client. The main changes include making configuration parsing asynchronous to support HTTP endpoint queries, adding a new binary protocol (version 2) for more efficient double encoding, and restructuring the buffer implementation with version-specific classes.
- Adds
protocol_versionconfiguration option with support for 'auto', '1', and '2' values - Implements binary serialization for doubles in protocol version 2 vs text serialization in version 1
- Makes
Sender.fromConfig()andSenderOptions.fromConfig()async to support server version negotiation
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/util/mockhttp.ts | Adds settings endpoint mock and protocol version configuration support |
| test/sender.transport.test.ts | Updates all test calls to use async Sender.fromConfig and adds protocol_version parameters |
| test/sender.integration.test.ts | Converts Sender constructor calls to use SenderOptions.resolveAuto for proper version resolution |
| test/sender.config.test.ts | Updates configuration tests to be async and adds protocol_version to all test cases |
| test/sender.buffer.test.ts | Adds protocol_version parameter to all Sender constructor calls in tests |
| test/options.test.ts | Extensive updates to test protocol version parsing, validation, and HTTP endpoint negotiation |
| src/utils.ts | Adds fetchJson utility function for HTTP requests |
| src/sender.ts | Makes fromConfig and fromEnv methods async, changes buffer creation to use factory pattern |
| src/options.ts | Adds protocol version parsing, validation, and automatic resolution via HTTP settings endpoint |
| src/buffer/index.ts | Refactors to interface-based design with factory function for version-specific buffer creation |
| src/buffer/bufferv2.ts | Implements binary double serialization for protocol version 2 |
| src/buffer/bufferv1.ts | Implements text-based serialization for protocol version 1 (existing behavior) |
| src/buffer/base.ts | Moves common buffer functionality to abstract base class |
puzpuzpuz
reviewed
Aug 5, 2025
puzpuzpuz
reviewed
Aug 6, 2025
puzpuzpuz
reviewed
Aug 6, 2025
puzpuzpuz
approved these changes
Aug 6, 2025
puzpuzpuz
approved these changes
Aug 6, 2025
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.
Support for sending doubles as binary, and resolving the protocol version option.