apache-iggy 0.10.0 → 0.10.1-edge.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/e2e/tcp.parallel.e2e.js +4 -1
- package/dist/e2e/tcp.system.e2e.js +4 -1
- package/dist/wire/command-set.d.ts +0 -1
- package/dist/wire/command-set.js +1 -3
- package/dist/wire/command.code.d.ts +0 -1
- package/dist/wire/command.code.js +0 -1
- package/dist/wire/error.code.js +2 -0
- package/dist/wire/error.code.test.js +6 -0
- package/dist/wire/message/message.utils.d.ts +0 -10
- package/dist/wire/message/message.utils.js +1 -22
- package/dist/wire/system/get-stats.command.d.ts +17 -0
- package/dist/wire/system/get-stats.command.js +69 -16
- package/dist/wire/system/get-stats.command.test.d.ts +2 -0
- package/dist/wire/system/get-stats.command.test.js +97 -0
- package/dist/wire/vsr/index.js +2 -3
- package/package.json +5 -5
- package/dist/wire/message/flush-unsaved-buffers.command.d.ts +0 -26
- package/dist/wire/message/flush-unsaved-buffers.command.js +0 -36
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
Apache Iggy Node.js client written in typescript, it currently only supports tcp & tls transports.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Disclaimer: although all iggy commands & basic client/stream are implemented this is still a WIP, provided as is, and has still a long way to go to be considered "battle tested".
|
|
14
14
|
|
|
15
15
|
note: This lib started as _iggy-bin_ ( [github](https://github.com/T1B0/iggy-bin) / [npm](https://www.npmjs.com/package/iggy-bin)) before migrating under iggy-rs org. package iggy-bin@v1.3.4 is equivalent to @iggy.rs/sdk@v1.0.3 and migrating again under apache iggy monorepo ( [github](https://github.com/apache/iggy/tree/master/foreign/node) and is now published on npmjs as apache-iggy
|
|
16
16
|
|
|
@@ -43,7 +43,10 @@ describe('e2e -> parallel', async () => {
|
|
|
43
43
|
'availableMemory', 'runTime', 'startTime', 'readBytes', 'writtenBytes',
|
|
44
44
|
'messagesSizeBytes', 'streamsCount', 'topicsCount', 'partitionsCount',
|
|
45
45
|
'segmentsCount', 'messagesCount', 'clientsCount', 'consumersGroupsCount',
|
|
46
|
-
'hostname', 'osName', 'osVersion', 'kernelVersion'
|
|
46
|
+
'hostname', 'osName', 'osVersion', 'kernelVersion',
|
|
47
|
+
'iggyServerVersion', 'iggyServerSemver', 'cacheMetrics',
|
|
48
|
+
'threadsCount', 'freeDiskSpace', 'totalDiskSpace',
|
|
49
|
+
'openFilesCount', 'openFilesLimit'
|
|
47
50
|
]);
|
|
48
51
|
resp.forEach(r => assert.ok(r));
|
|
49
52
|
});
|
|
@@ -31,7 +31,10 @@ describe('e2e -> system', async () => {
|
|
|
31
31
|
'availableMemory', 'runTime', 'startTime', 'readBytes', 'writtenBytes',
|
|
32
32
|
'messagesSizeBytes', 'streamsCount', 'topicsCount', 'partitionsCount',
|
|
33
33
|
'segmentsCount', 'messagesCount', 'clientsCount', 'consumersGroupsCount',
|
|
34
|
-
'hostname', 'osName', 'osVersion', 'kernelVersion'
|
|
34
|
+
'hostname', 'osName', 'osVersion', 'kernelVersion',
|
|
35
|
+
'iggyServerVersion', 'iggyServerSemver', 'cacheMetrics',
|
|
36
|
+
'threadsCount', 'freeDiskSpace', 'totalDiskSpace',
|
|
37
|
+
'openFilesCount', 'openFilesLimit'
|
|
35
38
|
]);
|
|
36
39
|
});
|
|
37
40
|
it('e2e -> system::logout', async () => {
|
|
@@ -76,7 +76,6 @@ type OffsetAPI = ReturnType<typeof offsetAPI>;
|
|
|
76
76
|
declare const messageAPI: (c: ClientProvider) => {
|
|
77
77
|
poll: (request: import("./message/poll-messages.command.js").PollMessages) => Promise<import("./index.js").PollMessagesResponse>;
|
|
78
78
|
send: (arg: import("./message/send-messages.command.js").SendMessages) => Promise<import("./message/send-messages.command.js").SendMessagesResponse>;
|
|
79
|
-
flushUnsavedBuffers: (arg: import("./message/flush-unsaved-buffers.command.js").FlushUnsavedBuffer) => Promise<boolean>;
|
|
80
79
|
};
|
|
81
80
|
type MessageAPI = ReturnType<typeof messageAPI>;
|
|
82
81
|
declare const systemAPI: (c: ClientProvider) => {
|
package/dist/wire/command-set.js
CHANGED
|
@@ -41,7 +41,6 @@ import { storeOffset } from './offset/store-offset.command.js';
|
|
|
41
41
|
import { deleteOffset } from './offset/delete-offset.command.js';
|
|
42
42
|
import { sendMessages } from './message/send-messages.command.js';
|
|
43
43
|
import { pollMessages } from './message/poll-messages.command.js';
|
|
44
|
-
import { flushUnsavedBuffers } from './message/flush-unsaved-buffers.command.js';
|
|
45
44
|
import { createStream } from './stream/create-stream.command.js';
|
|
46
45
|
import { updateStream } from './stream/update-stream.command.js';
|
|
47
46
|
import { getStream } from './stream/get-stream.command.js';
|
|
@@ -132,8 +131,7 @@ const offsetAPI = (c) => ({
|
|
|
132
131
|
});
|
|
133
132
|
const messageAPI = (c) => ({
|
|
134
133
|
poll: pollMessages(c),
|
|
135
|
-
send: sendMessages(c)
|
|
136
|
-
flushUnsavedBuffers: flushUnsavedBuffers(c)
|
|
134
|
+
send: sendMessages(c)
|
|
137
135
|
});
|
|
138
136
|
const systemAPI = (c) => ({
|
|
139
137
|
ping: ping(c),
|
package/dist/wire/error.code.js
CHANGED
|
@@ -84,6 +84,7 @@ export const translateErrorCode = (code) => {
|
|
|
84
84
|
case '82': return "Invalid number encoding";
|
|
85
85
|
case '83': return "Invalid boolean value";
|
|
86
86
|
case '84': return "Invalid number value";
|
|
87
|
+
case '85': return "Request is below the deduplication window; outcome unknown, resending may duplicate the write";
|
|
87
88
|
case '100': return "Client with ID: {0} was not found.";
|
|
88
89
|
case '101': return "Invalid client ID";
|
|
89
90
|
case '206': return "Connection closed";
|
|
@@ -140,6 +141,7 @@ export const translateErrorCode = (code) => {
|
|
|
140
141
|
case '2019': return "Invalid partitions count";
|
|
141
142
|
case '2020': return "Topic directory: {0} not found";
|
|
142
143
|
case '2021': return "Too many topics";
|
|
144
|
+
case '2022': return "Partitions limit reached, raise [metadata] partitions_max";
|
|
143
145
|
// TOPIC
|
|
144
146
|
case '3000': return "Cannot create partition with ID: {0} for stream with ID: {1} and topic with ID: {2}";
|
|
145
147
|
case '3001': return "Failed to create directory for partitions for stream with ID: {0} and topic with ID: {1}";
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
import assert from 'node:assert/strict';
|
|
18
18
|
import { it } from 'node:test';
|
|
19
19
|
import { translateErrorCode } from './error.code.js';
|
|
20
|
+
it('translates the partitions capacity error', () => {
|
|
21
|
+
assert.equal(translateErrorCode(2022), 'Partitions limit reached, raise [metadata] partitions_max');
|
|
22
|
+
});
|
|
23
|
+
it('reports an unknown outcome for an aged-out request', () => {
|
|
24
|
+
assert.equal(translateErrorCode(85), 'Request is below the deduplication window; outcome unknown, resending may duplicate the write');
|
|
25
|
+
});
|
|
20
26
|
it('translates the consumer-offset capacity error', () => {
|
|
21
27
|
assert.equal(translateErrorCode(3024), 'Consumer offset limit reached for partition, raise [partition] consumer_offsets_max');
|
|
22
28
|
});
|
|
@@ -81,14 +81,4 @@ export declare const encodeMessagesBatch: (messages: MessageToEncode[]) => Buffe
|
|
|
81
81
|
* @throws Error if the message array is empty
|
|
82
82
|
*/
|
|
83
83
|
export declare const serializeSendMessages: (streamId: Id, topicId: Id, messages: CreateMessage[], partitioning?: Partitioning) => Buffer<ArrayBuffer>;
|
|
84
|
-
/**
|
|
85
|
-
* Serializes a flush unsaved buffers command payload.
|
|
86
|
-
*
|
|
87
|
-
* @param streamId - Stream identifier
|
|
88
|
-
* @param topicId - Topic identifier
|
|
89
|
-
* @param partitionId - Partition ID to flush
|
|
90
|
-
* @param fsync - Whether to force sync to disk
|
|
91
|
-
* @returns Serialized command payload
|
|
92
|
-
*/
|
|
93
|
-
export declare const serializeFlushUnsavedBuffers: (streamId: Id, topicId: Id, partitionId: number, fsync?: boolean) => Buffer<ArrayBuffer>;
|
|
94
84
|
//# sourceMappingURL=message.utils.d.ts.map
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
import { randomFillSync } from 'node:crypto';
|
|
18
|
-
import { uint32ToBuf, u128ToBuf
|
|
18
|
+
import { uint32ToBuf, u128ToBuf } from '../number.utils.js';
|
|
19
19
|
import { serializeHeaders } from './header.utils.js';
|
|
20
20
|
import { serializeIdentifier } from '../identifier.utils.js';
|
|
21
21
|
import { serializePartitioning } from './partitioning.utils.js';
|
|
@@ -198,25 +198,4 @@ export const serializeSendMessages = (streamId, topicId, messages, partitioning)
|
|
|
198
198
|
bBatch
|
|
199
199
|
]);
|
|
200
200
|
};
|
|
201
|
-
/**
|
|
202
|
-
* Serializes a flush unsaved buffers command payload.
|
|
203
|
-
*
|
|
204
|
-
* @param streamId - Stream identifier
|
|
205
|
-
* @param topicId - Topic identifier
|
|
206
|
-
* @param partitionId - Partition ID to flush
|
|
207
|
-
* @param fsync - Whether to force sync to disk
|
|
208
|
-
* @returns Serialized command payload
|
|
209
|
-
*/
|
|
210
|
-
export const serializeFlushUnsavedBuffers = (streamId, topicId, partitionId, fsync = false) => {
|
|
211
|
-
const streamIdentifier = serializeIdentifier(streamId);
|
|
212
|
-
const topicIdentifier = serializeIdentifier(topicId);
|
|
213
|
-
const bPartitionId = uint32ToBuf(partitionId);
|
|
214
|
-
const bFSync = uint8ToBuf(fsync ? 1 : 0);
|
|
215
|
-
return Buffer.concat([
|
|
216
|
-
streamIdentifier,
|
|
217
|
-
topicIdentifier,
|
|
218
|
-
bPartitionId,
|
|
219
|
-
bFSync
|
|
220
|
-
]);
|
|
221
|
-
};
|
|
222
201
|
//# sourceMappingURL=message.utils.js.map
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { CommandResponse } from '../../client/index.js';
|
|
2
|
+
export type CacheMetrics = {
|
|
3
|
+
streamId: number;
|
|
4
|
+
topicId: number;
|
|
5
|
+
partitionId: number;
|
|
6
|
+
hits: bigint;
|
|
7
|
+
misses: bigint;
|
|
8
|
+
hitRatio: number;
|
|
9
|
+
};
|
|
2
10
|
export type Stats = {
|
|
3
11
|
processId: number;
|
|
4
12
|
cpuUsage: number;
|
|
@@ -22,6 +30,15 @@ export type Stats = {
|
|
|
22
30
|
osName: string;
|
|
23
31
|
osVersion: string;
|
|
24
32
|
kernelVersion: string;
|
|
33
|
+
iggyServerVersion: string;
|
|
34
|
+
/** 0 when the server does not report it. */
|
|
35
|
+
iggyServerSemver: number;
|
|
36
|
+
cacheMetrics: CacheMetrics[];
|
|
37
|
+
threadsCount: number;
|
|
38
|
+
freeDiskSpace: bigint;
|
|
39
|
+
totalDiskSpace: bigint;
|
|
40
|
+
openFilesCount: bigint;
|
|
41
|
+
openFilesLimit: bigint;
|
|
25
42
|
};
|
|
26
43
|
export declare const GET_STATS: {
|
|
27
44
|
code: number;
|
|
@@ -16,7 +16,36 @@
|
|
|
16
16
|
// under the License.
|
|
17
17
|
import { COMMAND_CODE } from '../command.code.js';
|
|
18
18
|
import { wrapCommand } from '../command.utils.js';
|
|
19
|
+
import { deserializeError } from '../error.utils.js';
|
|
20
|
+
// process_id through consumer_groups_count
|
|
21
|
+
const FIXED_HEAD_SIZE = 108;
|
|
22
|
+
// stream_id, topic_id, partition_id, hits, misses, hit_ratio
|
|
23
|
+
const CACHE_METRIC_SIZE = 4 + 4 + 4 + 8 + 8 + 4;
|
|
24
|
+
// threads_count, free_disk_space, total_disk_space
|
|
25
|
+
const THREADS_AND_DISK_SIZE = 4 + 8 + 8;
|
|
26
|
+
// open_files_count, open_files_limit
|
|
27
|
+
const OPEN_FILES_SIZE = 8 + 8;
|
|
28
|
+
const ensureLength = (b, end) => {
|
|
29
|
+
if (end > b.length)
|
|
30
|
+
deserializeError('stats', end, b.length);
|
|
31
|
+
};
|
|
32
|
+
/** A u32 length, then that many bytes of text. */
|
|
33
|
+
const deserializeString = (b, position) => {
|
|
34
|
+
ensureLength(b, position + 4);
|
|
35
|
+
const end = position + 4 + b.readUInt32LE(position);
|
|
36
|
+
ensureLength(b, end);
|
|
37
|
+
return { value: b.subarray(position + 4, end).toString(), end };
|
|
38
|
+
};
|
|
39
|
+
const deserializeCacheMetric = (b, position) => ({
|
|
40
|
+
streamId: b.readUInt32LE(position),
|
|
41
|
+
topicId: b.readUInt32LE(position + 4),
|
|
42
|
+
partitionId: b.readUInt32LE(position + 8),
|
|
43
|
+
hits: b.readBigUInt64LE(position + 12),
|
|
44
|
+
misses: b.readBigUInt64LE(position + 20),
|
|
45
|
+
hitRatio: b.readFloatLE(position + 28)
|
|
46
|
+
});
|
|
19
47
|
const deserializeGetStats = (b) => {
|
|
48
|
+
ensureLength(b, FIXED_HEAD_SIZE);
|
|
20
49
|
const processId = b.readUInt32LE(0);
|
|
21
50
|
const cpuUsage = b.readFloatLE(4);
|
|
22
51
|
const totalCpuUsage = b.readFloatLE(8);
|
|
@@ -35,18 +64,34 @@ const deserializeGetStats = (b) => {
|
|
|
35
64
|
const messagesCount = b.readBigUInt64LE(92);
|
|
36
65
|
const clientsCount = b.readUInt32LE(100);
|
|
37
66
|
const consumersGroupsCount = b.readUInt32LE(104);
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
position
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
position += 4 +
|
|
48
|
-
|
|
49
|
-
const
|
|
67
|
+
const hostname = deserializeString(b, FIXED_HEAD_SIZE);
|
|
68
|
+
const osName = deserializeString(b, hostname.end);
|
|
69
|
+
const osVersion = deserializeString(b, osName.end);
|
|
70
|
+
const kernelVersion = deserializeString(b, osVersion.end);
|
|
71
|
+
const iggyServerVersion = deserializeString(b, kernelVersion.end);
|
|
72
|
+
let position = iggyServerVersion.end;
|
|
73
|
+
ensureLength(b, position + 4 + 4);
|
|
74
|
+
const iggyServerSemver = b.readUInt32LE(position);
|
|
75
|
+
const cacheMetricsCount = b.readUInt32LE(position + 4);
|
|
76
|
+
position += 4 + 4;
|
|
77
|
+
ensureLength(b, position + cacheMetricsCount * CACHE_METRIC_SIZE + THREADS_AND_DISK_SIZE);
|
|
78
|
+
const cacheMetrics = [];
|
|
79
|
+
for (let index = 0; index < cacheMetricsCount; index += 1) {
|
|
80
|
+
cacheMetrics.push(deserializeCacheMetric(b, position));
|
|
81
|
+
position += CACHE_METRIC_SIZE;
|
|
82
|
+
}
|
|
83
|
+
const threadsCount = b.readUInt32LE(position);
|
|
84
|
+
const freeDiskSpace = b.readBigUInt64LE(position + 4);
|
|
85
|
+
const totalDiskSpace = b.readBigUInt64LE(position + 12);
|
|
86
|
+
position += THREADS_AND_DISK_SIZE;
|
|
87
|
+
// Servers that predate the open-files fields end the reply here.
|
|
88
|
+
let openFilesCount = 0n;
|
|
89
|
+
let openFilesLimit = 0n;
|
|
90
|
+
if (b.length > position) {
|
|
91
|
+
ensureLength(b, position + OPEN_FILES_SIZE);
|
|
92
|
+
openFilesCount = b.readBigUInt64LE(position);
|
|
93
|
+
openFilesLimit = b.readBigUInt64LE(position + 8);
|
|
94
|
+
}
|
|
50
95
|
return {
|
|
51
96
|
processId,
|
|
52
97
|
cpuUsage,
|
|
@@ -66,10 +111,18 @@ const deserializeGetStats = (b) => {
|
|
|
66
111
|
messagesCount,
|
|
67
112
|
clientsCount,
|
|
68
113
|
consumersGroupsCount,
|
|
69
|
-
hostname,
|
|
70
|
-
osName,
|
|
71
|
-
osVersion,
|
|
72
|
-
kernelVersion
|
|
114
|
+
hostname: hostname.value,
|
|
115
|
+
osName: osName.value,
|
|
116
|
+
osVersion: osVersion.value,
|
|
117
|
+
kernelVersion: kernelVersion.value,
|
|
118
|
+
iggyServerVersion: iggyServerVersion.value,
|
|
119
|
+
iggyServerSemver,
|
|
120
|
+
cacheMetrics,
|
|
121
|
+
threadsCount,
|
|
122
|
+
freeDiskSpace,
|
|
123
|
+
totalDiskSpace,
|
|
124
|
+
openFilesCount,
|
|
125
|
+
openFilesLimit
|
|
73
126
|
};
|
|
74
127
|
};
|
|
75
128
|
export const GET_STATS = {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
import { describe, it } from 'node:test';
|
|
18
|
+
import assert from 'node:assert/strict';
|
|
19
|
+
import { GET_STATS } from './get-stats.command.js';
|
|
20
|
+
import { DeserializeError } from '../error.utils.js';
|
|
21
|
+
const u32 = (value) => {
|
|
22
|
+
const b = Buffer.alloc(4);
|
|
23
|
+
b.writeUInt32LE(value);
|
|
24
|
+
return b;
|
|
25
|
+
};
|
|
26
|
+
const u64 = (value) => {
|
|
27
|
+
const b = Buffer.alloc(8);
|
|
28
|
+
b.writeBigUInt64LE(value);
|
|
29
|
+
return b;
|
|
30
|
+
};
|
|
31
|
+
const f32 = (value) => {
|
|
32
|
+
const b = Buffer.alloc(4);
|
|
33
|
+
b.writeFloatLE(value);
|
|
34
|
+
return b;
|
|
35
|
+
};
|
|
36
|
+
const str = (value) => Buffer.concat([u32(Buffer.byteLength(value)), Buffer.from(value)]);
|
|
37
|
+
const cacheMetric = (streamId, topicId, partitionId) => Buffer.concat([
|
|
38
|
+
u32(streamId), u32(topicId), u32(partitionId),
|
|
39
|
+
u64(1000n), u64(50n), f32(0.95)
|
|
40
|
+
]);
|
|
41
|
+
const buildStatsPayload = (openFiles) => Buffer.concat([
|
|
42
|
+
u32(1234), f32(25.5), f32(50),
|
|
43
|
+
u64(1073741824n), u64(8589934592n), u64(4294967296n),
|
|
44
|
+
u64(3600n), u64(1710000000000n), u64(1000000n), u64(500000n),
|
|
45
|
+
u64(2000000n),
|
|
46
|
+
u32(3), u32(10), u32(30), u32(90), u64(50000n), u32(5), u32(2),
|
|
47
|
+
str('node-1'), str('Linux'), str('6.1'), str('6.1.0'), str('0.6.0'),
|
|
48
|
+
u32(600),
|
|
49
|
+
u32(2), cacheMetric(1, 1, 0), cacheMetric(2, 3, 1),
|
|
50
|
+
u32(16), u64(107374182400n), u64(512110190592n),
|
|
51
|
+
...(openFiles ? [u64(openFiles.count), u64(openFiles.limit)] : [])
|
|
52
|
+
]);
|
|
53
|
+
const deserialize = (data) => GET_STATS.deserialize({ status: 0, length: data.length, data });
|
|
54
|
+
describe('GetStats Command', () => {
|
|
55
|
+
it('deserializes open files count and limit', () => {
|
|
56
|
+
const stats = deserialize(buildStatsPayload({ count: 1234n, limit: 1048576n }));
|
|
57
|
+
assert.equal(stats.processId, 1234);
|
|
58
|
+
assert.equal(stats.kernelVersion, '6.1.0');
|
|
59
|
+
assert.equal(stats.openFilesCount, 1234n);
|
|
60
|
+
assert.equal(stats.openFilesLimit, 1048576n);
|
|
61
|
+
});
|
|
62
|
+
it('deserializes server version, cache metrics, threads and disk space', () => {
|
|
63
|
+
const stats = deserialize(buildStatsPayload());
|
|
64
|
+
assert.equal(stats.iggyServerVersion, '0.6.0');
|
|
65
|
+
assert.equal(stats.iggyServerSemver, 600);
|
|
66
|
+
assert.deepEqual(stats.cacheMetrics, [
|
|
67
|
+
{
|
|
68
|
+
streamId: 1, topicId: 1, partitionId: 0,
|
|
69
|
+
hits: 1000n, misses: 50n, hitRatio: Math.fround(0.95)
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
streamId: 2, topicId: 3, partitionId: 1,
|
|
73
|
+
hits: 1000n, misses: 50n, hitRatio: Math.fround(0.95)
|
|
74
|
+
}
|
|
75
|
+
]);
|
|
76
|
+
assert.equal(stats.threadsCount, 16);
|
|
77
|
+
assert.equal(stats.freeDiskSpace, 107374182400n);
|
|
78
|
+
assert.equal(stats.totalDiskSpace, 512110190592n);
|
|
79
|
+
});
|
|
80
|
+
it('reads open files fields as 0 when the reply ends at total_disk_space', () => {
|
|
81
|
+
const stats = deserialize(buildStatsPayload());
|
|
82
|
+
assert.equal(stats.kernelVersion, '6.1.0');
|
|
83
|
+
assert.equal(stats.openFilesCount, 0n);
|
|
84
|
+
assert.equal(stats.openFilesLimit, 0n);
|
|
85
|
+
});
|
|
86
|
+
it('throws on truncated open files fields', () => {
|
|
87
|
+
const payload = buildStatsPayload({ count: 1234n, limit: 1048576n });
|
|
88
|
+
for (let cut = 1; cut < 16; cut += 1)
|
|
89
|
+
assert.throws(() => deserialize(payload.subarray(0, payload.length - cut)), DeserializeError);
|
|
90
|
+
});
|
|
91
|
+
it('throws on a reply truncated before total_disk_space ends', () => {
|
|
92
|
+
const payload = buildStatsPayload();
|
|
93
|
+
for (let length = 0; length < payload.length; length += 1)
|
|
94
|
+
assert.throws(() => deserialize(payload.subarray(0, length)), DeserializeError, `a reply cut to ${length} bytes must not decode`);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=get-stats.command.test.js.map
|
package/dist/wire/vsr/index.js
CHANGED
|
@@ -61,9 +61,8 @@ export class VsrSession {
|
|
|
61
61
|
else {
|
|
62
62
|
if (this.state.session === null)
|
|
63
63
|
throw responseError(command, UNAUTHENTICATED);
|
|
64
|
-
// Partition ops consume an id too
|
|
65
|
-
//
|
|
66
|
-
// metadata watermark tolerates the gaps.
|
|
64
|
+
// Partition ops consume an id too: dedup needs each send to carry a
|
|
65
|
+
// distinct number, and the metadata watermark tolerates the gaps.
|
|
67
66
|
request = this.state.nextRequestId();
|
|
68
67
|
session = this.state.session;
|
|
69
68
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apache-iggy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1-edge.1",
|
|
5
5
|
"description": "Official Apache Iggy NodeJS SDK",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"iggy",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"author": "github.com/T1B0",
|
|
51
51
|
"license": "Apache-2.0",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@node-rs/xxhash": "1.7.
|
|
53
|
+
"@node-rs/xxhash": "1.7.8",
|
|
54
54
|
"debug": "4.4.3",
|
|
55
55
|
"generic-pool": "3.9.0",
|
|
56
56
|
"uuidv7": "1.2.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@commitlint/cli": "21.2.
|
|
60
|
-
"@commitlint/config-conventional": "21.2.
|
|
59
|
+
"@commitlint/cli": "21.2.3",
|
|
60
|
+
"@commitlint/config-conventional": "21.2.3",
|
|
61
61
|
"@cucumber/cucumber": "13.2.1",
|
|
62
62
|
"@swc-node/register": "1.12.1",
|
|
63
63
|
"@types/debug": "4.1.13",
|
|
64
|
-
"@types/node": "26.
|
|
64
|
+
"@types/node": "26.6.2",
|
|
65
65
|
"c8": "^12.0.0",
|
|
66
66
|
"husky": "9.1.7",
|
|
67
67
|
"typescript": "6.0.3",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type Id } from '../identifier.utils.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parameters for the flush unsaved buffers command.
|
|
4
|
-
*/
|
|
5
|
-
export type FlushUnsavedBuffer = {
|
|
6
|
-
/** Stream identifier */
|
|
7
|
-
streamId: Id;
|
|
8
|
-
/** Topic identifier */
|
|
9
|
-
topicId: Id;
|
|
10
|
-
/** Partition ID to flush */
|
|
11
|
-
partitionId: number;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Flush unsaved buffers command definition.
|
|
15
|
-
* Forces buffered messages to be persisted to disk.
|
|
16
|
-
*/
|
|
17
|
-
export declare const FLUSH_UNSAVED_BUFFERS: {
|
|
18
|
-
code: number;
|
|
19
|
-
serialize: ({ streamId, topicId, partitionId }: FlushUnsavedBuffer) => Buffer<ArrayBuffer>;
|
|
20
|
-
deserialize: (r: import("../../index.js").CommandResponse) => boolean;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Executable flush unsaved buffers command function.
|
|
24
|
-
*/
|
|
25
|
-
export declare const flushUnsavedBuffers: (getClient: import("../../index.js").ClientProvider) => (arg: FlushUnsavedBuffer) => Promise<boolean>;
|
|
26
|
-
//# sourceMappingURL=flush-unsaved-buffers.command.d.ts.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
import { serializeFlushUnsavedBuffers } from './message.utils.js';
|
|
18
|
-
import { deserializeVoidResponse } from '../../client/client.utils.js';
|
|
19
|
-
import { wrapCommand } from '../command.utils.js';
|
|
20
|
-
import { COMMAND_CODE } from '../command.code.js';
|
|
21
|
-
/**
|
|
22
|
-
* Flush unsaved buffers command definition.
|
|
23
|
-
* Forces buffered messages to be persisted to disk.
|
|
24
|
-
*/
|
|
25
|
-
export const FLUSH_UNSAVED_BUFFERS = {
|
|
26
|
-
code: COMMAND_CODE.FlushUnsavedBuffers,
|
|
27
|
-
serialize: ({ streamId, topicId, partitionId }) => {
|
|
28
|
-
return serializeFlushUnsavedBuffers(streamId, topicId, partitionId);
|
|
29
|
-
},
|
|
30
|
-
deserialize: deserializeVoidResponse
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Executable flush unsaved buffers command function.
|
|
34
|
-
*/
|
|
35
|
-
export const flushUnsavedBuffers = wrapCommand(FLUSH_UNSAVED_BUFFERS);
|
|
36
|
-
//# sourceMappingURL=flush-unsaved-buffers.command.js.map
|