pulsar-client 1.9.0 → 1.10.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/.github/workflows/ci-build-release-napi.yml +17 -13
- package/.github/workflows/ci-pr-validation.yml +45 -18
- package/GenCertFile.js +1 -1
- package/docs/release-process.md +1 -1
- package/examples/consumer_listener.js +5 -1
- package/index.d.ts +22 -1
- package/index.js +5 -5
- package/license-checker-config.json +43 -0
- package/package.json +8 -60
- package/pkg/load_test.js +1 -1
- package/pkg/mac/{common.sh → download-cpp-client.sh} +10 -11
- package/pulsar-client-cpp.txt +2 -2
- package/src/Consumer.cc +40 -25
- package/src/Consumer.h +1 -0
- package/src/ConsumerConfig.cc +65 -6
- package/src/ConsumerConfig.h +4 -1
- package/src/ThreadSafeDeferred.cc +4 -0
- package/src/ThreadSafeDeferred.h +1 -0
- package/tests/client.test.js +2 -2
- package/tests/consumer.test.js +116 -2
- package/tests/end_to_end.test.js +1 -1
- package/tests/producer.test.js +1 -1
- package/tests/reader.test.js +1 -1
- package/tstest.ts +10 -0
- package/Gruntfile.js +0 -31
- package/build-support/dep-version.py +0 -24
- package/dependencies.yaml +0 -28
- package/pkg/mac/build-cpp-deps-lib.sh +0 -186
- package/pkg/mac/build-cpp-lib.sh +0 -48
|
@@ -41,6 +41,8 @@ jobs:
|
|
|
41
41
|
- arm64
|
|
42
42
|
nodejs:
|
|
43
43
|
- 18
|
|
44
|
+
python:
|
|
45
|
+
- "3.10"
|
|
44
46
|
steps:
|
|
45
47
|
- uses: actions/checkout@v3
|
|
46
48
|
- name: Use Node.js ${{ matrix.nodejs }}
|
|
@@ -48,7 +50,12 @@ jobs:
|
|
|
48
50
|
with:
|
|
49
51
|
node-version: ${{ matrix.nodejs }}
|
|
50
52
|
cache: 'npm'
|
|
51
|
-
|
|
53
|
+
|
|
54
|
+
- name: Use Python ${{ matrix.python }}
|
|
55
|
+
uses: actions/setup-python@v3
|
|
56
|
+
with:
|
|
57
|
+
python-version: ${{ matrix.python }}
|
|
58
|
+
|
|
52
59
|
- name: Cache Dependencies
|
|
53
60
|
id: cache-dependencies
|
|
54
61
|
uses: actions/cache@v3
|
|
@@ -64,20 +71,10 @@ jobs:
|
|
|
64
71
|
echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
|
|
65
72
|
fi
|
|
66
73
|
|
|
67
|
-
- name: Build CPP dependencies lib
|
|
68
|
-
if: steps.cache-dependencies.outputs.cache-hit != 'true'
|
|
69
|
-
run: |
|
|
70
|
-
export ARCH=${{ env.ARCH }}
|
|
71
|
-
pkg/mac/build-cpp-deps-lib.sh
|
|
72
|
-
|
|
73
|
-
- name: Build CPP lib
|
|
74
|
-
if: steps.cache-pulsar.outputs.cache-hit != 'true'
|
|
75
|
-
run: |
|
|
76
|
-
export ARCH=${{ env.ARCH }}
|
|
77
|
-
pkg/mac/build-cpp-lib.sh
|
|
78
|
-
|
|
79
74
|
- name: Build Node binaries lib
|
|
80
75
|
run: |
|
|
76
|
+
export ARCH=${{ env.ARCH }}
|
|
77
|
+
pkg/mac/download-cpp-client.sh
|
|
81
78
|
npm install --ignore-scripts
|
|
82
79
|
npx node-pre-gyp configure --target_arch=${{ matrix.arch }}
|
|
83
80
|
npx node-pre-gyp build --target_arch=${{ matrix.arch }}
|
|
@@ -162,6 +159,8 @@ jobs:
|
|
|
162
159
|
- x86
|
|
163
160
|
nodejs:
|
|
164
161
|
- 18
|
|
162
|
+
python:
|
|
163
|
+
- "3.10"
|
|
165
164
|
steps:
|
|
166
165
|
- uses: actions/checkout@v3
|
|
167
166
|
- name: Use Node.js ${{ matrix.nodejs }}
|
|
@@ -171,6 +170,11 @@ jobs:
|
|
|
171
170
|
architecture: ${{ matrix.arch }}
|
|
172
171
|
cache: 'npm'
|
|
173
172
|
|
|
173
|
+
- name: Use Python ${{ matrix.python }}
|
|
174
|
+
uses: actions/setup-python@v3
|
|
175
|
+
with:
|
|
176
|
+
python-version: ${{ matrix.python }}
|
|
177
|
+
|
|
174
178
|
- name: Cache CPP Client
|
|
175
179
|
id: cache-dependencies
|
|
176
180
|
uses: actions/cache@v3
|
|
@@ -30,6 +30,10 @@ jobs:
|
|
|
30
30
|
name: Run unit tests
|
|
31
31
|
runs-on: ubuntu-22.04
|
|
32
32
|
timeout-minutes: 120
|
|
33
|
+
strategy:
|
|
34
|
+
matrix:
|
|
35
|
+
python:
|
|
36
|
+
- "3.10"
|
|
33
37
|
|
|
34
38
|
steps:
|
|
35
39
|
- uses: actions/checkout@v3
|
|
@@ -38,9 +42,17 @@ jobs:
|
|
|
38
42
|
with:
|
|
39
43
|
node-version: 18
|
|
40
44
|
|
|
45
|
+
- name: Use Python ${{ matrix.python }}
|
|
46
|
+
uses: actions/setup-python@v3
|
|
47
|
+
with:
|
|
48
|
+
python-version: ${{ matrix.python }}
|
|
49
|
+
|
|
41
50
|
- name: Run Test
|
|
42
51
|
run: |
|
|
43
52
|
./tests/run-unit-tests.sh
|
|
53
|
+
- name: Check license headers
|
|
54
|
+
run: |
|
|
55
|
+
npm run license:checkheader
|
|
44
56
|
|
|
45
57
|
validation-yarn:
|
|
46
58
|
name: Validation use yarn install
|
|
@@ -71,6 +83,8 @@ jobs:
|
|
|
71
83
|
- arm64
|
|
72
84
|
nodejs:
|
|
73
85
|
- 18
|
|
86
|
+
python:
|
|
87
|
+
- "3.10"
|
|
74
88
|
steps:
|
|
75
89
|
- uses: actions/checkout@v3
|
|
76
90
|
- name: Use Node.js ${{ matrix.nodejs }}
|
|
@@ -78,13 +92,11 @@ jobs:
|
|
|
78
92
|
with:
|
|
79
93
|
node-version: ${{ matrix.nodejs }}
|
|
80
94
|
cache: 'npm'
|
|
81
|
-
|
|
82
|
-
- name:
|
|
83
|
-
|
|
84
|
-
uses: actions/cache@v3
|
|
95
|
+
|
|
96
|
+
- name: Use Python ${{ matrix.python }}
|
|
97
|
+
uses: actions/setup-python@v3
|
|
85
98
|
with:
|
|
86
|
-
|
|
87
|
-
key: ${{ runner.os }}-${{ matrix.arch }}-mac-${{ hashFiles('pkg/mac/build-cpp-deps-lib.sh') }}
|
|
99
|
+
python-version: ${{ matrix.python }}
|
|
88
100
|
|
|
89
101
|
- name: Add arch env vars
|
|
90
102
|
run: |
|
|
@@ -94,20 +106,10 @@ jobs:
|
|
|
94
106
|
echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
|
|
95
107
|
fi
|
|
96
108
|
|
|
97
|
-
- name: Build CPP dependencies lib
|
|
98
|
-
if: steps.cache-dependencies.outputs.cache-hit != 'true'
|
|
99
|
-
run: |
|
|
100
|
-
export ARCH=${{ env.ARCH }}
|
|
101
|
-
pkg/mac/build-cpp-deps-lib.sh
|
|
102
|
-
|
|
103
|
-
- name: Build CPP lib
|
|
104
|
-
if: steps.cache-pulsar.outputs.cache-hit != 'true'
|
|
105
|
-
run: |
|
|
106
|
-
export ARCH=${{ env.ARCH }}
|
|
107
|
-
pkg/mac/build-cpp-lib.sh
|
|
108
|
-
|
|
109
109
|
- name: Build Node binaries lib
|
|
110
110
|
run: |
|
|
111
|
+
export ARCH=${{ env.ARCH }}
|
|
112
|
+
pkg/mac/download-cpp-client.sh
|
|
111
113
|
npm install --ignore-scripts
|
|
112
114
|
npx node-pre-gyp configure --target_arch=${{ matrix.arch }}
|
|
113
115
|
npx node-pre-gyp build --target_arch=${{ matrix.arch }}
|
|
@@ -194,6 +196,8 @@ jobs:
|
|
|
194
196
|
- x86
|
|
195
197
|
nodejs:
|
|
196
198
|
- 18
|
|
199
|
+
python:
|
|
200
|
+
- "3.10"
|
|
197
201
|
steps:
|
|
198
202
|
- uses: actions/checkout@v3
|
|
199
203
|
- name: Use Node.js ${{ matrix.nodejs }}
|
|
@@ -203,6 +207,11 @@ jobs:
|
|
|
203
207
|
architecture: ${{ matrix.arch }}
|
|
204
208
|
cache: 'npm'
|
|
205
209
|
|
|
210
|
+
- name: Use Python ${{ matrix.python }}
|
|
211
|
+
uses: actions/setup-python@v3
|
|
212
|
+
with:
|
|
213
|
+
python-version: ${{ matrix.python }}
|
|
214
|
+
|
|
206
215
|
- name: Cache CPP Client
|
|
207
216
|
id: cache-dependencies
|
|
208
217
|
uses: actions/cache@v3
|
|
@@ -244,6 +253,10 @@ jobs:
|
|
|
244
253
|
timeout-minutes: 3000
|
|
245
254
|
strategy:
|
|
246
255
|
fail-fast: false
|
|
256
|
+
matrix:
|
|
257
|
+
python:
|
|
258
|
+
- "3.10"
|
|
259
|
+
|
|
247
260
|
steps:
|
|
248
261
|
- uses: actions/checkout@v3
|
|
249
262
|
- name: Use Node.js 18
|
|
@@ -251,6 +264,10 @@ jobs:
|
|
|
251
264
|
with:
|
|
252
265
|
node-version: 18
|
|
253
266
|
cache: 'npm'
|
|
267
|
+
- name: Use Python ${{ matrix.python }}
|
|
268
|
+
uses: actions/setup-python@v3
|
|
269
|
+
with:
|
|
270
|
+
python-version: ${{ matrix.python }}
|
|
254
271
|
- name: Install CPP lib
|
|
255
272
|
run: |
|
|
256
273
|
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true
|
|
@@ -274,6 +291,10 @@ jobs:
|
|
|
274
291
|
timeout-minutes: 3000
|
|
275
292
|
strategy:
|
|
276
293
|
fail-fast: false
|
|
294
|
+
matrix:
|
|
295
|
+
python:
|
|
296
|
+
- "3.10"
|
|
297
|
+
|
|
277
298
|
steps:
|
|
278
299
|
- uses: actions/checkout@v3
|
|
279
300
|
- name: Use Node.js 18
|
|
@@ -281,6 +302,12 @@ jobs:
|
|
|
281
302
|
with:
|
|
282
303
|
node-version: 18
|
|
283
304
|
cache: 'npm'
|
|
305
|
+
|
|
306
|
+
- name: Use Python ${{ matrix.python }}
|
|
307
|
+
uses: actions/setup-python@v3
|
|
308
|
+
with:
|
|
309
|
+
python-version: ${{ matrix.python }}
|
|
310
|
+
|
|
284
311
|
- name: Install CPP lib
|
|
285
312
|
run: |
|
|
286
313
|
source pulsar-client-cpp.txt
|
package/GenCertFile.js
CHANGED
package/docs/release-process.md
CHANGED
|
@@ -197,7 +197,7 @@ Source files:
|
|
|
197
197
|
https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/pulsar-client-node-1.X.0-rc.1/
|
|
198
198
|
|
|
199
199
|
Pulsar's KEYS file containing PGP keys we use to sign the release:
|
|
200
|
-
https://
|
|
200
|
+
https://downloads.apache.org/pulsar/KEYS
|
|
201
201
|
|
|
202
202
|
SHA-512 checksum:
|
|
203
203
|
5f6c7e1a096a3ae66eee71c552af89532ed86bf94da3f3d49836c080426ee5dcaabeda440a989d51772d2e67e2dca953eeee9ea83cfbc7c2a0847a0ec04b310f apache-pulsar-client-node-1.X.0.tar.gz
|
|
@@ -19,9 +19,13 @@
|
|
|
19
19
|
|
|
20
20
|
const Pulsar = require('../');
|
|
21
21
|
|
|
22
|
+
// It will be released and disconnected when there are no references,
|
|
23
|
+
// so declare it with let.
|
|
24
|
+
let client;
|
|
25
|
+
|
|
22
26
|
(async () => {
|
|
23
27
|
// Create a client
|
|
24
|
-
|
|
28
|
+
client = new Pulsar.Client({
|
|
25
29
|
serviceUrl: 'pulsar://localhost:6650',
|
|
26
30
|
operationTimeoutSeconds: 30,
|
|
27
31
|
});
|
package/index.d.ts
CHANGED
|
@@ -98,10 +98,12 @@ export interface ConsumerConfig {
|
|
|
98
98
|
batchIndexAckEnabled?: boolean;
|
|
99
99
|
regexSubscriptionMode?: RegexSubscriptionMode;
|
|
100
100
|
deadLetterPolicy?: DeadLetterPolicy;
|
|
101
|
+
batchReceivePolicy?: ConsumerBatchReceivePolicy;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
export class Consumer {
|
|
104
105
|
receive(timeout?: number): Promise<Message>;
|
|
106
|
+
batchReceive(): Promise<Message []>;
|
|
105
107
|
acknowledge(message: Message): Promise<null>;
|
|
106
108
|
acknowledgeId(messageId: MessageId): Promise<null>;
|
|
107
109
|
negativeAcknowledge(message: Message): void;
|
|
@@ -181,12 +183,18 @@ export interface DeadLetterPolicy {
|
|
|
181
183
|
initialSubscriptionName?: string;
|
|
182
184
|
}
|
|
183
185
|
|
|
186
|
+
export interface ConsumerBatchReceivePolicy {
|
|
187
|
+
maxNumMessages?: number;
|
|
188
|
+
maxNumBytes?: number;
|
|
189
|
+
timeoutMs?: number;
|
|
190
|
+
}
|
|
191
|
+
|
|
184
192
|
export class AuthenticationTls {
|
|
185
193
|
constructor(params: { certificatePath: string, privateKeyPath: string });
|
|
186
194
|
}
|
|
187
195
|
|
|
188
196
|
export class AuthenticationAthenz {
|
|
189
|
-
constructor(params: string | AthenzConfig);
|
|
197
|
+
constructor(params: string | AthenzConfig | AthenzX509Config);
|
|
190
198
|
}
|
|
191
199
|
|
|
192
200
|
export interface AthenzConfig {
|
|
@@ -198,9 +206,22 @@ export interface AthenzConfig {
|
|
|
198
206
|
keyId?: string;
|
|
199
207
|
principalHeader?: string;
|
|
200
208
|
roleHeader?: string;
|
|
209
|
+
caCert?: string;
|
|
210
|
+
/**
|
|
211
|
+
* @deprecated
|
|
212
|
+
*/
|
|
201
213
|
tokenExpirationTime?: string;
|
|
202
214
|
}
|
|
203
215
|
|
|
216
|
+
export class AthenzX509Config {
|
|
217
|
+
providerDomain: string;
|
|
218
|
+
privateKey: string;
|
|
219
|
+
x509CertChain: string;
|
|
220
|
+
ztsUrl: string;
|
|
221
|
+
roleHeader?: string;
|
|
222
|
+
caCert?: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
204
225
|
export class AuthenticationToken {
|
|
205
226
|
constructor(params: { token: string });
|
|
206
227
|
}
|
package/index.js
CHANGED
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
const PulsarBinding = require('./src/pulsar-binding');
|
|
21
|
-
const AuthenticationTls = require('./src/AuthenticationTls
|
|
22
|
-
const AuthenticationAthenz = require('./src/AuthenticationAthenz
|
|
23
|
-
const AuthenticationToken = require('./src/AuthenticationToken
|
|
24
|
-
const AuthenticationOauth2 = require('./src/AuthenticationOauth2
|
|
25
|
-
const Client = require('./src/Client
|
|
21
|
+
const AuthenticationTls = require('./src/AuthenticationTls');
|
|
22
|
+
const AuthenticationAthenz = require('./src/AuthenticationAthenz');
|
|
23
|
+
const AuthenticationToken = require('./src/AuthenticationToken');
|
|
24
|
+
const AuthenticationOauth2 = require('./src/AuthenticationOauth2');
|
|
25
|
+
const Client = require('./src/Client');
|
|
26
26
|
|
|
27
27
|
const LogLevel = {
|
|
28
28
|
DEBUG: 0,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"license": "license-header.txt",
|
|
3
|
+
"trailingWhitespace": "TRIM",
|
|
4
|
+
"ignoreFile": ".gitignore",
|
|
5
|
+
"ignore": [
|
|
6
|
+
"NOTICE",
|
|
7
|
+
"**/*.txt",
|
|
8
|
+
"**/*.bat",
|
|
9
|
+
"**/*.pem",
|
|
10
|
+
"**/*.key",
|
|
11
|
+
"**/*.crt"
|
|
12
|
+
],
|
|
13
|
+
"defaultFormat": {
|
|
14
|
+
"prepend": "#",
|
|
15
|
+
"eachLine": {
|
|
16
|
+
"prepend": "# "
|
|
17
|
+
},
|
|
18
|
+
"append": "#"
|
|
19
|
+
},
|
|
20
|
+
"licenseFormats": {
|
|
21
|
+
"c|cc|cpp|h|hpp|js|ts|css": {
|
|
22
|
+
"prepend": "/**",
|
|
23
|
+
"eachLine": {
|
|
24
|
+
"prepend": " * "
|
|
25
|
+
},
|
|
26
|
+
"append": " */"
|
|
27
|
+
},
|
|
28
|
+
"conf|gitignore|npmignore|eslintignore|sh|py|yml|yaml": {
|
|
29
|
+
"prepend": "#",
|
|
30
|
+
"eachLine": {
|
|
31
|
+
"prepend": "# "
|
|
32
|
+
},
|
|
33
|
+
"append": "#"
|
|
34
|
+
},
|
|
35
|
+
"html|xml|md": {
|
|
36
|
+
"prepend": "<!--\n",
|
|
37
|
+
"eachLine": {
|
|
38
|
+
"prepend": " "
|
|
39
|
+
},
|
|
40
|
+
"append": "\n-->"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pulsar-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Pulsar Node.js client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
"lint": "clang-format-lint src/*.cc src/*.h && eslint --ext .js .",
|
|
18
18
|
"format": "clang-format-lint --fix src/*.cc src/*.h && eslint --fix --ext .js .",
|
|
19
19
|
"dtslint": "dtslint .",
|
|
20
|
-
"license:report": "mkdir -p report &&
|
|
21
|
-
"license:
|
|
20
|
+
"license:report": "mkdir -p report && license-checker --json > report/licenses.json",
|
|
21
|
+
"license:checkheader": "license-check-and-add check",
|
|
22
|
+
"license:addheader": "license-check-and-add add",
|
|
22
23
|
"test": "jest --verbose --detectOpenHandles",
|
|
23
24
|
"docs": "typedoc"
|
|
24
25
|
},
|
|
@@ -34,27 +35,26 @@
|
|
|
34
35
|
"node": ">=10.16.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"dtslint": "^4.2.0",
|
|
38
38
|
"@seadub/clang-format-lint": "0.0.2",
|
|
39
39
|
"@types/node": "^14.14.25",
|
|
40
40
|
"clang-format": "^1.4.0",
|
|
41
41
|
"commander": "^6.1.0",
|
|
42
42
|
"delay": "^4.4.0",
|
|
43
|
+
"dtslint": "^4.2.0",
|
|
43
44
|
"eslint": "^7.8.1",
|
|
44
45
|
"eslint-config-airbnb-base": "^14.2.0",
|
|
45
46
|
"eslint-plugin-import": "^2.22.0",
|
|
46
47
|
"eslint-plugin-jest": "^24.3.6",
|
|
47
|
-
"grunt": "^1.4.1",
|
|
48
|
-
"grunt-license-report": "^0.0.8",
|
|
49
48
|
"hdr-histogram-js": "^2.0.1",
|
|
50
49
|
"jest": "^27.2.4",
|
|
51
|
-
"license-check-and-add": "^
|
|
50
|
+
"license-check-and-add": "^4.0.5",
|
|
51
|
+
"license-checker": "^25.0.1",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"typedoc": "^0.23.28",
|
|
54
54
|
"typescript": "^4.9.5"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@mapbox/node-pre-gyp": "^1.0.
|
|
57
|
+
"@mapbox/node-pre-gyp": "^1.0.11",
|
|
58
58
|
"bindings": "^1.5.0",
|
|
59
59
|
"node-addon-api": "^4.3.0"
|
|
60
60
|
},
|
|
@@ -64,57 +64,5 @@
|
|
|
64
64
|
"host": "https://archive.apache.org/dist/pulsar/pulsar-client-node/",
|
|
65
65
|
"remote_path": "pulsar-client-node-{version}",
|
|
66
66
|
"package_name": "napi-{platform}-{libc}-{arch}.tar.gz"
|
|
67
|
-
},
|
|
68
|
-
"license-check-and-add-config": {
|
|
69
|
-
"folder": ".",
|
|
70
|
-
"license": "license-header.txt",
|
|
71
|
-
"exact_paths_method": "EXCLUDE",
|
|
72
|
-
"exact_paths": [
|
|
73
|
-
".git/",
|
|
74
|
-
"build/",
|
|
75
|
-
"node_modules/",
|
|
76
|
-
"report/",
|
|
77
|
-
"LICENSE"
|
|
78
|
-
],
|
|
79
|
-
"file_type_method": "EXCLUDE",
|
|
80
|
-
"file_types": [
|
|
81
|
-
".json",
|
|
82
|
-
".pem",
|
|
83
|
-
".txt",
|
|
84
|
-
".gz",
|
|
85
|
-
".bat"
|
|
86
|
-
],
|
|
87
|
-
"trailing_whitespace": "TRIM",
|
|
88
|
-
"insert_license": true,
|
|
89
|
-
"default_format": {
|
|
90
|
-
"prepend": "#",
|
|
91
|
-
"eachLine": {
|
|
92
|
-
"prepend": "# "
|
|
93
|
-
},
|
|
94
|
-
"append": "#"
|
|
95
|
-
},
|
|
96
|
-
"license_formats": {
|
|
97
|
-
"c|cc|cpp|h|hpp|js|ts|css": {
|
|
98
|
-
"prepend": "/**",
|
|
99
|
-
"eachLine": {
|
|
100
|
-
"prepend": " * "
|
|
101
|
-
},
|
|
102
|
-
"append": " */"
|
|
103
|
-
},
|
|
104
|
-
"conf|gitignore|npmignore|eslintignore|sh|py": {
|
|
105
|
-
"prepend": "#",
|
|
106
|
-
"eachLine": {
|
|
107
|
-
"prepend": "# "
|
|
108
|
-
},
|
|
109
|
-
"append": "#"
|
|
110
|
-
},
|
|
111
|
-
"html|xml|md": {
|
|
112
|
-
"prepend": "<!--\n",
|
|
113
|
-
"eachLine": {
|
|
114
|
-
"prepend": " "
|
|
115
|
-
},
|
|
116
|
-
"append": "\n-->"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
67
|
}
|
|
120
68
|
}
|
package/pkg/load_test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
1
2
|
#
|
|
2
3
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
4
|
# or more contributor license agreements. See the NOTICE file
|
|
@@ -19,19 +20,17 @@
|
|
|
19
20
|
|
|
20
21
|
set -e -x
|
|
21
22
|
|
|
23
|
+
ROOT_DIR=`cd $(dirname $0) && cd ../../ && pwd`
|
|
24
|
+
source $ROOT_DIR/pulsar-client-cpp.txt
|
|
25
|
+
|
|
22
26
|
if [ -z "$ARCH" ]; then
|
|
23
27
|
export ARCH=$(uname -m)
|
|
24
28
|
fi
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
cd $MAC_BUILD_DIR
|
|
33
|
-
mkdir -p build
|
|
34
|
-
cd build
|
|
35
|
-
mkdir -p install
|
|
36
|
-
export PREFIX=`pwd`/install
|
|
30
|
+
rm -rf $ROOT_DIR/pkg/mac/build-pulsar
|
|
31
|
+
mkdir -p $ROOT_DIR/pkg/mac/build-pulsar/install
|
|
32
|
+
cd $ROOT_DIR/pkg/mac
|
|
33
|
+
curl -L -O ${CPP_CLIENT_BASE_URL}/macos-${ARCH}.zip
|
|
34
|
+
unzip -d $ROOT_DIR/pkg/mac/build-pulsar/install macos-${ARCH}.zip
|
|
35
|
+
rm -rf macos-${ARCH}.zip
|
|
37
36
|
|
package/pulsar-client-cpp.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
CPP_CLIENT_BASE_URL=https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.2
|
|
2
|
-
CPP_CLIENT_VERSION=3.2
|
|
1
|
+
CPP_CLIENT_BASE_URL=https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.4.2
|
|
2
|
+
CPP_CLIENT_VERSION=3.4.2
|
package/src/Consumer.cc
CHANGED
|
@@ -38,6 +38,7 @@ void Consumer::Init(Napi::Env env, Napi::Object exports) {
|
|
|
38
38
|
DefineClass(env, "Consumer",
|
|
39
39
|
{
|
|
40
40
|
InstanceMethod("receive", &Consumer::Receive),
|
|
41
|
+
InstanceMethod("batchReceive", &Consumer::BatchReceive),
|
|
41
42
|
InstanceMethod("acknowledge", &Consumer::Acknowledge),
|
|
42
43
|
InstanceMethod("acknowledgeId", &Consumer::AcknowledgeId),
|
|
43
44
|
InstanceMethod("negativeAcknowledge", &Consumer::NegativeAcknowledge),
|
|
@@ -192,36 +193,17 @@ struct ConsumerNewInstanceContext {
|
|
|
192
193
|
Napi::Value Consumer::NewInstance(const Napi::CallbackInfo &info, std::shared_ptr<pulsar_client_t> cClient) {
|
|
193
194
|
auto deferred = ThreadSafeDeferred::New(info.Env());
|
|
194
195
|
auto config = info[0].As<Napi::Object>();
|
|
195
|
-
std::shared_ptr<ConsumerConfig> consumerConfig = std::make_shared<ConsumerConfig>(
|
|
196
|
+
std::shared_ptr<ConsumerConfig> consumerConfig = std::make_shared<ConsumerConfig>();
|
|
197
|
+
|
|
198
|
+
consumerConfig->InitConfig(deferred, config, &MessageListener);
|
|
199
|
+
if (deferred->IsDone()) {
|
|
200
|
+
return deferred->Promise();
|
|
201
|
+
}
|
|
196
202
|
|
|
197
203
|
const std::string &topic = consumerConfig->GetTopic();
|
|
198
204
|
const std::vector<std::string> &topics = consumerConfig->GetTopics();
|
|
199
205
|
const std::string &topicsPattern = consumerConfig->GetTopicsPattern();
|
|
200
|
-
if (topic.empty() && topics.size() == 0 && topicsPattern.empty()) {
|
|
201
|
-
deferred->Reject(
|
|
202
|
-
std::string("Topic, topics or topicsPattern is required and must be specified as a string when "
|
|
203
|
-
"creating consumer"));
|
|
204
|
-
return deferred->Promise();
|
|
205
|
-
}
|
|
206
206
|
const std::string &subscription = consumerConfig->GetSubscription();
|
|
207
|
-
if (subscription.empty()) {
|
|
208
|
-
deferred->Reject(
|
|
209
|
-
std::string("Subscription is required and must be specified as a string when creating consumer"));
|
|
210
|
-
return deferred->Promise();
|
|
211
|
-
}
|
|
212
|
-
int32_t ackTimeoutMs = consumerConfig->GetAckTimeoutMs();
|
|
213
|
-
if (ackTimeoutMs != 0 && ackTimeoutMs < MIN_ACK_TIMEOUT_MILLIS) {
|
|
214
|
-
std::string msg("Ack timeout should be 0 or greater than or equal to " +
|
|
215
|
-
std::to_string(MIN_ACK_TIMEOUT_MILLIS));
|
|
216
|
-
deferred->Reject(msg);
|
|
217
|
-
return deferred->Promise();
|
|
218
|
-
}
|
|
219
|
-
int32_t nAckRedeliverTimeoutMs = consumerConfig->GetNAckRedeliverTimeoutMs();
|
|
220
|
-
if (nAckRedeliverTimeoutMs < 0) {
|
|
221
|
-
std::string msg("NAck timeout should be greater than or equal to zero");
|
|
222
|
-
deferred->Reject(msg);
|
|
223
|
-
return deferred->Promise();
|
|
224
|
-
}
|
|
225
207
|
|
|
226
208
|
auto ctx = new ConsumerNewInstanceContext(deferred, cClient, consumerConfig);
|
|
227
209
|
|
|
@@ -291,6 +273,39 @@ class ConsumerReceiveWorker : public Napi::AsyncWorker {
|
|
|
291
273
|
int64_t timeout;
|
|
292
274
|
};
|
|
293
275
|
|
|
276
|
+
Napi::Value Consumer::BatchReceive(const Napi::CallbackInfo &info) {
|
|
277
|
+
auto deferred = ThreadSafeDeferred::New(Env());
|
|
278
|
+
auto ctx = new ExtDeferredContext(deferred);
|
|
279
|
+
pulsar_consumer_batch_receive_async(
|
|
280
|
+
this->cConsumer.get(),
|
|
281
|
+
[](pulsar_result result, pulsar_messages_t *rawMessages, void *ctx) {
|
|
282
|
+
auto deferredContext = static_cast<ExtDeferredContext *>(ctx);
|
|
283
|
+
auto deferred = deferredContext->deferred;
|
|
284
|
+
delete deferredContext;
|
|
285
|
+
|
|
286
|
+
if (result != pulsar_result_Ok) {
|
|
287
|
+
deferred->Reject(std::string("Failed to batch receive message: ") + pulsar_result_str(result));
|
|
288
|
+
} else {
|
|
289
|
+
deferred->Resolve([rawMessages](const Napi::Env env) {
|
|
290
|
+
int listSize = pulsar_messages_size(rawMessages);
|
|
291
|
+
Napi::Array jsArray = Napi::Array::New(env, listSize);
|
|
292
|
+
for (int i = 0; i < listSize; i++) {
|
|
293
|
+
pulsar_message_t *rawMessage = pulsar_messages_get(rawMessages, i);
|
|
294
|
+
pulsar_message_t *message = pulsar_message_create();
|
|
295
|
+
pulsar_message_copy(rawMessage, message);
|
|
296
|
+
Napi::Object obj =
|
|
297
|
+
Message::NewInstance({}, std::shared_ptr<pulsar_message_t>(message, pulsar_message_free));
|
|
298
|
+
jsArray.Set(i, obj);
|
|
299
|
+
}
|
|
300
|
+
pulsar_messages_free(rawMessages);
|
|
301
|
+
return jsArray;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
ctx);
|
|
306
|
+
return deferred->Promise();
|
|
307
|
+
}
|
|
308
|
+
|
|
294
309
|
Napi::Value Consumer::Receive(const Napi::CallbackInfo &info) {
|
|
295
310
|
if (info[0].IsUndefined()) {
|
|
296
311
|
auto deferred = ThreadSafeDeferred::New(Env());
|
package/src/Consumer.h
CHANGED
|
@@ -44,6 +44,7 @@ class Consumer : public Napi::ObjectWrap<Consumer> {
|
|
|
44
44
|
MessageListenerCallback *listener;
|
|
45
45
|
|
|
46
46
|
Napi::Value Receive(const Napi::CallbackInfo &info);
|
|
47
|
+
Napi::Value BatchReceive(const Napi::CallbackInfo &info);
|
|
47
48
|
Napi::Value Acknowledge(const Napi::CallbackInfo &info);
|
|
48
49
|
Napi::Value AcknowledgeId(const Napi::CallbackInfo &info);
|
|
49
50
|
void NegativeAcknowledge(const Napi::CallbackInfo &info);
|
package/src/ConsumerConfig.cc
CHANGED
|
@@ -51,6 +51,10 @@ static const std::string CFG_DEAD_LETTER_POLICY = "deadLetterPolicy";
|
|
|
51
51
|
static const std::string CFG_DLQ_POLICY_TOPIC = "deadLetterTopic";
|
|
52
52
|
static const std::string CFG_DLQ_POLICY_MAX_REDELIVER_COUNT = "maxRedeliverCount";
|
|
53
53
|
static const std::string CFG_DLQ_POLICY_INIT_SUB_NAME = "initialSubscriptionName";
|
|
54
|
+
static const std::string CFG_BATCH_RECEIVE_POLICY = "batchReceivePolicy";
|
|
55
|
+
static const std::string CFG_BATCH_RECEIVE_POLICY_MAX_NUM_MESSAGES = "maxNumMessages";
|
|
56
|
+
static const std::string CFG_BATCH_RECEIVE_POLICY_MAX_NUM_BYTES = "maxNumBytes";
|
|
57
|
+
static const std::string CFG_BATCH_RECEIVE_POLICY_TIMEOUT_MS = "timeoutMs";
|
|
54
58
|
|
|
55
59
|
static const std::map<std::string, pulsar_consumer_type> SUBSCRIPTION_TYPE = {
|
|
56
60
|
{"Exclusive", pulsar_ConsumerExclusive},
|
|
@@ -74,7 +78,7 @@ static const std::map<std::string, pulsar_consumer_crypto_failure_action> CONSUM
|
|
|
74
78
|
|
|
75
79
|
void FinalizeListenerCallback(Napi::Env env, MessageListenerCallback *cb, void *) { delete cb; }
|
|
76
80
|
|
|
77
|
-
ConsumerConfig::ConsumerConfig(
|
|
81
|
+
ConsumerConfig::ConsumerConfig()
|
|
78
82
|
: topic(""),
|
|
79
83
|
topicsPattern(""),
|
|
80
84
|
subscription(""),
|
|
@@ -83,7 +87,10 @@ ConsumerConfig::ConsumerConfig(const Napi::Object &consumerConfig, pulsar_messag
|
|
|
83
87
|
listener(nullptr) {
|
|
84
88
|
this->cConsumerConfig = std::shared_ptr<pulsar_consumer_configuration_t>(
|
|
85
89
|
pulsar_consumer_configuration_create(), pulsar_consumer_configuration_free);
|
|
90
|
+
}
|
|
86
91
|
|
|
92
|
+
void ConsumerConfig::InitConfig(std::shared_ptr<ThreadSafeDeferred> deferred,
|
|
93
|
+
const Napi::Object &consumerConfig, pulsar_message_listener messageListener) {
|
|
87
94
|
if (consumerConfig.Has(CFG_TOPIC) && consumerConfig.Get(CFG_TOPIC).IsString()) {
|
|
88
95
|
this->topic = consumerConfig.Get(CFG_TOPIC).ToString().Utf8Value();
|
|
89
96
|
}
|
|
@@ -101,9 +108,21 @@ ConsumerConfig::ConsumerConfig(const Napi::Object &consumerConfig, pulsar_messag
|
|
|
101
108
|
this->topicsPattern = consumerConfig.Get(CFG_TOPICS_PATTERN).ToString().Utf8Value();
|
|
102
109
|
}
|
|
103
110
|
|
|
111
|
+
if (this->topic.empty() && this->topics.size() == 0 && this->topicsPattern.empty()) {
|
|
112
|
+
deferred->Reject(
|
|
113
|
+
std::string("Topic, topics or topicsPattern is required and must be specified as a string when "
|
|
114
|
+
"creating consumer"));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
104
118
|
if (consumerConfig.Has(CFG_SUBSCRIPTION) && consumerConfig.Get(CFG_SUBSCRIPTION).IsString()) {
|
|
105
119
|
this->subscription = consumerConfig.Get(CFG_SUBSCRIPTION).ToString().Utf8Value();
|
|
106
120
|
}
|
|
121
|
+
if (subscription.empty()) {
|
|
122
|
+
deferred->Reject(
|
|
123
|
+
std::string("Subscription is required and must be specified as a string when creating consumer"));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
107
126
|
|
|
108
127
|
if (consumerConfig.Has(CFG_SUBSCRIPTION_TYPE) && consumerConfig.Get(CFG_SUBSCRIPTION_TYPE).IsString()) {
|
|
109
128
|
std::string subscriptionType = consumerConfig.Get(CFG_SUBSCRIPTION_TYPE).ToString().Utf8Value();
|
|
@@ -139,18 +158,25 @@ ConsumerConfig::ConsumerConfig(const Napi::Object &consumerConfig, pulsar_messag
|
|
|
139
158
|
|
|
140
159
|
if (consumerConfig.Has(CFG_ACK_TIMEOUT) && consumerConfig.Get(CFG_ACK_TIMEOUT).IsNumber()) {
|
|
141
160
|
this->ackTimeoutMs = consumerConfig.Get(CFG_ACK_TIMEOUT).ToNumber().Int64Value();
|
|
142
|
-
if (this->ackTimeoutMs
|
|
143
|
-
|
|
161
|
+
if (this->ackTimeoutMs != 0 && ackTimeoutMs < MIN_ACK_TIMEOUT_MILLIS) {
|
|
162
|
+
std::string msg("Ack timeout should be 0 or greater than or equal to " +
|
|
163
|
+
std::to_string(MIN_ACK_TIMEOUT_MILLIS));
|
|
164
|
+
deferred->Reject(msg);
|
|
165
|
+
return;
|
|
144
166
|
}
|
|
167
|
+
pulsar_consumer_set_unacked_messages_timeout_ms(this->cConsumerConfig.get(), this->ackTimeoutMs);
|
|
145
168
|
}
|
|
146
169
|
|
|
147
170
|
if (consumerConfig.Has(CFG_NACK_REDELIVER_TIMEOUT) &&
|
|
148
171
|
consumerConfig.Get(CFG_NACK_REDELIVER_TIMEOUT).IsNumber()) {
|
|
149
172
|
this->nAckRedeliverTimeoutMs = consumerConfig.Get(CFG_NACK_REDELIVER_TIMEOUT).ToNumber().Int64Value();
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
173
|
+
if (nAckRedeliverTimeoutMs < 0) {
|
|
174
|
+
std::string msg("NAck timeout should be greater than or equal to zero");
|
|
175
|
+
deferred->Reject(msg);
|
|
176
|
+
return;
|
|
153
177
|
}
|
|
178
|
+
pulsar_configure_set_negative_ack_redelivery_delay_ms(this->cConsumerConfig.get(),
|
|
179
|
+
this->nAckRedeliverTimeoutMs);
|
|
154
180
|
}
|
|
155
181
|
|
|
156
182
|
if (consumerConfig.Has(CFG_RECV_QUEUE) && consumerConfig.Get(CFG_RECV_QUEUE).IsNumber()) {
|
|
@@ -265,6 +291,39 @@ ConsumerConfig::ConsumerConfig(const Napi::Object &consumerConfig, pulsar_messag
|
|
|
265
291
|
}
|
|
266
292
|
pulsar_consumer_configuration_set_dlq_policy(this->cConsumerConfig.get(), &dlq_policy);
|
|
267
293
|
}
|
|
294
|
+
|
|
295
|
+
if (consumerConfig.Has(CFG_BATCH_RECEIVE_POLICY) &&
|
|
296
|
+
consumerConfig.Get(CFG_BATCH_RECEIVE_POLICY).IsObject()) {
|
|
297
|
+
Napi::Object propObj = consumerConfig.Get(CFG_BATCH_RECEIVE_POLICY).ToObject();
|
|
298
|
+
int maxNumMessages = -1;
|
|
299
|
+
if (propObj.Has(CFG_BATCH_RECEIVE_POLICY_MAX_NUM_MESSAGES) &&
|
|
300
|
+
propObj.Get(CFG_BATCH_RECEIVE_POLICY_MAX_NUM_MESSAGES).IsNumber()) {
|
|
301
|
+
maxNumMessages = propObj.Get(CFG_BATCH_RECEIVE_POLICY_MAX_NUM_MESSAGES).ToNumber().Int32Value();
|
|
302
|
+
}
|
|
303
|
+
int maxNumBytes = 10 * 1024 * 1024;
|
|
304
|
+
if (propObj.Has(CFG_BATCH_RECEIVE_POLICY_MAX_NUM_BYTES) &&
|
|
305
|
+
propObj.Get(CFG_BATCH_RECEIVE_POLICY_MAX_NUM_BYTES).IsNumber()) {
|
|
306
|
+
maxNumBytes = propObj.Get(CFG_BATCH_RECEIVE_POLICY_MAX_NUM_BYTES).ToNumber().Int64Value();
|
|
307
|
+
}
|
|
308
|
+
int timeoutMs = 100;
|
|
309
|
+
if (propObj.Has(CFG_BATCH_RECEIVE_POLICY_TIMEOUT_MS) &&
|
|
310
|
+
propObj.Get(CFG_BATCH_RECEIVE_POLICY_TIMEOUT_MS).IsNumber()) {
|
|
311
|
+
timeoutMs = propObj.Get(CFG_BATCH_RECEIVE_POLICY_TIMEOUT_MS).ToNumber().Int64Value();
|
|
312
|
+
}
|
|
313
|
+
if (maxNumMessages <= 0 && maxNumBytes <= 0 && timeoutMs <= 0) {
|
|
314
|
+
std::string msg("At least one of maxNumMessages, maxNumBytes and timeoutMs must be specified.");
|
|
315
|
+
deferred->Reject(msg);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
pulsar_consumer_batch_receive_policy_t batch_receive_policy{maxNumMessages, maxNumBytes, timeoutMs};
|
|
319
|
+
int result = pulsar_consumer_configuration_set_batch_receive_policy(this->cConsumerConfig.get(),
|
|
320
|
+
&batch_receive_policy);
|
|
321
|
+
if (result == -1) {
|
|
322
|
+
std::string msg("Set batch receive policy failed: C client returned failure");
|
|
323
|
+
deferred->Reject(msg);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
268
327
|
}
|
|
269
328
|
|
|
270
329
|
ConsumerConfig::~ConsumerConfig() {
|
package/src/ConsumerConfig.h
CHANGED
|
@@ -21,14 +21,17 @@
|
|
|
21
21
|
#define CONSUMER_CONFIG_H
|
|
22
22
|
|
|
23
23
|
#include <pulsar/c/consumer_configuration.h>
|
|
24
|
+
#include "ThreadSafeDeferred.h"
|
|
24
25
|
#include "MessageListener.h"
|
|
25
26
|
|
|
26
27
|
#define MIN_ACK_TIMEOUT_MILLIS 10000
|
|
27
28
|
|
|
28
29
|
class ConsumerConfig {
|
|
29
30
|
public:
|
|
30
|
-
ConsumerConfig(
|
|
31
|
+
ConsumerConfig();
|
|
31
32
|
~ConsumerConfig();
|
|
33
|
+
void InitConfig(std::shared_ptr<ThreadSafeDeferred> deferred, const Napi::Object &consumerConfig,
|
|
34
|
+
pulsar_message_listener messageListener);
|
|
32
35
|
std::shared_ptr<pulsar_consumer_configuration_t> GetCConsumerConfig();
|
|
33
36
|
std::string GetTopic();
|
|
34
37
|
std::vector<std::string> GetTopics();
|
package/src/ThreadSafeDeferred.h
CHANGED
|
@@ -73,6 +73,7 @@ class ThreadSafeDeferred : public Napi::Promise::Deferred {
|
|
|
73
73
|
inline void Reject() { this->Reject(""); }
|
|
74
74
|
void Reject(
|
|
75
75
|
const std::string &); // <- if only Reject were virtual... But we can live without polymorphism here
|
|
76
|
+
bool IsDone() const;
|
|
76
77
|
|
|
77
78
|
static std::shared_ptr<ThreadSafeDeferred> New(const Napi::Env env);
|
|
78
79
|
};
|
package/tests/client.test.js
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
const httpRequest = require('./http_utils
|
|
21
|
-
const Pulsar = require('../index
|
|
20
|
+
const httpRequest = require('./http_utils');
|
|
21
|
+
const Pulsar = require('../index');
|
|
22
22
|
|
|
23
23
|
const baseUrl = 'http://localhost:8080';
|
|
24
24
|
|
package/tests/consumer.test.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
const Pulsar = require('../index
|
|
20
|
+
const Pulsar = require('../index');
|
|
21
21
|
|
|
22
22
|
(() => {
|
|
23
23
|
describe('Consumer', () => {
|
|
@@ -122,6 +122,37 @@ const Pulsar = require('../index.js');
|
|
|
122
122
|
nAckRedeliverTimeoutMs: -12,
|
|
123
123
|
})).rejects.toThrow('NAck timeout should be greater than or equal to zero');
|
|
124
124
|
});
|
|
125
|
+
|
|
126
|
+
test('Ack timeout less 10000', async () => {
|
|
127
|
+
await expect(client.subscribe({
|
|
128
|
+
topic: 'test-topic',
|
|
129
|
+
subscription: 'sub1',
|
|
130
|
+
subscriptionType: 'Shared',
|
|
131
|
+
ackTimeoutMs: 100,
|
|
132
|
+
})).rejects.toThrow('Ack timeout should be 0 or greater than or equal to 10000');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('NAck timeout less 0', async () => {
|
|
136
|
+
await expect(client.subscribe({
|
|
137
|
+
topic: 'test-topic',
|
|
138
|
+
subscription: 'sub1',
|
|
139
|
+
subscriptionType: 'Shared',
|
|
140
|
+
nAckRedeliverTimeoutMs: -1,
|
|
141
|
+
})).rejects.toThrow('NAck timeout should be greater than or equal to zero');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('Batch Receive Config Error', async () => {
|
|
145
|
+
await expect(client.subscribe({
|
|
146
|
+
topic: 'test-batch-receive-policy-error',
|
|
147
|
+
subscription: 'sub1',
|
|
148
|
+
subscriptionType: 'Shared',
|
|
149
|
+
batchReceivePolicy: {
|
|
150
|
+
maxNumMessages: -1,
|
|
151
|
+
maxNumBytes: -1,
|
|
152
|
+
timeoutMs: -1,
|
|
153
|
+
},
|
|
154
|
+
})).rejects.toThrow('At least one of maxNumMessages, maxNumBytes and timeoutMs must be specified.');
|
|
155
|
+
});
|
|
125
156
|
});
|
|
126
157
|
|
|
127
158
|
describe('Close', () => {
|
|
@@ -137,7 +168,7 @@ const Pulsar = require('../index.js');
|
|
|
137
168
|
|
|
138
169
|
await expect(consumer.close()).resolves.toEqual(null);
|
|
139
170
|
|
|
140
|
-
await expect(consumer.close()).
|
|
171
|
+
await expect(consumer.close()).resolves.toEqual(null);
|
|
141
172
|
});
|
|
142
173
|
});
|
|
143
174
|
|
|
@@ -315,6 +346,89 @@ const Pulsar = require('../index.js');
|
|
|
315
346
|
consumer.close();
|
|
316
347
|
dlqConsumer.close();
|
|
317
348
|
});
|
|
349
|
+
|
|
350
|
+
test('Batch Receive by maxNumberMessages', async () => {
|
|
351
|
+
const topicName = 'batch-receive-test-topic';
|
|
352
|
+
const producer = await client.createProducer({
|
|
353
|
+
topic: topicName,
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
const consumer = await client.subscribe({
|
|
357
|
+
topic: topicName,
|
|
358
|
+
subscription: 'sub1',
|
|
359
|
+
subscriptionType: 'Shared',
|
|
360
|
+
batchReceivePolicy: {
|
|
361
|
+
maxNumMessages: 10,
|
|
362
|
+
maxNumBytes: -1,
|
|
363
|
+
timeoutMs: 500,
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
const num = 10;
|
|
367
|
+
const messages = [];
|
|
368
|
+
for (let i = 0; i < num; i += 1) {
|
|
369
|
+
const msg = `my-message-${i}`;
|
|
370
|
+
await producer.send({ data: Buffer.from(msg) });
|
|
371
|
+
messages.push(msg);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const receiveMessages = await consumer.batchReceive();
|
|
375
|
+
expect(receiveMessages.length).toEqual(num);
|
|
376
|
+
const results = [];
|
|
377
|
+
for (let i = 0; i < receiveMessages.length; i += 1) {
|
|
378
|
+
const msg = receiveMessages[i];
|
|
379
|
+
console.log(msg.getData().toString());
|
|
380
|
+
results.push(msg.getData().toString());
|
|
381
|
+
}
|
|
382
|
+
expect(results).toEqual(messages);
|
|
383
|
+
|
|
384
|
+
// assert no more msgs.
|
|
385
|
+
expect(await consumer.batchReceive()).toEqual([]);
|
|
386
|
+
|
|
387
|
+
await producer.close();
|
|
388
|
+
await consumer.close();
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
test('Batch Receive by timeOutMs', async () => {
|
|
392
|
+
const topicName = 'batch-receive-test-topic-timeout';
|
|
393
|
+
const producer = await client.createProducer({
|
|
394
|
+
topic: topicName,
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
const consumer = await client.subscribe({
|
|
398
|
+
topic: topicName,
|
|
399
|
+
subscription: 'sub1',
|
|
400
|
+
subscriptionType: 'Shared',
|
|
401
|
+
batchReceivePolicy: {
|
|
402
|
+
maxNumMessages: 100,
|
|
403
|
+
maxNumBytes: -1,
|
|
404
|
+
timeoutMs: 500,
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
// just send 10 message waite trigger timeout.
|
|
408
|
+
const num = 10;
|
|
409
|
+
const messages = [];
|
|
410
|
+
for (let i = 0; i < num; i += 1) {
|
|
411
|
+
const msg = `my-message-${i}`;
|
|
412
|
+
await producer.send({ data: Buffer.from(msg) });
|
|
413
|
+
messages.push(msg);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const receiveMessages = await consumer.batchReceive();
|
|
417
|
+
expect(receiveMessages.length).toEqual(num);
|
|
418
|
+
const results = [];
|
|
419
|
+
for (let i = 0; i < receiveMessages.length; i += 1) {
|
|
420
|
+
const msg = receiveMessages[i];
|
|
421
|
+
console.log(msg.getData().toString());
|
|
422
|
+
results.push(msg.getData().toString());
|
|
423
|
+
}
|
|
424
|
+
expect(results).toEqual(messages);
|
|
425
|
+
|
|
426
|
+
// assert no more msgs.
|
|
427
|
+
expect(await consumer.batchReceive()).toEqual([]);
|
|
428
|
+
|
|
429
|
+
await producer.close();
|
|
430
|
+
await consumer.close();
|
|
431
|
+
});
|
|
318
432
|
});
|
|
319
433
|
});
|
|
320
434
|
})();
|
package/tests/end_to_end.test.js
CHANGED
package/tests/producer.test.js
CHANGED
package/tests/reader.test.js
CHANGED
package/tstest.ts
CHANGED
|
@@ -37,6 +37,16 @@ import Pulsar = require('./index');
|
|
|
37
37
|
principalHeader: 'Athenz-Principal-Auth',
|
|
38
38
|
roleHeader: 'Athenz-Role-Auth',
|
|
39
39
|
tokenExpirationTime: '3600',
|
|
40
|
+
caCert: 'file:///path/to/cacert.pem',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const authAthenz3: Pulsar.AuthenticationAthenz = new Pulsar.AuthenticationAthenz({
|
|
44
|
+
providerDomain: 'athenz.provider.domain',
|
|
45
|
+
privateKey: 'file:///path/to/private.key',
|
|
46
|
+
ztsUrl: 'https://localhost:8443',
|
|
47
|
+
roleHeader: 'Athenz-Role-Auth',
|
|
48
|
+
x509CertChain: 'file:///path/to/x509cert.pem',
|
|
49
|
+
caCert: 'file:///path/to/cacert.pem',
|
|
40
50
|
});
|
|
41
51
|
|
|
42
52
|
const authOauth2PrivateKey: Pulsar.AuthenticationOauth2 = new Pulsar.AuthenticationOauth2({
|
package/Gruntfile.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
|
|
20
|
-
module.exports = (grunt) => {
|
|
21
|
-
grunt.loadNpmTasks('grunt-license-report');
|
|
22
|
-
grunt.initConfig({
|
|
23
|
-
pkg: grunt.file.readJSON('package.json'),
|
|
24
|
-
'grunt-license-report': {
|
|
25
|
-
output: {
|
|
26
|
-
path: './report/licenses',
|
|
27
|
-
format: 'html',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
#
|
|
3
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
-
# or more contributor license agreements. See the NOTICE file
|
|
5
|
-
# distributed with this work for additional information
|
|
6
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
-
# to you under the Apache License, Version 2.0 (the
|
|
8
|
-
# "License"); you may not use this file except in compliance
|
|
9
|
-
# with the License. You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing,
|
|
14
|
-
# software distributed under the License is distributed on an
|
|
15
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
# KIND, either express or implied. See the License for the
|
|
17
|
-
# specific language governing permissions and limitations
|
|
18
|
-
# under the License.
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
import yaml, sys
|
|
22
|
-
|
|
23
|
-
deps = yaml.safe_load(open("dependencies.yaml"))
|
|
24
|
-
print(deps[sys.argv[1]])
|
package/dependencies.yaml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
|
|
20
|
-
# Only used for MacOS builds
|
|
21
|
-
boost: 1.80.0
|
|
22
|
-
cmake: 3.24.2
|
|
23
|
-
protobuf: 3.20.0
|
|
24
|
-
zlib: 1.2.13
|
|
25
|
-
zstd: 1.5.2
|
|
26
|
-
snappy: 1.1.9
|
|
27
|
-
openssl: 1.1.1s
|
|
28
|
-
curl: 7.85.0
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
-
# or more contributor license agreements. See the NOTICE file
|
|
5
|
-
# distributed with this work for additional information
|
|
6
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
-
# to you under the Apache License, Version 2.0 (the
|
|
8
|
-
# "License"); you may not use this file except in compliance
|
|
9
|
-
# with the License. You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing,
|
|
14
|
-
# software distributed under the License is distributed on an
|
|
15
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
# KIND, either express or implied. See the License for the
|
|
17
|
-
# specific language governing permissions and limitations
|
|
18
|
-
# under the License.
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
source $(dirname $0)/common.sh
|
|
22
|
-
|
|
23
|
-
cd $ROOT_DIR
|
|
24
|
-
|
|
25
|
-
pip3 install pyyaml
|
|
26
|
-
|
|
27
|
-
dep=$ROOT_DIR/build-support/dep-version.py
|
|
28
|
-
ZLIB_VERSION=$($dep zlib)
|
|
29
|
-
OPENSSL_VERSION=$($dep openssl)
|
|
30
|
-
BOOST_VERSION=$($dep boost)
|
|
31
|
-
PROTOBUF_VERSION=$($dep protobuf)
|
|
32
|
-
ZSTD_VERSION=$($dep zstd)
|
|
33
|
-
SNAPPY_VERSION=$($dep snappy)
|
|
34
|
-
CURL_VERSION=$($dep curl)
|
|
35
|
-
|
|
36
|
-
cd $MAC_BUILD_DIR/build
|
|
37
|
-
|
|
38
|
-
##############################################################################
|
|
39
|
-
if [ ! -f zlib-${ZLIB_VERSION}.done ]; then
|
|
40
|
-
echo "Building ZLib"
|
|
41
|
-
curl -O -L https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz
|
|
42
|
-
tar xfz zlib-$ZLIB_VERSION.tar.gz
|
|
43
|
-
pushd zlib-$ZLIB_VERSION
|
|
44
|
-
CFLAGS="-fPIC -O3 -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" ./configure --prefix=$PREFIX
|
|
45
|
-
make -j16
|
|
46
|
-
make install
|
|
47
|
-
popd
|
|
48
|
-
|
|
49
|
-
rm -rf zlib-$ZLIB_VERSION.tar.gz zlib-$ZLIB_VERSION
|
|
50
|
-
touch zlib-${ZLIB_VERSION}.done
|
|
51
|
-
else
|
|
52
|
-
echo "Using cached ZLib"
|
|
53
|
-
fi
|
|
54
|
-
|
|
55
|
-
###############################################################################
|
|
56
|
-
OPENSSL_VERSION_UNDERSCORE=$(echo $OPENSSL_VERSION | sed 's/\./_/g')
|
|
57
|
-
if [ ! -f openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.done ]; then
|
|
58
|
-
echo "Building OpenSSL"
|
|
59
|
-
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz
|
|
60
|
-
tar xfz OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz
|
|
61
|
-
pushd openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}
|
|
62
|
-
if [ $ARCH = 'arm64' ]; then
|
|
63
|
-
PLATFORM=darwin64-arm64-cc
|
|
64
|
-
else
|
|
65
|
-
PLATFORM=darwin64-x86_64-cc
|
|
66
|
-
fi
|
|
67
|
-
./Configure --prefix=$PREFIX no-shared no-unit-test $PLATFORM
|
|
68
|
-
make -j8
|
|
69
|
-
make install_sw
|
|
70
|
-
popd
|
|
71
|
-
|
|
72
|
-
rm -rf OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}
|
|
73
|
-
touch openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.done
|
|
74
|
-
else
|
|
75
|
-
echo "Using cached OpenSSL"
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
###############################################################################
|
|
79
|
-
BOOST_VERSION_=${BOOST_VERSION//./_}
|
|
80
|
-
DIR=boost-src-${BOOST_VERSION}
|
|
81
|
-
if [ ! -f $DIR.done ]; then
|
|
82
|
-
echo "Building Boost"
|
|
83
|
-
curl -O -L https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_}.tar.gz
|
|
84
|
-
tar xfz boost_${BOOST_VERSION_}.tar.gz
|
|
85
|
-
rm -rf $DIR
|
|
86
|
-
mv boost_${BOOST_VERSION_} $DIR
|
|
87
|
-
|
|
88
|
-
pushd $DIR
|
|
89
|
-
./bootstrap.sh --prefix=$PREFIX --with-libraries=system
|
|
90
|
-
./b2 address-model=64 cxxflags="-fPIC -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
91
|
-
link=static threading=multi \
|
|
92
|
-
variant=release \
|
|
93
|
-
install
|
|
94
|
-
popd
|
|
95
|
-
|
|
96
|
-
rm -rf $DIR boost_${BOOST_VERSION_}.tar.gz
|
|
97
|
-
touch $DIR.done
|
|
98
|
-
else
|
|
99
|
-
echo "Using cached Boost"
|
|
100
|
-
fi
|
|
101
|
-
|
|
102
|
-
###############################################################################
|
|
103
|
-
if [ ! -f protobuf-${PROTOBUF_VERSION}.done ]; then
|
|
104
|
-
echo "Building Protobuf"
|
|
105
|
-
curl -O -L https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
|
|
106
|
-
tar xfz protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
|
|
107
|
-
pushd protobuf-${PROTOBUF_VERSION}
|
|
108
|
-
CXXFLAGS="-fPIC -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
109
|
-
./configure --prefix=$PREFIX
|
|
110
|
-
make -j16 V=1
|
|
111
|
-
make install
|
|
112
|
-
popd
|
|
113
|
-
|
|
114
|
-
pushd install/lib
|
|
115
|
-
echo "Propose target arch static lib" ${ARCH}
|
|
116
|
-
mv libprotobuf.a libprotobuf_universal.a
|
|
117
|
-
lipo libprotobuf_universal.a -thin ${ARCH} -output libprotobuf.a
|
|
118
|
-
popd
|
|
119
|
-
|
|
120
|
-
rm -rf protobuf-${PROTOBUF_VERSION} protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
|
|
121
|
-
touch protobuf-${PROTOBUF_VERSION}.done
|
|
122
|
-
else
|
|
123
|
-
echo "Using cached Protobuf"
|
|
124
|
-
fi
|
|
125
|
-
|
|
126
|
-
###############################################################################
|
|
127
|
-
if [ ! -f zstd-${ZSTD_VERSION}.done ]; then
|
|
128
|
-
echo "Building ZStd"
|
|
129
|
-
curl -O -L https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz
|
|
130
|
-
tar xfz zstd-${ZSTD_VERSION}.tar.gz
|
|
131
|
-
pushd zstd-${ZSTD_VERSION}
|
|
132
|
-
CFLAGS="-fPIC -O3 -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
133
|
-
PREFIX=$PREFIX \
|
|
134
|
-
make -j16 -C lib install
|
|
135
|
-
popd
|
|
136
|
-
|
|
137
|
-
rm -rf zstd-${ZSTD_VERSION} zstd-${ZSTD_VERSION}.tar.gz
|
|
138
|
-
touch zstd-${ZSTD_VERSION}.done
|
|
139
|
-
else
|
|
140
|
-
echo "Using cached ZStd"
|
|
141
|
-
fi
|
|
142
|
-
|
|
143
|
-
###############################################################################
|
|
144
|
-
if [ ! -f snappy-${SNAPPY_VERSION}.done ]; then
|
|
145
|
-
echo "Building Snappy"
|
|
146
|
-
curl -O -L https://github.com/google/snappy/archive/refs/tags/${SNAPPY_VERSION}.tar.gz
|
|
147
|
-
tar xfz ${SNAPPY_VERSION}.tar.gz
|
|
148
|
-
pushd snappy-${SNAPPY_VERSION}
|
|
149
|
-
CXXFLAGS="-fPIC -O3 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
150
|
-
cmake . -DCMAKE_OSX_ARCHITECTURES=${ARCH} -DCMAKE_INSTALL_PREFIX=$PREFIX -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF
|
|
151
|
-
make -j16
|
|
152
|
-
make install
|
|
153
|
-
touch .done
|
|
154
|
-
popd
|
|
155
|
-
|
|
156
|
-
rm -rf snappy-${SNAPPY_VERSION} ${SNAPPY_VERSION}.tar.gz
|
|
157
|
-
touch snappy-${SNAPPY_VERSION}.done
|
|
158
|
-
else
|
|
159
|
-
echo "Using cached Snappy"
|
|
160
|
-
fi
|
|
161
|
-
|
|
162
|
-
###############################################################################
|
|
163
|
-
if [ ! -f curl-${CURL_VERSION}.done ]; then
|
|
164
|
-
echo "Building LibCurl"
|
|
165
|
-
CURL_VERSION_=${CURL_VERSION//./_}
|
|
166
|
-
curl -O -L https://github.com/curl/curl/releases/download/curl-${CURL_VERSION_}/curl-${CURL_VERSION}.tar.gz
|
|
167
|
-
tar xfz curl-${CURL_VERSION}.tar.gz
|
|
168
|
-
pushd curl-${CURL_VERSION}
|
|
169
|
-
CFLAGS="-fPIC -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
170
|
-
./configure --with-ssl=$PREFIX \
|
|
171
|
-
--without-nghttp2 \
|
|
172
|
-
--without-libidn2 \
|
|
173
|
-
--disable-ldap \
|
|
174
|
-
--without-brotli \
|
|
175
|
-
--without-secure-transport \
|
|
176
|
-
--disable-ipv6 \
|
|
177
|
-
--prefix=$PREFIX \
|
|
178
|
-
--host=$ARCH-apple-darwin
|
|
179
|
-
make -j16 install
|
|
180
|
-
popd
|
|
181
|
-
|
|
182
|
-
rm -rf curl-${CURL_VERSION} curl-${CURL_VERSION}.tar.gz
|
|
183
|
-
touch curl-${CURL_VERSION}.done
|
|
184
|
-
else
|
|
185
|
-
echo "Using cached LibCurl"
|
|
186
|
-
fi
|
package/pkg/mac/build-cpp-lib.sh
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
-
# or more contributor license agreements. See the NOTICE file
|
|
5
|
-
# distributed with this work for additional information
|
|
6
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
-
# to you under the Apache License, Version 2.0 (the
|
|
8
|
-
# "License"); you may not use this file except in compliance
|
|
9
|
-
# with the License. You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing,
|
|
14
|
-
# software distributed under the License is distributed on an
|
|
15
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
# KIND, either express or implied. See the License for the
|
|
17
|
-
# specific language governing permissions and limitations
|
|
18
|
-
# under the License.
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
source $(dirname $0)/common.sh
|
|
22
|
-
|
|
23
|
-
PULSAR_DIR=${MAC_BUILD_DIR}/build-pulsar
|
|
24
|
-
PULSAR_PREFIX=${PULSAR_DIR}/install
|
|
25
|
-
mkdir -p $PULSAR_PREFIX
|
|
26
|
-
cd $PULSAR_DIR
|
|
27
|
-
|
|
28
|
-
## Fetch from official release
|
|
29
|
-
curl -O -L "$CPP_CLIENT_BASE_URL"/apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}.tar.gz
|
|
30
|
-
tar xfz apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}.tar.gz
|
|
31
|
-
pushd apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}
|
|
32
|
-
rm -f CMakeCache.txt
|
|
33
|
-
cmake . \
|
|
34
|
-
-DCMAKE_OSX_ARCHITECTURES=${ARCH} \
|
|
35
|
-
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
|
|
36
|
-
-DCMAKE_INSTALL_PREFIX=$PULSAR_PREFIX \
|
|
37
|
-
-DCMAKE_BUILD_TYPE=Release \
|
|
38
|
-
-DCMAKE_PREFIX_PATH=$PREFIX \
|
|
39
|
-
-DCMAKE_INSTALL_LIBDIR=$PULSAR_PREFIX/lib \
|
|
40
|
-
-DLINK_STATIC=ON \
|
|
41
|
-
-DBUILD_TESTS=OFF \
|
|
42
|
-
-DBUILD_PYTHON_WRAPPER=OFF \
|
|
43
|
-
-DBUILD_DYNAMIC_LIB=OFF \
|
|
44
|
-
-DPROTOC_PATH=$PREFIX/bin/protoc
|
|
45
|
-
make -j16 install
|
|
46
|
-
popd
|
|
47
|
-
|
|
48
|
-
rm -rf apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}.tar.gz apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}
|