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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bca401e
chore(nodejs): extract transport from sender, add back support for co…
glasstiger Jul 16, 2025
7efb5ec
make linter happy
glasstiger Jul 16, 2025
0ddf668
more type fixes
glasstiger Jul 16, 2025
eb0d7ee
extract buffer from sender
glasstiger Jul 17, 2025
7f4d454
TimestampUnit type
glasstiger Jul 17, 2025
f54ad65
code formatting
glasstiger Jul 23, 2025
7a70a6d
feat(nodejs): protocol version option, binary protocol for doubles
glasstiger Jul 24, 2025
87c26a4
more tests
glasstiger Jul 24, 2025
591f740
Merge remote-tracking branch 'origin/main' into binary_protocol_arrays
glasstiger Jul 31, 2025
83455aa
formatting
glasstiger Jul 31, 2025
50adf5c
fix protocol_version doc
glasstiger Jul 31, 2025
e5a7dee
fix merge fallout
glasstiger Jul 31, 2025
dc29488
fix merge fallout
glasstiger Jul 31, 2025
3021396
fix merge fallout
glasstiger Jul 31, 2025
0ad1eca
js doc for buffer
glasstiger Jul 31, 2025
4880075
code formatting
glasstiger Jul 31, 2025
d873996
more js doc
glasstiger Jul 31, 2025
95d997f
remove redundant buffer overflow checks
glasstiger Aug 5, 2025
4f01717
js doc fix
glasstiger Aug 5, 2025
ccb6cab
js doc fix
glasstiger Aug 6, 2025
812d5b8
use request timeout and TLS settings from Sender options in '/setting…
glasstiger Aug 6, 2025
7c79739
use bracket notation for LINE_PROTO_SUPPORT_VERSION
glasstiger Aug 6, 2025
97066b4
clear timeout if fetch finished
glasstiger Aug 6, 2025
f9b58a4
improved js doc
glasstiger Aug 6, 2025
fd5471e
do not switch off TLS verification by default in sender options tests
glasstiger Aug 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
431 changes: 431 additions & 0 deletions src/buffer/base.ts

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions src/buffer/bufferv1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// @ts-check
import { SenderOptions } from "../options";
import { SenderBuffer } from "./index";
import { SenderBufferBase } from "./base";

/**
* Buffer implementation for protocol version 1.
* Sends floating point numbers in their text form.
*/
class SenderBufferV1 extends SenderBufferBase {
constructor(options: SenderOptions) {
super(options);
}

/**
* Writes a 64-bit floating point value into the buffer using v1 serialization (text format). <br>
* Use it to insert into DOUBLE or FLOAT database columns.
*
* @param {string} name - Column name.
* @param {number} value - Column value, accepts only number values.
* @return {Sender} Returns with a reference to this sender.
*/
floatColumn(name: string, value: number): SenderBuffer {
this.writeColumn(
name,
value,
() => {
const valueStr = value.toString();
this.checkCapacity([valueStr]);
this.write(valueStr);
},
"number",
);
return this;
}
}

export { SenderBufferV1 };
42 changes: 42 additions & 0 deletions src/buffer/bufferv2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check
import { SenderOptions } from "../options";
import { SenderBuffer } from "./index";
import { SenderBufferBase } from "./base";

const ENTITY_TYPE_DOUBLE: number = 16;
const EQUALS_SIGN: number = "=".charCodeAt(0);

/**
* Buffer implementation for protocol version 2.
* Sends floating point numbers in binary form.
*/
class SenderBufferV2 extends SenderBufferBase {
constructor(options: SenderOptions) {
super(options);
}

/**
* Writes a 64-bit floating point value into the buffer using v2 serialization (binary format). <br>
* Use it to insert into DOUBLE or FLOAT database columns.
*
* @param {string} name - Column name.
* @param {number} value - Column value, accepts only number values.
* @return {Sender} Returns with a reference to this sender.
*/
floatColumn(name: string, value: number): SenderBuffer {
this.writeColumn(
name,
value,
() => {
this.checkCapacity([], 10);
this.writeByte(EQUALS_SIGN);
this.writeByte(ENTITY_TYPE_DOUBLE);
this.writeDouble(value);
},
"number",
);
return this;
}
}

export { SenderBufferV2 };
Loading