pulsar-client 1.6.2 → 1.8.0-rc1
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/.asf.yaml +8 -1
- package/.github/PULL_REQUEST_TEMPLATE.md +65 -0
- package/.github/workflows/ci-build-release-napi.yml +195 -0
- package/.github/workflows/ci-pr-validation.yml +225 -0
- package/README.md +87 -68
- package/binding.gyp +41 -39
- package/{pulsar-test-service-stop.sh → build-support/dep-version.py} +4 -6
- package/build-support/download-release-artifacts.py +74 -0
- package/build-support/generate-source-archive.sh +28 -0
- package/build-support/install-cpp-client.sh +66 -0
- package/{pulsar-test-service-start.sh → build-support/pulsar-test-container-start.sh} +11 -21
- package/build-support/pulsar-test-service-start.sh +37 -0
- package/build-support/pulsar-test-service-stop.sh +32 -0
- package/{.github/workflows/nodejs.yml → build-support/sign-files.sh} +13 -12
- package/build-support/stage-release.sh +44 -0
- package/dependencies.yaml +28 -0
- package/docs/release-process.md +242 -0
- package/examples/consumer.js +1 -1
- package/examples/consumer_listener.js +1 -1
- package/examples/consumer_tls_auth.js +1 -1
- package/examples/custom_logger.js +60 -0
- package/examples/encryption-consumer.js +1 -1
- package/examples/encryption-producer.js +1 -1
- package/examples/producer.js +1 -1
- package/examples/producer_tls_auth.js +1 -1
- package/examples/reader.js +1 -1
- package/examples/reader_listener.js +1 -1
- package/index.d.ts +12 -4
- package/index.js +2 -1
- package/package.json +14 -12
- package/pkg/build-napi-inside-docker.sh +31 -0
- package/pkg/linux_glibc/Dockerfile +33 -0
- package/pkg/linux_musl/Dockerfile +32 -0
- package/pkg/load_test.js +30 -0
- package/pkg/mac/build-cpp-deps-lib.sh +186 -0
- package/pkg/mac/build-cpp-lib.sh +51 -0
- package/{docker-tests.sh → pkg/mac/common.sh} +13 -13
- package/pkg/windows/download-cpp-client.bat +12 -0
- package/pulsar-client-cpp.txt +2 -0
- package/src/AuthenticationAthenz.js +1 -1
- package/src/AuthenticationOauth2.js +1 -1
- package/src/AuthenticationTls.js +1 -1
- package/src/AuthenticationToken.js +1 -1
- package/src/Client.cc +84 -58
- package/src/Client.h +6 -4
- package/src/Consumer.cc +331 -234
- package/src/Consumer.h +11 -9
- package/src/ConsumerConfig.cc +54 -32
- package/src/ConsumerConfig.h +5 -6
- package/src/Message.cc +26 -29
- package/src/Message.h +4 -4
- package/src/MessageId.cc +19 -22
- package/src/MessageId.h +5 -6
- package/src/MessageListener.h +3 -8
- package/src/Producer.cc +116 -133
- package/src/Producer.h +3 -3
- package/src/ProducerConfig.cc +39 -22
- package/src/ProducerConfig.h +2 -2
- package/src/Reader.cc +147 -128
- package/src/Reader.h +5 -3
- package/src/ReaderConfig.cc +14 -20
- package/src/ReaderConfig.h +5 -6
- package/src/ReaderListener.h +2 -7
- package/src/SchemaInfo.cc +78 -0
- package/src/SchemaInfo.h +41 -0
- package/src/ThreadSafeDeferred.cc +98 -0
- package/src/ThreadSafeDeferred.h +85 -0
- package/src/pulsar-binding.js +8 -0
- package/tests/conf/standalone.conf +6 -0
- package/tests/consumer.test.js +2 -2
- package/tests/end_to_end.test.js +214 -2
- package/tests/producer.test.js +2 -2
- package/{run-unit-tests.sh → tests/run-unit-tests.sh} +5 -14
- package/pulsar-version.txt +0 -1
package/.asf.yaml
CHANGED
|
@@ -43,4 +43,11 @@ github:
|
|
|
43
43
|
# disable merge button:
|
|
44
44
|
merge: false
|
|
45
45
|
# disable rebase button:
|
|
46
|
-
rebase: false
|
|
46
|
+
rebase: false
|
|
47
|
+
|
|
48
|
+
notifications:
|
|
49
|
+
commits: commits@pulsar.apache.org
|
|
50
|
+
issues: commits@pulsar.apache.org
|
|
51
|
+
pullrequests: commits@pulsar.apache.org
|
|
52
|
+
discussions: dev@pulsar.apache.org
|
|
53
|
+
jira_options: link label
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
### Contribution Checklist
|
|
3
|
+
|
|
4
|
+
- PR title format should be *[type][component] summary*. For details, see *[Guideline - Pulsar PR Naming Convention](https://docs.google.com/document/d/1d8Pw6ZbWk-_pCKdOmdvx9rnhPiyuxwq60_TrD68d7BA/edit#heading=h.trs9rsex3xom)*.
|
|
5
|
+
|
|
6
|
+
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
|
|
7
|
+
|
|
8
|
+
- Each pull request should address only one issue, not mix up code from multiple issues.
|
|
9
|
+
|
|
10
|
+
- Each commit in the pull request has a meaningful commit message
|
|
11
|
+
|
|
12
|
+
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
<!-- Either this PR fixes an issue, -->
|
|
16
|
+
|
|
17
|
+
Fixes #<xyz>
|
|
18
|
+
|
|
19
|
+
<!-- or this PR is one task of an issue -->
|
|
20
|
+
|
|
21
|
+
Master Issue: #<xyz>
|
|
22
|
+
|
|
23
|
+
### Motivation
|
|
24
|
+
|
|
25
|
+
<!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
|
|
26
|
+
|
|
27
|
+
### Modifications
|
|
28
|
+
|
|
29
|
+
<!-- Describe the modifications you've done. -->
|
|
30
|
+
|
|
31
|
+
### Verifying this change
|
|
32
|
+
|
|
33
|
+
- [ ] Make sure that the change passes the CI checks.
|
|
34
|
+
|
|
35
|
+
*(Please pick either of the following options)*
|
|
36
|
+
|
|
37
|
+
This change is a trivial rework / code cleanup without any test coverage.
|
|
38
|
+
|
|
39
|
+
*(or)*
|
|
40
|
+
|
|
41
|
+
This change is already covered by existing tests, such as *(please describe tests)*.
|
|
42
|
+
|
|
43
|
+
*(or)*
|
|
44
|
+
|
|
45
|
+
This change added tests and can be verified as follows:
|
|
46
|
+
|
|
47
|
+
*(example:)*
|
|
48
|
+
- *Added integration tests for end-to-end deployment with large payloads (10MB)*
|
|
49
|
+
- *Extended integration test for recovery after broker failure*
|
|
50
|
+
|
|
51
|
+
### Documentation
|
|
52
|
+
|
|
53
|
+
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
|
|
54
|
+
|
|
55
|
+
- [ ] `doc-required`
|
|
56
|
+
(Your PR needs to update docs and you will update later)
|
|
57
|
+
|
|
58
|
+
- [ ] `doc-not-needed`
|
|
59
|
+
(Please explain why)
|
|
60
|
+
|
|
61
|
+
- [ ] `doc`
|
|
62
|
+
(Your PR contains doc changes)
|
|
63
|
+
|
|
64
|
+
- [ ] `doc-complete`
|
|
65
|
+
(Docs have been already added)
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
name: Build release napi
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- '*'
|
|
7
|
+
env:
|
|
8
|
+
FORCE_COLOR: 1
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.head_ref || github.run_id }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
jobs:
|
|
13
|
+
macos-napi:
|
|
14
|
+
name: Build NAPI macos - Node ${{matrix.nodejs}} - ${{matrix.arch}}
|
|
15
|
+
runs-on: macos-latest
|
|
16
|
+
timeout-minutes: 3000
|
|
17
|
+
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
arch:
|
|
22
|
+
- x64
|
|
23
|
+
- arm64
|
|
24
|
+
nodejs:
|
|
25
|
+
- 18
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v3
|
|
28
|
+
- name: Use Node.js ${{ matrix.nodejs }}
|
|
29
|
+
uses: actions/setup-node@v3
|
|
30
|
+
with:
|
|
31
|
+
node-version: ${{ matrix.nodejs }}
|
|
32
|
+
cache: 'npm'
|
|
33
|
+
|
|
34
|
+
- name: Cache Dependencies
|
|
35
|
+
id: cache-dependencies
|
|
36
|
+
uses: actions/cache@v3
|
|
37
|
+
with:
|
|
38
|
+
path: pkg/mac/build
|
|
39
|
+
key: ${{ runner.os }}-${{ matrix.arch }}-mac-${{ hashFiles('pkg/mac/build-cpp-deps-lib.sh') }}
|
|
40
|
+
|
|
41
|
+
- name: Add arch env vars
|
|
42
|
+
run: |
|
|
43
|
+
if [ "${{ matrix.arch }}" = "x64" ]; then
|
|
44
|
+
echo "ARCH=x86_64" >> $GITHUB_ENV
|
|
45
|
+
else
|
|
46
|
+
echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
- name: Build CPP dependencies lib
|
|
50
|
+
if: steps.cache-dependencies.outputs.cache-hit != 'true'
|
|
51
|
+
run: |
|
|
52
|
+
export ARCH=${{ env.ARCH }}
|
|
53
|
+
pkg/mac/build-cpp-deps-lib.sh
|
|
54
|
+
|
|
55
|
+
- name: Build CPP lib
|
|
56
|
+
if: steps.cache-pulsar.outputs.cache-hit != 'true'
|
|
57
|
+
run: |
|
|
58
|
+
export ARCH=${{ env.ARCH }}
|
|
59
|
+
pkg/mac/build-cpp-lib.sh
|
|
60
|
+
|
|
61
|
+
- name: Build Node binaries lib
|
|
62
|
+
run: |
|
|
63
|
+
npm install --ignore-scripts
|
|
64
|
+
npx node-pre-gyp configure --target_arch=${{ matrix.arch }}
|
|
65
|
+
npx node-pre-gyp build --target_arch=${{ matrix.arch }}
|
|
66
|
+
|
|
67
|
+
- name: Test loading Node binaries lib
|
|
68
|
+
if: matrix.arch == 'x64'
|
|
69
|
+
run: |
|
|
70
|
+
node pkg/load_test.js
|
|
71
|
+
|
|
72
|
+
- name: Package Node binaries lib
|
|
73
|
+
run: |
|
|
74
|
+
npx node-pre-gyp package --target_arch=${{ matrix.arch }}
|
|
75
|
+
|
|
76
|
+
- name: Upload artifacts
|
|
77
|
+
uses: actions/upload-artifact@v3
|
|
78
|
+
with:
|
|
79
|
+
name: macos-${{matrix.nodejs}}-${{matrix.arch}}
|
|
80
|
+
path: build/stage/*/*.tar.gz
|
|
81
|
+
|
|
82
|
+
linux-napi:
|
|
83
|
+
name: Build NAPI ${{matrix.image}} - Node ${{matrix.nodejs}} - ${{matrix.cpu.platform}}
|
|
84
|
+
runs-on: ubuntu-22.04
|
|
85
|
+
timeout-minutes: 3000
|
|
86
|
+
|
|
87
|
+
strategy:
|
|
88
|
+
fail-fast: false
|
|
89
|
+
matrix:
|
|
90
|
+
image:
|
|
91
|
+
- 'linux_glibc'
|
|
92
|
+
- 'linux_musl'
|
|
93
|
+
nodejs:
|
|
94
|
+
- 18
|
|
95
|
+
cpu:
|
|
96
|
+
- {arch: 'x86_64', platform: 'x86_64'}
|
|
97
|
+
- {arch: 'aarch64', platform: 'arm64'}
|
|
98
|
+
|
|
99
|
+
steps:
|
|
100
|
+
- name: checkout
|
|
101
|
+
uses: actions/checkout@v3
|
|
102
|
+
|
|
103
|
+
- name: Set up QEMU
|
|
104
|
+
uses: docker/setup-qemu-action@v2
|
|
105
|
+
|
|
106
|
+
- name: Setup Docker Buildx
|
|
107
|
+
uses: docker/setup-buildx-action@v2
|
|
108
|
+
|
|
109
|
+
- name: Build Linux Docker image
|
|
110
|
+
uses: docker/build-push-action@v3
|
|
111
|
+
with:
|
|
112
|
+
context: ./pkg/${{matrix.image}}
|
|
113
|
+
load: true
|
|
114
|
+
tags: build:latest
|
|
115
|
+
platforms: linux/${{matrix.cpu.arch}}
|
|
116
|
+
build-args: |
|
|
117
|
+
PLATFORM=${{matrix.cpu.platform}}
|
|
118
|
+
ARCH=${{matrix.cpu.arch}}
|
|
119
|
+
NODE_VERSION=${{matrix.nodejs}}
|
|
120
|
+
cache-from: type=gha
|
|
121
|
+
cache-to: type=gha,mode=max
|
|
122
|
+
|
|
123
|
+
- name: Build and Test NAPI file
|
|
124
|
+
run: |
|
|
125
|
+
docker run -i -v $PWD:/pulsar-client-node build:latest \
|
|
126
|
+
/pulsar-client-node/pkg/build-napi-inside-docker.sh
|
|
127
|
+
|
|
128
|
+
- name: Upload artifacts
|
|
129
|
+
uses: actions/upload-artifact@v3
|
|
130
|
+
with:
|
|
131
|
+
name: ${{matrix.image}}-${{matrix.nodejs}}-${{matrix.cpu.platform}}
|
|
132
|
+
path: build/stage/*/*.tar.gz
|
|
133
|
+
|
|
134
|
+
windows-napi:
|
|
135
|
+
name: Build NAPI windows - Node ${{matrix.nodejs}} - ${{matrix.arch}}
|
|
136
|
+
runs-on: windows-2022
|
|
137
|
+
timeout-minutes: 3000
|
|
138
|
+
|
|
139
|
+
strategy:
|
|
140
|
+
fail-fast: false
|
|
141
|
+
matrix:
|
|
142
|
+
arch:
|
|
143
|
+
- x64
|
|
144
|
+
- x86
|
|
145
|
+
nodejs:
|
|
146
|
+
- 18
|
|
147
|
+
steps:
|
|
148
|
+
- uses: actions/checkout@v3
|
|
149
|
+
- name: Use Node.js ${{ matrix.nodejs }}
|
|
150
|
+
uses: actions/setup-node@v3
|
|
151
|
+
with:
|
|
152
|
+
node-version: ${{ matrix.nodejs }}
|
|
153
|
+
architecture: ${{ matrix.arch }}
|
|
154
|
+
cache: 'npm'
|
|
155
|
+
|
|
156
|
+
- name: Cache CPP Client
|
|
157
|
+
id: cache-dependencies
|
|
158
|
+
uses: actions/cache@v3
|
|
159
|
+
with:
|
|
160
|
+
path: pkg/windows/
|
|
161
|
+
key: ${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('pulsar-client-cpp.txt') }}
|
|
162
|
+
|
|
163
|
+
- name: Add env vars
|
|
164
|
+
shell: bash
|
|
165
|
+
run: |
|
|
166
|
+
if [ "${{ matrix.arch }}" = "x86" ]; then
|
|
167
|
+
echo "TARGET=ia32" >> $GITHUB_ENV
|
|
168
|
+
else
|
|
169
|
+
echo "TARGET=${{ matrix.arch }}" >> $GITHUB_ENV
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
- name: Download CPP Client
|
|
173
|
+
if: steps.cache-dependencies.outputs.cache-hit != 'true'
|
|
174
|
+
run: |
|
|
175
|
+
pkg/windows/download-cpp-client.bat ${{ matrix.arch }}
|
|
176
|
+
|
|
177
|
+
- name: Build Node binaries lib
|
|
178
|
+
run: |
|
|
179
|
+
npm install --ignore-scripts
|
|
180
|
+
npx node-pre-gyp configure --target_arch=${{ env.TARGET }}
|
|
181
|
+
npx node-pre-gyp build --target_arch=${{ env.TARGET }}
|
|
182
|
+
|
|
183
|
+
- name: Test loading Node binaries lib
|
|
184
|
+
run: |
|
|
185
|
+
node pkg/load_test.js
|
|
186
|
+
|
|
187
|
+
- name: Package Node binaries lib
|
|
188
|
+
run: |
|
|
189
|
+
npx node-pre-gyp package --target_arch=${{ env.TARGET }}
|
|
190
|
+
|
|
191
|
+
- name: Upload artifacts
|
|
192
|
+
uses: actions/upload-artifact@v3
|
|
193
|
+
with:
|
|
194
|
+
name: windows-${{matrix.nodejs}}-${{matrix.arch}}
|
|
195
|
+
path: build/stage/*/*.tar.gz
|
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
name: PR validation
|
|
20
|
+
on:
|
|
21
|
+
pull_request:
|
|
22
|
+
branches: ['master']
|
|
23
|
+
|
|
24
|
+
concurrency:
|
|
25
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
26
|
+
cancel-in-progress: true
|
|
27
|
+
|
|
28
|
+
jobs:
|
|
29
|
+
unit-tests:
|
|
30
|
+
name: Run unit tests
|
|
31
|
+
runs-on: ubuntu-22.04
|
|
32
|
+
timeout-minutes: 120
|
|
33
|
+
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v3
|
|
36
|
+
- name: Use Node.js 18
|
|
37
|
+
uses: actions/setup-node@v3
|
|
38
|
+
with:
|
|
39
|
+
node-version: 18
|
|
40
|
+
|
|
41
|
+
- name: Run Test
|
|
42
|
+
run: |
|
|
43
|
+
./tests/run-unit-tests.sh
|
|
44
|
+
|
|
45
|
+
validation-yarn:
|
|
46
|
+
name: Validation use yarn install
|
|
47
|
+
runs-on: ubuntu-22.04
|
|
48
|
+
timeout-minutes: 120
|
|
49
|
+
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v3
|
|
52
|
+
- name: Use Node.js 18
|
|
53
|
+
uses: actions/setup-node@v3
|
|
54
|
+
with:
|
|
55
|
+
node-version: 18
|
|
56
|
+
|
|
57
|
+
- name: Use yarn install
|
|
58
|
+
run: |
|
|
59
|
+
yarn install --ignore-scripts
|
|
60
|
+
|
|
61
|
+
macos-napi:
|
|
62
|
+
name: Build NAPI macos - Node ${{matrix.nodejs}} - ${{matrix.arch}}
|
|
63
|
+
runs-on: macos-latest
|
|
64
|
+
timeout-minutes: 3000
|
|
65
|
+
|
|
66
|
+
strategy:
|
|
67
|
+
fail-fast: false
|
|
68
|
+
matrix:
|
|
69
|
+
arch:
|
|
70
|
+
- x64
|
|
71
|
+
- arm64
|
|
72
|
+
nodejs:
|
|
73
|
+
- 18
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v3
|
|
76
|
+
- name: Use Node.js ${{ matrix.nodejs }}
|
|
77
|
+
uses: actions/setup-node@v3
|
|
78
|
+
with:
|
|
79
|
+
node-version: ${{ matrix.nodejs }}
|
|
80
|
+
cache: 'npm'
|
|
81
|
+
|
|
82
|
+
- name: Cache Dependencies
|
|
83
|
+
id: cache-dependencies
|
|
84
|
+
uses: actions/cache@v3
|
|
85
|
+
with:
|
|
86
|
+
path: pkg/mac/build
|
|
87
|
+
key: ${{ runner.os }}-${{ matrix.arch }}-mac-${{ hashFiles('pkg/mac/build-cpp-deps-lib.sh') }}
|
|
88
|
+
|
|
89
|
+
- name: Add arch env vars
|
|
90
|
+
run: |
|
|
91
|
+
if [ "${{ matrix.arch }}" = "x64" ]; then
|
|
92
|
+
echo "ARCH=x86_64" >> $GITHUB_ENV
|
|
93
|
+
else
|
|
94
|
+
echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
|
|
95
|
+
fi
|
|
96
|
+
|
|
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
|
+
- name: Build Node binaries lib
|
|
110
|
+
run: |
|
|
111
|
+
npm install --ignore-scripts
|
|
112
|
+
npx node-pre-gyp configure --target_arch=${{ matrix.arch }}
|
|
113
|
+
npx node-pre-gyp build --target_arch=${{ matrix.arch }}
|
|
114
|
+
|
|
115
|
+
- name: Test loading Node binaries lib
|
|
116
|
+
if: matrix.arch == 'x64'
|
|
117
|
+
run: |
|
|
118
|
+
node pkg/load_test.js
|
|
119
|
+
|
|
120
|
+
- name: Package Node binaries lib
|
|
121
|
+
run: |
|
|
122
|
+
npx node-pre-gyp package --target_arch=${{ matrix.arch }}
|
|
123
|
+
|
|
124
|
+
linux-napi:
|
|
125
|
+
name: Build NAPI ${{matrix.image}} - Node ${{matrix.nodejs}} - ${{matrix.cpu.platform}}
|
|
126
|
+
runs-on: ubuntu-22.04
|
|
127
|
+
timeout-minutes: 3000
|
|
128
|
+
|
|
129
|
+
strategy:
|
|
130
|
+
fail-fast: false
|
|
131
|
+
matrix:
|
|
132
|
+
image:
|
|
133
|
+
- 'linux_glibc'
|
|
134
|
+
- 'linux_musl'
|
|
135
|
+
nodejs:
|
|
136
|
+
- 18
|
|
137
|
+
cpu:
|
|
138
|
+
- {arch: 'x86_64', platform: 'x86_64'}
|
|
139
|
+
- {arch: 'aarch64', platform: 'arm64'}
|
|
140
|
+
|
|
141
|
+
steps:
|
|
142
|
+
- name: checkout
|
|
143
|
+
uses: actions/checkout@v3
|
|
144
|
+
|
|
145
|
+
- name: Set up QEMU
|
|
146
|
+
uses: docker/setup-qemu-action@v2
|
|
147
|
+
|
|
148
|
+
- name: Setup Docker Buildx
|
|
149
|
+
uses: docker/setup-buildx-action@v2
|
|
150
|
+
|
|
151
|
+
- name: Build Linux Docker image
|
|
152
|
+
uses: docker/build-push-action@v3
|
|
153
|
+
with:
|
|
154
|
+
context: ./pkg/${{matrix.image}}
|
|
155
|
+
load: true
|
|
156
|
+
tags: build:latest
|
|
157
|
+
platforms: linux/${{matrix.cpu.arch}}
|
|
158
|
+
build-args: |
|
|
159
|
+
PLATFORM=${{matrix.cpu.platform}}
|
|
160
|
+
ARCH=${{matrix.cpu.arch}}
|
|
161
|
+
NODE_VERSION=${{matrix.nodejs}}
|
|
162
|
+
cache-from: type=gha
|
|
163
|
+
cache-to: type=gha,mode=max
|
|
164
|
+
|
|
165
|
+
- name: Build and Test NAPI file
|
|
166
|
+
run: |
|
|
167
|
+
docker run -i -v $PWD:/pulsar-client-node build:latest \
|
|
168
|
+
/pulsar-client-node/pkg/build-napi-inside-docker.sh
|
|
169
|
+
|
|
170
|
+
windows-napi:
|
|
171
|
+
name: Build NAPI windows - Node ${{matrix.nodejs}} - ${{matrix.arch}}
|
|
172
|
+
runs-on: windows-2022
|
|
173
|
+
timeout-minutes: 3000
|
|
174
|
+
|
|
175
|
+
strategy:
|
|
176
|
+
fail-fast: false
|
|
177
|
+
matrix:
|
|
178
|
+
arch:
|
|
179
|
+
- x64
|
|
180
|
+
- x86
|
|
181
|
+
nodejs:
|
|
182
|
+
- 18
|
|
183
|
+
steps:
|
|
184
|
+
- uses: actions/checkout@v3
|
|
185
|
+
- name: Use Node.js ${{ matrix.nodejs }}
|
|
186
|
+
uses: actions/setup-node@v3
|
|
187
|
+
with:
|
|
188
|
+
node-version: ${{ matrix.nodejs }}
|
|
189
|
+
architecture: ${{ matrix.arch }}
|
|
190
|
+
cache: 'npm'
|
|
191
|
+
|
|
192
|
+
- name: Cache CPP Client
|
|
193
|
+
id: cache-dependencies
|
|
194
|
+
uses: actions/cache@v3
|
|
195
|
+
with:
|
|
196
|
+
path: pkg/windows/
|
|
197
|
+
key: ${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('pulsar-client-cpp.txt') }}
|
|
198
|
+
|
|
199
|
+
- name: Add env vars
|
|
200
|
+
shell: bash
|
|
201
|
+
run: |
|
|
202
|
+
if [ "${{ matrix.arch }}" = "x86" ]; then
|
|
203
|
+
echo "TARGET=ia32" >> $GITHUB_ENV
|
|
204
|
+
else
|
|
205
|
+
echo "TARGET=${{ matrix.arch }}" >> $GITHUB_ENV
|
|
206
|
+
fi
|
|
207
|
+
|
|
208
|
+
- name: Download CPP Client
|
|
209
|
+
if: steps.cache-dependencies.outputs.cache-hit != 'true'
|
|
210
|
+
run: |
|
|
211
|
+
pkg/windows/download-cpp-client.bat ${{ matrix.arch }}
|
|
212
|
+
|
|
213
|
+
- name: Build Node binaries lib
|
|
214
|
+
run: |
|
|
215
|
+
npm install --ignore-scripts
|
|
216
|
+
npx node-pre-gyp configure --target_arch=${{ env.TARGET }}
|
|
217
|
+
npx node-pre-gyp build --target_arch=${{ env.TARGET }}
|
|
218
|
+
|
|
219
|
+
- name: Test loading Node binaries lib
|
|
220
|
+
run: |
|
|
221
|
+
node pkg/load_test.js
|
|
222
|
+
|
|
223
|
+
- name: Package Node binaries lib
|
|
224
|
+
run: |
|
|
225
|
+
npx node-pre-gyp package --target_arch=${{ env.TARGET }}
|
package/README.md
CHANGED
|
@@ -23,112 +23,131 @@
|
|
|
23
23
|
|
|
24
24
|
The Pulsar Node.js client can be used to create Pulsar producers and consumers in Node.js.
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Pulsar Node.js client library is based on the C++ client library. Follow the instructions for
|
|
29
|
-
[C++ library](https://pulsar.apache.org/docs/en/client-libraries-cpp/) for installing the binaries through
|
|
30
|
-
[RPM](https://pulsar.apache.org/docs/en/client-libraries-cpp/#rpm),
|
|
31
|
-
[Deb](https://pulsar.apache.org/docs/en/client-libraries-cpp/#deb) or
|
|
32
|
-
[Homebrew packages](https://pulsar.apache.org/docs/en/client-libraries-cpp/#macos).
|
|
33
|
-
|
|
34
|
-
(Note: you will need to install not only the pulsar-client library but also the pulsar-client-dev library)
|
|
35
|
-
|
|
36
|
-
Also, this library works only in Node.js 10.x or later because it uses the
|
|
26
|
+
This library works only in Node.js 10.x or later because it uses the
|
|
37
27
|
[node-addon-api](https://github.com/nodejs/node-addon-api) module to wrap the C++ library.
|
|
38
28
|
|
|
39
|
-
##
|
|
40
|
-
|
|
41
|
-
Compatibility between each version of the Node.js client and the C++ client is as follows:
|
|
29
|
+
## Getting Started
|
|
42
30
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
| 1.3.x | 2.7.0 or later |
|
|
49
|
-
| 1.4.x - 1.5.x | 2.8.0 or later |
|
|
50
|
-
|
|
51
|
-
If an incompatible version of the C++ client is installed, you may fail to build or run this library.
|
|
31
|
+
> **Note**
|
|
32
|
+
>
|
|
33
|
+
> These instructions are only available for versions after 1.8.0. For versions previous to 1.8.0, you need to install the C++ client first. Please switch to the corresponding version branch of this repo to read the specific instructions.
|
|
34
|
+
>
|
|
35
|
+
> To run the examples, skip this section.
|
|
52
36
|
|
|
53
|
-
|
|
37
|
+
To use the Pulsar Node.js client in your project, run:
|
|
54
38
|
|
|
55
|
-
|
|
39
|
+
```shell
|
|
40
|
+
npm install pulsar-client
|
|
41
|
+
```
|
|
56
42
|
|
|
57
|
-
|
|
43
|
+
or
|
|
58
44
|
|
|
59
45
|
```shell
|
|
60
|
-
|
|
61
|
-
-A x64 \
|
|
62
|
-
-DBUILD_PYTHON_WRAPPER=OFF -DBUILD_TESTS=OFF \
|
|
63
|
-
-DVCPKG_TRIPLET=x64-windows \
|
|
64
|
-
-DCMAKE_BUILD_TYPE=Release \
|
|
65
|
-
-S .
|
|
66
|
-
cmake --config Release
|
|
46
|
+
yarn add pulsar-client
|
|
67
47
|
```
|
|
68
48
|
|
|
49
|
+
Then you can run the following simple end-to-end example:
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const Pulsar = require('pulsar-client');
|
|
53
|
+
|
|
54
|
+
(async () => {
|
|
55
|
+
// Create a client
|
|
56
|
+
const client = new Pulsar.Client({
|
|
57
|
+
serviceUrl: 'pulsar://localhost:6650'
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Create a producer
|
|
61
|
+
const producer = await client.createProducer({
|
|
62
|
+
topic: 'persistent://public/default/my-topic',
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Create a consumer
|
|
66
|
+
const consumer = await client.subscribe({
|
|
67
|
+
topic: 'persistent://public/default/my-topic',
|
|
68
|
+
subscription: 'sub1'
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Send a message
|
|
72
|
+
producer.send({
|
|
73
|
+
data: Buffer.from("hello")
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Receive the message
|
|
77
|
+
const msg = await consumer.receive();
|
|
78
|
+
console.log(msg.getData().toString());
|
|
79
|
+
consumer.acknowledge(msg);
|
|
80
|
+
|
|
81
|
+
await producer.close();
|
|
82
|
+
await consumer.close();
|
|
83
|
+
await client.close();
|
|
84
|
+
})();
|
|
85
|
+
```
|
|
69
86
|
|
|
70
|
-
|
|
87
|
+
You should find the output as:
|
|
71
88
|
|
|
72
|
-
```shell
|
|
73
|
-
# for example
|
|
74
|
-
set PULSAR_CPP_DIR=C:\pulsar\pulsar-client-cpp
|
|
75
89
|
```
|
|
90
|
+
hello
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
You can see more examples in the [examples](./examples) directory. However, since these examples might use an API that was not released yet, you need to build this module. See the next section.
|
|
76
94
|
|
|
77
|
-
|
|
95
|
+
## How to build
|
|
96
|
+
|
|
97
|
+
First, clone the repository.
|
|
78
98
|
|
|
79
99
|
```shell
|
|
80
|
-
|
|
100
|
+
git clone https://github.com/apache/pulsar-client-node.git
|
|
101
|
+
cd pulsar-client-node
|
|
81
102
|
```
|
|
82
103
|
|
|
83
|
-
|
|
104
|
+
Since this client is a [C++ addon](https://nodejs.org/api/addons.html#c-addons) that depends on the [Pulsar C++ client](https://github.com/apache/pulsar-client-cpp), you need to install the C++ client first. You need to ensure there is a C++ compiler that supports C++11 installed in your system.
|
|
84
105
|
|
|
85
|
-
|
|
106
|
+
- Install C++ client on Linux:
|
|
86
107
|
|
|
87
108
|
```shell
|
|
88
|
-
|
|
109
|
+
build-support/install-cpp-client.sh
|
|
89
110
|
```
|
|
90
111
|
|
|
91
|
-
|
|
112
|
+
- Install C++ client on Windows:
|
|
92
113
|
|
|
93
114
|
```shell
|
|
94
|
-
|
|
115
|
+
pkg\windows\download-cpp-client.bat
|
|
95
116
|
```
|
|
96
117
|
|
|
97
|
-
|
|
98
|
-
2. Set the variable `PULSAR_CPP_DIR` with the `pulsar-client-cpp` path in a mac command tool.
|
|
118
|
+
- Install C++ client on macOS:
|
|
99
119
|
|
|
100
120
|
```shell
|
|
101
|
-
|
|
102
|
-
|
|
121
|
+
pkg/mac/build-cpp-deps-lib.sh
|
|
122
|
+
pkg/mac/build-cpp-lib.sh
|
|
103
123
|
```
|
|
104
124
|
|
|
105
|
-
|
|
106
|
-
### Install pulsar-client to your project
|
|
125
|
+
After the C++ client is installed, run the following command to build this C++ addon.
|
|
107
126
|
|
|
108
127
|
```shell
|
|
109
|
-
|
|
128
|
+
npm install
|
|
110
129
|
```
|
|
111
130
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
Please refer to [examples](https://github.com/apache/pulsar-client-node/tree/master/examples).
|
|
115
|
-
|
|
116
|
-
## How to build
|
|
117
|
-
|
|
118
|
-
### Install dependent npm modules and build Pulsar client library:
|
|
131
|
+
To verify it has been installed successfully, you can run an example like:
|
|
119
132
|
|
|
120
133
|
```shell
|
|
121
|
-
|
|
122
|
-
$ cd pulsar-client-node
|
|
123
|
-
$ npm install
|
|
134
|
+
node examples/producer
|
|
124
135
|
```
|
|
125
136
|
|
|
126
|
-
|
|
127
|
-
>
|
|
128
|
-
> 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.
|
|
129
|
-
|
|
130
|
-
### Rebuild Pulsar client library:
|
|
137
|
+
You should find the output as:
|
|
131
138
|
|
|
132
|
-
```shell
|
|
133
|
-
$ npm run build
|
|
134
139
|
```
|
|
140
|
+
Sent message: my-message-0
|
|
141
|
+
Sent message: my-message-1
|
|
142
|
+
Sent message: my-message-2
|
|
143
|
+
Sent message: my-message-3
|
|
144
|
+
Sent message: my-message-4
|
|
145
|
+
Sent message: my-message-5
|
|
146
|
+
Sent message: my-message-6
|
|
147
|
+
Sent message: my-message-7
|
|
148
|
+
Sent message: my-message-8
|
|
149
|
+
Sent message: my-message-9
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Documentation
|
|
153
|
+
* Please see https://pulsar.apache.org/docs/client-libraries-node/ for more details about the Pulsar Node.js client.
|