infinispan 0.10.0 → 0.11.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/.eslintrc +25 -0
- package/Jenkinsfile-release +5 -3
- package/documentation/asciidoc/topics/attributes/community-attributes.adoc +1 -0
- package/documentation/asciidoc/topics/code_examples/queries.js +92 -0
- package/documentation/asciidoc/topics/proc_configuring_connections.adoc +1 -1
- package/documentation/asciidoc/topics/ref_client_usage.adoc +12 -0
- package/lib/infinispan.js +61 -57
- package/package.json +4 -1
- package/smoke-tests.sh +1 -0
- package/types/README.md +91 -0
- package/types/index.d.ts +868 -0
- package/.jshintrc +0 -14
package/.eslintrc
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root":true,
|
|
3
|
+
"env": {
|
|
4
|
+
"es6": true,
|
|
5
|
+
"node": true
|
|
6
|
+
},
|
|
7
|
+
"parserOptions": {
|
|
8
|
+
"ecmaVersion": 2022,
|
|
9
|
+
"sourceType": "module"
|
|
10
|
+
},
|
|
11
|
+
"rules": {
|
|
12
|
+
"standard/no-callback-literal": "off",
|
|
13
|
+
"arrow-spacing": "error",
|
|
14
|
+
"arrow-parens": ["error", "as-needed"],
|
|
15
|
+
"arrow-body-style": ["error", "as-needed"],
|
|
16
|
+
"prefer-template": "error",
|
|
17
|
+
"no-unused-vars": ["warn", {
|
|
18
|
+
"argsIgnorePattern": "^_$|^e$|^reject$|^resolve$"
|
|
19
|
+
}],
|
|
20
|
+
"valid-jsdoc": "error",
|
|
21
|
+
"require-jsdoc": "warn",
|
|
22
|
+
"semi": ["error", "always"],
|
|
23
|
+
"quotes": ["error", "single", { "allowTemplateLiterals": true }]
|
|
24
|
+
}
|
|
25
|
+
}
|
package/Jenkinsfile-release
CHANGED
|
@@ -24,7 +24,7 @@ pipeline {
|
|
|
24
24
|
|
|
25
25
|
stage('Install release package') {
|
|
26
26
|
steps {
|
|
27
|
-
nodejs(nodeJSInstallationName: 'Node
|
|
27
|
+
nodejs(nodeJSInstallationName: 'Node 18') {
|
|
28
28
|
sh 'rm -drf node_modules/'
|
|
29
29
|
sh 'npm config ls'
|
|
30
30
|
sh 'npm install'
|
|
@@ -35,10 +35,12 @@ pipeline {
|
|
|
35
35
|
|
|
36
36
|
stage('Release') {
|
|
37
37
|
steps {
|
|
38
|
-
nodejs(nodeJSInstallationName: 'Node
|
|
38
|
+
nodejs(nodeJSInstallationName: 'Node 18') {
|
|
39
39
|
withCredentials([string(credentialsId: 'npmauthtoken', variable: 'NPM_AUTH_TOKEN')]) {
|
|
40
40
|
sh './set-npm-auth-token.sh'
|
|
41
41
|
}
|
|
42
|
+
sh "git status"
|
|
43
|
+
sh "git diff"
|
|
42
44
|
sh "npm-release ${version}"
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -46,7 +48,7 @@ pipeline {
|
|
|
46
48
|
|
|
47
49
|
stage('Generate JS API docs and upload') {
|
|
48
50
|
steps {
|
|
49
|
-
nodejs(nodeJSInstallationName: 'Node
|
|
51
|
+
nodejs(nodeJSInstallationName: 'Node 18') {
|
|
50
52
|
sh './node_modules/.bin/jsdoc lib/*.js'
|
|
51
53
|
sh 'mv out apidocs'
|
|
52
54
|
sh 'mkdir 1.0'
|
|
@@ -6,3 +6,4 @@
|
|
|
6
6
|
:node_docs: https://docs.jboss.org/infinispan/hotrod-clients/javascript/1.0/apidocs/
|
|
7
7
|
:server_docs: https://infinispan.org/docs/stable/titles/server/server.html
|
|
8
8
|
:code_tutorials: https://github.com/infinispan/infinispan-simple-tutorials/
|
|
9
|
+
:query_docs: https://infinispan.org/docs/stable/titles/query/query.html
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const infinispan = require('infinispan');
|
|
2
|
+
const protobuf = require('protobufjs');
|
|
3
|
+
// This example uses async/await paradigma
|
|
4
|
+
(async function () {
|
|
5
|
+
// User data protobuf definition
|
|
6
|
+
const cacheValueProtoDef = `package awesomepackage;
|
|
7
|
+
/**
|
|
8
|
+
* @TypeId(1000044)
|
|
9
|
+
*/
|
|
10
|
+
message AwesomeUser {
|
|
11
|
+
required string name = 1;
|
|
12
|
+
required int64 age = 2;
|
|
13
|
+
required bool isVerified =3;
|
|
14
|
+
}`
|
|
15
|
+
try {
|
|
16
|
+
// Creating clients for two caches:
|
|
17
|
+
// - ___protobuf_metadata for registering .proto file
|
|
18
|
+
// - queryCache for user data
|
|
19
|
+
const connectProp = { port: 11222, host: '127.0.0.1' };
|
|
20
|
+
const commonOpts = {
|
|
21
|
+
version: '3.0',
|
|
22
|
+
authentication: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
saslMechanism: 'DIGEST-MD5',
|
|
25
|
+
userName: 'admin',
|
|
26
|
+
password: 'pass'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const protoMetaClientOps = {
|
|
30
|
+
cacheName: '___protobuf_metadata',
|
|
31
|
+
dataFormat: { keyType: "text/plain", valueType: "text/plain" }
|
|
32
|
+
}
|
|
33
|
+
const clientOps = {
|
|
34
|
+
dataFormat: { keyType: "text/plain", valueType: "application/x-protostream" },
|
|
35
|
+
cacheName: 'queryCache'
|
|
36
|
+
}
|
|
37
|
+
var protoMetaClient = await infinispan.client(connectProp, Object.assign(commonOpts, protoMetaClientOps));
|
|
38
|
+
var client = await infinispan.client(connectProp, Object.assign(commonOpts, clientOps));
|
|
39
|
+
|
|
40
|
+
// Registering protobuf definition on server
|
|
41
|
+
await protoMetaClient.put("awesomepackage/AwesomeUser.proto", cacheValueProtoDef);
|
|
42
|
+
|
|
43
|
+
// Registering protobuf definition on protobufjs
|
|
44
|
+
const root = protobuf.parse(cacheValueProtoDef).root;
|
|
45
|
+
const AwesomeUser = root.lookupType(".awesomepackage.AwesomeUser");
|
|
46
|
+
client.registerProtostreamRoot(root);
|
|
47
|
+
client.registerProtostreamType(".awesomepackage.AwesomeUser", 1000044);
|
|
48
|
+
|
|
49
|
+
// Cleanup and populating the cache
|
|
50
|
+
await client.clear();
|
|
51
|
+
for (let i = 0; i < 10; i++) {
|
|
52
|
+
const payload = { name: "AwesomeName" + i, age: i, isVerified: (Math.random() < 0.5) };
|
|
53
|
+
const message = AwesomeUser.create(payload);
|
|
54
|
+
console.log("Creating entry:", message);
|
|
55
|
+
await client.put(i.toString(), message)
|
|
56
|
+
}
|
|
57
|
+
// Run the query
|
|
58
|
+
const queryStr = `select u.name,u.age from awesomepackage.AwesomeUser u where u.age<20 order by u.name asc`;
|
|
59
|
+
console.log("Running query:", queryStr);
|
|
60
|
+
const query = await client.query({ queryString: queryStr });
|
|
61
|
+
console.log("Query result:");
|
|
62
|
+
console.log(query);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
handleError(err);
|
|
65
|
+
} finally {
|
|
66
|
+
if (client) {
|
|
67
|
+
await client.disconnect();
|
|
68
|
+
}
|
|
69
|
+
if (protoMetaClient) {
|
|
70
|
+
await protoMetaClient.disconnect();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
|
|
75
|
+
function handleError(err) {
|
|
76
|
+
if (err.message.includes("'queryCache' not found")) {
|
|
77
|
+
console.log('*** ERROR ***');
|
|
78
|
+
console.log(`*** This example needs a cache 'queryCache' with the following config:
|
|
79
|
+
{
|
|
80
|
+
"local-cache": {
|
|
81
|
+
"statistics": true,
|
|
82
|
+
"encoding": {
|
|
83
|
+
"key": {
|
|
84
|
+
"media-type": "text/plain"
|
|
85
|
+
},
|
|
86
|
+
"value": {
|
|
87
|
+
"media-type": "application/x-protostream"
|
|
88
|
+
}}}}`)
|
|
89
|
+
} else {
|
|
90
|
+
console.log(err);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
= Configuring {brandname} connections
|
|
3
3
|
Configure {hr_js} clients to connect to {brandname} Server.
|
|
4
4
|
|
|
5
|
-
If add multiple server addresses to the configuration, the {hr_js} client loops through them until it finds a node to which it can connect.
|
|
5
|
+
If you add multiple server addresses to the configuration, the {hr_js} client loops through them until it finds a node to which it can connect.
|
|
6
6
|
|
|
7
7
|
However, you only need to add one {brandname} Server address for the client to receive the entire cluster topology.
|
|
8
8
|
If the {hr_js} client connects to a single server instance that is a member of a cluster, the client gets the address information for all nodes.
|
|
@@ -114,3 +114,15 @@ Use the `getWithMetadata` and `size` methods expire cache entries.
|
|
|
114
114
|
----
|
|
115
115
|
include::code_examples/ephemeral-data.js[]
|
|
116
116
|
----
|
|
117
|
+
|
|
118
|
+
== Working with queries
|
|
119
|
+
|
|
120
|
+
Use the `query` method to perform queries on your caches.
|
|
121
|
+
You must configure {hr_js} client to have `application/x-protostream` data format for values in your caches.
|
|
122
|
+
|
|
123
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
124
|
+
----
|
|
125
|
+
include::code_examples/queries.js[]
|
|
126
|
+
----
|
|
127
|
+
|
|
128
|
+
See link:{query_docs}[Querying {brandname} caches] for more information.
|
package/lib/infinispan.js
CHANGED
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
/**
|
|
135
135
|
* Returns the next entry being iterated over.
|
|
136
136
|
*
|
|
137
|
-
* @returns {
|
|
137
|
+
* @returns {Promise.<IteratorNext>}
|
|
138
138
|
* It returns a Promise which will be completed with an instance that
|
|
139
139
|
* provides the next element.
|
|
140
140
|
* @memberof Iterator#
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
/**
|
|
170
170
|
* Close the iteration.
|
|
171
171
|
*
|
|
172
|
-
* @returns {
|
|
172
|
+
* @returns {Promise}
|
|
173
173
|
* A Promise which will be completed once the iteration has been closed.
|
|
174
174
|
* @memberof Iterator#
|
|
175
175
|
* @since 0.3
|
|
@@ -201,7 +201,7 @@
|
|
|
201
201
|
/**
|
|
202
202
|
* Disconnect client from backend server(s).
|
|
203
203
|
*
|
|
204
|
-
* @returns {
|
|
204
|
+
* @returns {Promise<void>}
|
|
205
205
|
* A promise that will be completed once client has
|
|
206
206
|
* completed disconnection from server(s).
|
|
207
207
|
* @memberof Client#
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
* Get the value associated with the given key parameter.
|
|
215
215
|
*
|
|
216
216
|
* @param k {(String|Object)} Key to retrieve.
|
|
217
|
-
* @returns {
|
|
217
|
+
* @returns {Promise.<?String>}
|
|
218
218
|
* A promise that will be completed with the value associated with
|
|
219
219
|
* the key, or undefined if the value is not present.
|
|
220
220
|
* @memberof Client#
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
* Query the server with the given queryString.
|
|
231
231
|
*
|
|
232
232
|
* @param q {(Object)} query to retrieve.
|
|
233
|
-
* @returns {
|
|
233
|
+
* @returns {Promise.<?Object[]>}
|
|
234
234
|
* A promise that will be completed with the array of values associated with
|
|
235
235
|
* the query, or empty array if the no values matches the query.
|
|
236
236
|
* @memberof Client#
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
* Check whether the given key is present.
|
|
248
248
|
*
|
|
249
249
|
* @param k {(String|Object)} Key to check for presence.
|
|
250
|
-
* @returns {
|
|
250
|
+
* @returns {Promise.<boolean>}
|
|
251
251
|
* A promise that will be completed with true if there is a value
|
|
252
252
|
* associated with the key, or false otherwise.
|
|
253
253
|
* @memberof Client#
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
* Get the value and metadata associated with the given key parameter.
|
|
275
275
|
*
|
|
276
276
|
* @param k {(String|Object)} Key to retrieve.
|
|
277
|
-
* @returns {
|
|
277
|
+
* @returns {Promise.<?MetadataValue>}
|
|
278
278
|
* A promise that will be completed with the value and metadata
|
|
279
279
|
* associated with the key, or undefined if the value is not present.
|
|
280
280
|
* @memberof Client#
|
|
@@ -316,8 +316,8 @@
|
|
|
316
316
|
*
|
|
317
317
|
* @param k {(String|Object)} Key with which the specified value is to be associated.
|
|
318
318
|
* @param v {(String|Object)} Value to be associated with the specified key.
|
|
319
|
-
* @param opts {
|
|
320
|
-
* @returns {
|
|
319
|
+
* @param opts {StoreOptions=} Optional store options.
|
|
320
|
+
* @returns {Promise.<?(String|Object)>}
|
|
321
321
|
* A promise that will be completed with undefined unless 'previous'
|
|
322
322
|
* option has been enabled and a previous value exists, in which case it
|
|
323
323
|
* would return the previous value.
|
|
@@ -345,8 +345,8 @@
|
|
|
345
345
|
* Removes the mapping for a key if it is present.
|
|
346
346
|
*
|
|
347
347
|
* @param k {(String|Object)} Key whose mapping is to be removed.
|
|
348
|
-
* @param opts {
|
|
349
|
-
* @returns {
|
|
348
|
+
* @param opts {RemoveOptions=} Optional remove options.
|
|
349
|
+
* @returns {Promise.<(Boolean|String|Object)>}
|
|
350
350
|
* A promise that will be completed with true if the mapping was removed,
|
|
351
351
|
* or false if the key did not exist.
|
|
352
352
|
* If the 'previous' option is enabled, it returns the value
|
|
@@ -367,8 +367,8 @@
|
|
|
367
367
|
*
|
|
368
368
|
* @param k {(String|Object)} Key with which the specified value is to be associated.
|
|
369
369
|
* @param v {(String|Object)} Value to be associated with the specified key.
|
|
370
|
-
* @param opts {
|
|
371
|
-
* @returns {
|
|
370
|
+
* @param opts {StoreOptions=} Optional store options.
|
|
371
|
+
* @returns {Promise.<(Boolean|String|Object)>}
|
|
372
372
|
* A promise that will be completed with true if the mapping was stored,
|
|
373
373
|
* or false if the key is already present.
|
|
374
374
|
* If the 'previous' option is enabled, it returns the existing value
|
|
@@ -389,8 +389,8 @@
|
|
|
389
389
|
*
|
|
390
390
|
* @param k {(String|Object)} Key with which the specified value is associated.
|
|
391
391
|
* @param v {(String|Object)} Value expected to be associated with the specified key.
|
|
392
|
-
* @param opts {
|
|
393
|
-
* @returns {
|
|
392
|
+
* @param opts {StoreOptions=} Optional store options.
|
|
393
|
+
* @returns {Promise.<(Boolean|String|Object)>}
|
|
394
394
|
* A promise that will be completed with true if the mapping was replaced,
|
|
395
395
|
* or false if the key does not exist.
|
|
396
396
|
* If the 'previous' option is enabled, it returns the value that was
|
|
@@ -414,8 +414,8 @@
|
|
|
414
414
|
* @param version {Buffer} binary buffer version that should match the
|
|
415
415
|
* one in the server for the operation to succeed. Version information
|
|
416
416
|
* can be retrieved with getWithMetadata method.
|
|
417
|
-
* @param opts {
|
|
418
|
-
* @returns {
|
|
417
|
+
* @param opts {StoreOptions=} Optional store options.
|
|
418
|
+
* @returns {Promise.<(Boolean|String|Object)>}
|
|
419
419
|
* A promise that will be completed with true if the version matches
|
|
420
420
|
* and the mapping was replaced, otherwise it returns false if not
|
|
421
421
|
* replaced because key does not exist or version sent does not match
|
|
@@ -442,8 +442,8 @@
|
|
|
442
442
|
* @param version {Buffer} binary buffer version that should match the
|
|
443
443
|
* one in the server for the operation to succeed. Version information
|
|
444
444
|
* can be retrieved with getWithMetadata method.
|
|
445
|
-
* @param opts {
|
|
446
|
-
* @returns {
|
|
445
|
+
* @param opts {RemoveOptions=} Optional remove options.
|
|
446
|
+
* @returns {Promise.<(Boolean|String|Object)>}
|
|
447
447
|
* A promise that will be completed with true if the version matches
|
|
448
448
|
* and the mapping was removed, otherwise it returns false if not
|
|
449
449
|
* removed because key does not exist or version sent does not match
|
|
@@ -474,7 +474,7 @@
|
|
|
474
474
|
* Retrieves all of the entries for the provided keys.
|
|
475
475
|
*
|
|
476
476
|
* @param keys {(String[]|Object[])} Keys to find values for.
|
|
477
|
-
* @returns {
|
|
477
|
+
* @returns {Promise.<Entry[]>}
|
|
478
478
|
* A promise that will be completed with an array of entries for all
|
|
479
479
|
* keys found. If a key does not exist, there won't be an entry for that
|
|
480
480
|
* key in the returned array.
|
|
@@ -502,9 +502,9 @@
|
|
|
502
502
|
* Stores all of the mappings from the specified entry array.
|
|
503
503
|
*
|
|
504
504
|
* @param pairs {Entry[]} key/value pair mappings to be stored
|
|
505
|
-
* @param opts {MultiStoreOptions}
|
|
505
|
+
* @param opts {MultiStoreOptions=}
|
|
506
506
|
* Optional storage options to apply to all entries.
|
|
507
|
-
* @returns {
|
|
507
|
+
* @returns {Promise}
|
|
508
508
|
* A promise that will be completed when all entries have been stored.
|
|
509
509
|
* @memberof Client#
|
|
510
510
|
* @since 0.3
|
|
@@ -530,8 +530,8 @@
|
|
|
530
530
|
*
|
|
531
531
|
* @param batchSize {Number}
|
|
532
532
|
* The number of entries transferred from the server at a time.
|
|
533
|
-
* @param opts {
|
|
534
|
-
* @return {
|
|
533
|
+
* @param opts {IteratorOptions=} Optional iteration settings.
|
|
534
|
+
* @return {Promise.<Iterator>}
|
|
535
535
|
* A promise that will be completed with an iterator that can be used
|
|
536
536
|
* to retrieve stored elements.
|
|
537
537
|
* @memberof Client#
|
|
@@ -548,7 +548,7 @@
|
|
|
548
548
|
/**
|
|
549
549
|
* Count of entries in the server(s).
|
|
550
550
|
*
|
|
551
|
-
* @returns {
|
|
551
|
+
* @returns {Promise.<Number>}
|
|
552
552
|
* A promise that will be completed with the number of entries stored.
|
|
553
553
|
* @memberof Client#
|
|
554
554
|
* @since 0.3
|
|
@@ -561,7 +561,7 @@
|
|
|
561
561
|
/**
|
|
562
562
|
* Clear all entries stored in server(s).
|
|
563
563
|
*
|
|
564
|
-
* @returns {
|
|
564
|
+
* @returns {Promise}
|
|
565
565
|
* A promise that will be completed when the clear has been completed.
|
|
566
566
|
* @memberof Client#
|
|
567
567
|
* @since 0.3
|
|
@@ -574,7 +574,7 @@
|
|
|
574
574
|
/**
|
|
575
575
|
* Pings the server(s).
|
|
576
576
|
*
|
|
577
|
-
* @returns {
|
|
577
|
+
* @returns {Promise}
|
|
578
578
|
* A promise that will be completed when ping response was received.
|
|
579
579
|
* @memberof Client#
|
|
580
580
|
* @since 0.3
|
|
@@ -598,7 +598,7 @@
|
|
|
598
598
|
/**
|
|
599
599
|
* Retrieve various statistics from server(s).
|
|
600
600
|
*
|
|
601
|
-
* @returns {
|
|
601
|
+
* @returns {Promise<StatsItem[]>}
|
|
602
602
|
* A promise that will be completed with an array of statistics, where
|
|
603
603
|
* each element will have a single property. This single property will
|
|
604
604
|
* have the statistic name as property name and statistic value as
|
|
@@ -632,8 +632,8 @@
|
|
|
632
632
|
* entry version and listener id.
|
|
633
633
|
* 'remove' and 'expiry' events callback the function with key
|
|
634
634
|
* and listener id.
|
|
635
|
-
* @param opts {
|
|
636
|
-
* @returns {
|
|
635
|
+
* @param opts {ListenOptions=} Options for adding listener.
|
|
636
|
+
* @returns {Promise<String>}
|
|
637
637
|
* A promise that will be completed with the identifier of the listener.
|
|
638
638
|
* This identifier can be used to register multiple callbacks with the
|
|
639
639
|
* same listener, or to remove the listener.
|
|
@@ -663,7 +663,7 @@
|
|
|
663
663
|
*
|
|
664
664
|
* @param {String} listenerId
|
|
665
665
|
* Listener identifier to identify listener to remove.
|
|
666
|
-
* @return {
|
|
666
|
+
* @return {Promise}
|
|
667
667
|
* A promise that will be completed when the listener has been removed.
|
|
668
668
|
* @memberof Client#
|
|
669
669
|
* @since 0.3
|
|
@@ -690,7 +690,7 @@
|
|
|
690
690
|
*
|
|
691
691
|
* @param {String} scriptName Name of the script to store.
|
|
692
692
|
* @param {String} script Script to store in server.
|
|
693
|
-
* @return {
|
|
693
|
+
* @return {Promise}
|
|
694
694
|
* A promise that will be completed when the script has been stored.
|
|
695
695
|
* @memberof Client#
|
|
696
696
|
* @since 0.3
|
|
@@ -718,9 +718,9 @@
|
|
|
718
718
|
* Execute the named script passing in optional parameters.
|
|
719
719
|
*
|
|
720
720
|
* @param {String} scriptName Name of the script to execute.
|
|
721
|
-
* @param {
|
|
721
|
+
* @param {ExecParams[]} [params]
|
|
722
722
|
* Optional array of named parameters to pass to script in server.
|
|
723
|
-
* @returns {
|
|
723
|
+
* @returns {Promise<String|String[]>}
|
|
724
724
|
* A promise that will be completed with either the value returned by the
|
|
725
725
|
* script after execution for local scripts, or an array of values
|
|
726
726
|
* returned by the script when executed in multiple servers for
|
|
@@ -810,7 +810,7 @@
|
|
|
810
810
|
* previously declared via configuration.
|
|
811
811
|
*
|
|
812
812
|
* @param clusterName name of the cluster to which to switch to
|
|
813
|
-
* @return {
|
|
813
|
+
* @return {Promise<Boolean>}
|
|
814
814
|
* A promise encapsulating a Boolean that indicates {@code true} if the
|
|
815
815
|
* switch happened, or {@code false} otherwise.
|
|
816
816
|
* @memberof Topology#
|
|
@@ -823,7 +823,7 @@
|
|
|
823
823
|
* Switch remote cache manager to the default cluster,
|
|
824
824
|
* previously declared via configuration.
|
|
825
825
|
*
|
|
826
|
-
* @return {
|
|
826
|
+
* @return {Promise<Boolean>}
|
|
827
827
|
* A promise encapsulating a Boolean that indicates {@code true} if the
|
|
828
828
|
* switch happened, or {@code false} otherwise.
|
|
829
829
|
* @memberof Topology#
|
|
@@ -864,20 +864,18 @@
|
|
|
864
864
|
* @param args {(ServerAddress|ServerAddress[])}
|
|
865
865
|
* Optional single or multiple addresses to which to connect. If none
|
|
866
866
|
* provided, the client will connect to localhost:11222 address by default.
|
|
867
|
-
* @param options {
|
|
867
|
+
* @param [options] {ClientOptions}
|
|
868
868
|
* Optional configuration settings.
|
|
869
|
-
* @returns A promise that will be completed once the connection
|
|
870
|
-
* has been established. The promise will be completed with a client
|
|
871
|
-
* instance on which operations can invoked.
|
|
872
869
|
* @constructs Client
|
|
870
|
+
* @returns {Promise<ReturnType<Client>>}
|
|
873
871
|
* @since 0.3
|
|
874
872
|
*/
|
|
875
873
|
exports.client = function client(args, options) {
|
|
876
874
|
var merged = f.merge(Client.config, options);
|
|
877
875
|
var c = new Client(u.normalizeAddresses(args), merged);
|
|
876
|
+
|
|
878
877
|
return c.connect();
|
|
879
878
|
};
|
|
880
|
-
|
|
881
879
|
/**
|
|
882
880
|
* Cluster information.
|
|
883
881
|
*
|
|
@@ -894,26 +892,32 @@
|
|
|
894
892
|
* @static
|
|
895
893
|
* @typedef {Object} ClientOptions
|
|
896
894
|
* @property {?(2.9|2.5|2.2)} [version=2.9] - Version of client/server protocol.
|
|
897
|
-
* @property {?String} cacheName - Optional cache name.
|
|
895
|
+
* @property {?String} [cacheName] - Optional cache name.
|
|
898
896
|
* @property {?Number} [maxRetries=3] - Optional number of retries for operation.
|
|
897
|
+
* @property {?Object} [ssl] - TLS/SSL properties.
|
|
899
898
|
* @property {?boolean} [ssl.enabled=false] - Optional flag to enable SSL support.
|
|
900
899
|
* @property {?String} [ssl.secureProtocol=TLSv1_2_method] - Optional field with secure protocol in use.
|
|
901
|
-
* @property {?String[]} ssl.trustCerts - Optional paths of trusted SSL certificates.
|
|
902
|
-
* @property {?String} ssl.clientAuth.key - Optional path to client authentication key.
|
|
903
|
-
* @property {?String} ssl.clientAuth.passphrase - Optional password for client key.
|
|
904
|
-
* @property {?String} ssl.clientAuth.cert - Optional client certificate.
|
|
905
|
-
* @property {?String} ssl.sniHostName - Optional SNI host name.
|
|
906
|
-
* @property {?String} ssl.cryptoStore.path - Optional crypto store path.
|
|
907
|
-
* @property {?String} ssl.cryptoStore.passphrase - Optional password for crypto store.
|
|
908
|
-
* @property {?
|
|
909
|
-
* @property {?
|
|
910
|
-
* @property {?String} authentication.
|
|
911
|
-
* @property {?String} authentication.
|
|
912
|
-
* @property {?String} authentication.
|
|
913
|
-
* @property {?String} authentication.
|
|
900
|
+
* @property {?String[]} [ssl.trustCerts] - Optional paths of trusted SSL certificates.
|
|
901
|
+
* @property {?String} [ssl.clientAuth.key] - Optional path to client authentication key.
|
|
902
|
+
* @property {?String} [ssl.clientAuth.passphrase] - Optional password for client key.
|
|
903
|
+
* @property {?String} [ssl.clientAuth.cert] - Optional client certificate.
|
|
904
|
+
* @property {?String} [ssl.sniHostName] - Optional SNI host name.
|
|
905
|
+
* @property {?String} [ssl.cryptoStore.path] - Optional crypto store path.
|
|
906
|
+
* @property {?String} [ssl.cryptoStore.passphrase] - Optional password for crypto store.
|
|
907
|
+
* @property {?Object} [authentication]- Authentication properties.
|
|
908
|
+
* @property {?boolean} [authentication.enabled]- Enable authentication.
|
|
909
|
+
* @property {?String} [authentication.saslMechanism] - Select the SASL mechanism to use. Can be one of PLAIN, DIGEST-MD5, SCRAM-SHA-1, SCRAM-SHA-256, SCRAM-SHA-384, SCRAM-SHA-512, EXTERNAL, OAUTHBEARER
|
|
910
|
+
* @property {?String} [authentication.userName] - The authentication username. Required by the PLAIN, DIGEST and SCRAM mechanisms.
|
|
911
|
+
* @property {?String} [authentication.password] - The authentication password. Required by the PLAIN, DIGEST and SCRAM mechanisms.
|
|
912
|
+
* @property {?String} [authentication.token] - The OAuth token. Required by the OAUTHBEARER mechanism.
|
|
913
|
+
* @property {?String} [authentication.authzid] - The SASL authorization ID.
|
|
914
|
+
* @property {?String} [authentication.authzid] - The SASL authorization ID.
|
|
915
|
+
* @property {?Object} [dataFormat] - Content-type for entry
|
|
916
|
+
* @property {?String} [dataFormat.keyType] - Content-type for key
|
|
917
|
+
* @property {?String} [dataFormat.valueType] - Content-type for value
|
|
914
918
|
* @property {?boolean} [topologyUpdates=true] - Optional flag to controls whether the client deals with topology updates or not.
|
|
915
|
-
* @property {?(text/plain|application/json)} [mediaType=text/plain] - Media type of the cache contents.
|
|
916
|
-
* @property {?Cluster[]} clusters - Optional additional clusters for cross-site failovers.
|
|
919
|
+
* @property {?("text/plain"|"application/json")} [mediaType="text/plain"] - Media type of the cache contents.
|
|
920
|
+
* @property {?Cluster[]} [clusters] - Optional additional clusters for cross-site failovers.
|
|
917
921
|
* @since 0.3
|
|
918
922
|
*/
|
|
919
923
|
Client.config = {
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infinispan",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Infinispan Javascript client",
|
|
5
5
|
"main": "index",
|
|
6
|
+
"typings": "./types",
|
|
6
7
|
"directories": {
|
|
7
8
|
"test": "test"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
11
|
+
"lint": "eslint --ignore-path .gitignore .",
|
|
10
12
|
"test": "./node_modules/.bin/jasmine-node spec"
|
|
11
13
|
},
|
|
12
14
|
"author": "Galder Zamarreño",
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
"underscore": "^1.13.3"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
36
|
+
"eslint": "^8.26.0",
|
|
34
37
|
"growl": "^1.10.5",
|
|
35
38
|
"jasmine-node": "^3.0.0",
|
|
36
39
|
"jsdoc": "^3.6.10",
|
package/smoke-tests.sh
CHANGED
package/types/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
This directory contains all the type definitions that are used in this libray.
|
|
2
|
+
|
|
3
|
+
The below code can be used for testing the type support.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
const protobuf = require("protobufjs");
|
|
7
|
+
const infinispan = require("./lib/infinispan.js");
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var client = infinispan.client(
|
|
11
|
+
{ port: 11222, host: "127.0.0.1" },
|
|
12
|
+
{
|
|
13
|
+
dataFormat: {
|
|
14
|
+
keyType: "application/x-protostream",
|
|
15
|
+
valueType: "application/x-protostream",
|
|
16
|
+
},
|
|
17
|
+
authentication: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
saslMechanism: "DIGEST-MD5",
|
|
20
|
+
userName: "admin",
|
|
21
|
+
password: "pass",
|
|
22
|
+
serverName: "infinispan",
|
|
23
|
+
},
|
|
24
|
+
cacheName: "protoStreamCache",
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
var protoMetaClient = infinispan.client({ port: 11222, host: "127.0.0.1" }, {
|
|
29
|
+
authentication: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
saslMechanism: "DIGEST-MD5",
|
|
32
|
+
userName: "admin",
|
|
33
|
+
password: "pass",
|
|
34
|
+
serverName: "infinispan",
|
|
35
|
+
},
|
|
36
|
+
cacheName: "___protobuf_metadata",
|
|
37
|
+
dataFormat: { keyType: "text/plain", valueType: "text/plain" },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
protoMetaClient.then(async function (client) {
|
|
41
|
+
var myMsg2 = `package awesomepackage;
|
|
42
|
+
/**
|
|
43
|
+
* @TypeId(1000042)
|
|
44
|
+
*/
|
|
45
|
+
message AwesomeMessages {
|
|
46
|
+
required string name = 1;
|
|
47
|
+
required int64 age = 2;
|
|
48
|
+
|
|
49
|
+
}`
|
|
50
|
+
await client.put("awesomepackage/AwesomeMessage.proto", myMsg2);
|
|
51
|
+
await client.disconnect();
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
client.then(async function (client) {
|
|
56
|
+
var myMsg2 = `package awesomepackage;
|
|
57
|
+
/**
|
|
58
|
+
* @TypeId(1000042)
|
|
59
|
+
*/
|
|
60
|
+
message AwesomeMessages {
|
|
61
|
+
required string name = 1;
|
|
62
|
+
required int64 age = 2;
|
|
63
|
+
|
|
64
|
+
}`;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
let root = protobuf.parse(myMsg2).root;
|
|
68
|
+
let user = root.lookupType('awesomepackage.AwesomeMessages');
|
|
69
|
+
client.registerProtostreamType('.awesomepackage.AwesomeMessages', 1000042);
|
|
70
|
+
client.registerProtostreamRoot(root);
|
|
71
|
+
try {
|
|
72
|
+
for (let i = 0; i < 10; i++) {
|
|
73
|
+
let payload = { name: "Neeraj" + i, age: 20 + i };
|
|
74
|
+
let buf = user.create(payload);
|
|
75
|
+
await client.put(i + 1, buf);
|
|
76
|
+
console.log(await client.getWithMetadata(1));
|
|
77
|
+
}
|
|
78
|
+
var decoded = await client.query({ queryString: `select u.name,u.age from awesomepackage.AwesomeMessages u where u.age>20` });
|
|
79
|
+
console.log(decoded);
|
|
80
|
+
await client.disconnect();
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.log(error);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
In the put method, if someone provides only one argument then the compiler will throw the error as below :
|
|
89
|
+
`index.ts:70:18 - error TS2554: Expected 2-3 arguments, but got 1.`
|
|
90
|
+
|
|
91
|
+
The same follows for all the operations. There is a validation on client config also.
|