Skip to content

Commit ec0b2d3

Browse files
committed
Changes to support resolving gRPC proxies via the Coherence name service.
1 parent 259402a commit ec0b2d3

12 files changed

+907
-66
lines changed

.github/workflows/node.js.yml .github/workflows/build.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Copyright 2020, 2023, Oracle Corporation and/or its affiliates. All rights reserved.
1+
# Copyright 2020, 2025, Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at
33
# https://oss.oracle.com/licenses/upl.
44

55
# ---------------------------------------------------------------------------
66
# Coherence JavaScript Client GitHub Actions CI build.
77
# ---------------------------------------------------------------------------
88

9-
name: Node.js CI
9+
name: JS Client Validation
1010

1111
on:
1212
schedule:
@@ -18,7 +18,7 @@ on:
1818
types:
1919
- opened
2020
branches:
21-
- 'main'
21+
- '*'
2222
jobs:
2323
build:
2424

@@ -28,7 +28,7 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
node-version: [18.x, 19.x, 20.x, 21.x, 22.x, 23.x]
31-
coherence-version: [22.06.11, 24.09.2]
31+
coherence-version: [22.06.11, 14.1.2-0-1, 24.09.2]
3232

3333
steps:
3434
- uses: actions/checkout@v4
@@ -48,7 +48,7 @@ jobs:
4848
- run: COHERENCE_VERSION=${{ matrix.coherence-version }} npm run test-cycle-tls
4949
# clean up
5050
- name: Archive production artifacts
51-
if: always()
51+
if: failure()
5252
uses: actions/upload-artifact@v4
5353
with:
5454
name: save-log-file-${{ matrix.node-version }}-${{ matrix.coherence-version }}

