infinispan 0.13.0 → 0.15.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.
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ REGEX='^\[#[0-9]+\]\s[A-Z].*\n?(\n(\*\s.*\n)+)?$'
4
+ if ! grep -qE "$REGEX" "$1"; then
5
+ echo "Commit message format is incorrect. Run the following command:" >&2
6
+ echo " git config commit.template .gitmessage" >&2
7
+ echo "and retry" >&2
8
+ exit 1
9
+ fi
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ BASEDIR=$(dirname "$0")/..
4
+ BASEDIR_RESOLVED=$(realpath "$BASEDIR")
5
+
6
+ git config get --local core.hooksPath || git config set --local core.hooksPath "$BASEDIR_RESOLVED"/.githooks
7
+ git config get --local commit.template || git config set --local commit.template "$BASEDIR_RESOLVED"/.gitmessage
@@ -0,0 +1,15 @@
1
+ @echo off
2
+
3
+ set "DIRNAME=%~dp0%"
4
+ pushd "%DIRNAME%.."
5
+ set "BASEDIR_RESOLVED=%CD%"
6
+ popd
7
+
8
+ git config get --local core.hooksPath
9
+ if ERRORLEVEL 1 (
10
+ git config set --local core.hooksPath "%BASEDIR_RESOLVED%/.githooks
11
+ )
12
+ git config get --local commit.template
13
+ if ERRORLEVEL 1 (
14
+ git config set --local commit.template "%BASEDIR_RESOLVED%/.gitmessage
15
+ )
package/.gitmessage ADDED
@@ -0,0 +1,7 @@
1
+ # [#nnnnn] Title, summary, imperative, start upper case, don't end with a period
2
+ # No more than 50 chars. #### 50 chars is here: #
3
+ # Remember blank line between title and body.
4
+
5
+ # Body: Explain *what* and *why* (not *how*)
6
+ # Wrap at 72 chars. ################################## which is here: #
7
+
package/AI-CODE.md ADDED
@@ -0,0 +1,86 @@
1
+ # JS Client Code Instructions
2
+
3
+ ## Tech Stack
4
+ * **Runtime:** Node.js 24 LTS
5
+ * **Language:** JavaScript (ES6+) with TypeScript definition files (`types/index.d.ts`)
6
+ * **Protocol:** Hot Rod binary protocol — versions 2.2, 2.5, 2.9, 3.0, 4.0, 4.1
7
+ * **Test framework:** Jasmine 6
8
+ * **Linting:** ESLint (ES2022, single quotes, semicolons required, JSDoc required)
9
+ * **Docs:** JSDoc for API docs, AsciiDoc for user documentation
10
+
11
+ ## Project Structure
12
+
13
+ ```
14
+ index.js # Entry point — re-exports lib/infinispan.js
15
+ lib/
16
+ infinispan.js # Main client API (connect, CRUD, listeners, queries, scripts)
17
+ io.js # Transport layer (TCP sockets, topology, failover, consistent hashing)
18
+ protocols.js # Hot Rod protocol encode/decode for all supported versions
19
+ codec.js # Binary codec (VInt, VLong, strings, Protobuf, JSON)
20
+ listeners.js # Remote/local event listener management
21
+ functional.js # Functional combinators (lift, actions, pipeline, partial application)
22
+ utils.js # Logging, MurmurHash3, ReplayableBuffer, address normalization
23
+ uri.js # Hot Rod URI parsing (hotrod:// and hotrods:// schemes)
24
+ sasl/ # SASL authentication mechanisms
25
+ factory.js # Mechanism registry and negotiation
26
+ plain.js # PLAIN
27
+ digest.js # DIGEST-MD5
28
+ scram.js # SCRAM-SHA-1/256/384/512
29
+ external.js # EXTERNAL (TLS cert)
30
+ oauthbearer.js # OAUTHBEARER
31
+ spec/ # Tests
32
+ *_spec.js # Test suites
33
+ utils/testing.js # Shared test utilities and assertion helpers
34
+ configs/ # Infinispan server XML configurations for test scenarios
35
+ types/ # TypeScript type definitions
36
+ documentation/ # AsciiDoc user documentation
37
+ scripts/ # Build and test tooling
38
+ ```
39
+
40
+ ## Build and Test Commands
41
+ * **Install dependencies:** `npm install`
42
+ * **Lint:** `npm run lint`
43
+ * **Run tests (with containers):** `npm run test:docker`
44
+ * **Run tests (containers already running):** `npm test`
45
+ * **Start test containers:** `npm run docker:up`
46
+ * **Stop test containers:** `npm run docker:down`
47
+ * **Run a single spec:** `npx jasmine spec/infinispan_local_spec.js`
48
+ * **Generate SSL certificates:** `npm run ssl:generate`
49
+ * **Generate API docs:** `npm run docs:api`
50
+ * **Override server version:** `INFINISPAN_VERSION=16.1.3 npm run test:docker`
51
+
52
+ ## Architecture Notes
53
+
54
+ * **Consistent hashing:** Keys are routed to owning servers using MurmurHash3. Topology updates from the server adjust the hash ring automatically.
55
+ * **Multiplexing:** Multiple in-flight requests share a single TCP connection per server, routed by message ID.
56
+ * **State threading in codec:** The codec layer uses a functional "lift" pattern where encode/decode functions return `{answer, state}` tuples for immutable state management through the pipeline.
57
+ * **Failover:** Automatic retry with round-robin fallback to other cluster members. Cross-site failover supported via `clusters` option and `switchToCluster()`.
58
+
59
+ ## Development Standards
60
+ * **Style:** Use `var` for variable declarations (not `const`/`let`) to match existing codebase.
61
+ * **Module pattern:** All modules wrap code in an IIFE: `(function() { ... }.call(this));`
62
+ * **JSDoc:** Required for all public functions. Use `@param`, `@returns`, `@since` tags.
63
+ * **Testing:** Tests use Promise chains with `spec/utils/testing.js` helpers. Follow the pattern:
64
+ ```javascript
65
+ var t = require('./utils/testing');
66
+ it('should do something', function(done) {
67
+ t.client(t.local, t.authOpts)
68
+ .then(t.assert(t.put('key', 'value')))
69
+ .then(t.assert(t.get('key'), t.toBe('value')))
70
+ .then(t.assert(t.disconnect()))
71
+ .then(function() { done(); }, t.failed(done));
72
+ });
73
+ ```
74
+ * **Commit logs:** Commit logs must always start with `[#nnnnn] Summary`.
75
+ * **Git branches:** Branches should be named `issueid/issue_summary` and use `origin/main` as the upstream.
76
+
77
+ ## Development Platform
78
+ * **Repository:** https://github.com/infinispan/js-client
79
+ * **Issues:** Use GitHub Issues with appropriate labels.
80
+ * **License:** Apache-2.0
81
+
82
+ ## Related Projects
83
+
84
+ * **Infinispan server:** The Infinispan server source code is in ../infinispan
85
+ * **Operator:** The Infinispan Operator source code is in ../infinispan-operator
86
+ * **Console:** The Infinispan Console source code is in ../infinispan-console
package/README.md CHANGED
@@ -1,13 +1,18 @@
1
1
  # Hot Rod JS Client
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/infinispan)](https://www.npmjs.com/package/infinispan)
4
+ [![License](https://img.shields.io/npm/l/infinispan)](https://github.com/infinispan/js-client/blob/main/LICENSE)
5
+ [![CI](https://github.com/infinispan/js-client/actions/workflows/ci.yml/badge.svg)](https://github.com/infinispan/js-client/actions/workflows/ci.yml)
6
+ [![Node.js](https://img.shields.io/node/v/infinispan)](https://www.npmjs.com/package/infinispan)
7
+ [![npm downloads](https://img.shields.io/npm/dm/infinispan)](https://www.npmjs.com/package/infinispan)
8
+
3
9
  `infinispan` is an asynchronous event-driven Infinispan client for Node.js.
4
10
  The results of the asynchronous operations are represented using
5
11
  [Promise](https://www.promisejs.org) instances. Amongst many advantages,
6
12
  promises make it easy to transform/chain multiple asynchronous invocations
7
13
  and they improve error handling by making it easy to centralise it.
8
14
 
9
- The client is under heavy development but here's a summary of its
10
- current capabilities:
15
+ Here's a summary of its current capabilities:
11
16
 
12
17
  * `infinispan` client can be constructed with a single server address or
13
18
  multiple servers addresses. When passing multiple addresses, it will iterate
@@ -54,106 +59,91 @@ The client is normally connected to one of the sites, but if its members fail to
54
59
 
55
60
  Find installation, configuration, and example usage in the Hot Rod JS Client Guide at [infinispan.org/documentation](https://infinispan.org/documentation/).
56
61
 
57
- You can also build the Hot Rod JS Client Guide as follows:
58
-
59
- 1. Clone the source repository.
60
- ```bash
61
- $ git clone git@github.com:infinispan/js-client.git
62
- ```
62
+ You can also build the Hot Rod JS Client Guide locally:
63
63
 
64
- 2. Build the HTML from the asciidoc source.
65
64
  ```bash
66
- $ asciidoctor documentation/asciidoc/titles/js_client.asciidoc
65
+ npm run docs:user
67
66
  ```
68
67
 
69
- 3. Open `documentation/asciidoc/titles/js_client.html` in any browser.
68
+ Open `out/docs/index.html` in any browser.
70
69
 
71
70
  # API docs
72
71
 
73
72
  Review [Hot Rod JS client API documentation](http://docs.jboss.org/infinispan/hotrod-clients/javascript/1.0/apidocs/module-infinispan.html).
74
73
 
75
- You can also build API docs from the source repository as follows:
74
+ To generate API docs locally:
76
75
 
77
- 1. Generate JSDoc formatted API docs.
78
76
  ```bash
79
- $ npm install jsdoc
80
- $ ./node_modules/.bin/jsdoc lib/*.js
77
+ npm run docs:api
81
78
  ```
82
79
 
83
- 2. Open `open out/index.html` in any browser.
80
+ Open `out/index.html` in any browser.
84
81
 
85
82
  # Testing
86
83
 
87
- Before executing any tests, Infinispan Server instances need to be started
88
- up so that testsuite can run against those. To ease this process, a script
89
- has been created in the root directory to start all the expected server
90
- instances.
84
+ Tests run against Infinispan Server instances in Docker containers.
91
85
 
92
- Go to the root of the repo and execute:
86
+ ## Prerequisites
93
87
 
94
- ```bash
95
- $ npm install
96
- ```
88
+ - Docker and Docker Compose
89
+ - Java (for SSL certificate generation via `keytool`)
90
+ - Node.js 24+
97
91
 
98
- Next, start the Infinispan Servers via:
92
+ ## Running tests
99
93
 
100
94
  ```bash
101
- $ ./run-servers.sh
95
+ npm install
96
+ npm run test:docker
102
97
  ```
103
98
 
104
- To run the testsuite once execute:
105
-
106
- ```bash
107
- $ ./run-testsuite.sh
108
- ```
99
+ This starts all required containers, generates SSL certificates if needed,
100
+ waits for the cluster to form, runs the full test suite, and tears down
101
+ the containers on exit.
109
102
 
110
- To run tests continuously execute:
103
+ To test against a specific Infinispan version:
111
104
 
112
105
  ```bash
113
- $ ./node_modules/.bin/jasmine-node spec --autotest --watch lib --captureExceptions
106
+ INFINISPAN_VERSION=16.1.3 npm run test:docker
114
107
  ```
115
108
 
116
- To run individual tests execute:
109
+ ### Manual container lifecycle
117
110
 
118
- ```bash
119
- $ node node_modules/jasmine-node/lib/jasmine-node/cli.js spec/infinispan_local_spec.js --captureExceptions
120
- ```
121
-
122
- To help with testing, you can quickly run the smoke tests via:
111
+ For iterative development, start containers once and run tests repeatedly:
123
112
 
124
113
  ```bash
125
- $ ./smoke-tests.sh
114
+ npm run docker:up
115
+ npm test
116
+ # ... make changes ...
117
+ npm test
118
+ npm run docker:down
126
119
  ```
127
120
 
128
- Both testsuite and smoke tests can be run with older protocol versions, e.g.
121
+ ### Individual tests
129
122
 
130
- ```bash
131
- $ protocol=2.5 ./smoke-tests.sh
132
- ```
133
-
134
- ## Note for Mac Users:
135
- You might experience MPING issues running an Infinispan cluster.
123
+ With containers running:
136
124
 
137
125
  ```bash
138
- 13:37:15,561 ERROR (jgroups-5,server-two) [org.jgroups.protocols.MPING]
126
+ npx jasmine spec/infinispan_local_spec.js
139
127
  ```
140
128
 
141
- If you run into the errors above, add the following to the routes of your host
129
+ ### SSL certificates
130
+
131
+ Certificates are generated automatically on first test run. To regenerate:
142
132
 
143
133
  ```bash
144
- sudo route add -net 224.0.0.0/5 127.0.0.1
145
- sudo route add -net 232.0.0.0/5 192.168.1.3
134
+ npm run ssl:generate
146
135
  ```
147
136
 
148
- # Manual stress tests
137
+ ## Manual stress tests
149
138
 
150
- The testsuite now contains manual stress tests that take several minutes to run.
139
+ The testsuite contains manual stress tests that take several minutes to run.
151
140
  To run these tests, execute:
152
141
 
153
- $ ./node_modules/.bin/jasmine-node spec-manual --captureExceptions
154
-
142
+ ```bash
143
+ npx jasmine spec-manual/*_spec.js
144
+ ```
155
145
 
156
- # Memory profiling
146
+ ## Memory profiling
157
147
 
158
148
  The source code comes with some programs that allow the client's memory consumption to be profiled.
159
149
  Those programs rely on having access to the global garbage collector.
@@ -164,38 +154,20 @@ Example:
164
154
  node --expose-gc memory-profiling/infinispan_memory_many_get.js
165
155
  ```
166
156
 
167
- So of programs might only report the memory usage before/after.
157
+ Some programs might only report the memory usage before/after.
168
158
  Others might generate heap dumps which can be visualized using Google Chrome.
169
159
  Within Chrome, the Developer Tools UI contains a `Memory` tab where heap dumps can be loaded.
170
160
 
171
-
172
- # Debugging
161
+ ## Debugging
173
162
 
174
163
  To debug tests with IDE:
175
164
 
176
- node --inspect-brk node_modules/jasmine-node/lib/jasmine-node/cli.js spec/codec_spec.js
177
-
178
- Or:
179
-
180
- node --inspect-brk node_modules/jasmine-node/lib/jasmine-node/cli.js spec/infinispan_local_spec.js
165
+ ```bash
166
+ node --inspect-brk node_modules/.bin/jasmine spec/codec_spec.js
167
+ ```
181
168
 
182
169
  And then start a remote Node.js debugger from IDE on port 9229.
183
170
 
184
- # Tests, servers and ports
185
-
186
- Here's some more detailed information on which tests interact with which servers and on which ports.
187
- On top of that, you can find information on which tests are always running as opposed to those that are started (and stopped) by the tests themselves.
188
-
189
- | Test | Server Profile | Ports (Auto/Manual) |
190
- | :------------ | :-------------: | :-------------------------------------- |
191
- | local spec | local | `11222` (A) |
192
- | expiry spec | local | `11222` (A) |
193
- | cluster spec | clustered | `11322` (A), `11332` (A), `11342` (A) |
194
- | failover spec | clustered | `11422` (M), `11432` (M), `11442` (M) |
195
- | ssl spec | local | `11232` (A), `12242` (A), `12252` (A) |
196
- | xsite spec | earth, moon | `11522` (earth, M), `11532` (moon, M) |
197
-
198
171
  # Reporting an issue
199
172
 
200
- This project does not use Github issues.
201
- Instead, please report them via JIRA (project [HRJS](https://issues.jboss.org/projects/HRJS/summary)).
173
+ Report issues via [GitHub Issues](https://github.com/infinispan/js-client/issues).