pulsar-client 1.4.1 → 1.5.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/README.md +17 -2
- package/binding.gyp +49 -5
- package/package.json +4 -4
- package/src/Consumer.cc +11 -0
package/README.md
CHANGED
|
@@ -46,13 +46,24 @@ Compatibility between each version of the Node.js client and the C++ client is a
|
|
|
46
46
|
| 1.1.x | 2.4.0 or later |
|
|
47
47
|
| 1.2.x | 2.5.0 or later |
|
|
48
48
|
| 1.3.x | 2.7.0 or later |
|
|
49
|
-
| 1.4.x
|
|
49
|
+
| 1.4.x - 1.5.x | 2.8.0 or later |
|
|
50
50
|
|
|
51
51
|
If an incompatible version of the C++ client is installed, you may fail to build or run this library.
|
|
52
52
|
|
|
53
53
|
## How to install
|
|
54
54
|
|
|
55
|
-
###
|
|
55
|
+
### Install on windows
|
|
56
|
+
|
|
57
|
+
1. [Build the Pulsar C++ client on windows](https://pulsar.apache.org/docs/en/next/client-libraries-cpp/).
|
|
58
|
+
|
|
59
|
+
2. Set the variable `PULSAR_CPP_DIR` with the `pulsar-client-cpp` path in a Windows command tool.
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
# for example
|
|
63
|
+
set PULSAR_CPP_DIR=C:\pulsar\pulsar-client-cpp
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Install pulsar-client to your project
|
|
56
67
|
|
|
57
68
|
```shell
|
|
58
69
|
$ npm install pulsar-client
|
|
@@ -72,6 +83,10 @@ $ cd pulsar-client-node
|
|
|
72
83
|
$ npm install
|
|
73
84
|
```
|
|
74
85
|
|
|
86
|
+
> **Note**
|
|
87
|
+
>
|
|
88
|
+
> If you build `pulsar-client-node on` windows, you need to set the variable `PULSAR_CPP_DIR` first, then install npm (run the command `npm install`) in a Windows command-line tool.
|
|
89
|
+
|
|
75
90
|
### Rebuild Pulsar client library:
|
|
76
91
|
|
|
77
92
|
```shell
|
package/binding.gyp
CHANGED
|
@@ -18,14 +18,23 @@
|
|
|
18
18
|
#
|
|
19
19
|
|
|
20
20
|
{
|
|
21
|
+
'conditions': [
|
|
22
|
+
['OS=="win"', {
|
|
23
|
+
'variables': {
|
|
24
|
+
'pulsar_cpp_dir%': '<!(echo %PULSAR_CPP_DIR%)',
|
|
25
|
+
},
|
|
26
|
+
}]
|
|
27
|
+
],
|
|
21
28
|
"targets": [
|
|
22
29
|
{
|
|
23
30
|
"target_name": "Pulsar",
|
|
31
|
+
"cflags_cc": ["-std=gnu++11"],
|
|
24
32
|
"cflags!": ["-fno-exceptions"],
|
|
25
|
-
"cflags_cc!": ["-fno-exceptions"],
|
|
26
|
-
"include_dirs": [
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
"cflags_cc!": ["-fno-exceptions", "-std=gnu++14", "-std=gnu++17"],
|
|
34
|
+
"include_dirs": [
|
|
35
|
+
"<!@(node -p \"require('node-addon-api').include\")",
|
|
36
|
+
],
|
|
37
|
+
"defines": ["NAPI_VERSION=4", "NAPI_DISABLE_CPP_EXCEPTIONS=1"],
|
|
29
38
|
"sources": [
|
|
30
39
|
"src/addon.cc",
|
|
31
40
|
"src/Message.cc",
|
|
@@ -39,7 +48,42 @@
|
|
|
39
48
|
"src/Reader.cc",
|
|
40
49
|
"src/ReaderConfig.cc",
|
|
41
50
|
],
|
|
42
|
-
|
|
51
|
+
'conditions': [
|
|
52
|
+
['OS=="win"', {
|
|
53
|
+
"include_dirs": [
|
|
54
|
+
"<(pulsar_cpp_dir)\include",
|
|
55
|
+
],
|
|
56
|
+
"libraries": [
|
|
57
|
+
"-l<(pulsar_cpp_dir)\\build\lib\Release\pulsar.lib"
|
|
58
|
+
],
|
|
59
|
+
"dependencies": [
|
|
60
|
+
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
61
|
+
],
|
|
62
|
+
"copies": [
|
|
63
|
+
{
|
|
64
|
+
"destination": "<(PRODUCT_DIR)",
|
|
65
|
+
"files": [
|
|
66
|
+
"<(pulsar_cpp_dir)\\build\lib\Release\pulsar.dll",
|
|
67
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libcurl.dll",
|
|
68
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libprotobuf.dll",
|
|
69
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libssl-1_1-x64.dll",
|
|
70
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libcrypto-1_1-x64.dll",
|
|
71
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\dl.dll",
|
|
72
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\snappy.dll",
|
|
73
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\zlib1.dll",
|
|
74
|
+
"<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\zstd.dll",
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}, { # 'OS!="win"'
|
|
79
|
+
"libraries": [
|
|
80
|
+
"-lpulsar",
|
|
81
|
+
],
|
|
82
|
+
"dependencies": [
|
|
83
|
+
"<!@(node -p \"require('node-addon-api').gyp\")"
|
|
84
|
+
],
|
|
85
|
+
}]
|
|
86
|
+
]
|
|
43
87
|
}
|
|
44
88
|
]
|
|
45
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pulsar-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Pulsar Node.js client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"typescript": "^4.1.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@mapbox/node-pre-gyp": "^1.0.7",
|
|
54
55
|
"bindings": "^1.5.0",
|
|
55
|
-
"node-addon-api": "^3.
|
|
56
|
-
"node-gyp": "^8.
|
|
57
|
-
"node-pre-gyp": "^0.15.0"
|
|
56
|
+
"node-addon-api": "^3.2.1",
|
|
57
|
+
"node-gyp": "^8.4.1"
|
|
58
58
|
},
|
|
59
59
|
"binary": {
|
|
60
60
|
"module_name": "libpulsar",
|
package/src/Consumer.cc
CHANGED
|
@@ -164,6 +164,12 @@ class ConsumerNewInstanceWorker : public Napi::AsyncWorker {
|
|
|
164
164
|
|
|
165
165
|
consumer->SetCConsumer(this->consumerWrapper);
|
|
166
166
|
consumer->SetListenerCallback(this->listener);
|
|
167
|
+
|
|
168
|
+
if (this->listener) {
|
|
169
|
+
// resume to enable MessageListener function callback
|
|
170
|
+
resume_message_listener(this->consumerWrapper->cConsumer);
|
|
171
|
+
}
|
|
172
|
+
|
|
167
173
|
this->deferred.Resolve(obj);
|
|
168
174
|
}
|
|
169
175
|
void OnError(const Napi::Error &e) { this->deferred.Reject(Napi::Error::New(Env(), e.Message()).Value()); }
|
|
@@ -183,6 +189,11 @@ class ConsumerNewInstanceWorker : public Napi::AsyncWorker {
|
|
|
183
189
|
} else {
|
|
184
190
|
worker->consumerWrapper->cConsumer = consumer;
|
|
185
191
|
worker->listener = worker->consumerConfig->GetListenerCallback();
|
|
192
|
+
|
|
193
|
+
if (worker->listener) {
|
|
194
|
+
// pause, will resume in OnOK, to prevent MessageListener get a nullptr of consumer
|
|
195
|
+
pulsar_consumer_pause_message_listener(consumer);
|
|
196
|
+
}
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
delete worker->consumerConfig;
|