apache-iggy 0.5.2 → 0.6.0-edge.2

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.
Files changed (75) hide show
  1. package/dist/client/client.connection.js +30 -34
  2. package/dist/client/client.socket.js +1 -1
  3. package/dist/debug-send.js +14 -16
  4. package/dist/debug.js +13 -15
  5. package/dist/e2e/tcp.cluster.e2e.d.ts +20 -0
  6. package/dist/e2e/tcp.cluster.e2e.js +55 -0
  7. package/dist/e2e/tcp.consumer-group.e2e.js +41 -29
  8. package/dist/e2e/tcp.consumer-stream.e2e.js +11 -12
  9. package/dist/e2e/tcp.send-message.e2e.js +60 -23
  10. package/dist/e2e/tcp.stream.e2e.js +5 -6
  11. package/dist/e2e/tcp.system.e2e.js +1 -1
  12. package/dist/e2e/tcp.topic.e2e.js +18 -23
  13. package/dist/e2e/tcp.user.e2e.js +5 -0
  14. package/dist/stream/consumer-stream.d.ts +2 -2
  15. package/dist/stream/consumer-stream.js +4 -14
  16. package/dist/tcp.e2e.js +2 -0
  17. package/dist/wire/client/get-client.command.d.ts +2 -2
  18. package/dist/wire/client/get-client.command.js +5 -1
  19. package/dist/wire/cluster/cluster.type.d.ts +54 -0
  20. package/dist/wire/cluster/cluster.type.js +62 -0
  21. package/dist/wire/cluster/cluster.utils.d.ts +40 -0
  22. package/dist/wire/cluster/cluster.utils.js +85 -0
  23. package/dist/wire/cluster/get-cluster-metadata.command.d.ts +27 -0
  24. package/dist/wire/cluster/get-cluster-metadata.command.js +30 -0
  25. package/dist/wire/cluster/index.d.ts +21 -0
  26. package/dist/wire/cluster/index.js +21 -0
  27. package/dist/wire/command-set.d.ts +15 -6
  28. package/dist/wire/command-set.js +14 -2
  29. package/dist/wire/command.code.d.ts +1 -0
  30. package/dist/wire/command.code.js +1 -0
  31. package/dist/wire/command.utils.js +0 -6
  32. package/dist/wire/consumer-group/create-group.command.d.ts +1 -2
  33. package/dist/wire/consumer-group/create-group.command.js +4 -4
  34. package/dist/wire/consumer-group/create-group.command.test.js +1 -2
  35. package/dist/wire/consumer-group/ensure-group.virtual.command.d.ts +23 -0
  36. package/dist/wire/consumer-group/ensure-group.virtual.command.js +33 -0
  37. package/dist/wire/consumer-group/get-group.command.d.ts +2 -2
  38. package/dist/wire/consumer-group/get-group.command.js +2 -0
  39. package/dist/wire/consumer-group/index.d.ts +1 -0
  40. package/dist/wire/consumer-group/index.js +1 -0
  41. package/dist/wire/error.utils.d.ts +4 -0
  42. package/dist/wire/error.utils.js +10 -0
  43. package/dist/wire/message/header.type.d.ts +1 -1
  44. package/dist/wire/message/poll-messages.command.d.ts +1 -1
  45. package/dist/wire/message/poll.utils.d.ts +1 -1
  46. package/dist/wire/message/poll.utils.js +1 -2
  47. package/dist/wire/offset/delete-offset.command.js +1 -1
  48. package/dist/wire/offset/get-offset.command.d.ts +7 -3
  49. package/dist/wire/offset/get-offset.command.js +3 -3
  50. package/dist/wire/offset/offset.utils.d.ts +2 -2
  51. package/dist/wire/offset/offset.utils.js +13 -4
  52. package/dist/wire/offset/store-offset.command.d.ts +1 -1
  53. package/dist/wire/stream/create-stream.command.d.ts +2 -2
  54. package/dist/wire/stream/create-stream.command.js +4 -4
  55. package/dist/wire/stream/create-stream.command.test.js +2 -3
  56. package/dist/wire/stream/ensure-stream.virtual.command.d.ts +21 -0
  57. package/dist/wire/stream/ensure-stream.virtual.command.js +26 -0
  58. package/dist/wire/stream/get-stream.command.d.ts +2 -2
  59. package/dist/wire/stream/get-stream.command.js +2 -0
  60. package/dist/wire/stream/index.d.ts +1 -0
  61. package/dist/wire/stream/index.js +1 -0
  62. package/dist/wire/system/get-stats.command.d.ts +1 -1
  63. package/dist/wire/topic/create-topic.command.d.ts +1 -2
  64. package/dist/wire/topic/create-topic.command.js +9 -9
  65. package/dist/wire/topic/create-topic.command.test.js +2 -3
  66. package/dist/wire/topic/ensure-topic.virtual.command.d.ts +22 -0
  67. package/dist/wire/topic/ensure-topic.virtual.command.js +28 -0
  68. package/dist/wire/topic/get-topic.command.d.ts +2 -2
  69. package/dist/wire/topic/get-topic.command.js +2 -0
  70. package/dist/wire/topic/index.d.ts +1 -0
  71. package/dist/wire/topic/index.js +1 -0
  72. package/dist/wire/topic/topic.utils.js +1 -1
  73. package/dist/wire/user/get-user.command.d.ts +2 -2
  74. package/dist/wire/user/get-user.command.js +5 -1
  75. package/package.json +1 -1
