pulsar-client 1.13.2-rc.1 → 1.14.0-rc.1
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/.idea/aws.xml +18 -0
- package/.idea/codeStyles/Project.xml +7 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +7 -0
- package/.idea/modules.xml +9 -0
- package/.idea/pulsar-client-node.iml +46 -0
- package/.idea/pulsar_client_node.iml +8 -0
- package/.idea/vcs.xml +6 -0
- package/index.d.ts +17 -0
- package/package.json +1 -1
- package/src/Client.cc +2 -1
- package/src/Client.h +1 -0
- package/src/ConsumerConfig.cc +66 -0
- package/src/cert.pem +3278 -0
- package/.clang-format +0 -26
- package/.eslintignore +0 -21
- package/.eslintrc.json +0 -22
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -85
- package/.github/workflows/ci-build-release-napi.yml +0 -211
- package/.github/workflows/ci-pr-validation.yml +0 -334
- package/build-support/download-release-artifacts.py +0 -77
- package/build-support/generate-source-archive.sh +0 -28
- package/build-support/pulsar-test-container-start.sh +0 -43
- package/build-support/pulsar-test-service-start.sh +0 -39
- package/build-support/pulsar-test-service-stop.sh +0 -32
- package/build-support/sign-files.sh +0 -32
- package/build-support/stage-release.sh +0 -44
- package/docs/release-process.md +0 -291
- package/examples/certificate/private-key.client-rsa.pem +0 -27
- package/examples/certificate/public-key.client-rsa.pem +0 -9
- package/examples/consumer-schema.js +0 -66
- package/examples/consumer.js +0 -46
- package/examples/consumer_listener.js +0 -44
- package/examples/consumer_tls_auth.js +0 -51
- package/examples/consummer_token_auth.js +0 -50
- package/examples/consummer_token_auth_supplier.js +0 -56
- package/examples/custom_logger.js +0 -60
- package/examples/encryption-consumer.js +0 -47
- package/examples/encryption-producer.js +0 -50
- package/examples/encryption-reader.js +0 -44
- package/examples/producer-schema.js +0 -76
- package/examples/producer.js +0 -48
- package/examples/producer_tls_auth.js +0 -52
- package/examples/producer_token_auth.js +0 -48
- package/examples/producer_token_auth_supplier.js +0 -53
- package/examples/reader.js +0 -43
- package/examples/reader_listener.js +0 -37
- package/license-checker-config.json +0 -43
- package/license-header.txt +0 -16
- package/perf/perf_consumer.js +0 -103
- package/perf/perf_producer.js +0 -118
- package/pkg/linux/Dockerfile_linux_glibc +0 -31
- package/pkg/linux/Dockerfile_linux_musl +0 -32
- package/pkg/linux/build-napi-inside-docker.sh +0 -31
- package/pkg/linux/download-cpp-client.sh +0 -65
- package/pkg/load_test.js +0 -34
- package/pkg/mac/download-cpp-client.sh +0 -36
- package/pkg/windows/download-cpp-client.bat +0 -12
- package/tests/certificate/private-key.client-rsa.pem +0 -27
- package/tests/certificate/public-key.client-rsa.pem +0 -9
- package/tests/certificate/server.crt +0 -20
- package/tests/certificate/server.key +0 -28
- package/tests/client.test.js +0 -122
- package/tests/conf/standalone.conf +0 -308
- package/tests/consumer.test.js +0 -434
- package/tests/docker-load-test.sh +0 -35
- package/tests/end_to_end.test.js +0 -1447
- package/tests/http_utils.js +0 -45
- package/tests/load-test.sh +0 -43
- package/tests/producer.test.js +0 -160
- package/tests/reader.test.js +0 -175
- package/tests/run-unit-tests.sh +0 -35
- package/tsconfig.json +0 -22
- package/tslint.json +0 -9
- package/tstest.ts +0 -408
- package/typedoc.json +0 -15
|
@@ -1,52 +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
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
const auth = new Pulsar.AuthenticationTls({
|
|
24
|
-
certificatePath: '/path/to/client.crt',
|
|
25
|
-
privateKeyPath: '/path/to/client.key',
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Create a client
|
|
29
|
-
const client = new Pulsar.Client({
|
|
30
|
-
serviceUrl: 'pulsar+ssl://localhost:6651',
|
|
31
|
-
authentication: auth,
|
|
32
|
-
tlsTrustCertsFilePath: '/path/to/server.crt',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Create a producer
|
|
36
|
-
const producer = await client.createProducer({
|
|
37
|
-
topic: 'persistent://public/default/my-topic',
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Send messages
|
|
41
|
-
for (let i = 0; i < 10; i += 1) {
|
|
42
|
-
const msg = `my-message-${i}`;
|
|
43
|
-
producer.send({
|
|
44
|
-
data: Buffer.from(msg),
|
|
45
|
-
});
|
|
46
|
-
console.log(`Sent message: ${msg}`);
|
|
47
|
-
}
|
|
48
|
-
await producer.flush();
|
|
49
|
-
|
|
50
|
-
await producer.close();
|
|
51
|
-
await client.close();
|
|
52
|
-
})();
|
|
@@ -1,48 +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
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
const auth = new Pulsar.AuthenticationToken({token: "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY"});
|
|
24
|
-
|
|
25
|
-
// Create a client
|
|
26
|
-
const client = new Pulsar.Client({
|
|
27
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
28
|
-
authentication: auth,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Create a producer
|
|
32
|
-
const producer = await client.createProducer({
|
|
33
|
-
topic: 'persistent://public/default/my-topic',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Send messages
|
|
37
|
-
for (let i = 0; i < 10; i += 1) {
|
|
38
|
-
const msg = `my-message-${i}`;
|
|
39
|
-
producer.send({
|
|
40
|
-
data: Buffer.from(msg),
|
|
41
|
-
});
|
|
42
|
-
console.log(`Sent message: ${msg}`);
|
|
43
|
-
}
|
|
44
|
-
await producer.flush();
|
|
45
|
-
|
|
46
|
-
await producer.close();
|
|
47
|
-
await client.close();
|
|
48
|
-
})();
|
|
@@ -1,53 +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
|
-
const Pulsar = require('..');
|
|
21
|
-
|
|
22
|
-
async function getToken() {
|
|
23
|
-
console.log("Get token");
|
|
24
|
-
return "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
(async () => {
|
|
28
|
-
const auth = new Pulsar.AuthenticationToken({token: getToken});
|
|
29
|
-
|
|
30
|
-
// Create a client
|
|
31
|
-
const client = new Pulsar.Client({
|
|
32
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
33
|
-
authentication: auth,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Create a producer
|
|
37
|
-
const producer = await client.createProducer({
|
|
38
|
-
topic: 'persistent://public/default/my-topic',
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Send messages
|
|
42
|
-
for (let i = 0; i < 10; i += 1) {
|
|
43
|
-
const msg = `my-message-${i}`;
|
|
44
|
-
producer.send({
|
|
45
|
-
data: Buffer.from(msg),
|
|
46
|
-
});
|
|
47
|
-
console.log(`Sent message: ${msg}`);
|
|
48
|
-
}
|
|
49
|
-
await producer.flush();
|
|
50
|
-
|
|
51
|
-
await producer.close();
|
|
52
|
-
await client.close();
|
|
53
|
-
})();
|
package/examples/reader.js
DELETED
|
@@ -1,43 +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
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create a reader
|
|
30
|
-
const reader = await client.createReader({
|
|
31
|
-
topic: 'persistent://public/default/my-topic',
|
|
32
|
-
startMessageId: Pulsar.MessageId.earliest(),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// read messages
|
|
36
|
-
for (let i = 0; i < 10; i += 1) {
|
|
37
|
-
const msg = await reader.readNext();
|
|
38
|
-
console.log(msg.getData().toString());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
await reader.close();
|
|
42
|
-
await client.close();
|
|
43
|
-
})();
|
|
@@ -1,37 +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
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create a reader
|
|
30
|
-
const reader = await client.createReader({
|
|
31
|
-
topic: 'persistent://public/default/my-topic',
|
|
32
|
-
startMessageId: Pulsar.MessageId.latest(),
|
|
33
|
-
listener: (msg, reader) => {
|
|
34
|
-
console.log(msg.getData().toString());
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
})();
|
|
@@ -1,43 +0,0 @@
|
|
|
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/license-header.txt
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
or more contributor license agreements. See the NOTICE file
|
|
3
|
-
distributed with this work for additional information
|
|
4
|
-
regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
to you under the Apache License, Version 2.0 (the
|
|
6
|
-
"License"); you may not use this file except in compliance
|
|
7
|
-
with the License. You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing,
|
|
12
|
-
software distributed under the License is distributed on an
|
|
13
|
-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
KIND, either express or implied. See the License for the
|
|
15
|
-
specific language governing permissions and limitations
|
|
16
|
-
under the License.
|
package/perf/perf_consumer.js
DELETED
|
@@ -1,103 +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
|
-
const commander = require('commander');
|
|
21
|
-
const delay = require('delay');
|
|
22
|
-
const {
|
|
23
|
-
performance,
|
|
24
|
-
} = require('perf_hooks');
|
|
25
|
-
const Pulsar = require('../index.js');
|
|
26
|
-
|
|
27
|
-
// Parse args
|
|
28
|
-
(() => {
|
|
29
|
-
commander
|
|
30
|
-
.option('-s, --subscription [subscription]', 'Subscription')
|
|
31
|
-
.option('-u, --url [url]', 'Pulsar Service URL')
|
|
32
|
-
.option('-t, --topic [topic]', 'Topic Name')
|
|
33
|
-
.option('-m, --messages [messages]', 'Number of Messages', 1000)
|
|
34
|
-
.option('-i, --iteration [iteration]', 'Iteration of Measure', 3, parseInt)
|
|
35
|
-
.on('--help', () => {
|
|
36
|
-
console.log('');
|
|
37
|
-
console.log('Examples:');
|
|
38
|
-
console.log(' $ node perf/perf_consumer.js --subscription sub1 --url pulsar://localhost:6650 --topic persistent://public/default/my-topic');
|
|
39
|
-
})
|
|
40
|
-
.parse(process.argv);
|
|
41
|
-
|
|
42
|
-
if (typeof commander.subscription === 'undefined') {
|
|
43
|
-
console.error('no subscription given!');
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
if (typeof commander.url === 'undefined') {
|
|
47
|
-
console.error('no URL given!');
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
if (typeof commander.topic === 'undefined') {
|
|
51
|
-
console.error('no topic name given!');
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
console.log('----------------------');
|
|
56
|
-
commander.options.forEach((option) => {
|
|
57
|
-
const optionName = (option.long).replace('--', '');
|
|
58
|
-
console.log(`${optionName}: ${commander[optionName]}`);
|
|
59
|
-
});
|
|
60
|
-
console.log('----------------------');
|
|
61
|
-
})();
|
|
62
|
-
|
|
63
|
-
(async () => {
|
|
64
|
-
// Create a client
|
|
65
|
-
const clientConfig = {
|
|
66
|
-
serviceUrl: commander.url,
|
|
67
|
-
};
|
|
68
|
-
const client = new Pulsar.Client(clientConfig);
|
|
69
|
-
|
|
70
|
-
// Create a consumer
|
|
71
|
-
const consumerConfig = {
|
|
72
|
-
topic: commander.topic,
|
|
73
|
-
subscription: commander.subscription,
|
|
74
|
-
};
|
|
75
|
-
const consumer = await client.subscribe(consumerConfig);
|
|
76
|
-
|
|
77
|
-
const numOfMessages = parseInt(commander.messages, 10);
|
|
78
|
-
for (let i = 0; i < commander.iteration; i += 1) {
|
|
79
|
-
// measure
|
|
80
|
-
await delay(1000);
|
|
81
|
-
const startTimeMilliSeconds = performance.now();
|
|
82
|
-
const results = [];
|
|
83
|
-
for (let mi = 0; mi < numOfMessages; mi += 1) {
|
|
84
|
-
results.push(new Promise((resolve) => {
|
|
85
|
-
consumer.receive().then((msg) => {
|
|
86
|
-
consumer.acknowledge(msg);
|
|
87
|
-
resolve(msg.getData().length);
|
|
88
|
-
});
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
const messageSizes = await Promise.all(results);
|
|
92
|
-
const endTimeMilliSeconds = performance.now();
|
|
93
|
-
|
|
94
|
-
// result
|
|
95
|
-
const durationSeconds = (endTimeMilliSeconds - startTimeMilliSeconds) / 1000.0;
|
|
96
|
-
const rate = numOfMessages / durationSeconds;
|
|
97
|
-
const totalMessageSize = messageSizes.reduce((a, b) => a + b);
|
|
98
|
-
const throuhputMbit = (totalMessageSize / 1024 / 1024 * 8) / durationSeconds;
|
|
99
|
-
console.log('Throughput received: %f msg/s --- %f Mbit/s', rate.toFixed(3), throuhputMbit.toFixed(3));
|
|
100
|
-
}
|
|
101
|
-
await consumer.close();
|
|
102
|
-
await client.close();
|
|
103
|
-
})();
|
package/perf/perf_producer.js
DELETED
|
@@ -1,118 +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
|
-
const commander = require('commander');
|
|
21
|
-
const delay = require('delay');
|
|
22
|
-
const hdr = require('hdr-histogram-js');
|
|
23
|
-
const {
|
|
24
|
-
performance,
|
|
25
|
-
} = require('perf_hooks');
|
|
26
|
-
|
|
27
|
-
const Pulsar = require('../index.js');
|
|
28
|
-
|
|
29
|
-
// Parse args
|
|
30
|
-
(() => {
|
|
31
|
-
commander
|
|
32
|
-
.option('-s, --size [size]', 'Message Size', 1024, parseInt)
|
|
33
|
-
.option('-u, --url [url]', 'Pulsar Service URL')
|
|
34
|
-
.option('-t, --topic [topic]', 'Topic Name')
|
|
35
|
-
.option('-i, --iteration [iteration]', 'Iteration of Measure', 3, parseInt)
|
|
36
|
-
.option('-m, --messages [messages]', 'Number of Messages', 1000, parseInt)
|
|
37
|
-
.on('--help', () => {
|
|
38
|
-
console.log('');
|
|
39
|
-
console.log('Examples:');
|
|
40
|
-
console.log(' $ node perf/perf_producer.js --url pulsar://localhost:6650 --topic persistent://public/default/my-topic');
|
|
41
|
-
})
|
|
42
|
-
.parse(process.argv);
|
|
43
|
-
|
|
44
|
-
if (typeof commander.url === 'undefined') {
|
|
45
|
-
console.error('no URL given!');
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
if (typeof commander.topic === 'undefined') {
|
|
49
|
-
console.error('no topic name given!');
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
console.log('----------------------');
|
|
54
|
-
commander.options.forEach((option) => {
|
|
55
|
-
const optionName = (option.long).replace('--', '');
|
|
56
|
-
console.log(`${optionName}: ${commander[optionName]}`);
|
|
57
|
-
});
|
|
58
|
-
console.log('----------------------');
|
|
59
|
-
})();
|
|
60
|
-
|
|
61
|
-
// Produce
|
|
62
|
-
(async () => {
|
|
63
|
-
// Create a client
|
|
64
|
-
const clientConfig = {
|
|
65
|
-
serviceUrl: commander.url,
|
|
66
|
-
};
|
|
67
|
-
const client = new Pulsar.Client(clientConfig);
|
|
68
|
-
|
|
69
|
-
// Create a producer
|
|
70
|
-
const producerConfig = {
|
|
71
|
-
topic: commander.topic,
|
|
72
|
-
};
|
|
73
|
-
const producer = await client.createProducer(producerConfig);
|
|
74
|
-
|
|
75
|
-
const sizeOfMessage = commander.size;
|
|
76
|
-
const message = Buffer.alloc(sizeOfMessage, 1);
|
|
77
|
-
const numOfMessages = commander.messages;
|
|
78
|
-
for (let i = 0; i < commander.iteration; i += 1) {
|
|
79
|
-
const histogram = hdr.build({
|
|
80
|
-
bitBucketSize: 64,
|
|
81
|
-
highestTrackableValue: 120000 * 1000,
|
|
82
|
-
numberOfSignificantValueDigits: 5,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// measure
|
|
86
|
-
await delay(1000);
|
|
87
|
-
const startMeasureTimeMilliSeconds = performance.now();
|
|
88
|
-
for (let mi = 0; mi < numOfMessages; mi += 1) {
|
|
89
|
-
const startSendTimeMilliSeconds = performance.now();
|
|
90
|
-
producer.send({
|
|
91
|
-
data: message,
|
|
92
|
-
}).then(() => {
|
|
93
|
-
// add latency
|
|
94
|
-
histogram.recordValue((performance.now() - startSendTimeMilliSeconds));
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
await producer.flush();
|
|
98
|
-
const endMeasureTimeMilliSeconds = performance.now();
|
|
99
|
-
|
|
100
|
-
// result
|
|
101
|
-
const elapsedSeconds = (endMeasureTimeMilliSeconds - startMeasureTimeMilliSeconds) / 1000;
|
|
102
|
-
const rate = numOfMessages / elapsedSeconds;
|
|
103
|
-
const throuhputMbit = (sizeOfMessage * numOfMessages / 1024 / 1024 * 8) / elapsedSeconds;
|
|
104
|
-
console.log('Throughput produced: %f msg/s --- %f Mbit/s --- Latency: mean: %f ms - med: %f - 95pct: %f - 99pct: %f - 99.9pct: %f - 99.99pct: %f - Max: %f',
|
|
105
|
-
rate.toFixed(3),
|
|
106
|
-
throuhputMbit.toFixed(3),
|
|
107
|
-
histogram.mean,
|
|
108
|
-
histogram.getValueAtPercentile(50),
|
|
109
|
-
histogram.getValueAtPercentile(95),
|
|
110
|
-
histogram.getValueAtPercentile(99),
|
|
111
|
-
histogram.getValueAtPercentile(99.9),
|
|
112
|
-
histogram.getValueAtPercentile(99.99),
|
|
113
|
-
histogram.maxValue);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
await producer.close();
|
|
117
|
-
await client.close();
|
|
118
|
-
})();
|
|
@@ -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
|
-
ARG NODE_VERSION
|
|
21
|
-
|
|
22
|
-
FROM node:${NODE_VERSION}-buster
|
|
23
|
-
|
|
24
|
-
RUN apt-get update -y && \
|
|
25
|
-
apt-get install -y \
|
|
26
|
-
curl \
|
|
27
|
-
g++ \
|
|
28
|
-
make \
|
|
29
|
-
python3
|
|
30
|
-
|
|
31
|
-
CMD ["sh"]
|
|
@@ -1,32 +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
|
-
ARG NODE_VERSION
|
|
21
|
-
|
|
22
|
-
FROM node:${NODE_VERSION}-alpine3.15
|
|
23
|
-
|
|
24
|
-
RUN apk add \
|
|
25
|
-
bash \
|
|
26
|
-
curl \
|
|
27
|
-
python3 \
|
|
28
|
-
make \
|
|
29
|
-
g++ \
|
|
30
|
-
sudo
|
|
31
|
-
|
|
32
|
-
CMD ["sh"]
|
|
@@ -1,31 +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
|
-
set -e -x
|
|
22
|
-
|
|
23
|
-
cd /pulsar-client-node
|
|
24
|
-
|
|
25
|
-
pkg/linux/download-cpp-client.sh
|
|
26
|
-
|
|
27
|
-
npm install --ignore-scripts
|
|
28
|
-
npx node-pre-gyp configure
|
|
29
|
-
npx node-pre-gyp build
|
|
30
|
-
npx node-pre-gyp package
|
|
31
|
-
node pkg/load_test.js
|
|
@@ -1,65 +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
|
-
set -e -x
|
|
22
|
-
|
|
23
|
-
ROOT_DIR=`cd $(dirname $0) && cd ../../ && pwd`
|
|
24
|
-
source $ROOT_DIR/pulsar-client-cpp.txt
|
|
25
|
-
|
|
26
|
-
if [ "$USER" != "root" -a "$USER" != "" ]; then
|
|
27
|
-
SUDO="sudo"
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
# Get the flavor of Linux
|
|
31
|
-
export $(cat /etc/*-release | grep "^ID=")
|
|
32
|
-
UNAME_ARCH=$(uname -m)
|
|
33
|
-
if [ "$UNAME_ARCH" == 'aarch64' ]; then
|
|
34
|
-
PLATFORM=arm64
|
|
35
|
-
else
|
|
36
|
-
PLATFORM=x86_64
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
|
-
rm -rf $ROOT_DIR/pkg/linux/pulsar-cpp
|
|
40
|
-
mkdir $ROOT_DIR/pkg/linux/pulsar-cpp
|
|
41
|
-
rm -rf $ROOT_DIR/pkg/linux/tmp
|
|
42
|
-
mkdir $ROOT_DIR/pkg/linux/tmp
|
|
43
|
-
cd $ROOT_DIR/pkg/linux/tmp
|
|
44
|
-
|
|
45
|
-
if [ "$ID" == 'ubuntu' -o "$ID" == 'debian' ]; then
|
|
46
|
-
curl -L -O ${CPP_CLIENT_BASE_URL}/deb-${PLATFORM}/apache-pulsar-client-dev.deb
|
|
47
|
-
$SUDO ar x apache-pulsar-client-dev.deb
|
|
48
|
-
$SUDO tar -xvf data.tar.xz
|
|
49
|
-
cp -r usr/* $ROOT_DIR/pkg/linux/pulsar-cpp/
|
|
50
|
-
|
|
51
|
-
elif [ "$ID" == 'alpine' ]; then
|
|
52
|
-
curl -L -O ${CPP_CLIENT_BASE_URL}/apk-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-dev-${CPP_CLIENT_VERSION}-r0.apk
|
|
53
|
-
$SUDO tar -xvf apache-pulsar-client-dev-${CPP_CLIENT_VERSION}-r0.apk
|
|
54
|
-
cp -r usr/* $ROOT_DIR/pkg/linux/pulsar-cpp/
|
|
55
|
-
|
|
56
|
-
elif [ "$ID" == '"centos"' -o "$ID" == '"rocky"' ]; then
|
|
57
|
-
curl -L -O ${CPP_CLIENT_BASE_URL}/rpm-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-devel-${CPP_CLIENT_VERSION}-1.${UNAME_ARCH}.rpm
|
|
58
|
-
$SUDO rpm -i --prefix=$ROOT_DIR/pkg/linux/pulsar-cpp apache-pulsar-client-devel-${CPP_CLIENT_VERSION}-1.${UNAME_ARCH}.rpm --nodeps --force
|
|
59
|
-
|
|
60
|
-
else
|
|
61
|
-
echo "Unknown Linux distribution: '$ID'"
|
|
62
|
-
exit 1
|
|
63
|
-
fi
|
|
64
|
-
|
|
65
|
-
$SUDO rm -rf $ROOT_DIR/pkg/linux/tmp
|