apache-iggy 0.6.0-edge.2 → 0.6.0
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/dist/e2e/tcp.cluster.e2e.js +29 -21
- package/dist/wire/cluster/cluster.type.d.ts +2 -1
- package/dist/wire/cluster/cluster.type.js +2 -1
- package/dist/wire/cluster/cluster.utils.d.ts +9 -5
- package/dist/wire/cluster/cluster.utils.js +33 -24
- package/dist/wire/message/partitioning.utils.d.ts +1 -1
- package/dist/wire/message/poll.utils.d.ts +2 -1
- package/package.json +21 -14
|
@@ -16,35 +16,43 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { after, describe, it } from
|
|
20
|
-
import assert from
|
|
21
|
-
import { getTestClient } from
|
|
19
|
+
import { after, describe, it } from "node:test";
|
|
20
|
+
import assert from "node:assert/strict";
|
|
21
|
+
import { getTestClient } from "./test-client.utils.js";
|
|
22
22
|
// cluster mode still in dev atm
|
|
23
23
|
// response is mocked from /core/configs/server.toml
|
|
24
24
|
const expectedMeta = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"transport": "TCP",
|
|
28
|
-
"nodes": [
|
|
25
|
+
name: "iggy-cluster",
|
|
26
|
+
nodes: [
|
|
29
27
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
name: "iggy-node-1",
|
|
29
|
+
ip: "127.0.0.1",
|
|
30
|
+
endpoints: {
|
|
31
|
+
tcp: 8090,
|
|
32
|
+
quic: 8080,
|
|
33
|
+
http: 3000,
|
|
34
|
+
websocket: 8092,
|
|
35
|
+
},
|
|
36
|
+
role: "Leader",
|
|
37
|
+
status: "Healthy",
|
|
35
38
|
},
|
|
36
39
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
name: "iggy-node-2",
|
|
41
|
+
ip: "127.0.0.1",
|
|
42
|
+
endpoints: {
|
|
43
|
+
tcp: 8091,
|
|
44
|
+
quic: 8081,
|
|
45
|
+
http: 3001,
|
|
46
|
+
websocket: 8093,
|
|
47
|
+
},
|
|
48
|
+
role: "Follower",
|
|
49
|
+
status: "Healthy",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
44
52
|
};
|
|
45
|
-
describe(
|
|
53
|
+
describe("e2e -> system", async () => {
|
|
46
54
|
const c = getTestClient();
|
|
47
|
-
it(
|
|
55
|
+
it("e2e -> cluster::getClusterMetadata", async () => {
|
|
48
56
|
const meta = await c.cluster.getClusterMetadata();
|
|
49
57
|
assert.deepEqual(meta, expectedMeta);
|
|
50
58
|
});
|
|
@@ -40,11 +40,12 @@ export declare const TransportProtocol: {
|
|
|
40
40
|
readonly TCP: 1;
|
|
41
41
|
readonly QUIC: 2;
|
|
42
42
|
readonly HTTP: 3;
|
|
43
|
+
readonly WebSocket: 4;
|
|
43
44
|
};
|
|
44
45
|
export type TransportProtocol = typeof TransportProtocol;
|
|
45
46
|
export type TransportProtocolKey = keyof TransportProtocol;
|
|
46
47
|
export type TransportProtocolValue = ValueOf<TransportProtocol>;
|
|
47
|
-
export declare const ReverseTransportProtocol: Record<1 | 2 | 3, "TCP" | "QUIC" | "HTTP">;
|
|
48
|
+
export declare const ReverseTransportProtocol: Record<1 | 2 | 4 | 3, "TCP" | "QUIC" | "HTTP" | "WebSocket">;
|
|
48
49
|
export declare const isClusterNodeRole: (n: number) => n is ClusterNodeRoleValue;
|
|
49
50
|
export declare const isClusterNodeStatus: (n: number) => n is ClusterNodeStatusValue;
|
|
50
51
|
export declare const isTransportProtocol: (n: number) => n is TransportProtocolValue;
|
|
@@ -38,7 +38,8 @@ export const ReverseClusterNodeStatus = reverseRecord(ClusterNodeStatus);
|
|
|
38
38
|
export const TransportProtocol = {
|
|
39
39
|
TCP: 1,
|
|
40
40
|
QUIC: 2,
|
|
41
|
-
HTTP: 3
|
|
41
|
+
HTTP: 3,
|
|
42
|
+
WebSocket: 4
|
|
42
43
|
};
|
|
43
44
|
export const ReverseTransportProtocol = reverseRecord(TransportProtocol);
|
|
44
45
|
export const isClusterNodeRole = (n) => n in ReverseClusterNodeRole;
|
|
@@ -16,11 +16,17 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { type ClusterNodeRoleKey, type ClusterNodeStatusKey
|
|
19
|
+
import { type ClusterNodeRoleKey, type ClusterNodeStatusKey } from './cluster.type.js';
|
|
20
|
+
export type TransportEndpoints = {
|
|
21
|
+
tcp: number;
|
|
22
|
+
quic: number;
|
|
23
|
+
http: number;
|
|
24
|
+
websocket: number;
|
|
25
|
+
};
|
|
20
26
|
export type ClusterNode = {
|
|
21
|
-
id: number;
|
|
22
27
|
name: string;
|
|
23
|
-
|
|
28
|
+
ip: string;
|
|
29
|
+
endpoints: TransportEndpoints;
|
|
24
30
|
role: ClusterNodeRoleKey;
|
|
25
31
|
status: ClusterNodeStatusKey;
|
|
26
32
|
};
|
|
@@ -31,8 +37,6 @@ type DeserializedClusterNode = {
|
|
|
31
37
|
export declare const deserializeNode: (b: Buffer, pos?: number) => DeserializedClusterNode;
|
|
32
38
|
export type ClusterMetadata = {
|
|
33
39
|
name: string;
|
|
34
|
-
id: number;
|
|
35
|
-
transport: TransportProtocolKey;
|
|
36
40
|
nodes: ClusterNode[];
|
|
37
41
|
};
|
|
38
42
|
export declare const deserializeMetadata: (b: Buffer, pos?: number) => ClusterMetadata;
|
|
@@ -17,58 +17,69 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { deserializeError } from '../error.utils.js';
|
|
20
|
-
import { mapClusterNodeRole, mapClusterNodeStatus,
|
|
21
|
-
const CLUSTER_NODE_MIN_BUFFER_SIZE =
|
|
20
|
+
import { mapClusterNodeRole, mapClusterNodeStatus, } from './cluster.type.js';
|
|
21
|
+
const CLUSTER_NODE_MIN_BUFFER_SIZE = 18; // 4 + 1 + 4 + 1 + 8 (endpoints) + 1 + 1;
|
|
22
22
|
export const deserializeNode = (b, pos = 0) => {
|
|
23
23
|
if (b.length - pos < CLUSTER_NODE_MIN_BUFFER_SIZE)
|
|
24
24
|
deserializeError('cluster node', pos, b.length, CLUSTER_NODE_MIN_BUFFER_SIZE);
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const startPos = pos;
|
|
26
|
+
// Read name
|
|
27
27
|
const nameLen = b.readUInt32LE(pos);
|
|
28
28
|
if (b.length - pos < 4 + nameLen)
|
|
29
|
-
deserializeError('cluster node', pos, b.length, 4 + nameLen, {
|
|
29
|
+
deserializeError('cluster node', pos, b.length, 4 + nameLen, { nameLen });
|
|
30
30
|
const name = b.subarray(pos + 4, pos + 4 + nameLen).toString();
|
|
31
31
|
pos += nameLen + 4;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
pos
|
|
32
|
+
// Read IP
|
|
33
|
+
const ipLen = b.readUInt32LE(pos);
|
|
34
|
+
if (b.length - pos < 4 + ipLen)
|
|
35
|
+
deserializeError('cluster node', pos, b.length, 4 + ipLen, { nameLen, name, ipLen });
|
|
36
|
+
const ip = b.subarray(pos + 4, pos + 4 + ipLen).toString();
|
|
37
|
+
pos += ipLen + 4;
|
|
38
|
+
// Read transport endpoints (4 ports, each u16)
|
|
39
|
+
if (b.length - pos < 8)
|
|
40
|
+
deserializeError('cluster node endpoints', pos, b.length, 8, { nameLen, name, ipLen, ip });
|
|
41
|
+
const endpoints = {
|
|
42
|
+
tcp: b.readUInt16LE(pos),
|
|
43
|
+
quic: b.readUInt16LE(pos + 2),
|
|
44
|
+
http: b.readUInt16LE(pos + 4),
|
|
45
|
+
websocket: b.readUInt16LE(pos + 6)
|
|
46
|
+
};
|
|
47
|
+
pos += 8;
|
|
48
|
+
// Read role and status
|
|
37
49
|
if (b.length - pos < 2)
|
|
38
|
-
deserializeError('cluster node', pos, b.length, 2, {
|
|
50
|
+
deserializeError('cluster node', pos, b.length, 2, { nameLen, name, ipLen, ip });
|
|
39
51
|
const role = mapClusterNodeRole(b.readUInt8(pos));
|
|
40
52
|
pos += 1;
|
|
41
53
|
const status = mapClusterNodeStatus(b.readUInt8(pos));
|
|
42
54
|
pos += 1;
|
|
43
55
|
return {
|
|
44
|
-
length:
|
|
56
|
+
length: pos - startPos,
|
|
45
57
|
data: {
|
|
46
|
-
id,
|
|
47
58
|
name,
|
|
48
|
-
|
|
59
|
+
ip,
|
|
60
|
+
endpoints,
|
|
49
61
|
role,
|
|
50
62
|
status
|
|
51
63
|
}
|
|
52
64
|
};
|
|
53
65
|
};
|
|
54
|
-
// min = 4 + 1 + 4 +
|
|
55
|
-
const CLUSTER_METADATA_MIN_SIZE =
|
|
66
|
+
// min = 4 + 1 + 4 + CLUSTER_NODE_MIN_BUFFER_SIZE;
|
|
67
|
+
const CLUSTER_METADATA_MIN_SIZE = 8 + CLUSTER_NODE_MIN_BUFFER_SIZE;
|
|
56
68
|
export const deserializeMetadata = (b, pos = 0) => {
|
|
57
69
|
if (b.length - pos < CLUSTER_METADATA_MIN_SIZE)
|
|
58
70
|
deserializeError('cluster metadata', pos, b.length, CLUSTER_METADATA_MIN_SIZE);
|
|
71
|
+
// Read cluster name
|
|
59
72
|
const nameLen = b.readUInt32LE(pos);
|
|
60
73
|
if (b.length - pos < 4 + nameLen)
|
|
61
74
|
deserializeError('cluster metadata', pos, b.length, 4 + nameLen, { nameLen });
|
|
62
75
|
const name = b.subarray(pos + 4, pos + 4 + nameLen).toString();
|
|
63
76
|
pos += nameLen + 4;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
pos += 4;
|
|
68
|
-
const transport = mapTransportProtocol(b.readUInt8(pos));
|
|
69
|
-
pos += 1;
|
|
77
|
+
// Read nodes count
|
|
78
|
+
if (b.length - pos < 4)
|
|
79
|
+
deserializeError('cluster metadata', pos, b.length, 4, { nameLen, name });
|
|
70
80
|
const nodeCount = b.readUInt32LE(pos);
|
|
71
81
|
pos += 4;
|
|
82
|
+
// Read nodes array
|
|
72
83
|
const nodes = [];
|
|
73
84
|
for (let i = 0; i < nodeCount; i++) {
|
|
74
85
|
const { length, data } = deserializeNode(b, pos);
|
|
@@ -77,8 +88,6 @@ export const deserializeMetadata = (b, pos = 0) => {
|
|
|
77
88
|
}
|
|
78
89
|
return {
|
|
79
90
|
name,
|
|
80
|
-
id,
|
|
81
|
-
transport,
|
|
82
91
|
nodes
|
|
83
92
|
};
|
|
84
93
|
};
|
|
@@ -44,7 +44,7 @@ export declare const Partitioning: {
|
|
|
44
44
|
PartitionId: (id: number) => PartitionId;
|
|
45
45
|
MessageKey: (key: MessageKeyValue) => MessageKey;
|
|
46
46
|
};
|
|
47
|
-
export declare const serializeMessageKey: (v: MessageKeyValue) => Buffer<
|
|
47
|
+
export declare const serializeMessageKey: (v: MessageKeyValue) => Buffer<ArrayBufferLike>;
|
|
48
48
|
export declare const serializePartitioningValue: (part: Partitioning) => Buffer;
|
|
49
49
|
export declare const default_partionning: Balanced;
|
|
50
50
|
export declare const serializePartitioning: (p?: Partitioning) => Buffer<ArrayBuffer>;
|
|
@@ -60,7 +60,8 @@ export declare const PollingStrategy: {
|
|
|
60
60
|
Offset: (n: bigint) => OffsetPollingStrategy;
|
|
61
61
|
Timestamp: (n: bigint) => TimestampPollingStrategy;
|
|
62
62
|
};
|
|
63
|
-
export declare const serializePollMessages: (streamId: Id, topicId: Id, consumer: Consumer, partitionId: number | null, pollingStrategy: PollingStrategy,
|
|
63
|
+
export declare const serializePollMessages: (streamId: Id, topicId: Id, consumer: Consumer, partitionId: number | null, pollingStrategy: PollingStrategy, // default to OffsetPollingStrategy
|
|
64
|
+
count?: number, autocommit?: boolean) => Buffer<ArrayBuffer>;
|
|
64
65
|
export declare const MessageState: {
|
|
65
66
|
Available: number;
|
|
66
67
|
Unavailable: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apache-iggy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.0
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"description": "Official Apache Iggy NodeJS SDK",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"iggy",
|
|
@@ -47,24 +47,31 @@
|
|
|
47
47
|
"author": "github.com/T1B0",
|
|
48
48
|
"license": "Apache-2.0",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"debug": "4.3
|
|
50
|
+
"debug": "4.4.3",
|
|
51
51
|
"generic-pool": "3.9.0",
|
|
52
52
|
"uuidv7": "1.0.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@commitlint/cli": "
|
|
56
|
-
"@commitlint/config-conventional": "
|
|
57
|
-
"@cucumber/cucumber": "
|
|
58
|
-
"@
|
|
59
|
-
"@semantic-release/exec": "6.0.3",
|
|
60
|
-
"@semantic-release/git": "10.0.1",
|
|
61
|
-
"@semantic-release/release-notes-generator": "14.0.1",
|
|
62
|
-
"@swc-node/register": "1.10.9",
|
|
55
|
+
"@commitlint/cli": "20.1.0",
|
|
56
|
+
"@commitlint/config-conventional": "20.0.0",
|
|
57
|
+
"@cucumber/cucumber": "12.2.0",
|
|
58
|
+
"@swc-node/register": "1.11.1",
|
|
63
59
|
"@types/debug": "4.1.12",
|
|
64
|
-
"@types/node": "
|
|
60
|
+
"@types/node": "24.10.1",
|
|
65
61
|
"husky": "9.1.7",
|
|
66
|
-
"
|
|
67
|
-
"typescript": "
|
|
68
|
-
|
|
62
|
+
"typescript": "5.9.3",
|
|
63
|
+
"typescript-eslint": "^8.47.0"
|
|
64
|
+
},
|
|
65
|
+
"optionalDependencies": {
|
|
66
|
+
"@swc/core-darwin-arm64": "^1.15.3",
|
|
67
|
+
"@swc/core-darwin-x64": "^1.15.3",
|
|
68
|
+
"@swc/core-linux-arm-gnueabihf": "^1.15.3",
|
|
69
|
+
"@swc/core-linux-arm64-gnu": "^1.15.3",
|
|
70
|
+
"@swc/core-linux-arm64-musl": "^1.15.3",
|
|
71
|
+
"@swc/core-linux-x64-gnu": "^1.15.3",
|
|
72
|
+
"@swc/core-linux-x64-musl": "^1.15.3",
|
|
73
|
+
"@swc/core-win32-arm64-msvc": "^1.15.3",
|
|
74
|
+
"@swc/core-win32-ia32-msvc": "^1.15.3",
|
|
75
|
+
"@swc/core-win32-x64-msvc": "^1.15.3"
|
|
69
76
|
}
|
|
70
77
|
}
|