Skip to content

feat(nodejs): protocol version option, binary protocol for doubles #49

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 25 commits into from
Aug 6, 2025

Conversation

glasstiger
Copy link
Collaborator

@glasstiger glasstiger commented Jul 24, 2025

Support for sending doubles as binary, and resolving the protocol version option.

@glasstiger glasstiger changed the base branch from sender_transport to main July 31, 2025 16:12
@puzpuzpuz puzpuzpuz requested review from puzpuzpuz and Copilot August 4, 2025 10:12
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_version configuration 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() and SenderOptions.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 puzpuzpuz self-requested a review August 6, 2025 13:59
@glasstiger glasstiger merged commit 1d43359 into main Aug 6, 2025
4 checks passed
@glasstiger glasstiger deleted the binary_protocol_arrays branch August 6, 2025 15:05
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.

2 participants