@@ -125,43 +125,39 @@ export class IggyConnection extends EventEmitter {
125
125
  }
126
126
  _onData(data) {
127
127
  debug('ONDATA', typeof data, Buffer.isBuffer(data), data?.length, this.waitingResponseEnd);
128
- if (this.waitingResponseEnd) {
128
+ // Append new data to any buffered data
129
+ if (this.waitingResponseEnd && this.readBuffers.length > 0) {
129
130
  data = Buffer.concat([this.readBuffers, data]);
130
131
  }
131
- if (data.length < 8) {
132
- this.socket.unshift(data);
133
- return;
134
- }
135
- /**
136
- * data[0:4] hold response status code
137
- * const status = data.readUInt32LE(0);
138
- * data[4:8] hold response length
139
- */
140
- const responseSize = data.readUInt32LE(4);
141
- /** response is just head, no payload */
142
- if (responseSize === 0 && data.length === 8) {
143
- this.emit('response', data);
144
- return;
145
- }
146
- const payloadLength = data.length - 8;
147
- /** payload is complete */
148
- if (payloadLength === responseSize) {
149
- this.emit('response', data);
150
- this._endResponseWait();
151
- return;
152
- }
153
- /** payload is incomplete, buffering until next data event */
154
- if (payloadLength < responseSize) {
155
- this.waitingResponseEnd = true;
156
- this.readBuffers = data;
157
- return;
158
- }
159
- /** payload is bigger than expected, cut response and unshift extra data */
160
- if (payloadLength > responseSize) {
161
- this.emit('response', data.subarray(0, 8 + responseSize));
162
- this._endResponseWait();
163
- this.socket.unshift(data.subarray(8 + responseSize));
132
+ // Keep processing while we have enough data
133
+ let offset = 0;
134
+ while (offset < data.length) {
135
+ const remaining = data.length - offset;
136
+ // Need at least 8 bytes for the header (4 bytes status + 4 bytes length)
137
+ if (remaining < 8) {
138
+ // Buffer the incomplete header and wait for more data
139
+ this.waitingResponseEnd = true;
140
+ this.readBuffers = data.subarray(offset);
141
+ return;
142
+ }
143
+ // Read the header
144
+ const responseSize = data.readUInt32LE(offset + 4);
145
+ const totalSize = 8 + responseSize;
146
+ // Check if we have the complete response (header + payload)
147
+ if (remaining < totalSize) {
148
+ // Buffer the incomplete response and wait for more data
149
+ this.waitingResponseEnd = true;
150
+ this.readBuffers = data.subarray(offset);
151
+ return;
152
+ }
153
+ // We have a complete response, extract it and emit
154
+ const response = data.subarray(offset, offset + totalSize);
155
+ this.emit('response', response);
156
+ // Move to the next response
157
+ offset += totalSize;
164
158
  }
159
+ // All data processed, reset buffers
160
+ this._endResponseWait();
165
161
  }
166
162
  writeCommand(command, payload) {
167
163
  const cmd = serializeCommand(command, payload);
@@ -56,7 +56,7 @@ export class CommandResponseStream extends EventEmitter {
56
56
  await this.connection.connect();
57
57
  if (!this.isAuthenticated && !UNLOGGED_COMMAND_CODE.includes(command))
58
58
  await this.authenticate(this.options.credentials);
59
- return new Promise(async (resolve, reject) => {
59
+ return new Promise((resolve, reject) => {
60
60
  if (last)
61
61
  this._execQueue.push({ command, payload, resolve, reject });
62
62
  else
@@ -20,17 +20,15 @@ import assert from 'node:assert/strict';
20
20
  import { SingleClient } from './client/index.js';
21
21
  import { groupConsumerStream } from './stream/consumer-stream.js';
22
22
  import { PollingStrategy } from './wire/index.js';
23
- const streamId = 321;
24
- const topicId = 543;
25
- const groupId = 531231;
23
+ const streamName = 'debug-snd-stream';
24
+ const topicName = 'debug-snd-topic';
25
+ const groupName = 'debug-snd-group';
26
26
  const stream = {
27
- streamId,
28
- name: 'debug2-send-message-stream'
27
+ name: streamName
29
28
  };
30
29
  const topic = {
31
- streamId,
32
- topicId,
33
- name: 'debug2-send-message-topic',
30
+ streamId: streamName,
31
+ name: topicName,
34
32
  partitionCount: 1,
35
33
  compressionAlgorithm: 1
36
34
  };
@@ -51,13 +49,13 @@ const opt = {
51
49
  };
52
50
  const c = new SingleClient(opt);
53
51
  const cleanup = async () => {
54
- assert.ok(await c.stream.delete(stream));
52
+ assert.ok(await c.stream.delete({ streamId: streamName }));
55
53
  assert.ok(await c.session.logout());
56
54
  c.destroy();
57
55
  };
58
56
  const msg = {
59
- streamId,
60
- topicId,
57
+ streamId: streamName,
58
+ topicId: topicName,
61
59
  messages: [
62
60
  { payload: 'yolo msg 2' },
63
61
  { payload: 'yolo msg v4' },
@@ -66,9 +64,9 @@ const msg = {
66
64
  };
67
65
  try {
68
66
  await c.stream.create(stream);
69
- console.log('server stream CREATED::', { streamId });
67
+ console.log('server stream CREATED::', { streamName });
70
68
  await c.topic.create(topic);
71
- console.log('server topic CREATED::', { topicId });
69
+ console.log('server topic CREATED::', { topicName });
72
70
  // send
73
71
  setInterval(async () => {
74
72
  assert.ok(await c.message.send(msg));
@@ -76,9 +74,9 @@ try {
76
74
  }, 3000);
77
75
  // POLL MESSAGE
78
76
  const pollReq = {
79
- groupId,
80
- streamId,
81
- topicId,
77
+ groupName,
78
+ streamId: streamName,
79
+ topicId: topicName,
82
80
  pollingStrategy: PollingStrategy.Next,
83
81
  count: 1,
84
82
  interval: 5000
package/dist/debug.js CHANGED
@@ -21,17 +21,15 @@ import { Client } from './client/index.js';
21
21
  import { uuidv7, uuidv4 } from 'uuidv7';
22
22
  import { groupConsumerStream } from './stream/consumer-stream.js';
23
23
  import { PollingStrategy } from './wire/index.js';
24
- const streamId = 123;
25
- const topicId = 345;
26
- const groupId = 12353;
24
+ const streamName = 'debug-stream';
25
+ const topicName = 'debug-topic';
26
+ const groupName = 'debug-group';
27
27
  const stream = {
28
- streamId,
29
28
  name: 'debug-send-message-stream'
30
29
  };
31
30
  const topic = {
32
- streamId,
33
- topicId,
34
- name: 'debug-send-message-topic',
31
+ streamId: streamName,
32
+ name: topicName,
35
33
  partitionCount: 1,
36
34
  compressionAlgorithm: 1
37
35
  };
@@ -48,13 +46,13 @@ const opt = {
48
46
  };
49
47
  const c = new Client(opt);
50
48
  const cleanup = async () => {
51
- assert.ok(await c.stream.delete(stream));
49
+ assert.ok(await c.stream.delete({ streamId: streamName }));
52
50
  assert.ok(await c.session.logout());
53
51
  c.destroy();
54
52
  };
55
53
  const msg = {
56
- streamId,
57
- topicId,
54
+ streamId: streamName,
55
+ topicId: topicName,
58
56
  messages: [
59
57
  { payload: 'yolo msg 2' },
60
58
  { id: 0, payload: 'nooooooooo' },
@@ -65,17 +63,17 @@ const msg = {
65
63
  };
66
64
  try {
67
65
  await c.stream.create(stream);
68
- console.log('server stream CREATED::', { streamId });
66
+ console.log('server stream CREATED::', { streamName });
69
67
  await c.topic.create(topic);
70
- console.log('server topic CREATED::', { topicId });
68
+ console.log('server topic CREATED::', { topicName });
71
69
  // send
72
70
  assert.ok(await c.message.send(msg));
73
71
  console.log('message SEND::', { msg });
74
72
  // POLL MESSAGE
75
73
  const pollReq = {
76
- groupId,
77
- streamId,
78
- topicId,
74
+ groupName,
75
+ streamId: streamName,
76
+ topicId: topicName,
79
77
  pollingStrategy: PollingStrategy.Next,
80
78
  count: 5,
81
79
  interval: 5000
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=tcp.cluster.e2e.d.ts.map
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { after, describe, it } from 'node:test';
20
+ import assert from 'node:assert/strict';
21
+ import { getTestClient } from './test-client.utils.js';
22
+ // cluster mode still in dev atm
23
+ // response is mocked from /core/configs/server.toml
24
+ const expectedMeta = {
25
+ "name": "iggy-cluster",
26
+ "id": 1,
27
+ "transport": "TCP",
28
+ "nodes": [
29
+ {
30
+ "id": 1,
31
+ "name": "iggy-node-1",
32
+ "address": "127.0.0.1:8090",
33
+ "role": "Leader",
34
+ "status": "Healthy"
35
+ },
36
+ {
37
+ "id": 2,
38
+ "name": "iggy-node-2",
39
+ "address": "127.0.0.1:8091",
40
+ "role": "Follower",
41
+ "status": "Healthy"
42
+ }
43
+ ]
44
+ };
45
+ describe('e2e -> system', async () => {
46
+ const c = getTestClient();
47
+ it('e2e -> cluster::getClusterMetadata', async () => {
48
+ const meta = await c.cluster.getClusterMetadata();
49
+ assert.deepEqual(meta, expectedMeta);
50
+ });
51
+ after(() => {
52
+ c.destroy();
53
+ });
54
+ });
55
+ //# sourceMappingURL=tcp.cluster.e2e.js.map
@@ -29,43 +29,49 @@ describe('e2e -> consumer-group', async () => {
29
29
  options: { host, port },
30
30
  credentials: { username: 'iggy', password: 'iggy' }
31
31
  });
32
- const streamId = 555;
33
- const topicId = 666;
34
- const stream = {
35
- streamId,
36
- name: 'e2e-consumer-group-stream'
37
- };
32
+ const streamName = 'e2e-consumer-group-stream-543';
33
+ const topicName = 'e2e-consumer-group-topic-543';
34
+ const groupName = 'e2e-cg-cg-1';
35
+ let payloadLength = 0;
36
+ await c.stream.create({ name: streamName });
38
37
  const topic = {
39
- streamId,
40
- topicId,
41
- name: 'e2e-consumer-group-topic',
38
+ streamId: streamName,
39
+ name: topicName,
42
40
  partitionCount: 3,
43
41
  compressionAlgorithm: 1
44
42
  };
45
- let payloadLength = 0;
46
- await c.stream.create(stream);
47
43
  await c.topic.create(topic);
48
- const groupId = 333;
49
- const group = { streamId, topicId, groupId, name: 'e2e-cg-1' };
44
+ const group = {
45
+ streamId: streamName, topicId: topicName, name: groupName
46
+ };
50
47
  it('e2e -> consumer-group::create', async () => {
51
- const r = await c.group.create(group);
52
- assert.deepEqual(r, { id: groupId, name: 'e2e-cg-1', partitionsCount: 3, membersCount: 0 });
48
+ const g = await c.group.create(group);
49
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
50
+ const { id, ...rest } = g;
51
+ assert.deepEqual(rest, { name: groupName, partitionsCount: 3, membersCount: 0 });
53
52
  });
54
53
  it('e2e -> consumer-group::get', async () => {
55
- const gg = await c.group.get({ streamId, topicId, groupId });
56
- assert.deepEqual(gg, { id: groupId, name: 'e2e-cg-1', partitionsCount: 3, membersCount: 0 });
54
+ const gg = await c.group.get({
55
+ streamId: streamName, topicId: topicName, groupId: groupName
56
+ });
57
+ assert.ok(gg);
58
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
59
+ const { id, ...rest } = gg;
60
+ assert.deepEqual(rest, { name: groupName, partitionsCount: 3, membersCount: 0 });
57
61
  });
58
62
  it('e2e -> consumer-group::list', async () => {
59
- const lg = await c.group.list({ streamId, topicId });
60
- assert.deepEqual(lg, [{ id: groupId, name: 'e2e-cg-1', partitionsCount: 3, membersCount: 0 }]);
63
+ const lg = await c.group.list({ streamId: streamName, topicId: topicName });
64
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
+ const [{ id, ...rest }] = lg;
66
+ assert.deepEqual([rest], [{ name: groupName, partitionsCount: 3, membersCount: 0 }]);
61
67
  });
62
68
  it('e2e -> consumer-stream::send-messages', async () => {
63
69
  const ct = 1000;
64
70
  const mn = 200;
65
71
  for (let i = 0; i <= ct; i += mn) {
66
72
  assert.ok(await c.message.send({
67
- streamId,
68
- topicId,
73
+ streamId: streamName,
74
+ topicId: topicName,
69
75
  messages: generateMessages(mn),
70
76
  partition: Partitioning.MessageKey(`key-${i % 300}`)
71
77
  }));
@@ -73,14 +79,16 @@ describe('e2e -> consumer-group', async () => {
73
79
  payloadLength = ct;
74
80
  });
75
81
  it('e2e -> consumer-group::join', async () => {
76
- assert.ok(await c.group.join({ streamId, topicId, groupId }));
82
+ assert.ok(await c.group.join({
83
+ streamId: streamName, topicId: topicName, groupId: groupName
84
+ }));
77
85
  });
78
86
  it('e2e -> consumer-group::poll', async () => {
79
87
  const pollReq = {
80
- streamId,
81
- topicId,
82
- consumer: Consumer.Group(groupId),
83
- partitionId: 0,
88
+ streamId: streamName,
89
+ topicId: topicName,
90
+ consumer: Consumer.Group(groupName),
91
+ partitionId: null,
84
92
  pollingStrategy: PollingStrategy.Next,
85
93
  count: 100,
86
94
  autocommit: true
@@ -97,13 +105,17 @@ describe('e2e -> consumer-group', async () => {
97
105
  assert.equal(count, 0);
98
106
  });
99
107
  it('e2e -> consumer-group::leave', async () => {
100
- assert.ok(await c.group.leave({ streamId, topicId, groupId }));
108
+ assert.ok(await c.group.leave({
109
+ streamId: streamName, topicId: topicName, groupId: groupName
110
+ }));
101
111
  });
102
112
  it('e2e -> consumer-group::delete', async () => {
103
- assert.ok(await c.group.delete({ streamId, topicId, groupId }));
113
+ assert.ok(await c.group.delete({
114
+ streamId: streamName, topicId: topicName, groupId: groupName
115
+ }));
104
116
  });
105
117
  after(async () => {
106
- assert.ok(await c.stream.delete(stream));
118
+ assert.ok(await c.stream.delete({ streamId: streamName }));
107
119
  assert.ok(await c.session.logout());
108
120
  c.destroy();
109
121
  });
@@ -31,29 +31,28 @@ describe('e2e -> consumer-stream', async () => {
31
31
  credentials
32
32
  };
33
33
  const c = new Client(opt);
34
- const streamId = 137;
35
- const topicId = 123;
36
- const groupId = 12;
37
- await c.stream.create({ streamId, name: `e2e-stream-${streamId}` });
34
+ const groupName = 'cgtest-12';
35
+ const streamName = `e2e-stream-consumer-stream`;
36
+ const topicName = 'test-topic-stream-cg';
37
+ await c.stream.create({ name: streamName });
38
38
  await c.topic.create({
39
- streamId,
40
- topicId,
41
- name: 'test-topic-stream-cg',
39
+ streamId: streamName,
40
+ name: topicName,
42
41
  partitionCount: 3,
43
42
  compressionAlgorithm: 1
44
43
  });
45
44
  const ct = 1000;
46
45
  it('e2e -> consumer-stream::send-messages', async () => {
47
46
  for (let i = 0; i < ct; i += 100) {
48
- await sendSomeMessages(c.clientProvider)(streamId, topicId, Partitioning.MessageKey(`k-${i % 300}`));
47
+ await sendSomeMessages(c.clientProvider)(streamName, topicName, Partitioning.MessageKey(`k-${i % 300}`));
49
48
  }
50
49
  });
51
50
  it('e2e -> consumer-stream::poll-stream', async () => {
52
51
  // POLL MESSAGE
53
52
  const pollReq = {
54
- groupId,
55
- streamId,
56
- topicId,
53
+ groupName,
54
+ streamId: streamName,
55
+ topicId: topicName,
57
56
  pollingStrategy: PollingStrategy.Next,
58
57
  count: 100,
59
58
  interval: 500
@@ -83,7 +82,7 @@ describe('e2e -> consumer-stream', async () => {
83
82
  });
84
83
  });
85
84
  after(async () => {
86
- assert.ok(await c.stream.delete({ streamId }));
85
+ assert.ok(await c.stream.delete({ streamId: streamName }));
87
86
  assert.ok(await c.session.logout());
88
87
  await c.destroy();
89
88
  });
@@ -23,35 +23,30 @@ import { generateMessages } from '../tcp.sm.utils.js';
23
23
  import { getTestClient } from './test-client.utils.js';
24
24
  describe('e2e -> message', async () => {
25
25
  const c = getTestClient();
26
- const streamId = 934;
27
- const topicId = 832;
28
- const partitionId = 1;
29
- const stream = {
30
- streamId,
31
- name: 'e2e-send-message-stream'
32
- };
26
+ const streamName = 'e2e-stream-934';
27
+ const topicName = 'e2e-topic-832';
28
+ const partitionId = 0;
29
+ await c.stream.create({ name: streamName });
33
30
  const topic = {
34
- streamId,
35
- topicId,
36
- name: 'e2e-send-message-topic',
31
+ streamId: streamName,
32
+ name: topicName,
37
33
  partitionCount: 1,
38
34
  compressionAlgorithm: 1
39
35
  };
36
+ await c.topic.create(topic);
40
37
  const msg = {
41
- streamId,
42
- topicId,
38
+ streamId: streamName,
39
+ topicId: topicName,
43
40
  messages: generateMessages(6),
44
41
  partition: Partitioning.PartitionId(partitionId)
45
42
  };
46
- await c.stream.create(stream);
47
- await c.topic.create(topic);
48
43
  it('e2e -> message::send', async () => {
49
44
  assert.ok(await c.message.send(msg));
50
45
  });
51
46
  it('e2e -> message::poll/last', async () => {
52
47
  const pollReq = {
53
- streamId,
54
- topicId,
48
+ streamId: streamName,
49
+ topicId: topicName,
55
50
  consumer: Consumer.Single,
56
51
  partitionId,
57
52
  pollingStrategy: PollingStrategy.Last,
@@ -64,8 +59,8 @@ describe('e2e -> message', async () => {
64
59
  });
65
60
  it('e2e -> message::poll/first', async () => {
66
61
  const pollReq = {
67
- streamId,
68
- topicId,
62
+ streamId: streamName,
63
+ topicId: topicName,
69
64
  consumer: Consumer.Single,
70
65
  partitionId,
71
66
  pollingStrategy: PollingStrategy.First,
@@ -78,8 +73,8 @@ describe('e2e -> message', async () => {
78
73
  });
79
74
  it('e2e -> message::poll/next', async () => {
80
75
  const pollReq = {
81
- streamId,
82
- topicId,
76
+ streamId: streamName,
77
+ topicId: topicName,
83
78
  consumer: Consumer.Single,
84
79
  partitionId,
85
80
  pollingStrategy: PollingStrategy.Next,
@@ -92,8 +87,8 @@ describe('e2e -> message', async () => {
92
87
  });
93
88
  it('e2e -> message::poll/next+commit', async () => {
94
89
  const pollReq = {
95
- streamId,
96
- topicId,
90
+ streamId: streamName,
91
+ topicId: topicName,
97
92
  consumer: Consumer.Single,
98
93
  partitionId,
99
94
  pollingStrategy: PollingStrategy.Next,
@@ -107,8 +102,50 @@ describe('e2e -> message', async () => {
107
102
  assert.equal(r2.count, 0);
108
103
  assert.equal(r2.messages.length, 0);
109
104
  });
105
+ it('e2e -> message::getOffset', async () => {
106
+ const offset = await c.offset.get({
107
+ streamId: streamName,
108
+ topicId: topicName,
109
+ consumer: Consumer.Single,
110
+ partitionId
111
+ });
112
+ assert.deepEqual(offset, { partitionId: 0, currentOffset: 5n, storedOffset: 5n });
113
+ });
114
+ it('e2e -> message::deleteOffset', async () => {
115
+ const r = await c.offset.delete({
116
+ streamId: streamName,
117
+ topicId: topicName,
118
+ consumer: Consumer.Single,
119
+ partitionId
120
+ });
121
+ assert.ok(r);
122
+ const offset = await c.offset.get({
123
+ streamId: streamName,
124
+ topicId: topicName,
125
+ consumer: Consumer.Single,
126
+ partitionId
127
+ });
128
+ assert.equal(offset, null);
129
+ });
130
+ it('e2e -> message::storeOffset', async () => {
131
+ const r = await c.offset.store({
132
+ streamId: streamName,
133
+ topicId: topicName,
134
+ consumer: Consumer.Single,
135
+ partitionId,
136
+ offset: 2n
137
+ });
138
+ assert.ok(r);
139
+ const offset = await c.offset.get({
140
+ streamId: streamName,
141
+ topicId: topicName,
142
+ consumer: Consumer.Single,
143
+ partitionId
144
+ });
145
+ assert.deepEqual(offset, { partitionId: 0, currentOffset: 5n, storedOffset: 2n });
146
+ });
110
147
  it('e2e -> message::cleanup', async () => {
111
- assert.ok(await c.stream.delete(stream));
148
+ assert.ok(await c.stream.delete({ streamId: streamName }));
112
149
  assert.ok(await c.session.logout());
113
150
  });
114
151
  after(() => {
@@ -21,11 +21,10 @@ import assert from 'node:assert/strict';
21
21
  import { getTestClient } from './test-client.utils.js';
22
22
  describe('e2e -> stream', async () => {
23
23
  const c = getTestClient();
24
- const streamId = 164;
25
24
  const name = 'e2e-tcp-stream';
26
25
  const name2 = `${name}-updated`;
27
26
  it('e2e -> stream::create', async () => {
28
- const stream = await c.stream.create({ streamId, name });
27
+ const stream = await c.stream.create({ name });
29
28
  assert.ok(stream);
30
29
  });
31
30
  it('e2e -> stream::list', async () => {
@@ -33,21 +32,21 @@ describe('e2e -> stream', async () => {
33
32
  assert.ok(streams.length > 0);
34
33
  });
35
34
  it('e2e -> stream::get', async () => {
36
- const stream = await c.stream.get({ streamId });
35
+ const stream = await c.stream.get({ streamId: name });
37
36
  assert.ok(stream);
38
37
  });
39
38
  it('e2e -> stream::update', async () => {
40
39
  const stream = await c.stream.update({
41
- streamId,
40
+ streamId: name,
42
41
  name: name2
43
42
  });
44
43
  assert.ok(stream);
45
44
  });
46
45
  it('e2e -> stream::purge', async () => {
47
- assert.ok(await c.stream.purge({ streamId }));
46
+ assert.ok(await c.stream.purge({ streamId: name2 }));
48
47
  });
49
48
  it('e2e -> stream::delete', async () => {
50
- assert.ok(await c.stream.delete({ streamId }));
49
+ assert.ok(await c.stream.delete({ streamId: name2 }));
51
50
  });
52
51
  it('e2e -> stream::cleanup', async () => {
53
52
  assert.ok(await c.session.logout());
@@ -25,7 +25,7 @@ describe('e2e -> system', async () => {
25
25
  assert.ok(await c.system.ping());
26
26
  });
27
27
  it('e2e -> system::login', async () => {
28
- assert.deepEqual(await c.session.login({ username: 'iggy', password: 'iggy' }), { userId: 1 });
28
+ assert.deepEqual(await c.session.login({ username: 'iggy', password: 'iggy' }), { userId: 0 });
29
29
  });
30
30
  it('e2e -> system::getStat', async () => {
31
31
  assert.deepEqual(Object.keys(await c.system.getStats()), [