.github/workflows/discovery.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright 2025, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at
3+
# https://oss.oracle.com/licenses/upl.
4+
5+
# ---------------------------------------------------------------------------
6+
# Coherence JavaScript Client GitHub Actions CI build.
7+
# ---------------------------------------------------------------------------
8+
9+
name: JS Client Discovery Validation
10+
11+
on:
12+
schedule:
13+
- cron: "0 5 * * *"
14+
push:
15+
branches-ignore:
16+
- ghpages
17+
pull_request:
18+
types:
19+
- opened
20+
branches:
21+
- '*'
22+
jobs:
23+
build:
24+
25+
runs-on: ubuntu-latest
26+
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
node-version: [20.x, 21.x, 22.x, 23.x]
31+
coherence-version: [22.06.11, 14.1.2-0-1, 24.09.2]
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Use Node.js ${{ matrix.node-version }}
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ matrix.node-version }}
39+
- run: curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-linux-x86_64.zip"
40+
- run: unzip protoc-22.2-linux-x86_64.zip -d /tmp/grpc
41+
- run: echo "/tmp/grpc/bin" >> $GITHUB_PATH
42+
- run: npm install
43+
- run: npm run compile
44+
45+
- name: Run Coherence Server
46+
shell: bash
47+
run: |
48+
export COHERENCE_VERSION=${{ matrix.coherence-version }}
49+
curl -sL https://raw.githubusercontent.com/oracle/coherence-cli/main/scripts/install.sh | bash
50+
cohctl version
51+
cohctl set profile grpc-cluster1 -v "-Dcoherence.grpc.server.port=10000" -y
52+
cohctl create cluster grpc-cluster1 -P grpc-cluster1 -r 1 -v ${{ matrix.coherence-version }} -y -a coherence-grpc-proxy
53+
cohctl set profile grpc-cluster2 -v "-Dcoherence.grpc.server.port=10001" -y
54+
cohctl create cluster grpc-cluster2 -P grpc-cluster2 -r 1 -H 30001 -v ${{ matrix.coherence-version }} -y -a coherence-grpc-proxy
55+
sleep 20
56+
cohctl monitor health -n localhost:7574 -T 40 -w
57+
58+
- name: Run resolver tests
59+
shell: bash
60+
run: |
61+
npm run test-resolver
62+
63+
- name: Archive production artifacts
64+
if: failure()
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: save-log-file-${{ matrix.node-version }}-${{ matrix.coherence-version }}
68+
path: ~/.cohctl/logs/*.*.log

README.md

+32-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ the network transport.
1212
* Registration of listeners to be notified of map mutations
1313

1414
### Requirements
15-
* Coherence CE `22.06` or later (or equivalent non-open source editions) with a configured [gRPC Proxy](https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.2206/develop-remote-clients/using-coherence-grpc-server.html)
15+
* Coherence CE versions `22.06`, `14.1.2-0-0`, `24.09` or later (or equivalent non-open source editions) with a configured [gRPC Proxy](https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.2206/develop-remote-clients/using-coherence-grpc-server.html)
1616
* Node `18.15.x` or later
1717
* NPM `9.x` or later
1818

@@ -40,7 +40,7 @@ For more details on the image, see the [documentation](https://github.com/oracle
4040

4141
### Declare Your Dependency
4242

43-
To use the Coherence gRPC JavaScript Client, simply declare it as a dependency in your
43+
To use the JavaScript Client for Oracle Coherence, simply declare it as a dependency in your
4444
project's `package.json`:
4545
```
4646
...
@@ -52,8 +52,8 @@ project's `package.json`:
5252

5353
### Compatibility with Java Types
5454
The following table provides a listing of mappings between Java types and Javascript types when working with
55-
Coherence `23.09` or later. If using Coherence `22.06.x`, these types will be returned as Number. It is recommended
56-
using `23.09` if intentionally using `java.math.BigInteger` or `java.math.BigDecimal` as part of your application.
55+
Coherence `24.09` or later. If using Coherence `22.06.x`, these types will be returned as Number. It is recommended
56+
using `24.09` if intentionally using `java.math.BigInteger` or `java.math.BigDecimal` as part of your application.
5757

5858
| Java Type | JavascriptType |
5959
|----------------------|------------------------|
@@ -68,15 +68,15 @@ using `23.09` if intentionally using `java.math.BigInteger` or `java.math.BigDec
6868
#### Establishing a Session
6969

7070
The Coherence uses the concept of a `Session` to manage a set of related Coherence resources,
71-
such as maps and/or caches. When using the Coherence JavaScript Client, a `Session` connects to a specific
71+
such as maps and/or caches. When using the JavaScript Client for Oracle Coherence, a `Session` connects to a specific
7272
gRPC endpoint and uses a specific serialization format to marshal requests and responses.
7373
This means that different sessions using different serializers may connect to the same server endpoint. Typically,
7474
for efficiency the client and server would be configured to use matching serialization formats to avoid
7575
deserialization of data on the server, but this does not have to be the case. If the server is using a different
7676
serializer for the server-side caches, it must be able to deserialize the client's requests, so there must be
7777
a serializer configured on the server to match that used by the client.
7878

79-
> NOTE: Currently, the Coherence JavaScript client only supports JSON serialization
79+
> NOTE: Currently, the JavaScript Client for Oracle Coherence only supports JSON serialization
8080
8181
A `Session` is constructed using an `Options` instance, or a generic object with the same keys and values.
8282

@@ -126,6 +126,32 @@ const opts = new Options({address: 'example.com:4444'})
126126
let session = new Session(opts)
127127
```
128128

129+
As of v1.2.3 of the JavaScript Client for Oracle Coherence, it's now possible to use the Coherence
130+
NameService to lookup gRPC Proxy endpoints. The format to enable this feature is
131+
`coherence:///<host>([:port]|[:cluster-name]|[:port:cluster-name])`
132+
133+
For example:
134+
* `coherence:///localhost` will connect to the name service bound to a local coherence cluster on port `7574` (the default Coherence cluster port).
135+
* `coherence:///localhost:8000` will connect to the name service bound to a local coherence cluster on port `8000`.
136+
* `coherence:///localhost:remote-cluster` will connect to the name service bound to a local coherence cluster on port `7574` (the default Coherence cluster port) and look up the name service for the given cluster name. Note: this typically means both clusters have a local member sharing a cluster port.
137+
* `coherence:///localhost:8000:remote-cluster` will connect to the name service bound to a local coherence cluster on port `8000` and look up the name service for the given cluster name. Note: this typically means both clusters have a local member sharing a cluster port.
138+
139+
While this is useful for local development, this may have limited uses in a production environment. For example,
140+
Coherence running within a container with the cluster port (`7574`) exposed so external clients may connect. The
141+
lookup will fail to work for the client as the Coherence name service return a private network address which
142+
won't resolve. Lastly, if connecting to a cluster that has multiple proxies bound to different ports, gRPC, by default,
143+
will use the first address returned by the resolver. It is possible to enable round-robin load balancing by including
144+
a custom channel option when creating the session:
145+
146+
```typescript
147+
const { Session } = require('@oracle/coherence')
148+
149+
const opts = new Options({address: 'example.com:4444',
150+
channelOptions: {'grpc.service_config': JSON.stringify({ loadBalancingConfig: [{ round_robin: {} }], })}})
151+
152+
let session = new Session(opts)
153+
```
154+
129155
It's also possible to control the default address the session will bind to by providing
130156
an address via the `COHERENCE_SERVER_ADDRESS` environment variable. The format of the value would
131157
be the same as if you configured it programmatically as the above example shows.

etc/docker-compose-2-members.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
- "9612:9612"
2020
- "8080:8080"
2121
- "6676:6676"
22+
- "7574:7574"
2223
volumes:
2324
- .:/args
2425
- ./cert:/certs

etc/jvm-args-clear.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Copyright (c) 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates.
22
#
33
# Licensed under the Universal Permissive License v 1.0 as shown at
44
# https://oss.oracle.com/licenses/upl.
55

66
-Xms1g
77
-Xmx1g
88
-Dcoherence.log.level=9
9-
-Dcoherence.io.json.debug=true
9+
-Dcoherence.io.json.debug=false

etc/jvm-args-tls.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Copyright (c) 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates.
22
#
33
# Licensed under the Universal Permissive License v 1.0 as shown at
44
# https://oss.oracle.com/licenses/upl.
55

66
-Xms1g
77
-Xmx1g
88
-Dcoherence.log.level=9
9-
-Dcoherence.io.json.debug=true
9+
-Dcoherence.io.json.debug=false
1010
-Dcoherence.grpc.server.socketprovider=tls-files
1111
-Dcoherence.security.key=/certs/star-lord.pem
1212
-Dcoherence.security.cert=/certs/star-lord.crt

0 commit comments

Comments
 (0)