infinispan 0.9.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/stories/assembly_client_usage_examples.adoc +2 -8
- package/documentation/asciidoc/stories/{assembly_configuration.adoc → assembly_installation_configuration.adoc} +6 -4
- package/documentation/asciidoc/titles/js_client.asciidoc +1 -0
- package/documentation/asciidoc/titles/stories.adoc +1 -2
- package/documentation/asciidoc/topics/attributes/community-attributes.adoc +2 -1
- package/documentation/asciidoc/topics/attributes/downstream-attributes.adoc +0 -2
- package/documentation/asciidoc/topics/code_examples/authentication-digest.js +3 -2
- package/documentation/asciidoc/topics/code_examples/authentication-external.js +3 -2
- package/documentation/asciidoc/topics/code_examples/authentication-oauthbearer.js +3 -2
- package/documentation/asciidoc/topics/code_examples/authentication-plain.js +3 -2
- package/documentation/asciidoc/topics/code_examples/authentication-scram.js +3 -2
- package/documentation/asciidoc/topics/code_examples/await-single-entries.js +1 -1
- package/documentation/asciidoc/topics/code_examples/conditional-operations.js +7 -1
- package/documentation/asciidoc/topics/code_examples/connection-multiple-servers.js +5 -1
- package/documentation/asciidoc/topics/code_examples/data-types.js +2 -2
- package/documentation/asciidoc/topics/code_examples/ephemeral-data.js +11 -6
- package/documentation/asciidoc/topics/code_examples/hello-world.js +13 -1
- package/documentation/asciidoc/topics/code_examples/key-value-converter.js +3 -4
- package/documentation/asciidoc/topics/code_examples/multiple-entries.js +13 -2
- package/documentation/asciidoc/topics/code_examples/queries.js +92 -0
- package/documentation/asciidoc/topics/code_examples/register-event-listener.js +8 -4
- package/documentation/asciidoc/topics/code_examples/sample-script-execute.js +6 -1
- package/documentation/asciidoc/topics/code_examples/single-entries.js +13 -2
- package/documentation/asciidoc/topics/proc_configuring_connections.adoc +8 -9
- package/documentation/asciidoc/topics/proc_installing_clients.adoc +23 -5
- package/documentation/asciidoc/topics/ref_client_usage.adoc +128 -0
- package/lib/codec.js +153 -2
- package/lib/infinispan.js +87 -57
- package/lib/io.js +14 -8
- package/lib/protocols.js +129 -4
- package/lib/protostream/message-wrapping.proto +134 -0
- package/lib/protostream/query.proto +122 -0
- package/lib/sasl/bitops.js +5 -7
- package/lib/sasl/factory.js +71 -0
- package/lib/utils.js +1 -1
- package/memory-profiling/helper.js +9 -0
- package/memory-profiling/infinispan_memory_many_get.js +1 -3
- package/memory-profiling/infinispan_memory_one_get.js +6 -4
- package/package.json +10 -12
- package/run-servers.sh +1 -1
- package/smoke-tests.sh +1 -0
- package/spec/codec_spec.js +7 -7
- package/spec/configs/infinispan-clustered.xml +17 -14
- package/spec/configs/infinispan-ssl.xml +25 -22
- package/spec/configs/infinispan-xsite-EARTH.xml +17 -14
- package/spec/configs/infinispan-xsite-MOON.xml +14 -11
- package/spec/configs/infinispan.xml +22 -13
- package/spec/protostream_spec.js +237 -0
- package/spec/utils/testing.js +1 -3
- package/types/README.md +91 -0
- package/types/index.d.ts +868 -0
- package/.jshintrc +0 -14
- package/documentation/asciidoc/stories/assembly_getting_started.adoc +0 -11
- package/documentation/asciidoc/topics/community-attributes.adoc +0 -10
- package/documentation/asciidoc/topics/downstream-attributes.adoc +0 -10
- package/documentation/asciidoc/topics/proc_executing_scripts.adoc +0 -16
- package/documentation/asciidoc/topics/proc_registering_event_listeners.adoc +0 -31
- package/documentation/asciidoc/topics/proc_using_async_await.adoc +0 -23
- package/documentation/asciidoc/topics/proc_using_conditional_operations.adoc +0 -7
- package/documentation/asciidoc/topics/proc_working_ephemeral_data.adoc +0 -7
- package/documentation/asciidoc/topics/proc_working_multiple_entries.adoc +0 -7
- package/documentation/asciidoc/topics/proc_working_single_entries_statistics.adoc +0 -7
- package/documentation/asciidoc/topics/ref_basic_usage.adoc +0 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<infinispan
|
|
2
2
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
3
|
-
xsi:schemaLocation="urn:infinispan:config:
|
|
4
|
-
urn:infinispan:server:
|
|
3
|
+
xsi:schemaLocation="urn:infinispan:config:13.0 https://infinispan.org/schemas/infinispan-config-13.0.xsd
|
|
4
|
+
urn:infinispan:server:13.0 https://infinispan.org/schemas/infinispan-server-13.0.xsd
|
|
5
5
|
urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd"
|
|
6
|
-
xmlns="urn:infinispan:config:
|
|
7
|
-
xmlns:server="urn:infinispan:server:
|
|
6
|
+
xmlns="urn:infinispan:config:13.0"
|
|
7
|
+
xmlns:server="urn:infinispan:server:13.0">
|
|
8
8
|
>
|
|
9
9
|
|
|
10
10
|
<jgroups>
|
|
@@ -132,6 +132,7 @@
|
|
|
132
132
|
<security>
|
|
133
133
|
<authorization/>
|
|
134
134
|
</security>
|
|
135
|
+
<metrics accurate-size="true"/>
|
|
135
136
|
<distributed-cache name="xsiteCache" segments="20" remote-timeout="30000" >
|
|
136
137
|
<locking acquire-timeout="30000" concurrency-level="1000" />
|
|
137
138
|
<backups>
|
|
@@ -141,7 +142,7 @@
|
|
|
141
142
|
</distributed-cache>
|
|
142
143
|
</cache-container>
|
|
143
144
|
|
|
144
|
-
<server xmlns="urn:infinispan:server:
|
|
145
|
+
<server xmlns="urn:infinispan:server:13.0">
|
|
145
146
|
<interfaces>
|
|
146
147
|
<interface name="public">
|
|
147
148
|
<inet-address value="${infinispan.bind.address:127.0.0.1}"/>
|
|
@@ -174,15 +175,17 @@
|
|
|
174
175
|
</security>
|
|
175
176
|
|
|
176
177
|
<!-- not secured -->
|
|
177
|
-
<endpoints
|
|
178
|
-
<
|
|
179
|
-
<
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
<endpoints>
|
|
179
|
+
<endpoint socket-binding="default" security-realm="default">
|
|
180
|
+
<hotrod-connector name="hotrod">
|
|
181
|
+
<authentication>
|
|
182
|
+
<sasl mechanisms="PLAIN"/>
|
|
183
|
+
</authentication>
|
|
184
|
+
</hotrod-connector>
|
|
185
|
+
<rest-connector name="rest"/>
|
|
186
|
+
<!-- Uncomment to enable the memcached connector -->
|
|
187
|
+
<!-- memcached-connector socket-binding="memcached" / -->
|
|
188
|
+
</endpoint>
|
|
186
189
|
</endpoints>
|
|
187
190
|
</server>
|
|
188
191
|
</infinispan>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
3
3
|
xsi:schemaLocation="urn:infinispan:config:12.1 https://infinispan.org/schemas/infinispan-config-12.1.xsd
|
|
4
4
|
urn:infinispan:server:12.1 https://infinispan.org/schemas/infinispan-server-12.1.xsd
|
|
5
|
-
|
|
5
|
+
urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd"
|
|
6
6
|
xmlns="urn:infinispan:config:12.1"
|
|
7
7
|
xmlns:server="urn:infinispan:server:12.1">
|
|
8
8
|
|
|
@@ -132,6 +132,7 @@
|
|
|
132
132
|
<security>
|
|
133
133
|
<authorization/>
|
|
134
134
|
</security>
|
|
135
|
+
<metrics accurate-size="true"/>
|
|
135
136
|
<distributed-cache name="xsiteCache" segments="20" remote-timeout="30000" >
|
|
136
137
|
<locking acquire-timeout="30000" concurrency-level="1000"/>
|
|
137
138
|
<backups>
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
</distributed-cache>
|
|
144
145
|
</cache-container>
|
|
145
146
|
|
|
146
|
-
<server xmlns="urn:infinispan:server:
|
|
147
|
+
<server xmlns="urn:infinispan:server:13.0">
|
|
147
148
|
<interfaces>
|
|
148
149
|
<interface name="public">
|
|
149
150
|
<inet-address value="${infinispan.bind.address:127.0.0.1}"/>
|
|
@@ -176,15 +177,17 @@
|
|
|
176
177
|
</security>
|
|
177
178
|
|
|
178
179
|
<!-- not secured -->
|
|
179
|
-
<endpoints
|
|
180
|
-
<
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
180
|
+
<endpoints>
|
|
181
|
+
<endpoint socket-binding="default" security-realm="default">
|
|
182
|
+
<hotrod-connector name="hotrod">
|
|
183
|
+
<authentication>
|
|
184
|
+
<sasl mechanisms="PLAIN"/>
|
|
185
|
+
</authentication>
|
|
186
|
+
</hotrod-connector>
|
|
187
|
+
<rest-connector name="rest"/>
|
|
188
|
+
<!-- Uncomment to enable the memcached connector -->
|
|
189
|
+
<!-- memcached-connector socket-binding="memcached" / -->
|
|
190
|
+
</endpoint>
|
|
188
191
|
</endpoints>
|
|
189
192
|
</server>
|
|
190
193
|
</infinispan>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<infinispan
|
|
2
2
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
3
|
-
xsi:schemaLocation="urn:infinispan:config:
|
|
4
|
-
urn:infinispan:server:
|
|
5
|
-
xmlns="urn:infinispan:config:
|
|
6
|
-
xmlns:server="urn:infinispan:server:
|
|
3
|
+
xsi:schemaLocation="urn:infinispan:config:13.0 https://infinispan.org/schemas/infinispan-config-13.0.xsd
|
|
4
|
+
urn:infinispan:server:13.0 https://infinispan.org/schemas/infinispan-server-13.0.xsd"
|
|
5
|
+
xmlns="urn:infinispan:config:13.0"
|
|
6
|
+
xmlns:server="urn:infinispan:server:13.0">
|
|
7
7
|
|
|
8
8
|
<cache-container name="default" statistics="true" default-cache="default">
|
|
9
9
|
<!-- <security>-->
|
|
10
10
|
<!-- <authorization/>-->
|
|
11
11
|
<!-- </security>-->
|
|
12
|
+
<metrics accurate-size="true"/>
|
|
12
13
|
<local-cache name="default">
|
|
13
14
|
<locking acquire-timeout="30000" concurrency-level="1000" />
|
|
14
15
|
<encoding media-type="text/plain"/>
|
|
@@ -23,9 +24,15 @@
|
|
|
23
24
|
<local-cache name="jsonCache">
|
|
24
25
|
<encoding media-type="text/plain"/>
|
|
25
26
|
</local-cache>
|
|
27
|
+
<local-cache name="protoStreamCache">
|
|
28
|
+
<encoding>
|
|
29
|
+
<key media-type="text/plain"/>
|
|
30
|
+
<value media-type="application/x-protostream"/>
|
|
31
|
+
</encoding>
|
|
32
|
+
</local-cache>
|
|
26
33
|
</cache-container>
|
|
27
34
|
|
|
28
|
-
<server xmlns="urn:infinispan:server:
|
|
35
|
+
<server xmlns="urn:infinispan:server:13.0">
|
|
29
36
|
<interfaces>
|
|
30
37
|
<interface name="public">
|
|
31
38
|
<inet-address value="${infinispan.bind.address:127.0.0.1}"/>
|
|
@@ -55,14 +62,16 @@
|
|
|
55
62
|
</security-realms>
|
|
56
63
|
</security>
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
<endpoints>
|
|
66
|
+
<endpoint socket-binding="default" security-realm="default">
|
|
67
|
+
<hotrod-connector name="hotrod">
|
|
68
|
+
<authentication>
|
|
69
|
+
<sasl mechanisms="PLAIN DIGEST-MD5 SCRAM-SHA-1 SCRAM-SHA-256 SCRAM-SHA-384 SCRAM-SHA-512"
|
|
70
|
+
server-name="infinispan"/>
|
|
71
|
+
</authentication>
|
|
72
|
+
</hotrod-connector>
|
|
73
|
+
<rest-connector name="rest"/>
|
|
74
|
+
</endpoint>
|
|
66
75
|
</endpoints>
|
|
67
76
|
</server>
|
|
68
77
|
</infinispan>
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
//'use strict';
|
|
2
|
+
|
|
3
|
+
var _ = require('underscore');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var long = require('long');
|
|
6
|
+
|
|
7
|
+
var t = require('./utils/testing'); // Testing dependency
|
|
8
|
+
var protobuf = require('protobufjs');
|
|
9
|
+
const { iteratee } = require('underscore');
|
|
10
|
+
var ispn = require('../lib/infinispan');
|
|
11
|
+
|
|
12
|
+
var myMsg = `package awesomepackage;
|
|
13
|
+
syntax = "proto3";
|
|
14
|
+
/**
|
|
15
|
+
* @TypeId(1000043)
|
|
16
|
+
*/
|
|
17
|
+
message AwesomeMessage {
|
|
18
|
+
string awesome_field = 1;
|
|
19
|
+
}`
|
|
20
|
+
|
|
21
|
+
var myMsg2 = `package awesomepackage;
|
|
22
|
+
/**
|
|
23
|
+
* @TypeId(1000043)
|
|
24
|
+
*/
|
|
25
|
+
message AwesomeMessage {
|
|
26
|
+
required string awesome_field = 1;
|
|
27
|
+
}`
|
|
28
|
+
|
|
29
|
+
var myMsg3 = `package awesomepackage;
|
|
30
|
+
/**
|
|
31
|
+
* @TypeId(1000044)
|
|
32
|
+
*/
|
|
33
|
+
message AwesomeUser {
|
|
34
|
+
required string name = 1;
|
|
35
|
+
required int64 age = 2;
|
|
36
|
+
required bool isVerified =3;
|
|
37
|
+
}`
|
|
38
|
+
|
|
39
|
+
var p30 = t.protocol30({
|
|
40
|
+
dataFormat: {
|
|
41
|
+
keyType: 'text/plain',
|
|
42
|
+
valueType: 'application/x-protostream'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('Protobuf encoding', function () {
|
|
47
|
+
var expectedArray = [0x0a, 0x0d, 0x41, 0x77, 0x65, 0x73, 0x6f, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67];
|
|
48
|
+
var expectedBuffer = Buffer.from(expectedArray);
|
|
49
|
+
it("Encodes a proto message", function () {
|
|
50
|
+
root = protobuf.parse(myMsg).root;
|
|
51
|
+
|
|
52
|
+
// Obtain a message type
|
|
53
|
+
var AwesomeMessage = root.lookupType(".awesomepackage.AwesomeMessage");
|
|
54
|
+
var payload = { awesomeField: "AwesomeString" };
|
|
55
|
+
var errMsg = AwesomeMessage.verify(payload);
|
|
56
|
+
expect(errMsg === null).toBeTruthy();
|
|
57
|
+
var message = AwesomeMessage.create(payload); // or use .fromObject if conversion is necessary
|
|
58
|
+
var buffer = AwesomeMessage.encode(message).finish();
|
|
59
|
+
expect(Buffer.compare(buffer, expectedBuffer)).toBe(0);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
describe('Protostream encoding', function () {
|
|
65
|
+
p30.registerProtostreamType(".awesomepackage.AwesomeMessage", 1000043);
|
|
66
|
+
|
|
67
|
+
it("Returns the Protostream type", function () {
|
|
68
|
+
var psType = p30.lookupProtostreamTypeByName(".awesomepackage.AwesomeMessage");
|
|
69
|
+
expect(psType).toBe(1000043);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("Encodes a Protostream message", function () {
|
|
73
|
+
root = protobuf.parse(myMsg).root;
|
|
74
|
+
protobuf.loadSync(path.join(__dirname + '/../lib/protostream/message-wrapping.proto'), root);
|
|
75
|
+
// Obtain message types
|
|
76
|
+
var AwesomeMessage = root.lookupType(".awesomepackage.AwesomeMessage");
|
|
77
|
+
var WrappedMessage = root.lookupType(".org.infinispan.protostream.WrappedMessage");
|
|
78
|
+
// Build input message
|
|
79
|
+
var payload = { awesomeField: "AwesomeString" };
|
|
80
|
+
var errMsg = AwesomeMessage.verify(payload);
|
|
81
|
+
expect(errMsg === null).toBeTruthy();
|
|
82
|
+
var message = AwesomeMessage.create(payload);
|
|
83
|
+
// Build manually WrappedMessage
|
|
84
|
+
var buffer = AwesomeMessage.encode(message).finish();
|
|
85
|
+
var wmPayload = {
|
|
86
|
+
wrappedMessage: buffer,
|
|
87
|
+
wrappedTypeId: 1000043
|
|
88
|
+
};
|
|
89
|
+
errMsg = WrappedMessage.verify(wmPayload);
|
|
90
|
+
expect(errMsg === null).toBeTruthy();
|
|
91
|
+
var wmMessage = WrappedMessage.create(wmPayload);
|
|
92
|
+
var expectedWMBuffer = WrappedMessage.encode(wmMessage).finish();
|
|
93
|
+
|
|
94
|
+
// Call client API for encoding
|
|
95
|
+
var outBuf = t.newByteBuf(32);
|
|
96
|
+
p30.encodeMediaValue(message)(outBuf);
|
|
97
|
+
// outBuf contains the WM encoded by the client
|
|
98
|
+
|
|
99
|
+
// Removing buf length at the beginning for comparison
|
|
100
|
+
var trimmed = outBuf.buf.slice(1, outBuf.offset);
|
|
101
|
+
// check the client produces same byte buffer
|
|
102
|
+
expect(Buffer.compare(trimmed, expectedWMBuffer)).toBe(0);
|
|
103
|
+
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
describe("Put/Get protostream object to/from Infinispan", function () {
|
|
109
|
+
it("Puts protostream on Infinispan", async function (done) {
|
|
110
|
+
var root = protobuf.parse(myMsg).root;
|
|
111
|
+
var AwesomeMessage = root.lookupType(".awesomepackage.AwesomeMessage");
|
|
112
|
+
try {
|
|
113
|
+
var protoMetaClient = await ispn.client(t.local, { authentication: t.authOpts.authentication, cacheName: '___protobuf_metadata', dataFormat: { keyType: "text/plain", valueType: "text/plain" } });
|
|
114
|
+
var client = await t.client(t.local, { authentication: t.authOpts.authentication, cacheName: 'protoStreamCache', dataFormat: { keyType: "text/plain", valueType: "application/x-protostream" } });
|
|
115
|
+
var payload = { awesomeField: "AwesomeString" };
|
|
116
|
+
var errMsg = AwesomeMessage.verify(payload);
|
|
117
|
+
expect(errMsg === null).toBeTruthy();
|
|
118
|
+
var message = AwesomeMessage.create(payload);
|
|
119
|
+
|
|
120
|
+
await protoMetaClient.put("awesomepackage/AwesomeMessage.proto", myMsg2);
|
|
121
|
+
|
|
122
|
+
await client.clear();
|
|
123
|
+
expect(await client.size()).toBe(0);
|
|
124
|
+
await client.put("myKey", message);
|
|
125
|
+
expect(await client.size()).toBe(1);
|
|
126
|
+
await client.put("myKey1", 1.2);
|
|
127
|
+
await client.put("myKey2","string");
|
|
128
|
+
await client.put("myKey3",true);
|
|
129
|
+
await client.put("myKey4",new ArrayBuffer(8));
|
|
130
|
+
expect(await client.size()).toBe(5);
|
|
131
|
+
|
|
132
|
+
protoMetaClient.disconnect();
|
|
133
|
+
client.disconnect();
|
|
134
|
+
done();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
protoMetaClient.disconnect();
|
|
137
|
+
client.disconnect();
|
|
138
|
+
done(new Error(error));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
it("Gets protostream on Infinispan", async function (done) {
|
|
144
|
+
try {
|
|
145
|
+
var protoMetaClient = await ispn.client(t.local, { authentication: t.authOpts.authentication, cacheName: '___protobuf_metadata', dataFormat: { keyType: "text/plain", valueType: "text/plain" } });
|
|
146
|
+
var client = await t.client(t.local, { authentication: t.authOpts.authentication, cacheName: 'protoStreamCache', dataFormat: { keyType: "text/plain", valueType: "application/x-protostream" } });
|
|
147
|
+
client.registerProtostreamRoot(root);
|
|
148
|
+
var myObj=await client.get("myKey");
|
|
149
|
+
var myObj1=await client.get("myKey1");
|
|
150
|
+
var myObj2=await client.get("myKey2");
|
|
151
|
+
var myObj3=await client.get("myKey3");
|
|
152
|
+
var myObj4=await client.get("myKey4");
|
|
153
|
+
protoMetaClient.disconnect();
|
|
154
|
+
await client.clear();
|
|
155
|
+
client.disconnect();
|
|
156
|
+
done();
|
|
157
|
+
} catch (error) {
|
|
158
|
+
protoMetaClient.disconnect();
|
|
159
|
+
client.disconnect();
|
|
160
|
+
done(new Error(error));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('Querying in application/x-protostream format',function () {
|
|
167
|
+
var root = protobuf.parse(myMsg).root;
|
|
168
|
+
var AwesomeMessage = root.lookupType(".awesomepackage.AwesomeMessage");
|
|
169
|
+
var root2 = protobuf.parse(myMsg3).root;
|
|
170
|
+
var AwesomeUser = root2.lookupType(".awesomepackage.AwesomeUser");
|
|
171
|
+
it("Queries the server without projection", async function (done) {
|
|
172
|
+
try{
|
|
173
|
+
var protoMetaClient = await ispn.client(t.local, { authentication: t.authOpts.authentication, cacheName: '___protobuf_metadata', dataFormat: { keyType: "text/plain", valueType: "text/plain" } });
|
|
174
|
+
var client = await t.client(t.local, { authentication: t.authOpts.authentication, cacheName: 'protoStreamCache', dataFormat: { keyType: "application/x-protostream", valueType: "application/x-protostream" } });
|
|
175
|
+
await protoMetaClient.put("awesomepackage/AwesomeMessage.proto", myMsg2);
|
|
176
|
+
await client.clear();
|
|
177
|
+
for(let i=0;i<10;i++){
|
|
178
|
+
var payload = { awesomeField: "AwesomeString"+i };
|
|
179
|
+
var message = AwesomeMessage.create(payload);
|
|
180
|
+
await client.put(i,message)
|
|
181
|
+
}
|
|
182
|
+
var queryResp1 = await client.query({queryString:`from awesomepackage.AwesomeMessage ORDER BY awesome_field`});
|
|
183
|
+
expect(queryResp1.length).toBe(10);
|
|
184
|
+
var queryResp2 = await client.query({queryString:`from awesomepackage.AwesomeMessage a where a.awesome_field='AwesomeString1'`});
|
|
185
|
+
expect(queryResp2.length).toBe(1);
|
|
186
|
+
expect(queryResp2[0].awesomeField).toEqual('AwesomeString1');
|
|
187
|
+
var queryResp3 = await client.query({queryString:`from awesomepackage.AwesomeMessage a where a.awesome_field='AwesomeString100'`});
|
|
188
|
+
expect(queryResp3.length).toEqual(0);
|
|
189
|
+
protoMetaClient.disconnect();
|
|
190
|
+
await client.clear();
|
|
191
|
+
client.disconnect();
|
|
192
|
+
done();
|
|
193
|
+
}catch (error) {
|
|
194
|
+
protoMetaClient.disconnect();
|
|
195
|
+
client.disconnect();
|
|
196
|
+
done(new Error(error));
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("Queries the server with projection", async function (done) {
|
|
201
|
+
try{
|
|
202
|
+
var protoMetaClient = await ispn.client(t.local, { authentication: t.authOpts.authentication, cacheName: '___protobuf_metadata', dataFormat: { keyType: "text/plain", valueType: "text/plain" } });
|
|
203
|
+
var client = await t.client(t.local, { authentication: t.authOpts.authentication, cacheName: 'protoStreamCache', dataFormat: { keyType: "application/x-protostream", valueType: "application/x-protostream" } });
|
|
204
|
+
await protoMetaClient.put("awesomepackage/AwesomeUser.proto", myMsg3);
|
|
205
|
+
client.registerProtostreamRoot(root2);
|
|
206
|
+
client.registerProtostreamType(".awesomepackage.AwesomeUser",1000044);
|
|
207
|
+
await client.clear();
|
|
208
|
+
for (let i = 0; i < 10; i++){
|
|
209
|
+
var payload = { name: "AwesomeString"+i , age : i , isVerified: (Math.random()<0.5)};
|
|
210
|
+
var message = AwesomeUser.create(payload);
|
|
211
|
+
await client.put(i,message)
|
|
212
|
+
}
|
|
213
|
+
var query1 = await client.query({ queryString: `select u.name,u.age from awesomepackage.AwesomeUser u where u.age<20 order by u.name asc` });
|
|
214
|
+
expect(query1.length).toBe(10);
|
|
215
|
+
expect(query1[0].length).toBe(2);
|
|
216
|
+
for (let i = 0; i < 10; i++) {
|
|
217
|
+
expect(_.isEqual(query1[i][1], long.fromValue(i))).toBeTruthy();
|
|
218
|
+
}
|
|
219
|
+
var query2 = await client.query({queryString:`select u.name from awesomepackage.AwesomeUser u where u.age=2`});
|
|
220
|
+
expect(query2[0][0]).toBe("AwesomeString2");
|
|
221
|
+
|
|
222
|
+
var query3 = await client.query({queryString:`select u.name from awesomepackage.AwesomeUser u where u.age>20`});
|
|
223
|
+
expect(query3.length).toBe(0);
|
|
224
|
+
|
|
225
|
+
protoMetaClient.disconnect();
|
|
226
|
+
await client.clear();
|
|
227
|
+
client.disconnect();
|
|
228
|
+
done();
|
|
229
|
+
}catch (error) {
|
|
230
|
+
protoMetaClient.disconnect();
|
|
231
|
+
client.disconnect();
|
|
232
|
+
done(new Error(error));
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
);
|
package/spec/utils/testing.js
CHANGED
|
@@ -4,9 +4,6 @@ var _ = require('underscore');
|
|
|
4
4
|
|
|
5
5
|
var log4js = require('log4js');
|
|
6
6
|
|
|
7
|
-
var promiseFinally = require('promise.prototype.finally');
|
|
8
|
-
promiseFinally.shim(); // will be a no-op if not needed
|
|
9
|
-
|
|
10
7
|
var readFile = require('fs').readFile;
|
|
11
8
|
var httpRequest = require('request');
|
|
12
9
|
var util = require('util');
|
|
@@ -96,6 +93,7 @@ exports.client = function(args, opts) {
|
|
|
96
93
|
exports.protocol25 = function() { return protocols.version25(); };
|
|
97
94
|
|
|
98
95
|
exports.protocol29 = function(clientOpts) { return protocols.version29(clientOpts); };
|
|
96
|
+
exports.protocol30 = function(clientOpts) { return protocols.version30(clientOpts); };
|
|
99
97
|
|
|
100
98
|
exports.put = function(k, v, opts) {
|
|
101
99
|
return function(client) { return client.put(k, v, opts); }
|
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.
|