pulsar-client 1.3.0 → 1.3.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.
- package/.eslintrc.json +1 -1
- package/README.md +5 -4
- package/package.json +7 -6
- package/src/Message.cc +1 -1
- package/src/MessageId.cc +9 -2
- package/tests/consumer.test.js +12 -3
- package/tests/producer.test.js +12 -3
- package/tests/reader.test.js +37 -39
- package/tslint.json +2 -1
package/.eslintrc.json
CHANGED
package/README.md
CHANGED
|
@@ -42,10 +42,11 @@ Compatibility between each version of the Node.js client and the C++ client is a
|
|
|
42
42
|
|
|
43
43
|
| Node.js client | C++ client |
|
|
44
44
|
|----------------|----------------|
|
|
45
|
-
| 1.0.
|
|
46
|
-
| 1.1.
|
|
47
|
-
| 1.2.
|
|
48
|
-
| 1.3.
|
|
45
|
+
| 1.0.x | 2.3.0 or later |
|
|
46
|
+
| 1.1.x | 2.4.0 or later |
|
|
47
|
+
| 1.2.x | 2.5.0 or later |
|
|
48
|
+
| 1.3.x | 2.7.0 or later |
|
|
49
|
+
| 1.4.x | 2.8.0 or later |
|
|
49
50
|
|
|
50
51
|
If an incompatible version of the C++ client is installed, you may fail to build or run this library.
|
|
51
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pulsar-client",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Pulsar Node.js client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -37,22 +37,23 @@
|
|
|
37
37
|
"clang-format": "^1.4.0",
|
|
38
38
|
"commander": "^6.1.0",
|
|
39
39
|
"delay": "^4.4.0",
|
|
40
|
-
"dtslint": "^4.
|
|
40
|
+
"dtslint": "^3.4.2",
|
|
41
41
|
"eslint": "^7.8.1",
|
|
42
42
|
"eslint-config-airbnb-base": "^14.2.0",
|
|
43
43
|
"eslint-plugin-import": "^2.22.0",
|
|
44
|
-
"
|
|
44
|
+
"eslint-plugin-jest": "^24.3.6",
|
|
45
|
+
"grunt": "^1.4.1",
|
|
45
46
|
"grunt-license-report": "^0.0.8",
|
|
46
47
|
"hdr-histogram-js": "^2.0.1",
|
|
47
|
-
"jest": "^
|
|
48
|
+
"jest": "^27.2.4",
|
|
48
49
|
"license-check-and-add": "^2.3.6",
|
|
49
|
-
"lodash": "^4.17.
|
|
50
|
+
"lodash": "^4.17.21",
|
|
50
51
|
"typescript": "^4.1.3"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
54
|
"bindings": "^1.5.0",
|
|
54
55
|
"node-addon-api": "^3.0.0",
|
|
55
|
-
"node-gyp": "^
|
|
56
|
+
"node-gyp": "^8.2.0",
|
|
56
57
|
"node-pre-gyp": "^0.15.0"
|
|
57
58
|
},
|
|
58
59
|
"binary": {
|
package/src/Message.cc
CHANGED
|
@@ -100,7 +100,7 @@ Napi::Value Message::GetData(const Napi::CallbackInfo &info) {
|
|
|
100
100
|
}
|
|
101
101
|
void *data = const_cast<void *>(pulsar_message_get_data(this->cMessage));
|
|
102
102
|
size_t size = (size_t)pulsar_message_get_length(this->cMessage);
|
|
103
|
-
return Napi::Buffer<char>::
|
|
103
|
+
return Napi::Buffer<char>::Copy(env, (char *)data, size);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
Napi::Value Message::GetMessageId(const Napi::CallbackInfo &info) {
|
package/src/MessageId.cc
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
#include <stdlib.h>
|
|
21
|
+
|
|
20
22
|
#include "MessageId.h"
|
|
21
23
|
#include <pulsar/c/message.h>
|
|
22
24
|
#include <pulsar/c/message_id.h>
|
|
@@ -87,13 +89,15 @@ Napi::Value MessageId::Latest(const Napi::CallbackInfo &info) {
|
|
|
87
89
|
return obj;
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
void serializeFinalizeCallback(Napi::Env env, char *ptr) { free(ptr); }
|
|
93
|
+
|
|
90
94
|
Napi::Value MessageId::Serialize(const Napi::CallbackInfo &info) {
|
|
91
95
|
Napi::Env env = info.Env();
|
|
92
96
|
|
|
93
97
|
int len;
|
|
94
98
|
void *ptr = pulsar_message_id_serialize(GetCMessageId(), &len);
|
|
95
99
|
|
|
96
|
-
return Napi::Buffer<char>::New(env, (char *)ptr, len);
|
|
100
|
+
return Napi::Buffer<char>::New(env, (char *)ptr, len, serializeFinalizeCallback);
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
Napi::Value MessageId::Deserialize(const Napi::CallbackInfo &info) {
|
|
@@ -117,7 +121,10 @@ Napi::Value MessageId::Deserialize(const Napi::CallbackInfo &info) {
|
|
|
117
121
|
pulsar_message_id_t *MessageId::GetCMessageId() { return this->cMessageId; }
|
|
118
122
|
|
|
119
123
|
Napi::Value MessageId::ToString(const Napi::CallbackInfo &info) {
|
|
120
|
-
|
|
124
|
+
char *cStr = pulsar_message_id_str(this->cMessageId);
|
|
125
|
+
std::string s(cStr);
|
|
126
|
+
free(cStr);
|
|
127
|
+
return Napi::String::New(info.Env(), s);
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
MessageId::~MessageId() {
|
package/tests/consumer.test.js
CHANGED
|
@@ -21,10 +21,19 @@ const Pulsar = require('../index.js');
|
|
|
21
21
|
|
|
22
22
|
(() => {
|
|
23
23
|
describe('Consumer', () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let client;
|
|
25
|
+
|
|
26
|
+
beforeAll(() => {
|
|
27
|
+
client = new Pulsar.Client({
|
|
28
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
29
|
+
operationTimeoutSeconds: 30,
|
|
30
|
+
});
|
|
27
31
|
});
|
|
32
|
+
|
|
33
|
+
afterAll(async () => {
|
|
34
|
+
await client.close();
|
|
35
|
+
});
|
|
36
|
+
|
|
28
37
|
describe('Create', () => {
|
|
29
38
|
test('No Topic', async () => {
|
|
30
39
|
await expect(client.subscribe({
|
package/tests/producer.test.js
CHANGED
|
@@ -21,10 +21,19 @@ const Pulsar = require('../index.js');
|
|
|
21
21
|
|
|
22
22
|
(() => {
|
|
23
23
|
describe('Producer', () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let client;
|
|
25
|
+
|
|
26
|
+
beforeAll(() => {
|
|
27
|
+
client = new Pulsar.Client({
|
|
28
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
29
|
+
operationTimeoutSeconds: 30,
|
|
30
|
+
});
|
|
27
31
|
});
|
|
32
|
+
|
|
33
|
+
afterAll(async () => {
|
|
34
|
+
await client.close();
|
|
35
|
+
});
|
|
36
|
+
|
|
28
37
|
describe('Create', () => {
|
|
29
38
|
test('No Topic', async () => {
|
|
30
39
|
await expect(client.createProducer({
|
package/tests/reader.test.js
CHANGED
|
@@ -21,52 +21,50 @@ const Pulsar = require('../index.js');
|
|
|
21
21
|
|
|
22
22
|
(() => {
|
|
23
23
|
describe('Reader', () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
operationTimeoutSeconds: 30,
|
|
29
|
-
});
|
|
30
|
-
await expect(client.createReader({
|
|
31
|
-
startMessageId: Pulsar.MessageId.earliest(),
|
|
32
|
-
})).rejects.toThrow('Topic is required and must be specified as a string when creating reader');
|
|
33
|
-
await client.close();
|
|
24
|
+
test('No Topic', async () => {
|
|
25
|
+
const client = new Pulsar.Client({
|
|
26
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
27
|
+
operationTimeoutSeconds: 30,
|
|
34
28
|
});
|
|
29
|
+
await expect(client.createReader({
|
|
30
|
+
startMessageId: Pulsar.MessageId.earliest(),
|
|
31
|
+
})).rejects.toThrow('Topic is required and must be specified as a string when creating reader');
|
|
32
|
+
await client.close();
|
|
33
|
+
});
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
await expect(client.createReader({
|
|
42
|
-
topic: 0,
|
|
43
|
-
startMessageId: Pulsar.MessageId.earliest(),
|
|
44
|
-
})).rejects.toThrow('Topic is required and must be specified as a string when creating reader');
|
|
45
|
-
await client.close();
|
|
35
|
+
test('Not String Topic', async () => {
|
|
36
|
+
const client = new Pulsar.Client({
|
|
37
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
38
|
+
operationTimeoutSeconds: 30,
|
|
46
39
|
});
|
|
40
|
+
await expect(client.createReader({
|
|
41
|
+
topic: 0,
|
|
42
|
+
startMessageId: Pulsar.MessageId.earliest(),
|
|
43
|
+
})).rejects.toThrow('Topic is required and must be specified as a string when creating reader');
|
|
44
|
+
await client.close();
|
|
45
|
+
});
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
await expect(client.createReader({
|
|
54
|
-
topic: 'persistent://public/default/topic',
|
|
55
|
-
})).rejects.toThrow('StartMessageId is required and must be specified as a MessageId object when creating reader');
|
|
56
|
-
await client.close();
|
|
47
|
+
test('No StartMessageId', async () => {
|
|
48
|
+
const client = new Pulsar.Client({
|
|
49
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
50
|
+
operationTimeoutSeconds: 30,
|
|
57
51
|
});
|
|
52
|
+
await expect(client.createReader({
|
|
53
|
+
topic: 'persistent://public/default/topic',
|
|
54
|
+
})).rejects.toThrow('StartMessageId is required and must be specified as a MessageId object when creating reader');
|
|
55
|
+
await client.close();
|
|
56
|
+
});
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
await expect(client.createReader({
|
|
65
|
-
topic: 'persistent://public/default/topic',
|
|
66
|
-
startMessageId: 'not MessageId',
|
|
67
|
-
})).rejects.toThrow('StartMessageId is required and must be specified as a MessageId object when creating reader');
|
|
68
|
-
await client.close();
|
|
58
|
+
test('Not StartMessageId as MessageId', async () => {
|
|
59
|
+
const client = new Pulsar.Client({
|
|
60
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
61
|
+
operationTimeoutSeconds: 30,
|
|
69
62
|
});
|
|
63
|
+
await expect(client.createReader({
|
|
64
|
+
topic: 'persistent://public/default/topic',
|
|
65
|
+
startMessageId: 'not MessageId',
|
|
66
|
+
})).rejects.toThrow('StartMessageId is required and must be specified as a MessageId object when creating reader');
|
|
67
|
+
await client.close();
|
|
70
68
|
});
|
|
71
69
|
});
|
|
72
70
|
})();
|