├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── support-question--rfa-.md └── workflows │ ├── build-checks.yaml │ ├── build-compatability-1412.yaml │ ├── build-compatability-2206.yaml │ ├── build-compatability-v1-1412.yaml │ ├── build-compatability-v1.yaml │ ├── build-compatability.yaml │ ├── build-kind.yaml │ ├── build-perf.yaml │ ├── build-queues-1412.yaml │ ├── build-queues.yaml │ ├── build-trivy.yaml │ ├── build-v1.yaml │ ├── build.yaml │ ├── discovery-compatability-tests.yaml │ ├── examples-jakarta-v1.2.2.yaml │ ├── examples-jakarta.yaml │ ├── examples-v1.2.2.yaml │ ├── examples.yaml │ ├── resolver-clusters-compatability-tests.yaml │ ├── resolver-compatability-tests.yaml │ ├── streaming-jakarta.yaml │ └── streaming.yaml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── Makefile ├── README.md ├── SECURITY.md ├── THIRD_PARTY_LICENSES.txt ├── coherence ├── aggregators │ ├── aggregators.go │ └── doc.go ├── cache.go ├── coherence_test_helpers.go ├── common.go ├── discovery │ ├── doc.go │ ├── nslookup.go │ └── nslookup_test.go ├── doc.go ├── event.go ├── event_test.go ├── extractors │ ├── doc.go │ └── extractors.go ├── filters │ ├── doc.go │ └── filters.go ├── iterator.go ├── localcache.go ├── localcache_test.go ├── log_level_test.go ├── named_cache_client.go ├── named_cache_client_test.go ├── named_map_client.go ├── processors │ ├── doc.go │ └── processors.go ├── queue.go ├── queue_dequeue.go ├── queue_events.go ├── resolver.go ├── resolver_test.go ├── serializers.go ├── serializers_test.go ├── session.go ├── session_test.go ├── v1client.go ├── v1event.go ├── v1iterator.go ├── v1queues.go └── v1requests.go ├── examples ├── README.md ├── aggregators │ ├── basic │ │ └── main.go │ └── explain │ │ └── main.go ├── basic │ ├── README.md │ ├── contains │ │ └── main.go │ ├── crud │ │ └── main.go │ ├── expiry │ │ └── main.go │ ├── expiry_cache │ │ └── main.go │ ├── near_cache │ │ ├── high_units │ │ │ └── main.go │ │ ├── memory │ │ │ └── main.go │ │ └── ttl │ │ │ └── main.go │ ├── struct │ │ └── main.go │ └── struct_keys │ │ └── main.go ├── custom │ ├── comparators │ │ └── java │ │ │ └── com │ │ │ └── oracle │ │ │ └── coherence │ │ │ └── example │ │ │ └── CustomComparator.java │ └── entry_processors │ │ └── java │ │ └── com │ │ └── oracle │ │ └── coherence │ │ └── example │ │ └── UppercaseProcessor.java ├── doc.go ├── events │ ├── cache │ │ ├── all │ │ │ └── main.go │ │ ├── delete │ │ │ └── main.go │ │ ├── doc.go │ │ ├── filters │ │ │ └── main.go │ │ ├── insert │ │ │ └── main.go │ │ ├── key │ │ │ └── main.go │ │ ├── people_insert │ │ │ └── main.go │ │ ├── people_listen │ │ │ └── main.go │ │ └── update │ │ │ └── main.go │ ├── doc.go │ ├── lifecycle │ │ ├── all │ │ │ └── main.go │ │ ├── destroyed │ │ │ └── main.go │ │ ├── released │ │ │ └── main.go │ │ └── truncated │ │ │ └── main.go │ └── session │ │ └── all │ │ └── main.go ├── indexes │ ├── doc.go │ └── main.go ├── processors │ ├── blind │ │ └── main.go │ └── standard │ │ └── main.go ├── querying │ ├── filters │ │ └── main.go │ ├── filters_sorted │ │ └── main.go │ ├── keys │ │ └── main.go │ └── main.go ├── queues │ ├── dequeue │ │ └── main.go │ ├── doc.go │ ├── events │ │ └── main.go │ └── standard │ │ └── main.go └── rest │ └── main.go ├── go.mod ├── go.sum ├── java ├── coherence-go-client-data-jakarta │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── oracle │ │ └── coherence │ │ └── go │ │ └── testing │ │ ├── Address.java │ │ └── Customer.java ├── coherence-go-client-data-javax │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── oracle │ │ └── coherence │ │ └── go │ │ └── testing │ │ ├── Address.java │ │ └── Customer.java ├── coherence-go-queues │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── oracle │ │ └── coherence │ │ └── go │ │ └── queues │ │ └── PopulateQueue.java ├── coherence-go-test │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── coherence │ │ │ └── go │ │ │ └── testing │ │ │ ├── LongEntryProcessor.java │ │ │ ├── RestServer.java │ │ │ ├── SimpleCacheLoader.java │ │ │ └── package-info.java │ │ └── resources │ │ ├── META-INF │ │ └── type-aliases.properties │ │ └── test-cache-config.xml └── pom.xml ├── proto ├── doc.go ├── messages.pb.go ├── services.pb.go ├── services_grpc.pb.go └── v1 │ ├── cache_service_messages_v1.pb.go │ ├── common_messages_v1.pb.go │ ├── proxy_service_messages_v1.pb.go │ ├── proxy_service_v1.pb.go │ ├── proxy_service_v1_grpc.pb.go │ └── queue_service_messages_v1.pb.go ├── scripts ├── copyright.txt ├── download-protoc.sh ├── keys.sh ├── kind │ ├── coherence-cluster.yaml │ ├── kind-config.yaml │ ├── kind-label-node.sh │ ├── kind.sh │ ├── load-schools.yaml │ ├── roll-cluster.sh │ └── test-schools.yaml ├── perf-cluster.sh ├── run-compat-ce.sh ├── run-compat-commercial.sh ├── run-test-examples.sh └── startup-clusters.sh └── test ├── doc.go ├── e2e ├── discovery │ ├── run_test.go │ └── suite_test.go ├── kind │ ├── Dockerfile │ └── main.go ├── perf │ ├── run_test.go │ └── suite_test.go ├── queues │ ├── doc.go │ ├── queues_test.go │ └── suite_test.go ├── resolver │ ├── run_test.go │ └── suite_test.go ├── resolver_cluster │ ├── run_test.go │ └── suite_test.go ├── scope │ ├── doc.go │ ├── named_map_test.go │ └── suite_test.go ├── standalone │ ├── aggregator_test.go │ ├── doc.go │ ├── event_test.go │ ├── filter_test.go │ ├── index_test.go │ ├── java_object_test.go │ ├── lifecycle_test.go │ ├── named_cache_test.go │ ├── named_map_test.go │ ├── near_cache_test.go │ ├── processor_test.go │ ├── session_test.go │ └── suite_test.go └── streaming │ ├── streaming_test.go │ └── suite_test.go ├── utils ├── doc.go ├── docker-compose-2-members.yaml └── utils.go └── v1 └── base ├── base_events_test.go ├── base_test.go ├── doc.go └── suite_test.go /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This is the GitHub CODEOWNERS file that defines ownership of different source files. 2 | # See: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 3 | # 4 | # We specifically use this to ensure that pull requests must be approved by a code owner 5 | # 6 | 7 | 8 | # This is a global pattern matching all files anw owned by members of the oracle/coherence-dev-team team 9 | 10 | * @oracle/coherence-dev-team -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behaviour: 15 | 16 | **Expected behaviour** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Environment (please complete the following information):** 23 | - Coherence Go Client Version 24 | - Go Version - output of `go version` 25 | - Coherence cluster version you are connecting to 26 | - Coherence cluster edition: Community Edition/Enterprise Edition or Grid Edition 27 | - Java version and Java vendor used for Coherence 28 | - OS Coherence cluster is running on: [e.g. Linux] 29 | - OS Version Coherence cluster is running onL [e.g. OEL7] 30 | - Is this a container/cloud environment, e.g. Docker, CRI-O, Kubernetes, if so include additional information about the container environment, versions etc. 31 | 32 | **Additional context** 33 | Add any other context about the problem here. 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Enhancement Request 11 | 12 | **Is your feature request related to a problem? Please describe.** 13 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 14 | 15 | **Describe the solution you'd like** 16 | A clear and concise description of what you want to happen. 17 | 18 | **Describe alternatives you've considered** 19 | A clear and concise description of any alternative solutions or features you've considered. 20 | 21 | **Additional context** 22 | Add any other context or screenshots about the feature request here. 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support-question--rfa-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support Question (RFA) 3 | about: Support questions and requests for advice 4 | title: '' 5 | labels: RFA 6 | assignees: '' 7 | 8 | --- 9 | 10 | 17 | 18 | ## Type of question 19 | 20 | **Are you asking how to use a specific feature, or about general context and help around Coherence?** 21 | 22 | ## Question 23 | 24 | **What did you do?** 25 | A clear and concise description of the steps you took (or insert a code snippet). 26 | 27 | **What did you expect to see?** 28 | A clear and concise description of what you expected to happen (or insert a code snippet). 29 | 30 | **What did you see instead? Under which circumstances?** 31 | A clear and concise description of what you expected to happen (or insert a code snippet). 32 | 33 | 34 | **Environment** 35 | * Coherence Go Client version: 36 | 37 | insert release or Git SHA here 38 | 39 | * Coherence Cluster version: 40 | 41 | insert Coherence cluster version here 42 | 43 | * Go Version 44 | 45 | insert output of `go version` 46 | 47 | **Additional context** 48 | Add any other context about the question here. 49 | -------------------------------------------------------------------------------- /.github/workflows/build-checks.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions CI build - Checks 7 | # --------------------------------------------------------------------------- 8 | name: CI - Checks 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-24.04 19 | timeout-minutes: 60 20 | strategy: 21 | matrix: 22 | go-version: 23 | - 1.23.x 24 | 25 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 26 | # the copyright check cannot work out the date of the files from Git. 27 | steps: 28 | - uses: actions/checkout@v4 29 | with: 30 | fetch-depth: 0 31 | 32 | - name: Copyright Check 33 | shell: bash 34 | run: | 35 | make copyright 36 | 37 | - name: Golangci 38 | shell: bash 39 | run: | 40 | make golangci -------------------------------------------------------------------------------- /.github/workflows/build-perf.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions CI Perf Tests 7 | # --------------------------------------------------------------------------- 8 | name: CI Perf Tests 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches-ignore: 14 | - gh-pages 15 | schedule: 16 | # Every day at midnight 17 | - cron: '0 0 * * *' 18 | 19 | jobs: 20 | build: 21 | runs-on: ubuntu-latest 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | coherenceVersion: 28 | - 14.1.2-0-2 29 | - 25.03.1 30 | go-version: 31 | - 1.23.x 32 | - 1.24.x 33 | 34 | 35 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 36 | # the copyright check cannot work out the date of the files from Git. 37 | steps: 38 | - uses: actions/checkout@v4 39 | with: 40 | fetch-depth: 0 41 | 42 | - name: Set up JDK 43 | uses: actions/setup-java@v4 44 | with: 45 | java-version: '17' 46 | distribution: 'zulu' 47 | 48 | - name: Cache Go Modules 49 | uses: actions/cache@v4 50 | with: 51 | path: ~/go/pkg/mod 52 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 53 | restore-keys: | 54 | ${{ runner.os }}-go-mods- 55 | 56 | - name: Cache Maven packages 57 | uses: actions/cache@v4 58 | with: 59 | path: ~/.m2 60 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 61 | restore-keys: ${{ runner.os }}-m2 62 | 63 | - name: Set up Go 64 | uses: actions/setup-go@v5 65 | with: 66 | go-version: '${{ matrix.go-version }}' 67 | 68 | - name: Run Perf Test 69 | shell: bash 70 | run: | 71 | curl --retry 5 --retry-delay 2 -sL https://raw.githubusercontent.com/oracle/coherence-cli/main/scripts/install.sh | bash 72 | COHERENCE_CLIENT_REQUEST_TIMEOUT=200000 COHERENCE_VERSION=${{ matrix.coherenceVersion }} make test-perf 73 | 74 | - uses: actions/upload-artifact@v4 75 | if: failure() 76 | with: 77 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 78 | path: build/_output/test-logs 79 | 80 | - uses: actions/upload-artifact@v4 81 | with: 82 | name: test-result-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 83 | path: test/e2e/perf/results.txt 84 | -------------------------------------------------------------------------------- /.github/workflows/build-queues-1412.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions CI build Queues - 14.1.2 7 | # --------------------------------------------------------------------------- 8 | name: CI Queues - 14.1.2 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | schedule: 16 | # Every day at midnight 17 | - cron: '0 0 * * *' 18 | 19 | jobs: 20 | build: 21 | runs-on: ubuntu-22.04 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | coherenceVersion: 28 | - 14.1.2-0-2 29 | - 14.1.2-0-3-SNAPSHOT 30 | go-version: 31 | - 1.23.x 32 | - 1.24.x 33 | 34 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 35 | # the copyright check cannot work out the date of the files from Git. 36 | steps: 37 | - uses: actions/checkout@v4 38 | with: 39 | fetch-depth: 0 40 | 41 | - name: Get Docker Images 42 | shell: bash 43 | run: | 44 | docker pull gcr.io/distroless/java17-debian12 45 | 46 | - name: Set up JDK 17 for Build 47 | uses: actions/setup-java@v4 48 | with: 49 | java-version: '17' 50 | distribution: 'zulu' 51 | 52 | - name: Cache Go Modules 53 | uses: actions/cache@v4 54 | with: 55 | path: ~/go/pkg/mod 56 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 57 | restore-keys: | 58 | ${{ runner.os }}-go-mods- 59 | 60 | - name: Cache Maven packages 61 | uses: actions/cache@v4 62 | with: 63 | path: ~/.m2 64 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 65 | restore-keys: ${{ runner.os }}-m2 66 | 67 | - name: Set up Go 68 | uses: actions/setup-go@v5 69 | with: 70 | go-version: '${{ matrix.go-version }}' 71 | 72 | - name: E2E Queue Tests 73 | env: 74 | COH_VERSION: ${{ matrix.coherenceVersion }} 75 | shell: bash 76 | run: | 77 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 78 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 INCLUDE_LONG_RUNNING=true PROFILES=,-jakarta,javax,queues COHERENCE_VERSION=$COH_VERSION make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone-queues 79 | 80 | - uses: actions/upload-artifact@v4 81 | if: failure() 82 | with: 83 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 84 | path: build/_output/test-logs 85 | -------------------------------------------------------------------------------- /.github/workflows/build-queues.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions CI build Queues 7 | # --------------------------------------------------------------------------- 8 | name: CI Queues 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | schedule: 16 | # Every day at midnight 17 | - cron: '0 0 * * *' 18 | 19 | jobs: 20 | build: 21 | runs-on: ubuntu-22.04 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | coherenceVersion: 28 | - 25.03.1 29 | - 25.03.2-SNAPSHOT 30 | go-version: 31 | - 1.23.x 32 | - 1.24.x 33 | 34 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 35 | # the copyright check cannot work out the date of the files from Git. 36 | steps: 37 | - uses: actions/checkout@v4 38 | with: 39 | fetch-depth: 0 40 | 41 | - name: Get Docker Images 42 | shell: bash 43 | run: | 44 | docker pull gcr.io/distroless/java17-debian12 45 | 46 | - name: Set up JDK 17 for Build 47 | uses: actions/setup-java@v4 48 | with: 49 | java-version: '17' 50 | distribution: 'zulu' 51 | 52 | - name: Cache Go Modules 53 | uses: actions/cache@v4 54 | with: 55 | path: ~/go/pkg/mod 56 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 57 | restore-keys: | 58 | ${{ runner.os }}-go-mods- 59 | 60 | - name: Cache Maven packages 61 | uses: actions/cache@v4 62 | with: 63 | path: ~/.m2 64 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 65 | restore-keys: ${{ runner.os }}-m2 66 | 67 | - name: Set up Go 68 | uses: actions/setup-go@v5 69 | with: 70 | go-version: '${{ matrix.go-version }}' 71 | 72 | - name: E2E Queue Tests 73 | env: 74 | COH_VERSION: ${{ matrix.coherenceVersion }} 75 | shell: bash 76 | run: | 77 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 78 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 INCLUDE_LONG_RUNNING=true PROFILES=,jakarta,-javax,queues COHERENCE_VERSION=$COH_VERSION make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone-queues 79 | 80 | - uses: actions/upload-artifact@v4 81 | if: failure() 82 | with: 83 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 84 | path: build/_output/test-logs 85 | -------------------------------------------------------------------------------- /.github/workflows/build-trivy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023, 2024 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions Scheduled Trivy Scan 7 | # --------------------------------------------------------------------------- 8 | name: Scheduled Trivy Scan 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | schedule: 16 | # Every day at midnight 17 | - cron: '0 0 * * *' 18 | 19 | jobs: 20 | build: 21 | runs-on: ubuntu-22.04 22 | 23 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 24 | # the copyright check cannot work out the date of the files from Git. 25 | steps: 26 | - uses: actions/checkout@v4 27 | with: 28 | fetch-depth: 0 29 | 30 | - name: Setup oras 31 | run: | 32 | VERSION="1.2.0" 33 | curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz" 34 | mkdir -p oras-install/ 35 | tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/ 36 | sudo mv oras-install/oras /usr/local/bin/ 37 | rm -rf oras_${VERSION}_*.tar.gz oras-install/ 38 | 39 | - name: Get current date 40 | id: date 41 | run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT 42 | 43 | - name: Download and extract the vulnerability DB 44 | run: | 45 | mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db 46 | oras pull ghcr.io/aquasecurity/trivy-db:2 47 | tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db 48 | rm db.tar.gz 49 | 50 | - name: Download and extract the Java DB 51 | run: | 52 | mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db 53 | oras pull ghcr.io/aquasecurity/trivy-java-db:1 54 | tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db 55 | rm javadb.tar.gz 56 | 57 | - name: Trivy Scan 58 | shell: bash 59 | run: | 60 | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin 61 | export TRIVY_CACHE=$GITHUB_WORKSPACE/.cache/trivy 62 | make trivy-scan -------------------------------------------------------------------------------- /.github/workflows/build-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions CI build V1. 7 | # --------------------------------------------------------------------------- 8 | name: CI - V1 Base 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | timeout-minutes: 60 22 | strategy: 23 | matrix: 24 | go-version: 25 | - 1.23.x 26 | - 1.24.x 27 | coherence-version: 28 | - 25.03 29 | - 25.03.1 30 | - 25.03.2-SNAPSHOT 31 | 32 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 33 | # the copyright check cannot work out the date of the files from Git. 34 | steps: 35 | - uses: actions/checkout@v4 36 | with: 37 | fetch-depth: 0 38 | 39 | - name: Get Docker Images 40 | shell: bash 41 | run: | 42 | docker pull gcr.io/distroless/java17-debian12 43 | docker pull gcr.io/distroless/java11-debian11 44 | uname -a 45 | 46 | - name: Set up JDK 47 | uses: actions/setup-java@v4 48 | with: 49 | java-version: '17' 50 | distribution: 'zulu' 51 | 52 | - name: Cache Go Modules 53 | uses: actions/cache@v4 54 | with: 55 | path: ~/go/pkg/mod 56 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 57 | restore-keys: | 58 | ${{ runner.os }}-go-mods- 59 | 60 | - name: Cache Maven packages 61 | uses: actions/cache@v4 62 | with: 63 | path: ~/.m2 64 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 65 | restore-keys: ${{ runner.os }}-m2 66 | 67 | - name: Set up Go 68 | uses: actions/setup-go@v5 69 | with: 70 | go-version: '${{ matrix.go-version }}' 71 | 72 | - name: gRPC V1 Base Tests 73 | shell: bash 74 | run: | 75 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 76 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 PROFILES=,jakarta,-javax COHERENCE_VERSION=${{ matrix.coherence-version }} make clean generate-proto generate-proto-v1 build-test-images test-v1-base 77 | 78 | - uses: actions/upload-artifact@v4 79 | if: failure() 80 | with: 81 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherence-version }} 82 | path: build/_output/test-logs 83 | -------------------------------------------------------------------------------- /.github/workflows/discovery-compatability-tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Discovery Compatability Tests 7 | # --------------------------------------------------------------------------- 8 | name: Discovery Compatability 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | coherenceVersion: 25 | - 22.06.12 26 | - 22.06.13-SNAPSHOT 27 | - 25.03.1 28 | - 14.1.2-0-2 29 | - 14.1.2-0-3-SNAPSHOT 30 | go-version: 31 | - 1.23.x 32 | - 1.24.x 33 | 34 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 35 | # the copyright check cannot work out the date of the files from Git. 36 | steps: 37 | - uses: actions/checkout@v4 38 | with: 39 | fetch-depth: 0 40 | 41 | - name: Set up JDK 42 | uses: actions/setup-java@v4 43 | with: 44 | java-version: '17' 45 | distribution: 'zulu' 46 | 47 | - name: Cache Go Modules 48 | uses: actions/cache@v4 49 | with: 50 | path: ~/go/pkg/mod 51 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 52 | restore-keys: | 53 | ${{ runner.os }}-go-mods- 54 | 55 | - name: Cache Maven packages 56 | uses: actions/cache@v4 57 | with: 58 | path: ~/.m2 59 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 60 | restore-keys: ${{ runner.os }}-m2 61 | 62 | - name: Set up Go 63 | uses: actions/setup-go@v5 64 | with: 65 | go-version: '${{ matrix.go-version }}' 66 | 67 | - name: Discovery Compatability Tests 68 | shell: bash 69 | run: | 70 | export COHERENCE_VERSION=${{ matrix.coherenceVersion }} 71 | make clean test-clean test-discovery 72 | 73 | - uses: actions/upload-artifact@v4 74 | if: failure() 75 | with: 76 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 77 | path: build/_output/test-logs 78 | -------------------------------------------------------------------------------- /.github/workflows/examples-jakarta-v1.2.2.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions test examples against v23.03+ 7 | # and v1.2.2 client 8 | # --------------------------------------------------------------------------- 9 | name: CI-Examples Jakarta - v1.2.2 10 | 11 | on: 12 | workflow_dispatch: 13 | push: 14 | branches: 15 | - '*' 16 | 17 | jobs: 18 | build: 19 | runs-on: ubuntu-22.04 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | coherenceVersion: 26 | - 25.03 27 | - 25.03.1 28 | - 25.03.2-SNAPSHOT 29 | go-version: 30 | - 1.21.x 31 | - 1.22.x 32 | - 1.23.x 33 | - 1.24.x 34 | 35 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 36 | # the copyright check cannot work out the date of the files from Git. 37 | steps: 38 | - uses: actions/checkout@v4 39 | with: 40 | fetch-depth: 0 41 | 42 | - name: Get Docker Images 43 | shell: bash 44 | run: | 45 | docker pull gcr.io/distroless/java17-debian12 46 | uname -a 47 | 48 | - name: Set up JDK 49 | uses: actions/setup-java@v4 50 | with: 51 | java-version: '17' 52 | distribution: 'zulu' 53 | 54 | - name: Cache Go Modules 55 | uses: actions/cache@v4 56 | with: 57 | path: ~/go/pkg/mod 58 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 59 | restore-keys: | 60 | ${{ runner.os }}-go-mods- 61 | 62 | - name: Cache Maven packages 63 | uses: actions/cache@v4 64 | with: 65 | path: ~/.m2 66 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 67 | restore-keys: ${{ runner.os }}-m2 68 | 69 | - name: Set up Go 70 | uses: actions/setup-go@v5 71 | with: 72 | go-version: '${{ matrix.go-version }}' 73 | 74 | - name: Verify Examples 75 | shell: bash 76 | run: | 77 | # Alias curl to use retries 78 | alias curl='curl -L --retry 10 --retry-delay 5 -w "\nHTTP status: %{http_code}\n"' 79 | git checkout v1.2.2 80 | # Change the jib-maven-plugin as this version fails 81 | sed -i.bak 's/3\.3\.0<\/version.plugin.jib>/3.4.3<\/version.plugin.jib>/' java/pom.xml 82 | go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 83 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=${{ matrix.coherenceVersion }} PROFILES=,jakarta,-javax make clean generate-proto build-test-images test-cluster-startup test-examples 84 | make test-cluster-shutdown || true 85 | 86 | - uses: actions/upload-artifact@v4 87 | if: failure() 88 | with: 89 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 90 | path: build/_output/test-logs 91 | -------------------------------------------------------------------------------- /.github/workflows/examples-jakarta.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions test examples against v23.03+ 7 | # --------------------------------------------------------------------------- 8 | name: CI-Examples Jakarta 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | coherenceVersion: 25 | - 25.03.1 26 | - 25.03.2-SNAPSHOT 27 | go-version: 28 | - 1.23.x 29 | - 1.24.x 30 | 31 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 32 | # the copyright check cannot work out the date of the files from Git. 33 | steps: 34 | - uses: actions/checkout@v4 35 | with: 36 | fetch-depth: 0 37 | 38 | - name: Get Docker Images 39 | shell: bash 40 | run: | 41 | docker pull gcr.io/distroless/java17-debian12 42 | uname -a 43 | 44 | - name: Set up JDK 45 | uses: actions/setup-java@v4 46 | with: 47 | java-version: '17' 48 | distribution: 'zulu' 49 | 50 | - name: Cache Go Modules 51 | uses: actions/cache@v4 52 | with: 53 | path: ~/go/pkg/mod 54 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 55 | restore-keys: | 56 | ${{ runner.os }}-go-mods- 57 | 58 | - name: Cache Maven packages 59 | uses: actions/cache@v4 60 | with: 61 | path: ~/.m2 62 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 63 | restore-keys: ${{ runner.os }}-m2 64 | 65 | - name: Set up Go 66 | uses: actions/setup-go@v5 67 | with: 68 | go-version: '${{ matrix.go-version }}' 69 | 70 | - name: Verify Examples 71 | shell: bash 72 | run: | 73 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 74 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=${{ matrix.coherenceVersion }} PROFILES=,jakarta,-javax make clean generate-proto build-test-images test-cluster-startup test-examples 75 | make test-cluster-shutdown || true 76 | 77 | - uses: actions/upload-artifact@v4 78 | if: failure() 79 | with: 80 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 81 | path: build/_output/test-logs 82 | -------------------------------------------------------------------------------- /.github/workflows/examples-v1.2.2.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions test examples against v22.06 versions 7 | # and v1.2.2 client 8 | # --------------------------------------------------------------------------- 9 | name: CI-Examples v22.06 - v1.2.2 10 | 11 | on: 12 | workflow_dispatch: 13 | push: 14 | branches: 15 | - '*' 16 | 17 | jobs: 18 | build: 19 | runs-on: ubuntu-22.04 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | coherenceVersion: 26 | - 22.06.13-SNAPSHOT 27 | - 22.06.12 28 | go-version: 29 | - 1.21.x 30 | - 1.22.x 31 | - 1.23.x 32 | - 1.24.x 33 | 34 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 35 | # the copyright check cannot work out the date of the files from Git. 36 | steps: 37 | - uses: actions/checkout@v4 38 | with: 39 | fetch-depth: 0 40 | 41 | - name: Get Docker Images 42 | shell: bash 43 | run: | 44 | docker pull gcr.io/distroless/java11-debian11 45 | uname -a 46 | 47 | - name: Set up JDK 48 | uses: actions/setup-java@v4 49 | with: 50 | java-version: '11' 51 | distribution: 'zulu' 52 | 53 | - name: Cache Go Modules 54 | uses: actions/cache@v4 55 | with: 56 | path: ~/go/pkg/mod 57 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 58 | restore-keys: | 59 | ${{ runner.os }}-go-mods- 60 | 61 | - name: Cache Maven packages 62 | uses: actions/cache@v4 63 | with: 64 | path: ~/.m2 65 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 66 | restore-keys: ${{ runner.os }}-m2 67 | 68 | - name: Set up Go 69 | uses: actions/setup-go@v5 70 | with: 71 | go-version: '${{ matrix.go-version }}' 72 | 73 | - name: Verify Examples 74 | shell: bash 75 | run: | 76 | # Alias curl to use retries 77 | alias curl='curl -L --retry 10 --retry-delay 5 -w "\nHTTP status: %{http_code}\n"' 78 | git checkout v1.2.2 79 | # Change the jib-maven-plugin as this version fails 80 | sed -i.bak 's/3\.3\.0<\/version.plugin.jib>/3.4.3<\/version.plugin.jib>/' java/pom.xml 81 | go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 82 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java11-debian11 COHERENCE_VERSION=${{ matrix.coherenceVersion }} PROFILES=,-jakarta,javax make clean generate-proto build-test-images test-cluster-startup test-examples 83 | make test-cluster-shutdown || true 84 | 85 | - uses: actions/upload-artifact@v4 86 | if: failure() 87 | with: 88 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 89 | path: build/_output/test-logs 90 | -------------------------------------------------------------------------------- /.github/workflows/examples.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions test examples against v22.06 versions 7 | # --------------------------------------------------------------------------- 8 | name: CI-Examples v22.06 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | coherenceVersion: 25 | - 22.06.13-SNAPSHOT 26 | - 22.06.12 27 | - 14.1.2-0-2 28 | - 14.1.2-0-3-SNAPSHOT 29 | go-version: 30 | - 1.23.x 31 | - 1.24.x 32 | 33 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 34 | # the copyright check cannot work out the date of the files from Git. 35 | steps: 36 | - uses: actions/checkout@v4 37 | with: 38 | fetch-depth: 0 39 | 40 | - name: Get Docker Images 41 | shell: bash 42 | run: | 43 | docker pull gcr.io/distroless/java17-debian12 44 | 45 | - name: Set up JDK 46 | uses: actions/setup-java@v4 47 | with: 48 | java-version: '17' 49 | distribution: 'zulu' 50 | 51 | - name: Cache Go Modules 52 | uses: actions/cache@v4 53 | with: 54 | path: ~/go/pkg/mod 55 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 56 | restore-keys: | 57 | ${{ runner.os }}-go-mods- 58 | 59 | - name: Cache Maven packages 60 | uses: actions/cache@v4 61 | with: 62 | path: ~/.m2 63 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 64 | restore-keys: ${{ runner.os }}-m2 65 | 66 | - name: Set up Go 67 | uses: actions/setup-go@v5 68 | with: 69 | go-version: '${{ matrix.go-version }}' 70 | 71 | - name: Verify Examples 72 | shell: bash 73 | run: | 74 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 75 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=${{ matrix.coherenceVersion }} PROFILES=,-jakarta,javax make clean generate-proto generate-proto-v1 build-test-images test-cluster-startup test-examples 76 | make test-cluster-shutdown || true 77 | 78 | - uses: actions/upload-artifact@v4 79 | if: failure() 80 | with: 81 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 82 | path: build/_output/test-logs 83 | -------------------------------------------------------------------------------- /.github/workflows/resolver-clusters-compatability-tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Resolver Compatability Tests for Multiple Clusters 7 | # --------------------------------------------------------------------------- 8 | name: Resolver Compatability Multiple 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | coherenceVersion: 25 | - 22.06.12 26 | - 25.03.1 27 | - 14.1.2-0-2 28 | go-version: 29 | - 1.23.x 30 | - 1.24.x 31 | 32 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 33 | # the copyright check cannot work out the date of the files from Git. 34 | steps: 35 | - uses: actions/checkout@v4 36 | with: 37 | fetch-depth: 0 38 | 39 | - name: Set up JDK 40 | uses: actions/setup-java@v4 41 | with: 42 | java-version: '17' 43 | distribution: 'zulu' 44 | 45 | - name: Cache Go Modules 46 | uses: actions/cache@v4 47 | with: 48 | path: ~/go/pkg/mod 49 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 50 | restore-keys: | 51 | ${{ runner.os }}-go-mods- 52 | 53 | - name: Cache Maven packages 54 | uses: actions/cache@v4 55 | with: 56 | path: ~/.m2 57 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 58 | restore-keys: ${{ runner.os }}-m2 59 | 60 | - name: Set up Go 61 | uses: actions/setup-go@v5 62 | with: 63 | go-version: '${{ matrix.go-version }}' 64 | 65 | - name: Discovery Compatability Tests 66 | shell: bash 67 | run: | 68 | export COHERENCE_VERSION=${{ matrix.coherenceVersion }} 69 | make clean test-clean test-resolver-cluster 70 | 71 | - uses: actions/upload-artifact@v4 72 | if: failure() 73 | with: 74 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 75 | path: build/_output/test-logs 76 | -------------------------------------------------------------------------------- /.github/workflows/resolver-compatability-tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Resolver Compatability Tests 7 | # --------------------------------------------------------------------------- 8 | name: Resolver Compatability 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | coherenceVersion: 25 | - 22.06.12 26 | - 25.03.1 27 | - 14.1.2-0-2 28 | go-version: 29 | - 1.23.x 30 | - 1.24.x 31 | 32 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 33 | # the copyright check cannot work out the date of the files from Git. 34 | steps: 35 | - uses: actions/checkout@v4 36 | with: 37 | fetch-depth: 0 38 | 39 | - name: Set up JDK 40 | uses: actions/setup-java@v4 41 | with: 42 | java-version: '17' 43 | distribution: 'zulu' 44 | 45 | - name: Cache Go Modules 46 | uses: actions/cache@v4 47 | with: 48 | path: ~/go/pkg/mod 49 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 50 | restore-keys: | 51 | ${{ runner.os }}-go-mods- 52 | 53 | - name: Cache Maven packages 54 | uses: actions/cache@v4 55 | with: 56 | path: ~/.m2 57 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 58 | restore-keys: ${{ runner.os }}-m2 59 | 60 | - name: Set up Go 61 | uses: actions/setup-go@v5 62 | with: 63 | go-version: '${{ matrix.go-version }}' 64 | 65 | - name: Discovery Compatability Tests 66 | shell: bash 67 | run: | 68 | export COHERENCE_VERSION=${{ matrix.coherenceVersion }} 69 | curl --retry 5 --retry-delay 2 -sL https://raw.githubusercontent.com/oracle/coherence-cli/main/scripts/install.sh | bash 70 | cohctl version 71 | cohctl create cluster grpc-cluster -v ${{ matrix.coherenceVersion }} -y -a coherence-grpc-proxy 72 | sleep 20 73 | cohctl monitor health -n localhost:7574 -T 40 -w 74 | make clean test-clean test-resolver 75 | 76 | - name: Examples Tests Using Resolver 77 | shell: bash 78 | run: | 79 | export COHERENCE_SERVER_ADDRESS=coherence:///localhost:7574 80 | ./scripts/run-test-examples.sh 81 | cohctl stop cluster grpc-cluster -y 82 | cohctl remove cluster grpc-cluster -y 83 | 84 | - uses: actions/upload-artifact@v4 85 | if: failure() 86 | with: 87 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 88 | path: build/_output/test-logs 89 | -------------------------------------------------------------------------------- /.github/workflows/streaming-jakarta.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions test streaming against v23.03+ 7 | # --------------------------------------------------------------------------- 8 | name: CI-Streaming Jakarta 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | coherenceVersion: 25 | - 25.03.1 26 | - 25.03.2-SNAPSHOT 27 | go-version: 28 | - 1.23.x 29 | - 1.24.x 30 | 31 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 32 | # the copyright check cannot work out the date of the files from Git. 33 | steps: 34 | - uses: actions/checkout@v4 35 | with: 36 | fetch-depth: 0 37 | 38 | - name: Get Docker Images 39 | shell: bash 40 | run: | 41 | docker pull gcr.io/distroless/java17-debian12 42 | uname -a 43 | 44 | - name: Set up JDK 45 | uses: actions/setup-java@v4 46 | with: 47 | java-version: '17' 48 | distribution: 'zulu' 49 | 50 | - name: Cache Go Modules 51 | uses: actions/cache@v4 52 | with: 53 | path: ~/go/pkg/mod 54 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 55 | restore-keys: | 56 | ${{ runner.os }}-go-mods- 57 | 58 | - name: Cache Maven packages 59 | uses: actions/cache@v4 60 | with: 61 | path: ~/.m2 62 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 63 | restore-keys: ${{ runner.os }}-m2 64 | 65 | - name: Set up Go 66 | uses: actions/setup-go@v5 67 | with: 68 | go-version: '${{ matrix.go-version }}' 69 | 70 | - name: Verify 71 | shell: bash 72 | run: | 73 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 74 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=${{ matrix.coherenceVersion }} PROFILES=,jakarta,-javax make clean generate-proto generate-proto-v1 build-test-images test-cluster-startup test-e2e-streaming 75 | make test-cluster-shutdown || true 76 | 77 | - uses: actions/upload-artifact@v4 78 | if: failure() 79 | with: 80 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 81 | path: build/_output/test-logs 82 | -------------------------------------------------------------------------------- /.github/workflows/streaming.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | # --------------------------------------------------------------------------- 6 | # Coherence Go Client GitHub Actions test streaming against v22.06 versions 7 | # --------------------------------------------------------------------------- 8 | name: CI-Streaming v22.06 9 | 10 | on: 11 | workflow_dispatch: 12 | push: 13 | branches: 14 | - '*' 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-22.04 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | coherenceVersion: 25 | # - 22.06.13-SNAPSHOT 26 | # - 22.06.12 27 | - 14.1.2-0-2 28 | - 14.1.2-0-3-SNAPSHOT 29 | go-version: 30 | - 1.23.x 31 | - 1.24.x 32 | 33 | # Checkout the source, we need a depth of zero to fetch all of the history otherwise 34 | # the copyright check cannot work out the date of the files from Git. 35 | steps: 36 | - uses: actions/checkout@v4 37 | with: 38 | fetch-depth: 0 39 | 40 | - name: Get Docker Images 41 | shell: bash 42 | run: | 43 | docker pull gcr.io/distroless/java17-debian12 44 | 45 | - name: Set up JDK 46 | uses: actions/setup-java@v4 47 | with: 48 | java-version: '17' 49 | distribution: 'zulu' 50 | 51 | - name: Cache Go Modules 52 | uses: actions/cache@v4 53 | with: 54 | path: ~/go/pkg/mod 55 | key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} 56 | restore-keys: | 57 | ${{ runner.os }}-go-mods- 58 | 59 | - name: Cache Maven packages 60 | uses: actions/cache@v4 61 | with: 62 | path: ~/.m2 63 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 64 | restore-keys: ${{ runner.os }}-m2 65 | 66 | - name: Set up Go 67 | uses: actions/setup-go@v5 68 | with: 69 | go-version: '${{ matrix.go-version }}' 70 | 71 | - name: Verify 72 | shell: bash 73 | run: | 74 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 75 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=${{ matrix.coherenceVersion }} PROFILES=,-jakarta,javax make clean generate-proto generate-proto-v1 build-test-images test-cluster-startup test-e2e-streaming 76 | make test-cluster-shutdown || true 77 | 78 | - uses: actions/upload-artifact@v4 79 | if: failure() 80 | with: 81 | name: test-output-${{ matrix.go-version }}-${{ matrix.coherenceVersion }} 82 | path: build/_output/test-logs 83 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # used by intellij 2 | # ignore these types of java files 3 | *.class 4 | *.jar 5 | *.war 6 | *.rar 7 | *.gar 8 | 9 | # ignore these IntelliJ files 10 | .idea 11 | *.iml 12 | *.ipr 13 | *.iws 14 | 15 | # ignore these hidden and build specific files 16 | .* 17 | ~* 18 | 19 | # ignore these folders 20 | target 21 | dist 22 | _package 23 | store-bdb-active 24 | store-bdb-trash 25 | 26 | #ignore these specific files 27 | dependency-reduced-pom.xml 28 | 29 | # however allow these files 30 | !.ignore 31 | !.github 32 | !.gitignore 33 | !.mvn 34 | 35 | # Go 36 | 37 | bin/ 38 | build/ 39 | shared/ 40 | certs/ 41 | release/ 42 | etc/ 43 | coherence/coherence.test 44 | runner 45 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | *Detailed instructions on how to contribute to the project, if applicable. Must include section about Oracle Contributor Agreement with link and instructions* 2 | 3 | # Contributing to this repository 4 | 5 | We welcome your contributions! There are multiple ways to contribute. 6 | 7 | ## Opening issues 8 | 9 | For bugs or enhancement requests, please file a GitHub issue unless it's 10 | security related. When filing a bug remember that the better written the bug is, 11 | the more likely it is to be fixed. If you think you've found a security 12 | vulnerability, do not raise a GitHub issue and follow the instructions in our 13 | [security policy](./SECURITY.md). 14 | 15 | ## Contributing code 16 | 17 | We welcome your code contributions. Before submitting code via a pull request, 18 | you will need to have signed the [Oracle Contributor Agreement][OCA] (OCA) and 19 | your commits need to include the following line using the name and e-mail 20 | address you used to sign the OCA: 21 | 22 | ```text 23 | Signed-off-by: Your Name 24 | ``` 25 | 26 | This can be automatically added to pull requests by committing with `--sign-off` 27 | or `-s`, e.g. 28 | 29 | ```text 30 | git commit --signoff 31 | ``` 32 | 33 | Only pull requests from committers that can be verified as having signed the OCA 34 | can be accepted. 35 | 36 | ## Pull request process 37 | 38 | 1. Ensure there is an issue created to track and discuss the fix or enhancement 39 | you intend to submit. 40 | 1. Fork this repository. 41 | 1. Create a branch in your fork to implement the changes. We recommend using 42 | the issue number as part of your branch name, e.g. `1234-fixes`. 43 | 1. Ensure that any documentation is updated with the changes that are required 44 | by your change. 45 | 1. Ensure that any samples are updated if the base image has been changed. 46 | 1. Submit the pull request. *Do not leave the pull request blank*. Explain exactly 47 | what your changes are meant to do and provide simple steps on how to validate. 48 | your changes. Ensure that you reference the issue you created as well. 49 | 1. We will assign the pull request to 2-3 people for review before it is merged. 50 | 51 | ## Code of conduct 52 | 53 | Follow the [Golden Rule](https://en.wikipedia.org/wiki/Golden_Rule). If you'd 54 | like more specific guidelines, see the [Contributor Covenant Code of Conduct][COC]. 55 | 56 | [OCA]: https://oca.opensource.oracle.com 57 | [COC]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/ 58 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 Oracle and/or its affiliates. 2 | 3 | The Universal Permissive License (UPL), Version 1.0 4 | 5 | Subject to the condition set forth below, permission is hereby granted to any 6 | person obtaining a copy of this software, associated documentation and/or data 7 | (collectively the "Software"), free of charge and under any and all copyright 8 | rights in the Software, and any and all patent rights owned or freely 9 | licensable by each licensor hereunder covering either (i) the unmodified 10 | Software as contributed to or provided by such licensor, or (ii) the Larger 11 | Works (as defined below), to deal in both 12 | 13 | (a) the Software, and 14 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 15 | one is included with the Software (each a "Larger Work" to which the Software 16 | is contributed by such licensors), 17 | 18 | without restriction, including without limitation the rights to copy, create 19 | derivative works of, display, perform, and distribute the Software and make, 20 | use, sell, offer for sale, import, export, have made, and have sold the 21 | Software and the Larger Work(s), and to sublicense the foregoing rights on 22 | either these or other terms. 23 | 24 | This license is subject to the following condition: 25 | The above copyright notice and either this complete permission notice or at 26 | a minimum a reference to the UPL must be included in all copies or 27 | substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 | SOFTWARE. 36 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting security vulnerabilities 2 | 3 | Oracle values the independent security research community and believes that 4 | responsible disclosure of security vulnerabilities helps us ensure the security 5 | and privacy of all our users. 6 | 7 | Please do NOT raise a GitHub Issue to report a security vulnerability. If you 8 | believe you have found a security vulnerability, please submit a report to 9 | [secalert_us@oracle.com][1] preferably with a proof of concept. Please review 10 | some additional information on [how to report security vulnerabilities to Oracle][2]. 11 | We encourage people who contact Oracle Security to use email encryption using 12 | [our encryption key][3]. 13 | 14 | We ask that you do not use other channels or contact the project maintainers 15 | directly. 16 | 17 | Non-vulnerability related security issues including ideas for new or improved 18 | security features are welcome on GitHub Issues. 19 | 20 | ## Security updates, alerts and bulletins 21 | 22 | Security updates will be released on a regular cadence. Many of our projects 23 | will typically release security fixes in conjunction with the 24 | Oracle Critical Patch Update program. Additional 25 | information, including past advisories, is available on our [security alerts][4] 26 | page. 27 | 28 | ## Security-related information 29 | 30 | We will provide security related information such as a threat model, considerations 31 | for secure use, or any known security issues in our documentation. Please note 32 | that labs and sample code are intended to demonstrate a concept and may not be 33 | sufficiently hardened for production use. 34 | 35 | [1]: mailto:secalert_us@oracle.com 36 | [2]: https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html 37 | [3]: https://www.oracle.com/security-alerts/encryptionkey.html 38 | [4]: https://www.oracle.com/security-alerts/ 39 | -------------------------------------------------------------------------------- /coherence/aggregators/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package aggregators provides various aggregator functions and types. 9 | */ 10 | package aggregators 11 | -------------------------------------------------------------------------------- /coherence/discovery/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package discovery provides an implementation of Coherence NSLookup. 9 | 10 | Example: 11 | 12 | // open a connection to the default NameService port of 7574 providing a timeout of 5 seconds 13 | ns, err := discovery.Open("127.0.0.1:7574", 5) 14 | if err != nil { 15 | log.Fatal(err) 16 | } 17 | defer ns.Close() 18 | 19 | // return the cluster name of the cluster on this port 20 | clusterName, err = ns.Lookup(discovery.ClusterNameLookup) 21 | if err != nil { 22 | log.Fatal(err) 23 | } 24 | fmt.Println("Cluster name is", clusterName) 25 | 26 | // lookup other information such as management ports, metrics ports, etc 27 | var discoveredCluster discovery.DiscoveredCluster 28 | discoveredCluster, err = ns.DiscoverClusterInfo() 29 | if err != nil { 30 | log.Fatal(err) 31 | } 32 | fmt.Println("Management URLS", discoveredCluster.ManagementURLs) 33 | 34 | // lookup any foreign clusters also registered with this port 35 | clusterNames, err = ns.Lookup(discovery.NSPrefix + discovery.ClusterForeignLookup) 36 | if err != nil { 37 | log.Fatal(err) 38 | } 39 | fmt.Println("Foreign clusters are", clusterNames) 40 | */ 41 | package discovery 42 | -------------------------------------------------------------------------------- /coherence/discovery/nslookup_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package discovery 8 | 9 | import ( 10 | "github.com/onsi/gomega" 11 | "testing" 12 | ) 13 | 14 | var defaultTimeout int32 = 30 15 | 16 | func TestInvalidHostIp(t *testing.T) { 17 | g := gomega.NewGomegaWithT(t) 18 | 19 | _, err := Open("host:123:123", defaultTimeout) 20 | g.Expect(err).To(gomega.Not(gomega.BeNil())) 21 | 22 | _, err = Open("host:1233f", defaultTimeout) 23 | g.Expect(err).To(gomega.Not(gomega.BeNil())) 24 | 25 | _, err = Open("host:-1", defaultTimeout) 26 | g.Expect(err).To(gomega.Not(gomega.BeNil())) 27 | 28 | _, err = Open("host:1023", defaultTimeout) 29 | g.Expect(err).To(gomega.Not(gomega.BeNil())) 30 | 31 | _, err = Open("host:65536", defaultTimeout) 32 | g.Expect(err).To(gomega.Not(gomega.BeNil())) 33 | } 34 | 35 | func TestParseResults(t *testing.T) { 36 | g := gomega.NewGomegaWithT(t) 37 | g.Expect(len(parseResults(""))).To(gomega.Equal(0)) 38 | g.Expect(len(parseResults("[123]"))).To(gomega.Equal(1)) 39 | g.Expect(len(parseResults("[123, 123]"))).To(gomega.Equal(2)) 40 | g.Expect(len(parseResults("[123, 123, 456]"))).To(gomega.Equal(3)) 41 | result := parseResults("[A, BB, CCC]") 42 | g.Expect(len(result)).To(gomega.Equal(3)) 43 | for _, v := range result { 44 | valid := v == "A" || v == "BB" || v == "CCC" 45 | g.Expect(valid).To(gomega.BeTrue()) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /coherence/event_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package coherence 8 | 9 | import ( 10 | "github.com/onsi/gomega" 11 | "testing" 12 | ) 13 | 14 | func TestEventEmitter(t *testing.T) { 15 | g := gomega.NewWithT(t) 16 | var value = "" 17 | 18 | callback := func(a string) { 19 | value = a 20 | } 21 | 22 | emitter := newEventEmitter[string, string]() // string label and string event 23 | emitter.on("a", callback) 24 | emitter.emit("a", "event") 25 | g.Expect(value).Should(gomega.Equal("event")) 26 | emitter.emit("a", "event2") 27 | g.Expect(value).Should(gomega.Equal("event2")) 28 | } 29 | -------------------------------------------------------------------------------- /coherence/extractors/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package extractors provides various extractor functions and types. 9 | */ 10 | package extractors 11 | -------------------------------------------------------------------------------- /coherence/filters/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package filters provides various filter functions and types. 9 | */ 10 | package filters 11 | -------------------------------------------------------------------------------- /coherence/log_level_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package coherence 8 | 9 | import ( 10 | "bytes" 11 | "github.com/onsi/gomega" 12 | "log" 13 | "testing" 14 | ) 15 | 16 | func TestErrorLogLevel(t *testing.T) { 17 | runLogLevelTest(t, ERROR, ERROR, true) 18 | runLogLevelTest(t, WARNING, ERROR, false) 19 | runLogLevelTest(t, INFO, ERROR, false) 20 | runLogLevelTest(t, DEBUG, ERROR, false) 21 | runLogLevelTest(t, ALL, ERROR, false) 22 | 23 | runLogLevelTest(t, ERROR, WARNING, true) 24 | runLogLevelTest(t, WARNING, WARNING, true) 25 | runLogLevelTest(t, INFO, WARNING, false) 26 | runLogLevelTest(t, DEBUG, WARNING, false) 27 | runLogLevelTest(t, ALL, WARNING, false) 28 | 29 | runLogLevelTest(t, ERROR, INFO, true) 30 | runLogLevelTest(t, WARNING, INFO, true) 31 | runLogLevelTest(t, INFO, INFO, true) 32 | runLogLevelTest(t, DEBUG, INFO, false) 33 | runLogLevelTest(t, ALL, INFO, false) 34 | 35 | runLogLevelTest(t, ERROR, DEBUG, true) 36 | runLogLevelTest(t, WARNING, DEBUG, true) 37 | runLogLevelTest(t, INFO, DEBUG, true) 38 | runLogLevelTest(t, DEBUG, DEBUG, true) 39 | runLogLevelTest(t, ALL, DEBUG, false) 40 | 41 | runLogLevelTest(t, ERROR, ALL, true) 42 | runLogLevelTest(t, WARNING, ALL, true) 43 | runLogLevelTest(t, INFO, ALL, true) 44 | runLogLevelTest(t, DEBUG, ALL, true) 45 | runLogLevelTest(t, ALL, ALL, true) 46 | } 47 | 48 | func runLogLevelTest(t *testing.T, messageLevel, testLogLevel logLevel, expectOutput bool) { 49 | g := gomega.NewWithT(t) 50 | const message = "MESSAGE" 51 | 52 | var buf bytes.Buffer 53 | 54 | origOutput := log.Writer() 55 | log.SetOutput(&buf) 56 | defer log.SetOutput(origOutput) 57 | setLogLevel(testLogLevel.String()) 58 | 59 | logMessage(messageLevel, message) 60 | output := buf.String() 61 | 62 | if expectOutput { 63 | g.Expect(output).To(gomega.ContainSubstring(message)) 64 | } else { 65 | g.Expect(output).To(gomega.Not(gomega.ContainSubstring(message))) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /coherence/named_cache_client_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package coherence 8 | 9 | import ( 10 | "github.com/onsi/gomega" 11 | "testing" 12 | "time" 13 | ) 14 | 15 | // TestIsNearCacheEqual tests various scenarios where cache options should equal. 16 | func TestIsNearCacheEqual(t *testing.T) { 17 | var ( 18 | g = gomega.NewWithT(t) 19 | nearCacheOptions1 = NearCacheOptions{TTL: time.Duration(10) * time.Second, PruneFactor: 0.8} 20 | nearCacheOptions2 = NearCacheOptions{TTL: time.Duration(8) * time.Second, PruneFactor: 0.8} 21 | nearCacheOptions3 = NearCacheOptions{HighUnits: 100, PruneFactor: 0.8} 22 | nearCacheOptions4 = NearCacheOptions{HighUnitsMemory: 10_000, PruneFactor: 0.8} 23 | nearCacheOptions5 = NearCacheOptions{InvalidationStrategy: ListenAll, PruneFactor: 0.8} 24 | nearCacheOptions6 = NearCacheOptions{HighUnitsMemory: 10_000, PruneFactor: 0.7} 25 | ) 26 | 27 | localCache1 := newLocalCache[int, string]("test", withLocalCacheExpiry(time.Duration(10)*time.Second)) 28 | localCache2 := newLocalCache[int, string]("test", withLocalCacheHighUnits(100)) 29 | localCache3 := newLocalCache[int, string]("test", withLocalCacheHighUnitsMemory(10_000)) 30 | localCache4 := newLocalCache[int, string]("test", withInvalidationStrategy(ListenAll)) 31 | 32 | g.Expect(isNearCacheEqual[int, string](localCache1, &nearCacheOptions1)).To(gomega.Equal(true)) 33 | g.Expect(isNearCacheEqual[int, string](localCache1, &nearCacheOptions2)).To(gomega.Equal(false)) 34 | g.Expect(isNearCacheEqual[int, string](localCache2, &nearCacheOptions2)).To(gomega.Equal(false)) 35 | g.Expect(isNearCacheEqual[int, string](localCache2, &nearCacheOptions3)).To(gomega.Equal(true)) 36 | g.Expect(isNearCacheEqual[int, string](localCache3, &nearCacheOptions3)).To(gomega.Equal(false)) 37 | g.Expect(isNearCacheEqual[int, string](localCache3, &nearCacheOptions4)).To(gomega.Equal(true)) 38 | g.Expect(isNearCacheEqual[int, string](localCache3, &nearCacheOptions4)).To(gomega.Equal(true)) 39 | g.Expect(isNearCacheEqual[int, string](localCache4, &nearCacheOptions4)).To(gomega.Equal(false)) 40 | g.Expect(isNearCacheEqual[int, string](localCache4, &nearCacheOptions5)).To(gomega.Equal(true)) 41 | g.Expect(isNearCacheEqual[int, string](localCache3, &nearCacheOptions6)).To(gomega.Equal(false)) 42 | } 43 | 44 | // TestInvalidNearCacheOptions tests various edge cases for near cache options 45 | func TestInvalidNearCacheOptions(t *testing.T) { 46 | var ( 47 | g = gomega.NewWithT(t) 48 | nearCacheOptions1 = NearCacheOptions{HighUnits: -1} 49 | nearCacheOptions2 = NearCacheOptions{HighUnitsMemory: -1} 50 | nearCacheOptions3 = NearCacheOptions{HighUnitsMemory: 1, HighUnits: 1} 51 | nearCacheOptions4 = NearCacheOptions{TTL: time.Duration(1) * time.Second, HighUnitsMemory: 1, HighUnits: 1} 52 | nearCacheOptions5 = NearCacheOptions{} 53 | nearCacheOptions7 = NearCacheOptions{TTL: time.Duration(255) * time.Millisecond} 54 | ) 55 | 56 | err := ensureNearCacheOptions(&nearCacheOptions1) 57 | g.Expect(err).To(gomega.Equal(ErrNegativeNearCacheOptions)) 58 | 59 | err = ensureNearCacheOptions(&nearCacheOptions2) 60 | g.Expect(err).To(gomega.Equal(ErrNegativeNearCacheOptions)) 61 | 62 | err = ensureNearCacheOptions(&nearCacheOptions3) 63 | g.Expect(err).To(gomega.Equal(ErrInvalidNearCacheWithNoTTL)) 64 | 65 | err = ensureNearCacheOptions(&nearCacheOptions4) 66 | g.Expect(err).To(gomega.Equal(ErrInvalidNearCacheWithTTL)) 67 | 68 | err = ensureNearCacheOptions(&nearCacheOptions5) 69 | g.Expect(err).To(gomega.Equal(ErrInvalidNearCache)) 70 | 71 | err = ensureNearCacheOptions(&nearCacheOptions7) 72 | g.Expect(err).To(gomega.Equal(ErrInvalidNearCacheTTL)) 73 | } 74 | -------------------------------------------------------------------------------- /coherence/processors/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package processors provides various entry processor functions and types. 9 | */ 10 | package processors 11 | -------------------------------------------------------------------------------- /coherence/resolver_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package coherence 8 | 9 | import ( 10 | "github.com/onsi/gomega" 11 | "testing" 12 | ) 13 | 14 | func TestResolverParseNsLookupString(t *testing.T) { 15 | var ( 16 | g = gomega.NewWithT(t) 17 | err error 18 | results []string 19 | ) 20 | 21 | _, err = parseNsLookupString("") 22 | g.Expect(err).To(gomega.HaveOccurred()) 23 | 24 | _, err = parseNsLookupString("[123123123") 25 | g.Expect(err).To(gomega.HaveOccurred()) 26 | 27 | _, err = parseNsLookupString("123123123]") 28 | g.Expect(err).To(gomega.HaveOccurred()) 29 | 30 | results, err = parseNsLookupString("[]") 31 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 32 | g.Expect(len(results)).To(gomega.Equal(0)) 33 | 34 | results, err = parseNsLookupString("[127.0.0.1, 58193, 127.0.0.1, 58192, 127.0.0.1, 58194]") 35 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 36 | g.Expect(len(results)).To(gomega.Equal(3)) 37 | g.Expect(results[0]).To(gomega.Equal("127.0.0.1:58193")) 38 | g.Expect(results[1]).To(gomega.Equal("127.0.0.1:58192")) 39 | g.Expect(results[2]).To(gomega.Equal("127.0.0.1:58194")) 40 | 41 | results, err = parseNsLookupString("[127.0.0.1, 58193]") 42 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 43 | g.Expect(len(results)).To(gomega.Equal(1)) 44 | g.Expect(results[0]).To(gomega.Equal("127.0.0.1:58193")) 45 | 46 | results, err = parseNsLookupString("[127.0.0.1, 58193, 127.0.0.1, 58192]") 47 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 48 | g.Expect(len(results)).To(gomega.Equal(2)) 49 | g.Expect(results[0]).To(gomega.Equal("127.0.0.1:58193")) 50 | g.Expect(results[1]).To(gomega.Equal("127.0.0.1:58192")) 51 | } 52 | -------------------------------------------------------------------------------- /coherence/serializers_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package coherence 8 | 9 | import ( 10 | "github.com/onsi/gomega" 11 | "testing" 12 | ) 13 | 14 | func TestInvalidSerializer(t *testing.T) { 15 | g := gomega.NewWithT(t) 16 | 17 | // test that the default format of "json" will always be used 18 | serializer := NewSerializer[string]("invalid") 19 | 20 | serialized, err := serializer.Serialize("AAA") 21 | g.Expect(err).ShouldNot(gomega.HaveOccurred()) 22 | deserialized, err := serializer.Deserialize(serialized) 23 | g.Expect(err).ShouldNot(gomega.HaveOccurred()) 24 | g.Expect(*deserialized).To(gomega.Equal("AAA")) 25 | } 26 | 27 | func TestJsonSerializer(t *testing.T) { 28 | type person struct { 29 | ID int `json:"id"` 30 | Name string `json:"name"` 31 | } 32 | 33 | var myMap = map[int]person{ 34 | 1: {1, "tim"}, 35 | 2: {3, "tim2"}, 36 | } 37 | 38 | testSerialization[string](t, "hello") 39 | testSerialization[int](t, 123) 40 | testSerialization[float64](t, 123.123) 41 | testSerialization[int64](t, 23) 42 | testSerialization[bool](t, false) 43 | testSerialization[bool](t, true) 44 | testSerialization[byte](t, 1) 45 | testSerialization[[]byte](t, []byte{1, 2, 3, 4}) 46 | testSerialization[person](t, person{ID: 1, Name: "tim"}) 47 | testSerialization[[]string](t, []string{"hello", "hello2", "hello3"}) 48 | testSerialization[[]int](t, []int{12, 12, 12, 4, 4, 4, 3, 5}) 49 | testSerialization[map[int]person](t, myMap) 50 | } 51 | 52 | func testSerialization[V any](t *testing.T, v V) { 53 | var ( 54 | g = gomega.NewWithT(t) 55 | err error 56 | ) 57 | 58 | serializer := NewSerializer[V]("json") 59 | g.Expect(serializer).To(gomega.Not(gomega.BeNil())) 60 | 61 | value, err := serializer.Serialize(v) 62 | g.Expect(err).ShouldNot(gomega.HaveOccurred()) 63 | finaValue, err := serializer.Deserialize(value) 64 | g.Expect(err).ShouldNot(gomega.HaveOccurred()) 65 | g.Expect(*finaValue).To(gomega.Equal(v)) 66 | } 67 | -------------------------------------------------------------------------------- /coherence/session_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package coherence 8 | 9 | import ( 10 | "context" 11 | "github.com/onsi/gomega" 12 | "strconv" 13 | "testing" 14 | "time" 15 | ) 16 | 17 | func TestSessionValidation(t *testing.T) { 18 | var ( 19 | g = gomega.NewWithT(t) 20 | err error 21 | ctx = context.Background() 22 | ) 23 | 24 | _, err = NewSession(ctx, WithFormat("not-json")) 25 | g.Expect(err).To(gomega.Equal(ErrInvalidFormat)) 26 | 27 | // test default timeout 28 | timeout, _ := strconv.ParseInt(defaultRequestTimeout, 10, 64) 29 | s, err := NewSession(ctx) 30 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 31 | g.Expect(s.sessOpts.RequestTimeout).To(gomega.Equal(time.Duration(timeout) * time.Millisecond)) 32 | 33 | // test setting a request timeout 34 | s, err = NewSession(ctx, WithRequestTimeout(time.Duration(33)*time.Millisecond)) 35 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 36 | g.Expect(s.sessOpts.RequestTimeout).To(gomega.Equal(time.Duration(33) * time.Millisecond)) 37 | 38 | // test setting a disconnected timeout 39 | s, err = NewSession(ctx, WithDisconnectTimeout(time.Duration(34)*time.Millisecond)) 40 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 41 | g.Expect(s.sessOpts.DisconnectTimeout).To(gomega.Equal(time.Duration(34) * time.Millisecond)) 42 | 43 | // test setting a ready timeout 44 | s, err = NewSession(ctx, WithReadyTimeout(time.Duration(35)*time.Millisecond)) 45 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 46 | g.Expect(s.sessOpts.ReadyTimeout).To(gomega.Equal(time.Duration(35) * time.Millisecond)) 47 | } 48 | 49 | func TestSessionEnvValidation(t *testing.T) { 50 | var ( 51 | g = gomega.NewWithT(t) 52 | err error 53 | ctx = context.Background() 54 | ) 55 | 56 | // test default timeout 57 | t.Setenv("COHERENCE_CLIENT_REQUEST_TIMEOUT", "5000") 58 | s, err := NewSession(ctx) 59 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 60 | g.Expect(s.sessOpts.RequestTimeout).To(gomega.Equal(time.Duration(5000) * time.Millisecond)) 61 | 62 | // test setting a disconnected timeout 63 | t.Setenv("COHERENCE_SESSION_DISCONNECT_TIMEOUT", "6000") 64 | s, err = NewSession(ctx) 65 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 66 | g.Expect(s.sessOpts.DisconnectTimeout).To(gomega.Equal(time.Duration(6000) * time.Millisecond)) 67 | 68 | // test setting a ready timeout 69 | t.Setenv("COHERENCE_READY_TIMEOUT", "7000") 70 | s, err = NewSession(ctx) 71 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 72 | g.Expect(s.sessOpts.ReadyTimeout).To(gomega.Equal(time.Duration(7000) * time.Millisecond)) 73 | } 74 | 75 | func TestSessionEnvDebug(t *testing.T) { 76 | var ( 77 | g = gomega.NewWithT(t) 78 | ctx = context.Background() 79 | ) 80 | t.Setenv(envSessionDebug, "true") 81 | _, err := NewSession(ctx) 82 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 83 | } 84 | 85 | func TestConnectionOverride(t *testing.T) { 86 | var ( 87 | g = gomega.NewWithT(t) 88 | ctx = context.Background() 89 | ) 90 | t.Setenv(envHostName, "localhost:12345") 91 | s, err := NewSession(ctx) 92 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 93 | g.Expect(s.sessOpts.Address).To(gomega.Equal("localhost:12345")) 94 | } 95 | 96 | func TestInvalidFormat(t *testing.T) { 97 | var ( 98 | g = gomega.NewWithT(t) 99 | ctx = context.Background() 100 | ) 101 | _, err := NewSession(ctx, WithFormat("abc")) 102 | g.Expect(err).To(gomega.HaveOccurred()) 103 | } 104 | 105 | func TestSessionTimeout(t *testing.T) { 106 | var ( 107 | g = gomega.NewWithT(t) 108 | ctx = context.Background() 109 | ) 110 | 111 | t.Setenv(envRequestTimeout, "-1") 112 | _, err := NewSession(ctx) 113 | g.Expect(err).To(gomega.HaveOccurred()) 114 | } 115 | -------------------------------------------------------------------------------- /examples/aggregators/basic/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows aggregation examples using a NamedMap with key of int and value of Person struct. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/aggregators" 17 | "github.com/oracle/coherence-go-client/v2/coherence/extractors" 18 | "github.com/oracle/coherence-go-client/v2/coherence/filters" 19 | "math/big" 20 | ) 21 | 22 | type Person struct { 23 | ID int `json:"id"` 24 | Name string `json:"name"` 25 | Age int `json:"age"` 26 | Department string `json:"department"` 27 | } 28 | 29 | func main() { 30 | var ( 31 | personData = map[int]Person{ 32 | 1: {ID: 1, Name: "Tim", Age: 19, Department: "IT"}, 33 | 2: {ID: 2, Name: "Andrew", Age: 20, Department: "IT"}, 34 | 3: {ID: 3, Name: "John", Age: 30, Department: "HR"}, 35 | 4: {ID: 4, Name: "Steve", Age: 40, Department: "Finance"}, 36 | } 37 | count *int64 38 | bigRat *big.Rat 39 | ctx = context.Background() 40 | ) 41 | 42 | // create a new Session to the default gRPC port of 1408 using plain text 43 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 44 | 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | defer session.Close() 50 | 51 | // create a new NamedMap of Person with key int 52 | namedMap, err := coherence.GetNamedMap[int, Person](session, "aggregation-test") 53 | if err != nil { 54 | panic(err) 55 | } 56 | 57 | // clear the Map 58 | _ = namedMap.Clear(ctx) 59 | 60 | if err = namedMap.PutAll(ctx, personData); err != nil { 61 | panic(err) 62 | } 63 | values, err := coherence.Aggregate(ctx, namedMap, aggregators.Distinct(extractors.Extract[string]("department"))) 64 | if err != nil { 65 | panic(err) 66 | } 67 | fmt.Println("Distinct departments", *values) 68 | 69 | if count, err = coherence.Aggregate(ctx, namedMap, aggregators.Count()); err != nil { 70 | panic(err) 71 | } 72 | fmt.Println("Number of people", *count) 73 | 74 | age := extractors.Extract[int]("age") 75 | 76 | // Count with Filter age > 19 77 | count, err = coherence.AggregateFilter(ctx, namedMap, filters.Greater(age, 19), aggregators.Count()) 78 | if err != nil { 79 | panic(err) 80 | } 81 | fmt.Println("Number of people aged greater than 19 is", *count) 82 | 83 | // Average age of people < 30 84 | bigRat, err = coherence.AggregateFilter(ctx, namedMap, filters.Less(age, 30), aggregators.Average(age)) 85 | if err != nil { 86 | panic(err) 87 | } 88 | value, _ := bigRat.Float32() 89 | fmt.Printf("Average age of people less than 30 is %.2f\n", value) 90 | 91 | // return the oldest person in each department 92 | departmentResult, err := coherence.Aggregate(ctx, namedMap, 93 | aggregators.GroupBy(extractors.Extract[string]("department"), aggregators.Max(age))) 94 | if err != nil { 95 | panic(err) 96 | } 97 | for _, v := range departmentResult.Entries { 98 | fmt.Println("Department", v.Key, "Max age", v.Value) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /examples/aggregators/explain/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to run an explain plan using a NamedMap with key of int and value of Person struct. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "encoding/json" 15 | "fmt" 16 | "github.com/oracle/coherence-go-client/v2/coherence" 17 | "github.com/oracle/coherence-go-client/v2/coherence/aggregators" 18 | "github.com/oracle/coherence-go-client/v2/coherence/extractors" 19 | "github.com/oracle/coherence-go-client/v2/coherence/filters" 20 | ) 21 | 22 | type Person struct { 23 | ID int `json:"id"` 24 | Name string `json:"name"` 25 | Age int `json:"age"` 26 | Department string `json:"department"` 27 | } 28 | 29 | func main() { 30 | var ( 31 | personData = map[int]Person{ 32 | 1: {ID: 1, Name: "Tim", Age: 19, Department: "IT"}, 33 | 2: {ID: 2, Name: "Andrew", Age: 20, Department: "IT"}, 34 | 3: {ID: 3, Name: "John", Age: 30, Department: "HR"}, 35 | 4: {ID: 4, Name: "Steve", Age: 40, Department: "Finance"}, 36 | } 37 | ctx = context.Background() 38 | ) 39 | 40 | // create a new Session to the default gRPC port of 1408 using plain text 41 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | defer session.Close() 48 | 49 | // create a new NamedMap of Person with key int 50 | namedMap, err := coherence.GetNamedMap[int, Person](session, "explain-test") 51 | if err != nil { 52 | panic(err) 53 | } 54 | 55 | // Add an index on department 56 | department := extractors.Extract[string]("department") 57 | 58 | err = coherence.AddIndex(ctx, namedMap, department, true) 59 | if err != nil { 60 | panic(err) 61 | } 62 | 63 | // clear and populate the Map 64 | _ = namedMap.Clear(ctx) 65 | 66 | if err = namedMap.PutAll(ctx, personData); err != nil { 67 | panic(err) 68 | } 69 | 70 | jsonResult, err := coherence.AggregateFilter[int, Person, map[string]interface{}](ctx, namedMap, 71 | filters.Equal(department, "IT"), 72 | aggregators.QueryRecorder(aggregators.Explain)) 73 | if err != nil { 74 | panic(err) 75 | } 76 | 77 | var results string 78 | 79 | if results, err = getResults(jsonResult); err != nil { 80 | panic(err) 81 | } 82 | 83 | fmt.Println(aggregators.Explain) 84 | fmt.Println(results) 85 | 86 | jsonResult, err = coherence.AggregateFilter[int, Person, map[string]interface{}](ctx, namedMap, 87 | filters.Equal(department, "IT"), 88 | aggregators.QueryRecorder(aggregators.Trace)) 89 | if err != nil { 90 | panic(err) 91 | } 92 | 93 | if results, err = getResults(jsonResult); err != nil { 94 | panic(err) 95 | } 96 | fmt.Println(aggregators.Trace) 97 | fmt.Println(results) 98 | } 99 | 100 | func getResults(results *map[string]interface{}) (string, error) { 101 | prettyJSON, err := json.MarshalIndent(results, "", " ") 102 | if err != nil { 103 | return "", fmt.Errorf("error marshalling: %v", err) 104 | } 105 | 106 | return string(prettyJSON), nil 107 | } 108 | -------------------------------------------------------------------------------- /examples/basic/README.md: -------------------------------------------------------------------------------- 1 | # Basic Examples 2 | 3 | These example shows how to carry out basic operations against a NamedMap. 4 | 5 | -------------------------------------------------------------------------------- /examples/basic/contains/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to use ContainsKey, ContainsValue and ContainsEntry against a NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | ) 17 | 18 | func main() { 19 | var ( 20 | ctx = context.Background() 21 | contains bool 22 | ) 23 | 24 | // create a new Session to the default gRPC port of 1408 using plain text 25 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 26 | if err != nil { 27 | panic(err) 28 | } 29 | defer session.Close() 30 | 31 | // create a new NamedMap with key of int and value of string 32 | namedMap, err := coherence.GetNamedMap[int, string](session, "my-contains-map") 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | fmt.Println("Put key 1, value one") 38 | // put a new key / value 39 | if _, err = namedMap.Put(ctx, 1, "one"); err != nil { 40 | panic(err) 41 | } 42 | 43 | if contains, err = namedMap.ContainsKey(ctx, 1); err != nil { 44 | panic(err) 45 | } 46 | fmt.Printf("NamedMap ContainsKey 1 should be true and is %v\n", contains) 47 | 48 | if contains, err = namedMap.ContainsValue(ctx, "one"); err != nil { 49 | panic(err) 50 | } 51 | fmt.Printf("NamedMap ContainsValue \"one\" should be true and is %v\n", contains) 52 | 53 | if contains, err = namedMap.ContainsValue(ctx, "two"); err != nil { 54 | panic(err) 55 | } 56 | fmt.Printf("NamedMap ContainsValue \"two\" should be false and is %v\n", contains) 57 | 58 | if contains, err = namedMap.ContainsEntry(ctx, 1, "two"); err != nil { 59 | panic(err) 60 | } 61 | fmt.Printf("NamedMap ContainsEntry key=1, value=\"two\" should be false and is %v\n", contains) 62 | } 63 | -------------------------------------------------------------------------------- /examples/basic/crud/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to carry out basic operations against a NamedMap with primitive types. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | ) 17 | 18 | func main() { 19 | var ( 20 | value *string 21 | ctx = context.Background() 22 | size int 23 | ) 24 | 25 | // create a new Session to the default gRPC port of 1408 using plain text 26 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 27 | if err != nil { 28 | panic(err) 29 | } 30 | defer session.Close() 31 | 32 | // create a new NamedMap with key of int and value of string 33 | namedMap, err := coherence.GetNamedMap[int, string](session, "my-map") 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | fmt.Println("Put key 1, value one") 39 | // put a new key / value 40 | if _, err = namedMap.Put(ctx, 1, "one"); err != nil { 41 | panic(err) 42 | } 43 | 44 | // get the value for the given key 45 | if value, err = namedMap.Get(ctx, 1); err != nil { 46 | panic(err) 47 | } 48 | fmt.Println("Value for key 1 is", *value) 49 | 50 | if size, err = namedMap.Size(ctx); err != nil { 51 | panic(err) 52 | } 53 | fmt.Println("Cache size is", size) 54 | 55 | // update the value for key 1 56 | if _, err = namedMap.Put(ctx, 1, "ONE"); err != nil { 57 | panic(err) 58 | } 59 | 60 | // get the updated value for the given key 61 | if value, err = namedMap.Get(ctx, 1); err != nil { 62 | panic(err) 63 | } 64 | fmt.Println("Updated value is", *value) 65 | 66 | fmt.Println("Remove key", 1) 67 | if _, err = namedMap.Remove(ctx, 1); err != nil { 68 | panic(err) 69 | } 70 | 71 | if size, err = namedMap.Size(ctx); err != nil { 72 | panic(err) 73 | } 74 | fmt.Println("Cache size is", size) 75 | } 76 | -------------------------------------------------------------------------------- /examples/basic/expiry/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to put entries that expire in a NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | func main() { 20 | var ( 21 | value *string 22 | ctx = context.Background() 23 | size int 24 | ) 25 | 26 | // create a new Session to the default gRPC port of 1408 using plain text 27 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 28 | if err != nil { 29 | panic(err) 30 | } 31 | defer session.Close() 32 | 33 | // create a new NamedCache with key of int and value of string. 34 | // NOTE: A NamedCache is required to call the PutWithExpiry function. 35 | namedCache, err := coherence.GetNamedCache[int, string](session, "my-cache") 36 | if err != nil { 37 | panic(err) 38 | } 39 | 40 | fmt.Println("Put key 1, value \"one\" with expiry 5 seconds") 41 | // put a new key / value with expiry of 5 seconds 42 | if _, err = namedCache.PutWithExpiry(ctx, 1, "one", time.Duration(5)*time.Second); err != nil { 43 | panic(err) 44 | } 45 | 46 | // get the value for the given key, it should exist 47 | if value, err = namedCache.Get(ctx, 1); err != nil { 48 | panic(err) 49 | } 50 | fmt.Printf("Value for key 1 is %v, sleep 6 seconds and cache size should be zero\n", *value) 51 | 52 | time.Sleep(time.Duration(6) * time.Second) 53 | 54 | if size, err = namedCache.Size(ctx); err != nil { 55 | panic(err) 56 | } 57 | // cache size should now be zero 58 | fmt.Printf("Cache size = %d\n", size) 59 | 60 | if value, err = namedCache.Get(ctx, 1); err != nil { 61 | panic(err) 62 | } 63 | fmt.Printf("Value for key 1 is %v, should be nil pointer as entry no longer exists\n", value) 64 | } 65 | -------------------------------------------------------------------------------- /examples/basic/expiry_cache/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to put entries that expire in a NamedCache using the coherence.WithExpiry option. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | func main() { 20 | var ( 21 | value *string 22 | ctx = context.Background() 23 | size int 24 | ) 25 | 26 | // create a new Session to the default gRPC port of 1408 using plain text 27 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 28 | if err != nil { 29 | panic(err) 30 | } 31 | defer session.Close() 32 | 33 | // create a new NamedCache with key of int and value of string. 34 | // NOTE: A NamedCache is required to call the PutWithExpiry function. 35 | namedCache, err := coherence.GetNamedCache[int, string](session, "my-cache", coherence.WithExpiry(time.Duration(5)*time.Second)) 36 | if err != nil { 37 | panic(err) 38 | } 39 | 40 | fmt.Println("Put key 1, value \"one\" with using Put, default expiry will apply") 41 | // put a new key / value without specifying expiry 42 | if _, err = namedCache.Put(ctx, 1, "one"); err != nil { 43 | panic(err) 44 | } 45 | 46 | time.Sleep(time.Duration(6) * time.Second) 47 | 48 | if size, err = namedCache.Size(ctx); err != nil { 49 | panic(err) 50 | } 51 | fmt.Printf("Cache size = %d\n", size) 52 | 53 | if value, err = namedCache.Get(ctx, 1); err != nil { 54 | panic(err) 55 | } 56 | fmt.Printf("Value for key 1 is %v, should be nil pointer as entry no longer exists\n", value) 57 | 58 | // If we do call PutWithExpiry, this expiry value will override the default 59 | fmt.Println("Issue PutWithExpiry key 1, value \"one\" with expiry 10 seconds") 60 | // put a new key / value with expiry of 5 seconds 61 | if _, err = namedCache.PutWithExpiry(ctx, 1, "one", time.Duration(10)*time.Second); err != nil { 62 | panic(err) 63 | } 64 | 65 | time.Sleep(time.Duration(6) * time.Second) 66 | if size, err = namedCache.Size(ctx); err != nil { 67 | panic(err) 68 | } 69 | fmt.Printf("After 6 seconds cache size is size = %d, wait another 6 seconds\n", size) 70 | 71 | time.Sleep(time.Duration(6) * time.Second) 72 | if size, err = namedCache.Size(ctx); err != nil { 73 | panic(err) 74 | } 75 | fmt.Printf("After another 6 seconds cache size is size = %d\n", size) 76 | } 77 | -------------------------------------------------------------------------------- /examples/basic/near_cache/high_units/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to use a near cache with a NamedMap or NamedCache with high units of 1000. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | ) 17 | 18 | func main() { 19 | var ( 20 | ctx = context.Background() 21 | size int 22 | ) 23 | 24 | const maxEntries = 2000 25 | 26 | // create a new Session to the default gRPC port of 1408 using plain text 27 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 28 | if err != nil { 29 | panic(err) 30 | } 31 | defer session.Close() 32 | 33 | // near cache options to use for NamedCache 34 | nearCacheOptions := coherence.NearCacheOptions{HighUnits: 1000} 35 | 36 | // create a new NamedCache with key of int and value of string which has a 37 | // near cache that will keep up to 1000 units 38 | namedCache, err := coherence.GetNamedCache[int, string](session, "my-near-cache-high-units", coherence.WithNearCache(&nearCacheOptions)) 39 | if err != nil { 40 | panic(err) 41 | } 42 | 43 | defer namedCache.Release() 44 | 45 | err = namedCache.Clear(ctx) 46 | if err != nil { 47 | panic(err) 48 | } 49 | 50 | fmt.Println("Adding", maxEntries, "entries") 51 | buffer := make(map[int]string, 0) 52 | for i := 1; i <= maxEntries; i++ { 53 | buffer[i] = fmt.Sprintf("value-%v", i) 54 | } 55 | 56 | err = namedCache.PutAll(ctx, buffer) 57 | if err != nil { 58 | panic(err) 59 | } 60 | 61 | size, err = namedCache.Size(ctx) 62 | if err != nil { 63 | panic(err) 64 | } 65 | 66 | fmt.Printf("Cache size is %v, doing 1000 Get() operations to populate near cache\n\n", size) 67 | 68 | for i := 1; i <= 1000; i++ { 69 | _, err = namedCache.Get(ctx, i) 70 | if err != nil { 71 | panic(err) 72 | } 73 | } 74 | 75 | // issue another Get() for an entry in the near cache to show a hit 76 | _, err = namedCache.Get(ctx, 1) 77 | if err != nil { 78 | panic(err) 79 | } 80 | 81 | fmt.Println(namedCache.GetNearCacheStats()) 82 | 83 | fmt.Println("\nIssuing another get which will make the near cache over the high-units and it will prune to 80% of size") 84 | fmt.Println() 85 | 86 | _, err = namedCache.Get(ctx, 2000) 87 | if err != nil { 88 | panic(err) 89 | } 90 | 91 | fmt.Println(namedCache.GetNearCacheStats()) 92 | } 93 | -------------------------------------------------------------------------------- /examples/basic/near_cache/memory/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to use a near cache with a NamedMap or NamedCache with high units memory of 10k. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | ) 17 | 18 | func main() { 19 | var ( 20 | ctx = context.Background() 21 | size int 22 | ) 23 | 24 | const maxEntries = 5_000 25 | 26 | // create a new Session to the default gRPC port of 1408 using plain text 27 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 28 | if err != nil { 29 | panic(err) 30 | } 31 | defer session.Close() 32 | 33 | // near cache options to use for NamedCache 34 | nearCacheOptions := coherence.NearCacheOptions{HighUnitsMemory: 10 * 1024} 35 | 36 | // create a new NamedCache with key of int and value of string which has a 37 | // near cache that will keep local entries up to max size of 10K 38 | namedCache, err := coherence.GetNamedCache[int, string](session, "my-near-cache-high-units-memory", coherence.WithNearCache(&nearCacheOptions)) 39 | if err != nil { 40 | panic(err) 41 | } 42 | 43 | defer namedCache.Release() 44 | 45 | err = namedCache.Clear(ctx) 46 | if err != nil { 47 | panic(err) 48 | } 49 | 50 | fmt.Println("Adding", maxEntries, "entries") 51 | buffer := make(map[int]string, 0) 52 | for i := 1; i <= maxEntries; i++ { 53 | buffer[i] = fmt.Sprintf("value-%v", i) 54 | } 55 | 56 | err = namedCache.PutAll(ctx, buffer) 57 | if err != nil { 58 | panic(err) 59 | } 60 | size, err = namedCache.Size(ctx) 61 | if err != nil { 62 | panic(err) 63 | } 64 | 65 | fmt.Printf("Cache size is %v, doing %v Get() operations to populate near cache\n", size, 1000) 66 | 67 | for i := 1; i <= 1000; i++ { 68 | _, err = namedCache.Get(ctx, i) 69 | if err != nil { 70 | panic(err) 71 | } 72 | if i%100 == 0 { 73 | fmt.Println("count=", i) 74 | } 75 | } 76 | 77 | fmt.Printf("The near cache should not have a size of 1000 as it will be over the size limit\n\n") 78 | fmt.Println(namedCache.GetNearCacheStats()) 79 | } 80 | -------------------------------------------------------------------------------- /examples/basic/struct/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to carry out basic operations against a NamedMap with a key of int and value of Person struct. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/processors" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | person *Person 32 | size int 33 | ctx = context.Background() 34 | ) 35 | 36 | // create a new Session 37 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 38 | if err != nil { 39 | panic(err) 40 | } 41 | 42 | defer session.Close() 43 | 44 | // create a new NamedMap of Person with key int 45 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 46 | if err != nil { 47 | panic(err) 48 | } 49 | 50 | // clear the Map 51 | if err = namedMap.Clear(ctx); err != nil { 52 | panic(err) 53 | } 54 | 55 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 56 | fmt.Println("Add new Person", newPerson) 57 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 58 | panic(err) 59 | } 60 | 61 | if size, err = namedMap.Size(ctx); err != nil { 62 | panic(err) 63 | } 64 | fmt.Println("Cache size is", size) 65 | 66 | // get the Person 67 | if person, err = namedMap.Get(ctx, 1); err != nil { 68 | panic(err) 69 | } 70 | fmt.Println("Person from Get() is", *person) 71 | 72 | fmt.Println("Update person age using processor") 73 | // Update the age 74 | _, err = coherence.Invoke[int, Person, bool](ctx, namedMap, 1, processors.Update("age", 22)) 75 | if err != nil { 76 | panic(err) 77 | } 78 | 79 | // get the Person 80 | if person, err = namedMap.Get(ctx, 1); err != nil { 81 | panic(err) 82 | } 83 | fmt.Println("Updated person is", *person) 84 | 85 | _, err = namedMap.Remove(ctx, 1) 86 | if err != nil { 87 | panic(err) 88 | } 89 | 90 | if size, err = namedMap.Size(ctx); err != nil { 91 | panic(err) 92 | } 93 | fmt.Println("Cache size is", size) 94 | } 95 | -------------------------------------------------------------------------------- /examples/basic/struct_keys/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to carry out basic operations against a NamedMap where a key and value are structs. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/processors" 17 | ) 18 | 19 | // AccountKey defines the key for an account. 20 | type AccountKey struct { 21 | AccountID int `json:"accountID"` 22 | AccountType string `json:"accountType"` 23 | } 24 | 25 | func (ak AccountKey) String() string { 26 | return fmt.Sprintf("AccountKey{accountID=%d, accountType=%s}", ak.AccountID, ak.AccountType) 27 | } 28 | 29 | // Account defines the attributes for an account. 30 | type Account struct { 31 | AccountID int `json:"accountID"` 32 | AccountType string `json:"accountType"` 33 | Name string `json:"name"` 34 | Balance float32 `json:"balance"` 35 | } 36 | 37 | // GetKey returns the AccountKey for an Account. 38 | func (a Account) GetKey() AccountKey { 39 | return AccountKey{ 40 | AccountID: a.AccountID, 41 | AccountType: a.AccountType, 42 | } 43 | } 44 | 45 | func (a Account) String() string { 46 | return fmt.Sprintf("Account{accountKey=%v, name=%s, balance=$%.2f}", a.GetKey(), a.Name, a.Balance) 47 | } 48 | 49 | func main() { 50 | var ( 51 | account *Account 52 | size int 53 | ctx = context.Background() 54 | ) 55 | 56 | // create a new Session 57 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 58 | if err != nil { 59 | panic(err) 60 | } 61 | 62 | defer session.Close() 63 | 64 | // create a new NamedMap of Account with key of AccountKey 65 | namedMap, err := coherence.GetNamedMap[AccountKey, Account](session, "accounts") 66 | if err != nil { 67 | panic(err) 68 | } 69 | 70 | // clear the Map 71 | if err = namedMap.Clear(ctx); err != nil { 72 | panic(err) 73 | } 74 | 75 | newAccountKey := AccountKey{AccountID: 100, AccountType: "savings"} 76 | newAccount := Account{AccountID: newAccountKey.AccountID, AccountType: newAccountKey.AccountType, 77 | Name: "John Doe", Balance: 100_000} 78 | 79 | fmt.Println("Add new Account", newAccount, "with key", newAccountKey) 80 | if _, err = namedMap.Put(ctx, newAccount.GetKey(), newAccount); err != nil { 81 | panic(err) 82 | } 83 | 84 | if size, err = namedMap.Size(ctx); err != nil { 85 | panic(err) 86 | } 87 | fmt.Println("Cache size is", size) 88 | 89 | // get the Account 90 | if account, err = namedMap.Get(ctx, newAccountKey); err != nil { 91 | panic(err) 92 | } 93 | fmt.Println("Account from Get() is", *account) 94 | 95 | fmt.Println("Update account balance using processor") 96 | // Update the balance by $1000 97 | _, err = coherence.Invoke[AccountKey, Account, bool](ctx, namedMap, newAccountKey, 98 | processors.Update("balance", account.Balance+1000)) 99 | if err != nil { 100 | panic(err) 101 | } 102 | 103 | // get the Account 104 | if account, err = namedMap.Get(ctx, newAccountKey); err != nil { 105 | panic(err) 106 | } 107 | fmt.Println("Updated account is", *account) 108 | 109 | _, err = namedMap.Remove(ctx, newAccountKey) 110 | if err != nil { 111 | panic(err) 112 | } 113 | 114 | if size, err = namedMap.Size(ctx); err != nil { 115 | panic(err) 116 | } 117 | fmt.Println("Cache size is", size) 118 | } 119 | -------------------------------------------------------------------------------- /examples/custom/comparators/java/com/oracle/coherence/example/CustomComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package com.oracle.coherence.example; 8 | 9 | 10 | import com.oracle.coherence.io.json.JsonObject; 11 | 12 | import com.tangosol.util.ValueExtractor; 13 | import com.tangosol.util.function.Remote; 14 | 15 | import jakarta.json.bind.annotation.JsonbProperty; 16 | 17 | import java.io.Serializable; 18 | 19 | import java.util.Comparator; 20 | 21 | 22 | /** 23 | * An example {@link Comparator} that does custom sorting. 24 | */ 25 | public class CustomComparator implements 26 | Remote.Comparator, Comparator, Serializable { 27 | 28 | /** 29 | * Default constructor. 30 | */ 31 | public CustomComparator() { 32 | } 33 | 34 | public CustomComparator(ValueExtractor extractor) { 35 | m_extractor = extractor; 36 | } 37 | 38 | @Override 39 | public int compare(JsonObject json1, JsonObject json2) { 40 | String s1 = m_extractor.extract(json1); 41 | String s2 = m_extractor.extract(json2); 42 | // implement your own comparison operation here, this example assumes the values are Strings 43 | return s1.compareTo(s2); 44 | } 45 | 46 | /** 47 | * ValueExtractor to extract value(s) to be used in comparison 48 | */ 49 | @JsonbProperty("extractor") 50 | private ValueExtractor m_extractor; 51 | } 52 | -------------------------------------------------------------------------------- /examples/custom/entry_processors/java/com/oracle/coherence/example/UppercaseProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package com.oracle.coherence.example; 8 | 9 | import com.tangosol.util.InvocableMap; 10 | 11 | /** 12 | * Sample entry processor that ensures updates a {@link Customer}s name to uppercase. 13 | */ 14 | public class UppercaseProcessor implements InvocableMap.EntryProcessor { 15 | @Override 16 | public Void process(InvocableMap.Entry entry) { 17 | Customer customer = entry.getValue(); 18 | customer.setName(customer.getName().toUpperCase()); 19 | entry.setValue(customer); 20 | return null; 21 | } 22 | } -------------------------------------------------------------------------------- /examples/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package examples provides various examples using the coherence-go-client. 9 | */ 10 | package examples 11 | -------------------------------------------------------------------------------- /examples/events/cache/all/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for all events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/processors" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the NamedMap 55 | listener := coherence.NewMapListener[int, Person]().OnAny(func(e coherence.MapEvent[int, Person]) { 56 | var ( 57 | newValue *Person 58 | oldValue *Person 59 | ) 60 | key, err1 := e.Key() 61 | if err1 != nil { 62 | panic("unable to deserialize key") 63 | } 64 | 65 | if e.Type() == coherence.EntryInserted || e.Type() == coherence.EntryUpdated { 66 | newValue, err1 = e.NewValue() 67 | if err1 != nil { 68 | panic("unable to deserialize new value") 69 | } 70 | } 71 | if e.Type() == coherence.EntryDeleted || e.Type() == coherence.EntryUpdated { 72 | oldValue, err1 = e.OldValue() 73 | if err1 != nil { 74 | panic("unable to deserialize old value") 75 | } 76 | } 77 | 78 | fmt.Printf("**EVENT=%v: key=%v, oldValue=%v, newValue=%v\n", e.Type(), *key, oldValue, newValue) 79 | }) 80 | 81 | if err = namedMap.AddListener(ctx, listener); err != nil { 82 | panic(err) 83 | } 84 | 85 | defer func(ctx context.Context, namedMap coherence.NamedMap[int, Person], listener coherence.MapListener[int, Person]) { 86 | if err := namedMap.RemoveListener(ctx, listener); err != nil { 87 | panic(fmt.Sprintf("cannot remove listener %v", listener)) 88 | } 89 | }(ctx, namedMap, listener) 90 | 91 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 92 | fmt.Println("Add new Person", newPerson) 93 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 94 | panic(err) 95 | } 96 | 97 | if size, err = namedMap.Size(ctx); err != nil { 98 | panic(err) 99 | } 100 | fmt.Println("Cache size is", size) 101 | 102 | fmt.Println("Update person age using processor") 103 | // Update the age 104 | _, err = coherence.Invoke[int, Person, bool](ctx, namedMap, 1, processors.Update("age", 22)) 105 | if err != nil { 106 | panic(err) 107 | } 108 | 109 | _, err = namedMap.Remove(ctx, 1) 110 | if err != nil { 111 | panic(err) 112 | } 113 | 114 | if size, err = namedMap.Size(ctx); err != nil { 115 | panic(err) 116 | } 117 | fmt.Println("Cache size is", size) 118 | } 119 | -------------------------------------------------------------------------------- /examples/events/cache/delete/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for delete events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/processors" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the cache 55 | listener := coherence.NewMapListener[int, Person]().OnDeleted(func(e coherence.MapEvent[int, Person]) { 56 | key, err1 := e.Key() 57 | if err1 != nil { 58 | panic("unable to deserialize key") 59 | } 60 | oldValue, err1 := e.OldValue() 61 | if err1 != nil { 62 | panic("unable to deserialize old value") 63 | } 64 | 65 | fmt.Printf("**EVENT=Deleted: key=%v, value=%v\n", *key, oldValue) 66 | }) 67 | 68 | if err = namedMap.AddListener(ctx, listener); err != nil { 69 | panic(err) 70 | } 71 | defer func(ctx context.Context, namedMap coherence.NamedMap[int, Person], listener coherence.MapListener[int, Person]) { 72 | if err := namedMap.RemoveListener(ctx, listener); err != nil { 73 | panic(fmt.Sprintf("cannot remove listener %v", listener)) 74 | } 75 | }(ctx, namedMap, listener) 76 | 77 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 78 | fmt.Println("Add new Person", newPerson) 79 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 80 | panic(err) 81 | } 82 | 83 | if size, err = namedMap.Size(ctx); err != nil { 84 | panic(err) 85 | } 86 | fmt.Println("Cache size is", size) 87 | 88 | fmt.Println("Update person age using processor") 89 | // Update the age 90 | _, err = coherence.Invoke[int, Person, bool](ctx, namedMap, 1, processors.Update("age", 22)) 91 | if err != nil { 92 | panic(err) 93 | } 94 | 95 | _, err = namedMap.Remove(ctx, 1) 96 | if err != nil { 97 | panic(err) 98 | } 99 | 100 | if size, err = namedMap.Size(ctx); err != nil { 101 | panic(err) 102 | } 103 | fmt.Println("Cache size is", size) 104 | } 105 | -------------------------------------------------------------------------------- /examples/events/cache/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package cache shows examples using MapEvents. 9 | */ 10 | package cache 11 | -------------------------------------------------------------------------------- /examples/events/cache/insert/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for insert events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/processors" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the cache 55 | listener := coherence.NewMapListener[int, Person]().OnInserted(func(e coherence.MapEvent[int, Person]) { 56 | key, err1 := e.Key() 57 | if err1 != nil { 58 | panic(err) 59 | } 60 | newValue, err1 := e.NewValue() 61 | if err1 != nil { 62 | panic(err) 63 | } 64 | 65 | fmt.Printf("**EVENT=Inserted: key=%v, value=%v\n", *key, newValue) 66 | }) 67 | 68 | if err = namedMap.AddListener(ctx, listener); err != nil { 69 | panic(err) 70 | } 71 | 72 | defer func(ctx context.Context, namedMap coherence.NamedMap[int, Person], listener coherence.MapListener[int, Person]) { 73 | if err := namedMap.RemoveListener(ctx, listener); err != nil { 74 | panic(err) 75 | } 76 | }(ctx, namedMap, listener) 77 | 78 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 79 | fmt.Println("Add new Person", newPerson) 80 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 81 | panic(err) 82 | } 83 | 84 | if size, err = namedMap.Size(ctx); err != nil { 85 | panic(err) 86 | } 87 | fmt.Println("Cache size is", size) 88 | 89 | fmt.Println("Update person age using processor") 90 | // Update the age 91 | _, err = coherence.Invoke[int, Person, bool](ctx, namedMap, 1, processors.Update("age", 22)) 92 | if err != nil { 93 | panic(err) 94 | } 95 | 96 | _, err = namedMap.Remove(ctx, 1) 97 | if err != nil { 98 | panic(err) 99 | } 100 | 101 | if size, err = namedMap.Size(ctx); err != nil { 102 | panic(err) 103 | } 104 | fmt.Println("Cache size is", size) 105 | 106 | if err = namedMap.Truncate(ctx); err != nil { 107 | panic(err) 108 | } 109 | 110 | fmt.Println("Cache truncated") 111 | } 112 | -------------------------------------------------------------------------------- /examples/events/cache/key/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for events on a NamedMap or NamedCache for a specific key. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/processors" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | ctx := context.Background() 31 | 32 | // create a new Session 33 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | defer session.Close() 39 | 40 | // create a new NamedMap of Person with key int 41 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | // clear the Map 47 | if err = namedMap.Clear(ctx); err != nil { 48 | panic(err) 49 | } 50 | 51 | // Create a listener and add to the cache for key 1 52 | listener := coherence.NewMapListener[int, Person]().OnUpdated(func(e coherence.MapEvent[int, Person]) { 53 | key, err1 := e.Key() 54 | if err1 != nil { 55 | panic("unable to deserialize key") 56 | } 57 | 58 | newValue, err1 := e.NewValue() 59 | if err1 != nil { 60 | panic("unable to deserialize new value") 61 | } 62 | 63 | oldValue, err1 := e.OldValue() 64 | if err1 != nil { 65 | panic("unable to deserialize old value") 66 | } 67 | 68 | fmt.Printf("**EVENT=Updated: key=%v, oldValue=%v, newValue=%v\n", *key, *oldValue, *newValue) 69 | }) 70 | if err = namedMap.AddKeyListener(ctx, listener, 1); err != nil { 71 | panic(err) 72 | } 73 | 74 | defer func(ctx context.Context, namedMap coherence.NamedMap[int, Person], listener coherence.MapListener[int, Person]) { 75 | if err := namedMap.RemoveListener(ctx, listener); err != nil { 76 | panic(fmt.Sprintf("cannot remove listener %v", listener)) 77 | } 78 | }(ctx, namedMap, listener) 79 | 80 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 81 | fmt.Println("Add new Person", newPerson) 82 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 83 | panic(err) 84 | } 85 | 86 | fmt.Println("Update person age using processor") 87 | // Update the age 88 | _, err = coherence.Invoke[int, Person, bool](ctx, namedMap, 1, processors.Update("age", 22)) 89 | if err != nil { 90 | panic(err) 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /examples/events/cache/people_insert/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main inserts entries into a people NamedMap insert PutAll(). 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "log" 17 | "os" 18 | "strconv" 19 | "time" 20 | ) 21 | 22 | type Person struct { 23 | ID int `json:"id"` 24 | Name string `json:"name"` 25 | Age int `json:"age"` 26 | InsertTime int64 `json:"insertTime"` 27 | } 28 | 29 | func (p Person) String() string { 30 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d, insertTime=%v}", p.ID, p.Name, p.Age, p.InsertTime) 31 | } 32 | 33 | func main() { 34 | var ( 35 | ctx = context.Background() 36 | err error 37 | startID int 38 | iterations int 39 | size int 40 | ) 41 | 42 | // check arguments 43 | if len(os.Args) != 3 { 44 | log.Println("please provide a starting ID and number to insert") 45 | return 46 | } 47 | 48 | if startID, err = strconv.Atoi(os.Args[1]); err != nil { 49 | panic("invalid value for starting ID") 50 | } 51 | if iterations, err = strconv.Atoi(os.Args[2]); err != nil { 52 | panic("invalid value for iterations") 53 | } 54 | 55 | fmt.Println("Start ID=", startID, ",Iterations=", iterations) 56 | 57 | // create a new Session to the default gRPC port of 1408 using plain text 58 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 59 | if err != nil { 60 | panic(err) 61 | } 62 | defer session.Close() 63 | 64 | log.Printf("%v\n", session) 65 | 66 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 67 | if err != nil { 68 | panic(err) 69 | } 70 | 71 | if iterations == 0 { 72 | fmt.Println("Clearing cache") 73 | if err = namedMap.Clear(ctx); err != nil { 74 | panic(err) 75 | } 76 | fmt.Println("cache cleared") 77 | return 78 | } 79 | 80 | if iterations < 0 { 81 | panic("iterations cannot be less that zero") 82 | } 83 | 84 | log.Println("Adding", iterations, "people starting at", startID) 85 | batchSize := 1000 86 | buffer := make(map[int]Person) 87 | 88 | for i := startID; i < startID+iterations; i++ { 89 | p := Person{ID: i, Name: fmt.Sprintf("Name-%d", i), Age: 15 + i, InsertTime: time.Now().UnixNano()} 90 | buffer[p.ID] = p 91 | if i%batchSize == 0 { 92 | log.Println("Writing batch of", batchSize) 93 | if err = namedMap.PutAll(ctx, buffer); err != nil { 94 | panic(err) 95 | } 96 | buffer = make(map[int]Person) 97 | } 98 | } 99 | // write any left in the buffer 100 | if len(buffer) > 0 { 101 | if err = namedMap.PutAll(ctx, buffer); err != nil { 102 | panic(err) 103 | } 104 | } 105 | 106 | if size, err = namedMap.Size(ctx); err != nil { 107 | panic(err) 108 | } 109 | log.Println("Size is", size) 110 | } 111 | -------------------------------------------------------------------------------- /examples/events/cache/people_listen/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main listens for all events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "log" 17 | "time" 18 | ) 19 | 20 | type Person struct { 21 | ID int `json:"id"` 22 | Name string `json:"name"` 23 | Age int `json:"age"` 24 | InsertTime int64 `json:"insertTime"` 25 | } 26 | 27 | func (p Person) String() string { 28 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d, insertTime=%v}", p.ID, p.Name, p.Age, p.InsertTime) 29 | } 30 | 31 | func main() { 32 | ctx := context.Background() 33 | 34 | // create a new Session 35 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 36 | if err != nil { 37 | panic(err) 38 | } 39 | 40 | defer session.Close() 41 | 42 | // create a new NamedMap of Person with key int 43 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | fmt.Println("Adding listener for all events") 49 | listener := coherence.NewMapListener[int, Person]().OnAny(func(e coherence.MapEvent[int, Person]) { 50 | var ( 51 | newValue *Person 52 | oldValue *Person 53 | ) 54 | key, err1 := e.Key() 55 | if err1 != nil { 56 | panic("unable to deserialize key") 57 | } 58 | 59 | if e.Type() == coherence.EntryInserted || e.Type() == coherence.EntryUpdated { 60 | newValue, err1 = e.NewValue() 61 | if err1 != nil { 62 | panic("unable to deserialize new value") 63 | } 64 | } 65 | if e.Type() == coherence.EntryDeleted || e.Type() == coherence.EntryUpdated { 66 | oldValue, err1 = e.OldValue() 67 | if err1 != nil { 68 | panic("unable to deserialize old value") 69 | } 70 | } 71 | 72 | log.Printf("***EVENT=%v: key=%v, oldValue=%v, newValue=%v\n", e.Type(), *key, oldValue, newValue) 73 | }) 74 | 75 | if err = namedMap.AddListener(ctx, listener); err != nil { 76 | panic(err) 77 | } 78 | 79 | defer func(ctx context.Context, namedMap coherence.NamedMap[int, Person], listener coherence.MapListener[int, Person]) { 80 | if err := namedMap.RemoveListener(ctx, listener); err != nil { 81 | panic(fmt.Sprintf("cannot remove listener %v, %v", listener, err)) 82 | } 83 | }(ctx, namedMap, listener) 84 | 85 | time.Sleep(time.Duration(10000000) * time.Second) 86 | } 87 | -------------------------------------------------------------------------------- /examples/events/cache/update/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for update events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/processors" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the cache 55 | listener := coherence.NewMapListener[int, Person]().OnUpdated(func(e coherence.MapEvent[int, Person]) { 56 | key, err := e.Key() 57 | if err != nil { 58 | panic("unable to deserialize key") 59 | } 60 | 61 | newValue, err := e.NewValue() 62 | if err != nil { 63 | panic("unable to deserialize new value") 64 | } 65 | 66 | oldValue, err := e.OldValue() 67 | if err != nil { 68 | panic("unable to deserialize old value") 69 | } 70 | 71 | fmt.Printf("**EVENT=Updated: key=%v, oldValue=%v, newValue=%v\n", *key, *oldValue, *newValue) 72 | }) 73 | if err = namedMap.AddListener(ctx, listener); err != nil { 74 | panic(err) 75 | } 76 | 77 | defer func(ctx context.Context, namedMap coherence.NamedMap[int, Person], listener coherence.MapListener[int, Person]) { 78 | if err := namedMap.RemoveListener(ctx, listener); err != nil { 79 | panic(fmt.Sprintf("cannot remove listener %v", listener)) 80 | } 81 | }(ctx, namedMap, listener) 82 | 83 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 84 | fmt.Println("Add new Person", newPerson) 85 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 86 | panic(err) 87 | } 88 | 89 | if size, err = namedMap.Size(ctx); err != nil { 90 | panic(err) 91 | } 92 | fmt.Println("Cache size is", size) 93 | 94 | fmt.Println("Update person age using processor") 95 | // Update the age 96 | _, err = coherence.Invoke[int, Person, bool](ctx, namedMap, 1, processors.Update("age", 22)) 97 | if err != nil { 98 | panic(err) 99 | } 100 | 101 | if size, err = namedMap.Size(ctx); err != nil { 102 | panic(err) 103 | } 104 | fmt.Println("Cache size is", size) 105 | } 106 | -------------------------------------------------------------------------------- /examples/events/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package events shows examples using events. 9 | */ 10 | package events 11 | -------------------------------------------------------------------------------- /examples/events/lifecycle/all/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for all lifecycle events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the cache 55 | listener := coherence.NewMapLifecycleListener[int, Person]().OnAny(func(e coherence.MapLifecycleEvent[int, Person]) { 56 | fmt.Printf("**EVENT=%s: source=%v\n", e.Type(), e.Source()) 57 | }) 58 | 59 | namedMap.AddLifecycleListener(listener) 60 | 61 | defer namedMap.RemoveLifecycleListener(listener) 62 | 63 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 64 | fmt.Println("Add new Person", newPerson) 65 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 66 | panic(err) 67 | } 68 | 69 | if size, err = namedMap.Size(ctx); err != nil { 70 | panic(err) 71 | } 72 | 73 | fmt.Println("Cache size is", size, ", truncate cache") 74 | if err = namedMap.Truncate(ctx); err != nil { 75 | panic(err) 76 | } 77 | 78 | sleep("Sleeping to ensure we see event") 79 | 80 | fmt.Println("Cache size is", size, "destroy cache") 81 | if err = namedMap.Destroy(ctx); err != nil { 82 | panic(err) 83 | } 84 | 85 | sleep("Sleeping to ensure we see events") 86 | } 87 | 88 | func sleep(msg string) { 89 | fmt.Println(msg) 90 | time.Sleep(time.Duration(5) * time.Second) 91 | } 92 | -------------------------------------------------------------------------------- /examples/events/lifecycle/destroyed/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for destroyed events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the cache 55 | listener := coherence.NewMapLifecycleListener[int, Person](). 56 | OnDestroyed(func(e coherence.MapLifecycleEvent[int, Person]) { 57 | fmt.Printf("**EVENT=%s: source=%v\n", e.Type(), e.Source()) 58 | }) 59 | 60 | namedMap.AddLifecycleListener(listener) 61 | 62 | defer namedMap.RemoveLifecycleListener(listener) 63 | 64 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 65 | fmt.Println("Add new Person", newPerson) 66 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 67 | panic(err) 68 | } 69 | 70 | if size, err = namedMap.Size(ctx); err != nil { 71 | panic(err) 72 | } 73 | fmt.Println("Cache size is", size, ", destroying cache") 74 | 75 | if err = namedMap.Destroy(ctx); err != nil { 76 | panic(err) 77 | } 78 | 79 | sleep("Sleeping to ensure we see event") 80 | 81 | fmt.Println("Ensure we can no longer use the namedMap") 82 | _, err = namedMap.Size(ctx) 83 | fmt.Println("Size() operation returned error:", err) 84 | } 85 | 86 | func sleep(msg string) { 87 | fmt.Println(msg) 88 | time.Sleep(time.Duration(5) * time.Second) 89 | } 90 | -------------------------------------------------------------------------------- /examples/events/lifecycle/released/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for released events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the cache 55 | listener := coherence.NewMapLifecycleListener[int, Person](). 56 | OnReleased(func(e coherence.MapLifecycleEvent[int, Person]) { 57 | fmt.Printf("**EVENT=%s: source=%v\n", e.Type(), e.Source()) 58 | }) 59 | 60 | namedMap.AddLifecycleListener(listener) 61 | defer namedMap.RemoveLifecycleListener(listener) 62 | 63 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 64 | fmt.Println("Add new Person", newPerson) 65 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 66 | panic(err) 67 | } 68 | 69 | if size, err = namedMap.Size(ctx); err != nil { 70 | panic(err) 71 | } 72 | fmt.Println("Cache size is", size, "releasing cache") 73 | 74 | namedMap.Release() 75 | sleep("sleep") 76 | 77 | // try an operation and you will get error as the resources are released 78 | _, err = namedMap.Size(ctx) 79 | if err != coherence.ErrReleased { 80 | panic(err) 81 | } 82 | 83 | fmt.Println("Done") 84 | } 85 | 86 | func sleep(msg string) { 87 | fmt.Println(msg) 88 | time.Sleep(time.Duration(5) * time.Second) 89 | } 90 | -------------------------------------------------------------------------------- /examples/events/lifecycle/truncated/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for truncated events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | var ( 31 | size int 32 | ctx = context.Background() 33 | ) 34 | 35 | // create a new Session 36 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | 41 | defer session.Close() 42 | 43 | // create a new NamedMap of Person with key int 44 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 45 | if err != nil { 46 | panic(err) 47 | } 48 | 49 | // clear the Map 50 | if err = namedMap.Clear(ctx); err != nil { 51 | panic(err) 52 | } 53 | 54 | // Create a listener and add to the cache 55 | listener := coherence.NewMapLifecycleListener[int, Person](). 56 | OnTruncated(func(e coherence.MapLifecycleEvent[int, Person]) { 57 | fmt.Printf("**EVENT=%s: source=%v\n", e.Type(), e.Source()) 58 | }) 59 | 60 | namedMap.AddLifecycleListener(listener) 61 | 62 | defer namedMap.RemoveLifecycleListener(listener) 63 | 64 | newPerson := Person{ID: 1, Name: "Tim", Age: 21} 65 | fmt.Println("Add new Person", newPerson) 66 | if _, err = namedMap.Put(ctx, newPerson.ID, newPerson); err != nil { 67 | panic(err) 68 | } 69 | 70 | if size, err = namedMap.Size(ctx); err != nil { 71 | panic(err) 72 | } 73 | fmt.Println("Cache size is", size, "truncating cache") 74 | 75 | if err = namedMap.Truncate(ctx); err != nil { 76 | panic(err) 77 | } 78 | 79 | sleep("sleep") 80 | 81 | fmt.Println("Removing lifecycle listener, we should not see truncate event again") 82 | namedMap.RemoveLifecycleListener(listener) 83 | 84 | fmt.Println("Truncate cache again") 85 | if err = namedMap.Truncate(ctx); err != nil { 86 | panic(err) 87 | } 88 | 89 | sleep("sleep") 90 | fmt.Println("Done") 91 | } 92 | 93 | func sleep(msg string) { 94 | fmt.Println(msg) 95 | time.Sleep(time.Duration(5) * time.Second) 96 | } 97 | -------------------------------------------------------------------------------- /examples/events/session/all/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for all session events on a NamedMap or NamedCache. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | func (p Person) String() string { 26 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d}", p.ID, p.Name, p.Age) 27 | } 28 | 29 | func main() { 30 | ctx := context.Background() 31 | 32 | // create a new Session 33 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | // create a new NamedMap of Person with key int 39 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 40 | if err != nil { 41 | panic(err) 42 | } 43 | 44 | // clear the Map 45 | if err = namedMap.Clear(ctx); err != nil { 46 | panic(err) 47 | } 48 | 49 | // Create a listener to listen for session events 50 | listener := coherence.NewSessionLifecycleListener(). 51 | OnAny(func(e coherence.SessionLifecycleEvent) { 52 | fmt.Printf("**EVENT=%s: source=%v\n", e.Type(), e.Source()) 53 | }) 54 | 55 | session.AddSessionLifecycleListener(listener) 56 | defer session.RemoveSessionLifecycleListener(listener) 57 | 58 | session.Close() 59 | 60 | sleep("Sleeping to ensure we see events") 61 | } 62 | 63 | func sleep(msg string) { 64 | fmt.Println(msg) 65 | time.Sleep(time.Duration(5) * time.Second) 66 | } 67 | -------------------------------------------------------------------------------- /examples/indexes/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows examples using indexes. 9 | */ 10 | package main 11 | -------------------------------------------------------------------------------- /examples/indexes/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to add indexes against a NamedMap or NamedCache to support queries and aggregations. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/aggregators" 17 | "github.com/oracle/coherence-go-client/v2/coherence/extractors" 18 | "github.com/oracle/coherence-go-client/v2/coherence/filters" 19 | "time" 20 | ) 21 | 22 | type Person struct { 23 | ID int `json:"id"` 24 | Name string `json:"name"` 25 | Age int `json:"age"` 26 | City string `json:"city"` 27 | } 28 | 29 | func (p Person) String() string { 30 | return fmt.Sprintf("Person{id=%d, name=%s, age=%d, city=%s}", p.ID, p.Name, p.Age, p.City) 31 | } 32 | 33 | func main() { 34 | var ( 35 | ctx = context.Background() 36 | cities = []string{"Perth", "Adelaide", "Sydney", "Melbourne"} 37 | insertCount = 50_000 38 | count *int64 39 | ) 40 | 41 | // create a new Session to the default gRPC port of 1408 using plain text 42 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 43 | if err != nil { 44 | panic(err) 45 | } 46 | defer session.Close() 47 | 48 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 49 | if err != nil { 50 | panic(err) 51 | } 52 | 53 | if err = namedMap.Clear(ctx); err != nil { 54 | panic(err) 55 | } 56 | 57 | fmt.Printf("Adding %d random people using PutAll()\n", insertCount) 58 | 59 | batchSize := 5000 60 | buffer := make(map[int]Person) 61 | 62 | for i := 1; i <= insertCount; i++ { 63 | p := Person{ID: i, Name: fmt.Sprintf("Person-%d", i), Age: 15 + i%40, City: cities[i%4]} 64 | buffer[p.ID] = p 65 | if i%batchSize == 0 { 66 | if err = namedMap.PutAll(ctx, buffer); err != nil { 67 | panic(err) 68 | } 69 | buffer = make(map[int]Person) 70 | } 71 | } 72 | // write any left in the buffer 73 | if len(buffer) > 0 { 74 | if err = namedMap.PutAll(ctx, buffer); err != nil { 75 | panic(err) 76 | } 77 | } 78 | 79 | size, _ := namedMap.Size(ctx) 80 | fmt.Println("Cache size is", size) 81 | 82 | age := extractors.Extract[int]("age") 83 | 84 | fmt.Println("Retrieve the count of people between the age of 20 and 40 without indexes") 85 | start := time.Now() 86 | count, err = coherence.AggregateFilter(ctx, namedMap, filters.Between(age, 20, 40), aggregators.Count()) 87 | duration := time.Since(start) 88 | 89 | if err != nil { 90 | panic(err) 91 | } 92 | fmt.Printf("Count = %v, duration without index: %v. Adding index and waiting 10 seconds...\n", *count, duration) 93 | 94 | err = coherence.AddIndex(ctx, namedMap, age, true) 95 | if err != nil { 96 | panic(err) 97 | } 98 | 99 | time.Sleep(time.Duration(10) * time.Second) 100 | start = time.Now() 101 | count, err = coherence.AggregateFilter(ctx, namedMap, filters.Between(age, 20, 40), aggregators.Count()) 102 | duration = time.Since(start) 103 | 104 | if err != nil { 105 | panic(err) 106 | } 107 | fmt.Printf("Count = %v, duration WITH index: %v\n", *count, duration) 108 | 109 | err = coherence.RemoveIndex(ctx, namedMap, age) 110 | if err != nil { 111 | panic(err) 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /examples/querying/filters/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to run queries against a NamedMap or NamedCache using filters. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/extractors" 17 | "github.com/oracle/coherence-go-client/v2/coherence/filters" 18 | ) 19 | 20 | type Person struct { 21 | ID int `json:"id"` 22 | Name string `json:"name"` 23 | Age int `json:"age"` 24 | City string `json:"city"` 25 | } 26 | 27 | func main() { 28 | 29 | var ( 30 | ctx = context.Background() 31 | cities = []string{"Perth", "Adelaide", "Sydney", "Melbourne"} 32 | ) 33 | 34 | // create a new Session to the default gRPC port of 1408 using plain text 35 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 36 | if err != nil { 37 | panic(err) 38 | } 39 | defer session.Close() 40 | 41 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | if err = namedMap.Clear(ctx); err != nil { 47 | panic(err) 48 | } 49 | 50 | fmt.Println("Adding 20 random people") 51 | for i := 1; i <= 20; i++ { 52 | p := Person{ID: i, Name: fmt.Sprintf("Person-%d", i), Age: 15 + i, City: cities[i%4]} 53 | _, err = namedMap.Put(ctx, p.ID, p) 54 | if err != nil { 55 | panic(err) 56 | } 57 | } 58 | 59 | size, _ := namedMap.Size(ctx) 60 | fmt.Println("Cache size is", size) 61 | 62 | age := extractors.Extract[int]("age") 63 | city := extractors.Extract[string]("city") 64 | 65 | fmt.Println("Retrieve the people between the age of 17 and 21") 66 | ch := namedMap.EntrySetFilter(ctx, filters.Between(age, 17, 21)) 67 | for result := range ch { 68 | if result.Err != nil { 69 | panic(err) 70 | } 71 | 72 | fmt.Println("Key:", result.Key, "Value:", result.Value) 73 | } 74 | 75 | fmt.Println("Retrieve the people between the age of 17 and 30 and who live in Perth") 76 | ch = namedMap.EntrySetFilter(ctx, filters.Between(age, 17, 30).And(filters.Equal(city, "Perth"))) 77 | for result := range ch { 78 | if result.Err != nil { 79 | panic(err) 80 | } 81 | 82 | fmt.Println("Key:", result.Key, "Value:", result.Value) 83 | } 84 | 85 | fmt.Println("Retrieve the people between the age of 17 and 25 and who live in Perth or Melbourne") 86 | ch = namedMap.EntrySetFilter(ctx, filters.Between(age, 17, 25).And(filters.In(city, []string{"Perth", "Melbourne"}))) 87 | for result := range ch { 88 | if result.Err != nil { 89 | panic(err) 90 | } 91 | 92 | fmt.Println("Key:", result.Key, "Value:", result.Value) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /examples/querying/filters_sorted/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to run queries against a NamedMap or NamedCache using filters and sorting the results. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "github.com/oracle/coherence-go-client/v2/coherence/extractors" 17 | "github.com/oracle/coherence-go-client/v2/coherence/filters" 18 | "log" 19 | ) 20 | 21 | type Person struct { 22 | ID int `json:"id"` 23 | Name string `json:"name"` 24 | Age int `json:"age"` 25 | City string `json:"city"` 26 | } 27 | 28 | func (p *Person) String() string { 29 | return fmt.Sprintf("ID: %d, Name: %s, Age: %d", p.ID, p.Name, p.Age) 30 | } 31 | 32 | func main() { 33 | var ( 34 | ctx = context.Background() 35 | cities = []string{"Perth", "Adelaide", "Sydney", "Melbourne"} 36 | ) 37 | 38 | // create a new Session to the default gRPC port of 1408 using plain text 39 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 40 | if err != nil { 41 | panic(err) 42 | } 43 | defer session.Close() 44 | 45 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 46 | if err != nil { 47 | panic(err) 48 | } 49 | 50 | if session.GetProtocolVersion() == 0 { 51 | log.Println("feature not support in v0 gRPC API") 52 | return 53 | } 54 | 55 | if err = namedMap.Clear(ctx); err != nil { 56 | panic(err) 57 | } 58 | 59 | fmt.Println("Adding 20 random people") 60 | for i := 1; i <= 20; i++ { 61 | p := Person{ID: i, Name: fmt.Sprintf("Person-%d", i), Age: 15 + i, City: cities[i%4]} 62 | _, err = namedMap.Put(ctx, p.ID, p) 63 | if err != nil { 64 | panic(err) 65 | } 66 | } 67 | 68 | size, _ := namedMap.Size(ctx) 69 | fmt.Println("Cache size is", size) 70 | 71 | age := extractors.Extract[int]("age") 72 | city := extractors.Extract[string]("city") 73 | 74 | fmt.Println("Retrieve the people between the age of 17 and 21 and order by age ascending") 75 | ch := coherence.EntrySetFilterWithComparator(ctx, namedMap, filters.Between(age, 17, 21), extractors.ExtractorComparator(age, true)) 76 | for result := range ch { 77 | if result.Err != nil { 78 | panic(result.Err) 79 | } 80 | 81 | fmt.Printf("Key: %v, Value: %s\n", result.Key, result.Value.String()) 82 | } 83 | 84 | fmt.Println("Retrieve the people between the age of 17 and 30 and who live in Perth, sorted by age descending") 85 | ch = coherence.EntrySetFilterWithComparator(ctx, namedMap, filters.Between(age, 17, 30).And(filters.Equal(city, "Perth")), 86 | extractors.ExtractorComparator(age, false)) 87 | for result := range ch { 88 | if result.Err != nil { 89 | panic(err) 90 | } 91 | 92 | fmt.Printf("Key: %v, Value: %s\n", result.Key, result.Value.String()) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /examples/querying/keys/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to run queries against a NamedMap or NamedCache using keys. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | ) 17 | 18 | type Person struct { 19 | ID int `json:"id"` 20 | Name string `json:"name"` 21 | Age int `json:"age"` 22 | } 23 | 24 | func main() { 25 | var ctx = context.Background() 26 | 27 | // create a new Session to the default gRPC port of 1408 using plain text 28 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 29 | if err != nil { 30 | panic(err) 31 | } 32 | defer session.Close() 33 | 34 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | _ = namedMap.Clear(ctx) 40 | 41 | fmt.Println("Adding 10 random people for querying against keys") 42 | for i := 1; i <= 10; i++ { 43 | p := Person{ID: i, Name: fmt.Sprintf("Name-%d", i), Age: 15 + i} 44 | _, err = namedMap.Put(ctx, p.ID, p) 45 | if err != nil { 46 | panic(err) 47 | } 48 | } 49 | 50 | size, _ := namedMap.Size(ctx) 51 | fmt.Println("Cache size is", size) 52 | 53 | fmt.Println("Retrieve the people with keys 1, 4 and 5") 54 | ch := namedMap.GetAll(ctx, []int{1, 4, 5}) 55 | for result := range ch { 56 | if result.Err != nil { 57 | panic(err) 58 | } 59 | fmt.Println("Key:", result.Key, "Value:", result.Value) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/querying/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to run open-ended queries against a NamedMap or NamedCache using keys. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | ) 17 | 18 | func main() { 19 | type Person struct { 20 | ID int `json:"id"` 21 | Name string `json:"name"` 22 | Age int `json:"age"` 23 | } 24 | 25 | ctx := context.Background() 26 | 27 | // create a new Session to the default gRPC port of 1408 using plain text 28 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 29 | if err != nil { 30 | panic(err) 31 | } 32 | defer session.Close() 33 | 34 | namedMap, err := coherence.GetNamedMap[int, Person](session, "people") 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | _ = namedMap.Clear(ctx) 40 | 41 | fmt.Println("Adding 10 random people") 42 | for i := 1; i <= 10; i++ { 43 | p := Person{ID: i, Name: fmt.Sprintf("Name-%d", i), Age: 15 + i} 44 | _, err = namedMap.Put(ctx, p.ID, p) 45 | if err != nil { 46 | panic(err) 47 | } 48 | } 49 | 50 | fmt.Println("Running KeySet()") 51 | count := 0 52 | 53 | for result := range namedMap.KeySet(ctx) { 54 | if result.Err != nil { 55 | panic(result.Err) 56 | } 57 | fmt.Println("key", result.Key) 58 | count++ 59 | } 60 | fmt.Println("KeySet count", count) 61 | 62 | fmt.Println("Running EntrySet()") 63 | count = 0 64 | 65 | for result := range namedMap.EntrySet(ctx) { 66 | if result.Err != nil { 67 | panic(result.Err) 68 | } 69 | fmt.Println("Key:", result.Key, "Value:", result.Value) 70 | count++ 71 | } 72 | fmt.Println("EntrySet count", count) 73 | 74 | fmt.Println("Running Values()") 75 | count = 0 76 | 77 | for result := range namedMap.Values(ctx) { 78 | if result.Err != nil { 79 | panic(result.Err) 80 | } 81 | fmt.Println(result.Value) 82 | count++ 83 | } 84 | fmt.Println("Values() count", count) 85 | } 86 | -------------------------------------------------------------------------------- /examples/queues/dequeue/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to use a dequeue or double ended queue. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "log" 17 | ) 18 | 19 | func main() { 20 | var ( 21 | value *string 22 | ctx = context.Background() 23 | ) 24 | 25 | const iterations = 10 26 | 27 | // create a new Session to the default gRPC port of 1408 using plain text 28 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 29 | if err != nil { 30 | panic(err) 31 | } 32 | defer session.Close() 33 | 34 | namedQueue, err := coherence.GetNamedDeQueue[string](ctx, session, "double-ended-queue") 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | // add 10 entries to the end (tail) of the queue 40 | for i := 1; i <= iterations; i++ { 41 | v := fmt.Sprintf("value-%v", i) 42 | log.Printf("OfferTail() %s to the queue\n", v) 43 | err = namedQueue.OfferTail(ctx, v) 44 | if err != nil { 45 | panic(err) 46 | } 47 | } 48 | 49 | // Offer a value to the head 50 | err = namedQueue.OfferHead(ctx, "value-head") 51 | if err != nil { 52 | panic(err) 53 | } 54 | 55 | // peek the tail of the queue 56 | value, err = namedQueue.PeekTail(ctx) 57 | if err != nil { 58 | panic(err) 59 | } 60 | log.Printf("PeekTail() returned: %s\n", *value) 61 | 62 | // poll for iterations +1 because we added another entry to the head 63 | for i := 1; i <= iterations+1; i++ { 64 | value, err = namedQueue.PollHead(ctx) 65 | if err != nil { 66 | panic(err) 67 | } 68 | log.Printf("PollHead() returned: %s\n", *value) 69 | } 70 | 71 | // try to read again should get nil 72 | value, err = namedQueue.PollHead(ctx) 73 | if err != nil { 74 | panic(err) 75 | } 76 | log.Println("last value is", value) 77 | } 78 | -------------------------------------------------------------------------------- /examples/queues/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows examples using queues. 9 | */ 10 | package main 11 | -------------------------------------------------------------------------------- /examples/queues/events/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to listen for events on queues. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "time" 17 | ) 18 | 19 | func main() { 20 | var ctx = context.Background() 21 | 22 | // create a new Session to the default gRPC port of 1408 using plain text 23 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 24 | if err != nil { 25 | panic(err) 26 | } 27 | defer session.Close() 28 | 29 | namedQueue, err := coherence.GetNamedQueue[string](ctx, session, "queue-events", coherence.Queue) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | // Create a listener to monitor for Released events 35 | listener := coherence.NewQueueLifecycleListener[string](). 36 | OnReleased(func(e coherence.QueueLifecycleEvent[string]) { 37 | fmt.Printf("**EVENT=%s: source=%v\n", e.Type(), e.Source()) 38 | }) 39 | 40 | err = namedQueue.AddLifecycleListener(listener) 41 | if err != nil { 42 | panic(err) 43 | } 44 | 45 | namedQueue.Release() 46 | 47 | time.Sleep(5 * time.Second) 48 | } 49 | -------------------------------------------------------------------------------- /examples/queues/standard/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package main shows how to use queues. 9 | */ 10 | package main 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "github.com/oracle/coherence-go-client/v2/coherence" 16 | "log" 17 | ) 18 | 19 | func main() { 20 | var ( 21 | value *string 22 | ctx = context.Background() 23 | ) 24 | 25 | const iterations = 10 26 | 27 | // create a new Session to the default gRPC port of 1408 using plain text 28 | session, err := coherence.NewSession(ctx, coherence.WithPlainText()) 29 | if err != nil { 30 | panic(err) 31 | } 32 | defer session.Close() 33 | 34 | namedQueue, err := coherence.GetNamedQueue[string](ctx, session, "my-queue", coherence.Queue) 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | // Offer 10 entries to the tail of the queue 40 | for i := 1; i <= iterations; i++ { 41 | v := fmt.Sprintf("value-%v", i) 42 | log.Printf("OfferTail() %s to the queue\n", v) 43 | err = namedQueue.OfferTail(ctx, v) 44 | if err != nil { 45 | panic(err) 46 | } 47 | } 48 | 49 | for i := 1; i <= iterations; i++ { 50 | value, err = namedQueue.PollHead(ctx) 51 | if err != nil { 52 | panic(err) 53 | } 54 | log.Printf("PollHead() returned: %s\n", *value) 55 | } 56 | 57 | // try to read again should get nil 58 | value, err = namedQueue.PollHead(ctx) 59 | if err != nil { 60 | panic(err) 61 | } 62 | log.Println("last value is", value) 63 | } 64 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, 2025 Oracle and/or its affiliates. 3 | // Licensed under the Universal Permissive License v 1.0 as shown at 4 | // https://oss.oracle.com/licenses/upl. 5 | // 6 | module github.com/oracle/coherence-go-client/v2 7 | 8 | go 1.23.0 9 | 10 | toolchain go1.23.7 11 | 12 | require ( 13 | github.com/google/uuid v1.6.0 14 | github.com/onsi/gomega v1.37.0 15 | golang.org/x/text v0.25.0 16 | google.golang.org/grpc v1.72.2 17 | google.golang.org/protobuf v1.36.6 18 | ) 19 | 20 | require ( 21 | github.com/google/go-cmp v0.7.0 // indirect 22 | golang.org/x/net v0.40.0 // indirect 23 | golang.org/x/sys v0.33.0 // indirect 24 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect 25 | gopkg.in/yaml.v3 v3.0.1 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /java/coherence-go-client-data-jakarta/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 4.0.0 14 | 15 | 16 | com.oracle.coherence.go 17 | coherence-go-parent 18 | 1.0.0 19 | ../pom.xml 20 | 21 | 22 | coherence-go-client-data-jakarta 23 | 24 | Oracle Coherence Go Client Data Jakarta 25 | coherence-go-client-data-jakarta 26 | 27 | 28 | 29 | ${coherence.group.id} 30 | coherence-json 31 | ${coherence.version} 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /java/coherence-go-client-data-jakarta/src/main/java/com/oracle/coherence/go/testing/Address.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | 8 | package com.oracle.coherence.go.testing; 9 | 10 | import java.io.Serializable; 11 | import java.util.Objects; 12 | import jakarta.json.bind.annotation.JsonbProperty; 13 | 14 | /** 15 | * Class to represent an Australian address. 16 | * 17 | * @author Tim Middleton 2022-12-22 18 | */ 19 | public class Address 20 | implements Serializable { 21 | 22 | @JsonbProperty("addressLine1") 23 | private String addressLine1; 24 | 25 | @JsonbProperty("addressLine2") 26 | private String addressLine2; 27 | 28 | @JsonbProperty("suburb") 29 | private String suburb; 30 | 31 | @JsonbProperty("city") 32 | private String city; 33 | 34 | @JsonbProperty("state") 35 | private String state; 36 | 37 | @JsonbProperty("postcode") 38 | private int postCode; 39 | 40 | public Address() { 41 | } 42 | 43 | public Address(String addressLine1, String addressLine2, String suburb, String city, String state, int postCode) { 44 | this.addressLine1 = addressLine1; 45 | this.addressLine2 = addressLine2; 46 | this.suburb = suburb; 47 | this.city = city; 48 | this.state = state; 49 | this.postCode = postCode; 50 | } 51 | 52 | public String getAddressLine1() { 53 | return addressLine1; 54 | } 55 | 56 | public void setAddressLine1(String addressLine1) { 57 | this.addressLine1 = addressLine1; 58 | } 59 | 60 | public String getAddressLine2() { 61 | return addressLine2; 62 | } 63 | 64 | public void setAddressLine2(String addressLine2) { 65 | this.addressLine2 = addressLine2; 66 | } 67 | 68 | public String getCity() { 69 | return city; 70 | } 71 | 72 | public void setCity(String city) { 73 | this.city = city; 74 | } 75 | 76 | public String getState() { 77 | return state; 78 | } 79 | 80 | public void setState(String state) { 81 | this.state = state; 82 | } 83 | 84 | public int getPostCode() { 85 | return postCode; 86 | } 87 | 88 | public void setPostCode(int postCode) { 89 | this.postCode = postCode; 90 | } 91 | 92 | public String getSuburb() { 93 | return suburb; 94 | } 95 | 96 | public void setSuburb(String suburb) { 97 | this.suburb = suburb; 98 | } 99 | 100 | @Override 101 | public boolean equals(Object o) { 102 | if (this == o) return true; 103 | if (o == null || getClass() != o.getClass()) return false; 104 | Address address = (Address) o; 105 | return postCode == address.postCode && Objects.equals(addressLine1, address.addressLine1) && 106 | Objects.equals(addressLine2, address.addressLine2) && Objects.equals(suburb, address.suburb) && 107 | Objects.equals(city, address.city) && Objects.equals(state, address.state); 108 | } 109 | 110 | @Override 111 | public int hashCode() { 112 | return Objects.hash(addressLine1, addressLine2, suburb, city, state, postCode); 113 | } 114 | 115 | @Override 116 | public String toString() { 117 | return "Address{" + 118 | "addressLine1='" + addressLine1 + '\'' + 119 | ", addressLine2='" + addressLine2 + '\'' + 120 | ", suburb='" + suburb + '\'' + 121 | ", city='" + city + '\'' + 122 | ", state='" + state + '\'' + 123 | ", postCode=" + postCode + 124 | '}'; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /java/coherence-go-client-data-javax/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 4.0.0 14 | 15 | 16 | com.oracle.coherence.go 17 | coherence-go-parent 18 | 1.0.0 19 | ../pom.xml 20 | 21 | 22 | coherence-go-client-data-javax 23 | 24 | Oracle Coherence Go Client Data Javax 25 | coherence-go-client-data-javax 26 | 27 | 28 | 29 | ${coherence.group.id} 30 | coherence-json 31 | ${coherence.version} 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /java/coherence-go-client-data-javax/src/main/java/com/oracle/coherence/go/testing/Address.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | 8 | package com.oracle.coherence.go.testing; 9 | 10 | import javax.json.bind.annotation.JsonbProperty; 11 | import java.io.Serializable; 12 | import java.util.Objects; 13 | 14 | /** 15 | * Class to represent an Australian address. 16 | * 17 | * @author Tim Middleton 2022-12-22 18 | */ 19 | public class Address 20 | implements Serializable { 21 | 22 | @JsonbProperty("addressLine1") 23 | private String addressLine1; 24 | 25 | @JsonbProperty("addressLine2") 26 | private String addressLine2; 27 | 28 | @JsonbProperty("suburb") 29 | private String suburb; 30 | 31 | @JsonbProperty("city") 32 | private String city; 33 | 34 | @JsonbProperty("state") 35 | private String state; 36 | 37 | @JsonbProperty("postcode") 38 | private int postCode; 39 | 40 | public Address() { 41 | } 42 | 43 | public Address(String addressLine1, String addressLine2, String suburb, String city, String state, int postCode) { 44 | this.addressLine1 = addressLine1; 45 | this.addressLine2 = addressLine2; 46 | this.suburb = suburb; 47 | this.city = city; 48 | this.state = state; 49 | this.postCode = postCode; 50 | } 51 | 52 | public String getAddressLine1() { 53 | return addressLine1; 54 | } 55 | 56 | public void setAddressLine1(String addressLine1) { 57 | this.addressLine1 = addressLine1; 58 | } 59 | 60 | public String getAddressLine2() { 61 | return addressLine2; 62 | } 63 | 64 | public void setAddressLine2(String addressLine2) { 65 | this.addressLine2 = addressLine2; 66 | } 67 | 68 | public String getCity() { 69 | return city; 70 | } 71 | 72 | public void setCity(String city) { 73 | this.city = city; 74 | } 75 | 76 | public String getState() { 77 | return state; 78 | } 79 | 80 | public void setState(String state) { 81 | this.state = state; 82 | } 83 | 84 | public int getPostCode() { 85 | return postCode; 86 | } 87 | 88 | public void setPostCode(int postCode) { 89 | this.postCode = postCode; 90 | } 91 | 92 | public String getSuburb() { 93 | return suburb; 94 | } 95 | 96 | public void setSuburb(String suburb) { 97 | this.suburb = suburb; 98 | } 99 | 100 | @Override 101 | public boolean equals(Object o) { 102 | if (this == o) return true; 103 | if (o == null || getClass() != o.getClass()) return false; 104 | Address address = (Address) o; 105 | return postCode == address.postCode && Objects.equals(addressLine1, address.addressLine1) && 106 | Objects.equals(addressLine2, address.addressLine2) && Objects.equals(suburb, address.suburb) && 107 | Objects.equals(city, address.city) && Objects.equals(state, address.state); 108 | } 109 | 110 | @Override 111 | public int hashCode() { 112 | return Objects.hash(addressLine1, addressLine2, suburb, city, state, postCode); 113 | } 114 | 115 | @Override 116 | public String toString() { 117 | return "Address{" + 118 | "addressLine1='" + addressLine1 + '\'' + 119 | ", addressLine2='" + addressLine2 + '\'' + 120 | ", suburb='" + suburb + '\'' + 121 | ", city='" + city + '\'' + 122 | ", state='" + state + '\'' + 123 | ", postCode=" + postCode + 124 | '}'; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /java/coherence-go-queues/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 4.0.0 14 | 15 | 16 | com.oracle.coherence.go 17 | coherence-go-parent 18 | 1.0.0 19 | ../pom.xml 20 | 21 | 22 | coherence-go-queues 23 | 24 | Oracle Coherence Go Queues 25 | coherence-go-queues 26 | 27 | 28 | 29 | ${coherence.group.id} 30 | coherence 31 | ${coherence.version} 32 | 33 | 34 | 35 | 36 | 37 | jakarta 38 | 39 | false 40 | 41 | 42 | 43 | com.oracle.coherence.go 44 | coherence-go-client-data-jakarta 45 | 1.0.0 46 | 47 | 48 | 49 | 50 | 51 | javax 52 | 53 | false 54 | 55 | 56 | 57 | com.oracle.coherence.go 58 | coherence-go-client-data-javax 59 | 1.0.0 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /java/coherence-go-queues/src/main/java/com/oracle/coherence/go/queues/PopulateQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package com.oracle.coherence.go.queues; 8 | 9 | import com.oracle.coherence.go.testing.Customer; 10 | import com.tangosol.net.Coherence; 11 | import com.tangosol.net.NamedQueue; 12 | import com.tangosol.net.Session; 13 | import com.tangosol.coherence.config.scheme.SimpleDequeScheme; 14 | 15 | /** 16 | * Populate queues. 17 | */ 18 | public class PopulateQueue { 19 | public PopulateQueue() {} 20 | 21 | public void offerData() { 22 | Coherence coherence = Coherence.client().start().join(); 23 | Session session = coherence.getSession(); 24 | 25 | NamedQueue myQueue =SimpleDequeScheme.INSTANCE.realize("test-queue", session); 26 | for (int i = 1; i <= 1000; i++) { 27 | Customer customer = new Customer(); 28 | customer.setId(i); 29 | customer.setCustomerName("Name-" + i); 30 | customer.setCustomerType(Customer.GOLD); 31 | myQueue.offer(customer); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java/coherence-go-test/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 4.0.0 14 | 15 | 16 | com.oracle.coherence.go 17 | coherence-go-parent 18 | 1.0.0 19 | ../pom.xml 20 | 21 | 22 | coherence-go-test 23 | 24 | Oracle Coherence Go Client Test 25 | coherence-go-test 26 | 27 | 28 | 29 | jakarta 30 | 31 | false 32 | 33 | 34 | 35 | com.oracle.coherence.go 36 | coherence-go-client-data-jakarta 37 | 1.0.0 38 | 39 | 40 | 41 | 42 | 43 | javax 44 | 45 | 46 | 47 | . 48 | 49 | 50 | 51 | 52 | com.oracle.coherence.go 53 | coherence-go-client-data-javax 54 | 1.0.0 55 | 56 | 57 | 58 | 59 | 60 | queues 61 | 62 | false 63 | 64 | 65 | 66 | com.oracle.coherence.go 67 | coherence-go-queues 68 | 1.0.0 69 | 70 | 71 | 72 | 73 | 74 | 75 | ${coherence.group.id} 76 | coherence 77 | ${coherence.version} 78 | 79 | 80 | ${coherence.group.id} 81 | coherence-management 82 | ${coherence.version} 83 | 84 | 85 | ${coherence.group.id} 86 | coherence-grpc-proxy 87 | ${coherence.version} 88 | 89 | 90 | ${coherence.group.id} 91 | coherence-json 92 | ${coherence.version} 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /java/coherence-go-test/src/main/java/com/oracle/coherence/go/testing/LongEntryProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package com.oracle.coherence.go.testing; 8 | 9 | import com.tangosol.util.Base; 10 | import com.tangosol.util.InvocableMap; 11 | import com.tangosol.util.processor.AbstractProcessor; 12 | 13 | /** 14 | * An entry process that takes a long time to run to test timeouts. 15 | */ 16 | public class LongEntryProcessor extends AbstractProcessor { 17 | public LongEntryProcessor() { 18 | } 19 | @Override 20 | public Void process(InvocableMap.Entry entry) { 21 | System.out.println("LongEntryProcessor: Sleeping for 30 seconds"); 22 | Base.sleep(30_000L); 23 | return null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /java/coherence-go-test/src/main/java/com/oracle/coherence/go/testing/SimpleCacheLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | 8 | package com.oracle.coherence.go.testing; 9 | 10 | import com.tangosol.net.cache.CacheLoader; 11 | 12 | /** 13 | * A simple {@link CacheLoader} implementation to demonstrate basic functionality. 14 | * 15 | * @author Tim Middleton 2020.02.17 16 | */ 17 | public class SimpleCacheLoader 18 | implements CacheLoader { 19 | 20 | private String cacheName; 21 | 22 | /** 23 | * Constructs a {@link SimpleCacheLoader}. 24 | * 25 | * @param cacheName cache name 26 | */ 27 | public SimpleCacheLoader(String cacheName) { 28 | this.cacheName = cacheName; 29 | } 30 | 31 | /** 32 | * An implementation of a load which returns the String "Number " + the key. 33 | * 34 | * @param key key whose associated value is to be returned 35 | * @return the value for the given key 36 | */ 37 | @Override 38 | public String load(Integer key) { // <3> 39 | return "Number " + key; 40 | } 41 | } -------------------------------------------------------------------------------- /java/coherence-go-test/src/main/java/com/oracle/coherence/go/testing/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /** 8 | * Classes to support testing Go Client. 9 | */ 10 | package com.oracle.coherence.go.testing; 11 | -------------------------------------------------------------------------------- /java/coherence-go-test/src/main/resources/META-INF/type-aliases.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | # Licensed under the Universal Permissive License v 1.0 as shown at 4 | # https://oss.oracle.com/licenses/upl. 5 | # 6 | 7 | 8 | test.customer=com.oracle.coherence.go.testing.Customer 9 | test.address=com.oracle.coherence.go.testing.Address 10 | test.longEntryProcessor=com.oracle.coherence.go.testing.LongEntryProcessor -------------------------------------------------------------------------------- /java/coherence-go-test/src/main/resources/test-cache-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 11 | 12 | 13 | * 14 | distributed-scheme 15 | 16 | 17 | canary 18 | canary-scheme 19 | 20 | 21 | preload 22 | simple-cache-loader 23 | 24 | 25 | touch 26 | touch-scheme 27 | 28 | 29 | 30 | 31 | 32 | distributed-scheme 33 | PartitionedCache 34 | true 35 | 36 | 31 37 | 38 | 39 | BINARY 40 | 41 | 42 | true 43 | 44 | 45 | 46 | touch-scheme 47 | PartitionedCacheTouch 48 | true 49 | 50 | 31 51 | 52 | 53 | BINARY 54 | 10s 55 | 56 | 57 | true 58 | 59 | 60 | 61 | canary-scheme 62 | CanaryService 63 | true 64 | 65 | 31 66 | 67 | 68 | 69 | true 70 | 71 | 72 | 73 | simple-cache-loader 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | com.oracle.coherence.go.testing.SimpleCacheLoader 82 | 83 | 84 | java.lang.String 85 | {cache-name} 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /proto/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package proto contains automatically generated gRPC code. 9 | */ 10 | package proto 11 | -------------------------------------------------------------------------------- /proto/v1/proxy_service_v1.pb.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, 2024, Oracle and/or its affiliates. 3 | // 4 | // Licensed under the Universal Permissive License v 1.0 as shown at 5 | // https://oss.oracle.com/licenses/upl. 6 | 7 | // NamedCacheService V2 service definition. 8 | 9 | // Code generated by protoc-gen-go. DO NOT EDIT. 10 | // versions: 11 | // protoc-gen-go v1.36.6 12 | // protoc v3.19.2 13 | // source: proxy_service_v1.proto 14 | 15 | package v1 16 | 17 | import ( 18 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 19 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 20 | _ "google.golang.org/protobuf/types/known/emptypb" 21 | _ "google.golang.org/protobuf/types/known/wrapperspb" 22 | reflect "reflect" 23 | unsafe "unsafe" 24 | ) 25 | 26 | const ( 27 | // Verify that this generated code is sufficiently up-to-date. 28 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 29 | // Verify that runtime/protoimpl is sufficiently up-to-date. 30 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 31 | ) 32 | 33 | var File_proxy_service_v1_proto protoreflect.FileDescriptor 34 | 35 | const file_proxy_service_v1_proto_rawDesc = "" + 36 | "\n" + 37 | "\x16proxy_service_v1.proto\x12\x12coherence.proxy.v1\x1a\x1fproxy_service_messages_v1.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1egoogle/protobuf/wrappers.proto2g\n" + 38 | "\fProxyService\x12W\n" + 39 | "\n" + 40 | "subChannel\x12 .coherence.proxy.v1.ProxyRequest\x1a!.coherence.proxy.v1.ProxyResponse\"\x00(\x010\x01B_\n" + 41 | "+com.oracle.coherence.grpc.services.proxy.v1P\x01Z.github.com/oracle/coherence-go-client/proto/v1b\x06proto3" 42 | 43 | var file_proxy_service_v1_proto_goTypes = []any{ 44 | (*ProxyRequest)(nil), // 0: coherence.proxy.v1.ProxyRequest 45 | (*ProxyResponse)(nil), // 1: coherence.proxy.v1.ProxyResponse 46 | } 47 | var file_proxy_service_v1_proto_depIdxs = []int32{ 48 | 0, // 0: coherence.proxy.v1.ProxyService.subChannel:input_type -> coherence.proxy.v1.ProxyRequest 49 | 1, // 1: coherence.proxy.v1.ProxyService.subChannel:output_type -> coherence.proxy.v1.ProxyResponse 50 | 1, // [1:2] is the sub-list for method output_type 51 | 0, // [0:1] is the sub-list for method input_type 52 | 0, // [0:0] is the sub-list for extension type_name 53 | 0, // [0:0] is the sub-list for extension extendee 54 | 0, // [0:0] is the sub-list for field type_name 55 | } 56 | 57 | func init() { file_proxy_service_v1_proto_init() } 58 | func file_proxy_service_v1_proto_init() { 59 | if File_proxy_service_v1_proto != nil { 60 | return 61 | } 62 | file_proxy_service_messages_v1_proto_init() 63 | type x struct{} 64 | out := protoimpl.TypeBuilder{ 65 | File: protoimpl.DescBuilder{ 66 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 67 | RawDescriptor: unsafe.Slice(unsafe.StringData(file_proxy_service_v1_proto_rawDesc), len(file_proxy_service_v1_proto_rawDesc)), 68 | NumEnums: 0, 69 | NumMessages: 0, 70 | NumExtensions: 0, 71 | NumServices: 1, 72 | }, 73 | GoTypes: file_proxy_service_v1_proto_goTypes, 74 | DependencyIndexes: file_proxy_service_v1_proto_depIdxs, 75 | }.Build() 76 | File_proxy_service_v1_proto = out.File 77 | file_proxy_service_v1_proto_goTypes = nil 78 | file_proxy_service_v1_proto_depIdxs = nil 79 | } 80 | -------------------------------------------------------------------------------- /scripts/copyright.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) YYYY, Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ -------------------------------------------------------------------------------- /scripts/download-protoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (c) 2022, Oracle and/or its affiliates. 5 | # Licensed under the Universal Permissive License v 1.0 as shown at 6 | # https://oss.oracle.com/licenses/upl. 7 | # 8 | # Download Protoc 9 | 10 | if [ $# -ne 1 ] ; then 11 | echo "Please supply tools directory" 12 | exit 1 13 | fi 14 | 15 | export TOOLS_DIRECTORY=$1 16 | set -e 17 | 18 | if [ "`uname -a | grep Darwin`" ] ; then 19 | curl -Lo ${TOOLS_DIRECTORY}/file.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.2/protoc-3.19.2-osx-x86_64.zip 20 | else 21 | curl -Lo ${TOOLS_DIRECTORY}/file.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.2/protoc-3.19.2-linux-x86_64.zip 22 | fi 23 | 24 | cd ${TOOLS_DIRECTORY} 25 | unzip -od ${TOOLS_DIRECTORY} ${TOOLS_DIRECTORY}/file.zip -------------------------------------------------------------------------------- /scripts/kind/coherence-cluster.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | apiVersion: coherence.oracle.com/v1 5 | kind: Coherence 6 | metadata: 7 | name: perf-cluster 8 | spec: 9 | jvm: 10 | memory: 11 | initialHeapSize: $INITIAL_HEAP 12 | maxHeapSize: 1g 13 | replicas: 3 14 | readinessProbe: 15 | initialDelaySeconds: 10 16 | periodSeconds: 10 17 | suspendServicesOnShutdown: false 18 | image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2-java17" 19 | imagePullPolicy: IfNotPresent 20 | coherence: 21 | management: 22 | enabled: true 23 | ports: 24 | - name: management 25 | - name: grpc 26 | port: 1408 -------------------------------------------------------------------------------- /scripts/kind/kind-config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | kind: Cluster 5 | apiVersion: kind.x-k8s.io/v1alpha4 6 | nodes: 7 | - role: control-plane 8 | - role: worker 9 | - role: worker 10 | - role: worker 11 | -------------------------------------------------------------------------------- /scripts/kind/kind-label-node.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright (c) 2020, 2025, Oracle and/or its affiliates. 5 | # Licensed under the Universal Permissive License v 1.0 as shown at 6 | # http://oss.oracle.com/licenses/upl. 7 | # 8 | 9 | PREFIX=go-client 10 | 11 | kubectl label node ${PREFIX}-worker topology.kubernetes.io/zone=zone-one --overwrite 12 | kubectl label node ${PREFIX}-worker topology.kubernetes.io/region=one --overwrite 13 | kubectl label node ${PREFIX}-worker oci.oraclecloud.com/fault-domain=fd-one --overwrite 14 | kubectl label node ${PREFIX}-worker coherence.oracle.com/site=site-one --overwrite 15 | kubectl label node ${PREFIX}-worker coherence.oracle.com/rack=rack-one --overwrite 16 | kubectl label node ${PREFIX}-worker2 topology.kubernetes.io/zone=zone-two --overwrite || true 17 | kubectl label node ${PREFIX}-worker2 topology.kubernetes.io/region=two --overwrite || true 18 | kubectl label node ${PREFIX}-worker2 oci.oraclecloud.com/fault-domain=fd-two --overwrite || true 19 | kubectl label node ${PREFIX}-worker2 coherence.oracle.com/site=site-two --overwrite || true 20 | kubectl label node ${PREFIX}-worker2 coherence.oracle.com/rack=rack-two --overwrite || true 21 | kubectl label node ${PREFIX}-worker3 topology.kubernetes.io/zone=zone-three --overwrite || true 22 | kubectl label node ${PREFIX}-worker3 topology.kubernetes.io/region=three --overwrite || true 23 | kubectl label node ${PREFIX}-worker3 oci.oraclecloud.com/fault-domain=fd-three --overwrite || true 24 | kubectl label node ${PREFIX}-worker3 coherence.oracle.com/site=site-three --overwrite || true 25 | kubectl label node ${PREFIX}-worker3 coherence.oracle.com/rack=rack-three --overwrite || true 26 | 27 | -------------------------------------------------------------------------------- /scripts/kind/kind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2020, 2025, Oracle and/or its affiliates. 4 | # Licensed under the Universal Permissive License v 1.0 as shown at 5 | # http://oss.oracle.com/licenses/upl. 6 | # 7 | 8 | set -o errexit 9 | 10 | # desired cluster name; default is "kind" 11 | KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-coherence-go-client}" 12 | 13 | kind create cluster --name "${KIND_CLUSTER_NAME}" $@ 14 | -------------------------------------------------------------------------------- /scripts/kind/load-schools.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | apiVersion: batch/v1 5 | kind: Job 6 | metadata: 7 | name: go-perf-load-schools 8 | spec: 9 | completions: 1 # total times to run 10 | parallelism: 1 # how many pods to run at the same time 11 | template: 12 | metadata: 13 | labels: 14 | app: go-client 15 | spec: 16 | restartPolicy: Never 17 | containers: 18 | - name: perf-go-client 19 | image: "perf-go-client:1.0.0" 20 | imagePullPolicy: IfNotPresent 21 | env: 22 | - name: COHERENCE_SERVER_ADDRESS 23 | value: "perf-cluster-grpc:1408" 24 | - name: TEST_TYPE 25 | value: "load" 26 | - name: CACHE_COUNT 27 | value: "250000" 28 | resources: 29 | requests: 30 | memory: "1024Mi" 31 | limits: 32 | memory: "1024Mi" -------------------------------------------------------------------------------- /scripts/kind/roll-cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2020, 2025, Oracle and/or its affiliates. 4 | # Licensed under the Universal Permissive License v 1.0 as shown at 5 | # http://oss.oracle.com/licenses/upl. 6 | # 7 | 8 | set -o errexit 9 | maxIterations=10 10 | 11 | if [ ! -z "$MAX_ITERATIONS" ]; then 12 | maxIterations=$MAX_ITERATIONS 13 | fi 14 | 15 | if [ -z "$NAMESPACE" ]; then 16 | NAMESPACE=coherence-perf 17 | fi 18 | 19 | echo "`date`: Starting rolling restart, iterations=$maxIterations" 20 | 21 | for i in $(seq 1 $maxIterations); do 22 | 23 | echo "`date`: Iteration $i of $maxIterations" 24 | 25 | if [ $((i%2)) -eq 0 ]; then 26 | INITIAL_HEAP=1000m 27 | else 28 | INITIAL_HEAP=1001m 29 | fi 30 | 31 | export INITIAL_HEAP 32 | 33 | envsubst < ./scripts/kind/coherence-cluster.yaml | kubectl -n $NAMESPACE apply -f - 34 | 35 | echo "`date`: Waiting for cluster to be updated..." 36 | kubectl rollout status statefulset/perf-cluster -n $NAMESPACE --timeout=300s 37 | 38 | echo "`date`: Sleeping 10..." 39 | sleep 10 40 | done 41 | 42 | 43 | -------------------------------------------------------------------------------- /scripts/kind/test-schools.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | apiVersion: batch/v1 5 | kind: Job 6 | metadata: 7 | name: perf-go-client 8 | spec: 9 | backoffLimit: 0 10 | template: 11 | metadata: 12 | labels: 13 | app: perf-go-client 14 | spec: 15 | restartPolicy: Never 16 | containers: 17 | - name: go-client 18 | image: "perf-go-client:1.0.0" 19 | imagePullPolicy: IfNotPresent 20 | env: 21 | - name: COHERENCE_SERVER_ADDRESS 22 | value: "perf-cluster-grpc:1408" 23 | - name: COHERENCE_READY_TIMEOUT 24 | value: "30000" 25 | - name: TEST_TYPE 26 | value: "runTest" 27 | - name: COHERENCE_LOG_LEVEL 28 | value: "DEBUG" 29 | resources: 30 | requests: 31 | memory: "512Mi" 32 | limits: 33 | memory: "512Mi" 34 | ports: 35 | - containerPort: 8080 -------------------------------------------------------------------------------- /scripts/perf-cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (c) 2025 Oracle and/or its affiliates. 5 | # Licensed under the Universal Permissive License v 1.0 as shown at 6 | # https://oss.oracle.com/licenses/upl. 7 | # 8 | 9 | # Run Performance Test 10 | # environment variables COM accepted 11 | # Arguments: 12 | # 1 - directory for cohctl config 13 | # 2 - coherence version 14 | # 3 - start or stop 15 | pwd 16 | 17 | if [ $# -ne 3 ] ; then 18 | echo "Usage: $0 directory Coherence-Version [start|stop]" 19 | exit 20 | fi 21 | 22 | CONFIG_DIR=$1 23 | VERSION=$2 24 | COMMAND=$3 25 | 26 | if [ ! -d $CONFIG_DIR ]; then 27 | echo "${CONFIG_DIR} is not a directory" 28 | exit 1 29 | fi 30 | 31 | DIR=`pwd` 32 | OUTPUT=`mktemp` 33 | 34 | mkdir -p ${CONFIG_DIR} 35 | trap "rm -rf ${OUTPUT}" EXIT SIGINT 36 | 37 | echo 38 | echo "Config Dir: ${CONFIG_DIR}" 39 | echo "Version: ${VERSION}" 40 | echo "Commercial: ${COM}" 41 | echo 42 | 43 | type cohctl 44 | ret=$? 45 | if [ $ret -ne 0 ]; then 46 | echo "cohctl must be in path" 47 | exit 1 48 | fi 49 | 50 | # Build the Java project so we get any deps downloaded 51 | 52 | COHERENCE_GROUP_ID=com.oracle.coherence.ce 53 | if [ ! -z "$COM" ] ; then 54 | COHERENCE_GROUP_ID=com.oracle.coherence 55 | fi 56 | 57 | # Default command 58 | COHCTL="cohctl --config-dir ${CONFIG_DIR}" 59 | 60 | function pause() { 61 | echo "sleeping..." 62 | sleep 5 63 | } 64 | 65 | function message() { 66 | echo "=========================================================" 67 | echo "$*" 68 | } 69 | 70 | function save_logs() { 71 | mkdir -p build/_output/test-logs 72 | cp ${CONFIG_DIR}/logs/local/*.log build/_output/test-logs || true 73 | } 74 | 75 | function runCommand() { 76 | echo "=========================================================" 77 | echo "Running command: cohctl $*" 78 | $COHCTL $* > $OUTPUT 2>&1 79 | ret=$? 80 | cat $OUTPUT 81 | if [ $ret -ne 0 ] ; then 82 | echo "Command failed" 83 | # copy the log files 84 | save_logs 85 | exit 1 86 | fi 87 | } 88 | 89 | runCommand version 90 | runCommand set debug on 91 | 92 | if [ "${COMMAND}" == "start" ]; then 93 | # Create a cluster 94 | message "Create Cluster" 95 | runCommand create cluster local -y -v $VERSION $COM -S com.tangosol.net.Coherence -a coherence-grpc,coherence-grpc-proxy --machine machine1 -M 2g 96 | runCommand monitor health -n localhost:7574 -I -T 120 -w 97 | elif [ "${COMMAND}" == "stop" ]; then 98 | runCommand stop cluster local -y 99 | runCommand remove cluster local -y 100 | elif [ "${COMMAND}" == "status" ]; then 101 | runCommand get members 102 | else 103 | echo "Invalid command ${COMMAND}" 104 | exit 1 105 | fi 106 | -------------------------------------------------------------------------------- /scripts/run-compat-ce.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (c) 2022, 2024 Oracle and/or its affiliates. 5 | # Licensed under the Universal Permissive License v 1.0 as shown at 6 | # https://oss.oracle.com/licenses/upl. 7 | # 8 | 9 | # Run compatability tests 10 | set -e 11 | 12 | # Set the following to include long running streaming tests 13 | # INCLUDE_LONG_RUNNING=true 14 | 15 | echo "Coherence CE 22.06.12" 16 | COHERENCE_VERSION=22.06.12 PROFILES=,-jakarta,javax make clean generate-proto build-test-images test-e2e-standalone 17 | 18 | echo "Coherence CE 14.1.2-0-2" 19 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=14.1.2-0-2 PROFILES=,-jakarta,javax make clean generate-proto build-test-images test-e2e-standalone 20 | 21 | echo "Coherence CE 14.1.2-0-2 Streaming" 22 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=14.1.2-0-2 PROFILES=,-jakarta,javax make clean generate-proto build-test-images test-e2e-streaming 23 | 24 | echo "Coherence CE 22.06.12 with scope" 25 | COHERENCE_VERSION=22.06.12 PROFILES=,-jakarta,javax,scope make clean generate-proto build-test-images test-e2e-standalone-scope 26 | 27 | echo "Coherence CE 22.06.12 with SSL using env" 28 | SECURE=env COHERENCE_IGNORE_INVALID_CERTS=true \ 29 | COHERENCE_TLS_CERTS_PATH=`pwd`/test/utils/certs/guardians-ca.crt \ 30 | COHERENCE_TLS_CLIENT_CERT=`pwd`/test/utils/certs/star-lord.crt \ 31 | COHERENCE_TLS_CLIENT_KEY=`pwd`/test/utils/certs/star-lord.key \ 32 | COHERENCE_VERSION=22.06.7 PROFILES=,secure make clean certs generate-proto build-test-images test-e2e-standalone 33 | 34 | echo "Coherence CE 22.06.12 with SSL using options" 35 | # suite_test.go takes the below env vars and then populates the session options 36 | SECURE=options COHERENCE_IGNORE_INVALID_CERTS_OPTION=true \ 37 | COHERENCE_TLS_CERTS_PATH_OPTION=`pwd`/test/utils/certs/guardians-ca.crt \ 38 | COHERENCE_TLS_CLIENT_CERT_OPTION=`pwd`/test/utils/certs/star-lord.crt \ 39 | COHERENCE_TLS_CLIENT_KEY_OPTION=`pwd`/test/utils/certs/star-lord.key \ 40 | COHERENCE_VERSION=22.06.7 PROFILES=,secure make clean certs generate-proto build-test-images test-e2e-standalone 41 | 42 | echo "Coherence CE 22.06.12 with SSL using tlsConfig" 43 | # suite_test.go takes the below env vars and then creates a tls.Config and passes to the WithTLSConfig 44 | SECURE=tlsConfig COHERENCE_IGNORE_INVALID_CERTS_OPTION=true \ 45 | COHERENCE_TLS_CERTS_PATH_OPTION=`pwd`/test/utils/certs/guardians-ca.crt \ 46 | COHERENCE_TLS_CLIENT_CERT_OPTION=`pwd`/test/utils/certs/star-lord.crt \ 47 | COHERENCE_TLS_CLIENT_KEY_OPTION=`pwd`/test/utils/certs/star-lord.key \ 48 | COHERENCE_VERSION=22.06.7 PROFILES=,secure make clean certs generate-proto build-test-images test-e2e-standalone 49 | 50 | echo "Coherence CE 25.03.1" 51 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 PROFILES=,jakarta,-javax COHERENCE_VERSION=25.03.1 make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone 52 | 53 | echo "Coherence CE 25.03.1 with scope" 54 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 COHERENCE_VERSION=25.03.1 PROFILES=,jakarta,-javax,scope make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone-scope 55 | 56 | echo "Coherence CE 25.03.1 with queues" 57 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 PROFILES=,jakarta,-javax,queues COHERENCE_VERSION=25.03.1 make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone-queues 58 | 59 | echo "Coherence CE 25.03.1 Base Tests" 60 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 PROFILES=,jakarta,-javax COHERENCE_VERSION=25.03.1 make clean generate-proto generate-proto-v1 build-test-images test-v1-base 61 | 62 | echo "Coherence CE 25.03.1 All Tests gRPC v1" 63 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 PROFILES=,jakarta,-javax COHERENCE_VERSION=25.03.1 make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone 64 | -------------------------------------------------------------------------------- /scripts/run-compat-commercial.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (c) 2022, 2025 Oracle and/or its affiliates. 5 | # Licensed under the Universal Permissive License v 1.0 as shown at 6 | # https://oss.oracle.com/licenses/upl. 7 | # 8 | 9 | # Run compatability tests for commercial 10 | set -e 11 | 12 | # Coherence 14.1.1.2206.6 - javax 13 | echo "Coherence GE 14.1.1.2206.7" 14 | COHERENCE_VERSION=14.1.1-2206-7 COHERENCE_GROUP_ID=com.oracle.coherence make clean generate-proto build-test-images test-e2e-standalone 15 | 16 | echo "Coherence GE 15.1.1-0-0-SNAPSHOT" - Jakarta 17 | PROFILES=,jakarta,-javax COHERENCE_BASE_IMAGE=gcr.io/distroless/java17 COHERENCE_VERSION=15.1.1-0-0-SNAPSHOT COHERENCE_GROUP_ID=com.oracle.coherence make clean generate-proto build-test-images test-e2e-standalone 18 | 19 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java17-debian12 PROFILES=,-jakarta,javax COHERENCE_GROUP_ID=com.oracle.coherence COHERENCE_VERSION=14.1.2-0-1-SNAPSHOT make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone 20 | 21 | COHERENCE_BASE_IMAGE=gcr.io/distroless/java11-debian12 PROFILES=,-jakarta,javax,queues COHERENCE_GROUP_ID=com.oracle.coherence COHERENCE_VERSION=14.1.2-0-1-SNAPSHOT make clean generate-proto generate-proto-v1 build-test-images test-e2e-standalone-queues 22 | -------------------------------------------------------------------------------- /scripts/run-test-examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (c) 2022, 2025 Oracle and/or its affiliates. 5 | # Licensed under the Universal Permissive License v 1.0 as shown at 6 | # https://oss.oracle.com/licenses/upl. 7 | # 8 | 9 | 10 | function pause() { 11 | echo "sleeping..." 12 | sleep 5 13 | } 14 | 15 | function wait_for_ready() { 16 | counter=10 17 | PORT=$1 18 | if [ -z "$PORT" ] ; then 19 | PORT=30000 20 | fi 21 | pause 22 | echo "waiting for management to be ready on ${PORT}..." 23 | while [ $counter -gt 0 ] 24 | do 25 | curl http://127.0.0.1:${PORT}/management/coherence/cluster > /dev/null 2>&1 26 | ret=$? 27 | if [ $ret -eq 0 ] ; then 28 | echo "Management ready" 29 | pause 30 | return 0 31 | fi 32 | pause 33 | let counter=counter-1 34 | done 35 | echo "Management failed to be ready" 36 | save_logs 37 | exit 1 38 | } 39 | 40 | wait_for_ready 41 | 42 | pause && pause && pause && pause 43 | 44 | set -e 45 | cd examples 46 | 47 | find . -type f -name '*.go' | grep -v people_listen | grep -v people_insert | grep -v doc.go | grep -v rest | grep -v blocking | grep -v custom | while read file 48 | do 49 | echo 50 | echo "===========================================" 51 | echo $file 52 | echo "===========================================" 53 | 54 | if [ ! -z `echo $file | grep queues` ]; then 55 | # Check for queues which cannot be run unless we have versions 25.03, 14.1.2, or 15.1.1 56 | if echo "$COHERENCE_VERSION" | grep -q -e 25.03 -e 14.1.2 -e 15.1.1; then 57 | go run -race "$file" 58 | fi 59 | else 60 | go run -race $file 61 | fi 62 | done 63 | 64 | # Special case for REST server example 65 | go run -race rest/main.go & 66 | PID=$! 67 | 68 | sleep 10 69 | 70 | # Get all PIDS 71 | ALL_PIDS=`ps -ef | grep $PID | grep -v grep | awk '{print $2}' | tr '\n' ' '` 72 | echo "PIDS: ALL_PIDS" 73 | 74 | trap "kill -9 $ALL_PIDS || true" EXIT SIGINT SIGQUIT 75 | 76 | curl -X GET -i http://localhost:17268/people | grep Address 77 | curl -X GET -i http://localhost:17268/people/1 | grep '"id":1' 78 | curl -X DELETE -i http://localhost:17268/people/1 79 | curl -X GET -i http://localhost:17268/people/1 | grep 404 80 | curl -X POST -i http://localhost:17268/people/1 -d '{"id":1,"name":"Person-1","address":"Address 1","city":"Adelaide","age":16}' 81 | curl -X GET -i http://localhost:17268/people/1 | grep Address 82 | curl -X PUT -i http://localhost:17268/people/1 -d '{"id":1,"name":"Person-1","address":"Address 1","city":"Singapore","age":16}' 83 | curl -X GET -i http://localhost:17268/people/1 | grep Singapore 84 | -------------------------------------------------------------------------------- /scripts/startup-clusters.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (c) 2022, 2023 Oracle and/or its affiliates. 5 | # Licensed under the Universal Permissive License v 1.0 as shown at 6 | # https://oss.oracle.com/licenses/upl. 7 | # 8 | 9 | # Startup Coherence clusters for use with discovery tests 10 | # $1 = coherence jar 11 | # $2 = logs dir 12 | # $3 = cluster port 13 | 14 | set -e 15 | 16 | LOGSDIR=$1 17 | CLUSTER_PORT=$2 18 | COHERENCE_GROUP_ID=$3 19 | COHERENCE_VERSION=$4 20 | TAG="shutMeDownPlease" 21 | CLUSTERS=3 22 | 23 | PROFILE="-P-javax,-jakarta," 24 | if [ "$COHERENCE_GROUP_ID" == "com.oracle.coherence" ] ; then 25 | PROFILE="-P commercial" 26 | fi 27 | 28 | COHERENCE_STARTUP="-Dcoherence.wka=127.0.0.1 -Dcoherence.ttl=0 -Dcoherence.clusterport=${CLUSTER_PORT} -D${TAG} -Dcoherence.management.http=all -Dcoherence.management.http.port=0" 29 | 30 | set -x 31 | echo "Generating Classpath..." 32 | CP=`mvn -f java/coherence-go-test/pom.xml dependency:build-classpath -Dcoherence.group.id=${COHERENCE_GROUP_ID} -Dcoherence.version=${COHERENCE_VERSION} ${PROFILE} | sed -ne '/Dependencies classpath/,$ p' | sed '/INFO/d'` 33 | 34 | echo "Starting $CLUSTERS clusters..." 35 | for i in $(seq 1 $CLUSTERS) 36 | do 37 | cluster=cluster${i} 38 | echo "Starting $cluster ..." 39 | java ${COHERENCE_STARTUP} -Dcoherence.cluster=$cluster -cp ${CP} com.tangosol.net.DefaultCacheServer > ${LOGSDIR}/${cluster}.log 2>&1 & 40 | sleep 3 41 | done 42 | 43 | sleep 30 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package test provides tests for the coherence-go-client. 9 | */ 10 | package test 11 | -------------------------------------------------------------------------------- /test/e2e/discovery/run_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "fmt" 11 | "github.com/onsi/gomega" 12 | "github.com/oracle/coherence-go-client/v2/coherence/discovery" 13 | "github.com/oracle/coherence-go-client/v2/test/utils" 14 | "strings" 15 | "testing" 16 | ) 17 | 18 | // TestNSLookupCommands tests for discovery 19 | func TestNSLookupCommands(t *testing.T) { 20 | var ( 21 | g = gomega.NewGomegaWithT(t) 22 | result string 23 | clusterPorts []discovery.ClusterNSPort 24 | ) 25 | 26 | // sleep to ensure the clusters are ready 27 | utils.Sleep(20) 28 | 29 | ns, err := discovery.Open("127.0.0.1:7574", 5) 30 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 31 | 32 | defer func() { 33 | _ = ns.Close() 34 | }() 35 | 36 | // lookup the first cluster which should always be cluster1 due to startup order 37 | result, err = ns.Lookup(discovery.ClusterNameLookup) 38 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 39 | g.Expect(strings.Contains(result, "cluster1")).To(gomega.Equal(true)) 40 | 41 | // lookup the foreign clusters 42 | result, err = ns.Lookup(discovery.NSPrefix + discovery.ClusterForeignLookup) 43 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 44 | g.Expect(strings.Contains(result, "cluster2")).To(gomega.Equal(true)) 45 | g.Expect(strings.Contains(result, "cluster3")).To(gomega.Equal(true)) 46 | 47 | // get the cluster info 48 | result, err = ns.Lookup(discovery.ClusterInfoLookup) 49 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 50 | g.Expect(strings.Contains(result, "127.0.0.1")).To(gomega.Equal(true)) 51 | g.Expect(strings.Contains(result, "ServiceJoined")).To(gomega.Equal(true)) 52 | 53 | // discover name service ports 54 | clusterPorts, err = ns.DiscoverNameServicePorts() 55 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 56 | g.Expect(len(clusterPorts)).To(gomega.Equal(3)) 57 | 58 | // close the original ns lookup 59 | closeSilent(ns) 60 | 61 | count := 0 62 | // validate at least each cluster is there and lookup details for each 63 | for _, v := range clusterPorts { 64 | if v.ClusterName == "cluster1" || v.ClusterName == "cluster2" || v.ClusterName == "cluster3" { 65 | count++ 66 | } 67 | 68 | var ( 69 | nsNew *discovery.NSLookup 70 | addressPort = fmt.Sprintf("%s:%d", v.HostName, v.Port) 71 | discoveredCluster discovery.DiscoveredCluster 72 | ) 73 | 74 | // connect to the discovered cluster 75 | nsNew, err = discovery.Open(addressPort, 5) 76 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 77 | 78 | discoveredCluster, err = nsNew.DiscoverClusterInfo() 79 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 80 | g.Expect(discoveredCluster.Host).To(gomega.Equal(v.HostName)) 81 | g.Expect(discoveredCluster.ClusterName).To(gomega.Equal(v.ClusterName)) 82 | g.Expect(discoveredCluster.NSPort).To(gomega.Equal(v.Port)) 83 | g.Expect(discoveredCluster.NSPort).To(gomega.Equal(v.Port)) 84 | g.Expect(len(discoveredCluster.MetricsURLs)).To(gomega.Equal(0)) 85 | g.Expect(len(discoveredCluster.ManagementURLs)).To(gomega.Equal(1)) 86 | g.Expect(len(discoveredCluster.JMXURLs)).To(gomega.Equal(1)) 87 | 88 | closeSilent(nsNew) 89 | } 90 | g.Expect(count).To(gomega.Equal(3)) 91 | } 92 | 93 | // closeSilent closes a NsLookup connection and ignores if it is nil 94 | func closeSilent(ns *discovery.NSLookup) { 95 | if ns != nil { 96 | _ = ns.Close() 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /test/e2e/discovery/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "testing" 13 | ) 14 | 15 | // The entry point for the test suite 16 | func TestMain(m *testing.M) { 17 | exitCode := m.Run() 18 | 19 | fmt.Printf("Tests completed with return code %d\n", exitCode) 20 | 21 | os.Exit(exitCode) 22 | } 23 | -------------------------------------------------------------------------------- /test/e2e/kind/Dockerfile: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2025, Oracle and/or its affiliates. 3 | # 4 | # Licensed under the Universal Permissive License v 1.0 as shown at 5 | # http://oss.oracle.com/licenses/upl. 6 | 7 | FROM alpine AS builder 8 | 9 | COPY runner /runner 10 | RUN chmod 0555 /runner 11 | 12 | FROM scratch 13 | 14 | COPY --chown=1000:1000 --from=builder /runner /files/runner 15 | 16 | USER 1000:1000 17 | 18 | EXPOSE 8080 19 | 20 | ENTRYPOINT ["/files/runner"] 21 | CMD ["-h"] -------------------------------------------------------------------------------- /test/e2e/queues/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package queues provides integration tests for the coherence-go-client with queues for 24.03 and above. 9 | */ 10 | package queues 11 | -------------------------------------------------------------------------------- /test/e2e/queues/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package queues 8 | 9 | import ( 10 | "github.com/oracle/coherence-go-client/v2/test/utils" 11 | "testing" 12 | ) 13 | 14 | // The entry point for the test suite 15 | func TestMain(m *testing.M) { 16 | utils.RunTest(m, 1408, 30000, 8080, true) 17 | } 18 | -------------------------------------------------------------------------------- /test/e2e/resolver/run_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "context" 11 | "github.com/onsi/gomega" 12 | "github.com/oracle/coherence-go-client/v2/coherence" 13 | "github.com/oracle/coherence-go-client/v2/test/utils" 14 | "testing" 15 | ) 16 | 17 | // These tests assume a 3 node cluster with grpc proxy has been started and Name Service 18 | // is listening on localhost:7574 19 | 20 | // TestNsLookupGrpcAddresses tests NsLookupGrpcAddresses. 21 | func TestNsLookupGrpcAddresses(t *testing.T) { 22 | g := gomega.NewGomegaWithT(t) 23 | 24 | results, err := coherence.NsLookupGrpcAddresses("127.0.0.1:7574") 25 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 26 | g.Expect(len(results)).To(gomega.Equal(3)) 27 | 28 | _, err = coherence.NsLookupGrpcAddresses("rubbish") 29 | g.Expect(err).To(gomega.HaveOccurred()) 30 | } 31 | 32 | // TestNsLookupGrpcAddresses tests NsLookupGrpcAddresses. 33 | func TestConnectingUsingNSResolver(t *testing.T) { 34 | g := gomega.NewGomegaWithT(t) 35 | ctx := context.Background() 36 | t.Setenv("COHERENCE_LOG_LEVEL", "DEBUG") 37 | 38 | session, err := coherence.NewSession(ctx, coherence.WithPlainText(), coherence.WithAddress("coherence:///localhost:7574")) 39 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 40 | 41 | defer session.Close() 42 | utils.RunNSTestWithNamedMap(ctx, g, session, "grpc-ns-test") 43 | } 44 | -------------------------------------------------------------------------------- /test/e2e/resolver/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "testing" 13 | ) 14 | 15 | // The entry point for the test suite 16 | func TestMain(m *testing.M) { 17 | exitCode := m.Run() 18 | 19 | fmt.Printf("Tests completed with return code %d\n", exitCode) 20 | 21 | os.Exit(exitCode) 22 | } 23 | -------------------------------------------------------------------------------- /test/e2e/resolver_cluster/run_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "context" 11 | "github.com/onsi/gomega" 12 | "github.com/oracle/coherence-go-client/v2/coherence" 13 | "github.com/oracle/coherence-go-client/v2/test/utils" 14 | "testing" 15 | ) 16 | 17 | // These tests assume 3 clusters are running, as per discovery tests, and all are on 7574. 18 | // This test will test that we can do NS lookup using the ns and foreign cluster. 19 | 20 | // TestNsLookupGrpcAddresses tests NsLookupGrpcAddresses. 21 | func TestNsLookupGrpcAddressesMultipleClusters(t *testing.T) { 22 | g := gomega.NewGomegaWithT(t) 23 | 24 | // since the clusters are sharing cluster port then there will only be one grpc address 25 | results, err := coherence.NsLookupGrpcAddresses("127.0.0.1:7574") 26 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 27 | g.Expect(len(results)).To(gomega.Equal(1)) 28 | 29 | // look for the grpc address for cluster2 30 | results, err = coherence.NsLookupGrpcAddresses("127.0.0.1:7574/cluster2") 31 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 32 | g.Expect(len(results)).To(gomega.Equal(1)) 33 | 34 | // look for the grpc address for cluster2 35 | results, err = coherence.NsLookupGrpcAddresses("127.0.0.1:7574/cluster3") 36 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 37 | g.Expect(len(results)).To(gomega.Equal(1)) 38 | 39 | _, err = coherence.NsLookupGrpcAddresses("rubbish") 40 | g.Expect(err).To(gomega.HaveOccurred()) 41 | } 42 | 43 | // TestNsLookupGrpcAddresses tests NsLookupGrpcAddresses. 44 | func TestConnectingUsingNSResolverMultipleClusters(t *testing.T) { 45 | g := gomega.NewGomegaWithT(t) 46 | ctx := context.Background() 47 | t.Setenv("COHERENCE_LOG_LEVEL", "DEBUG") 48 | 49 | session, err := coherence.NewSession(ctx, coherence.WithPlainText(), coherence.WithAddress("coherence:///localhost:7574/cluster2")) 50 | g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) 51 | defer session.Close() 52 | 53 | utils.RunNSTestWithNamedMap(ctx, g, session, "grpc-ns-test-cluster") 54 | } 55 | -------------------------------------------------------------------------------- /test/e2e/resolver_cluster/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "testing" 13 | ) 14 | 15 | // The entry point for the test suite 16 | func TestMain(m *testing.M) { 17 | exitCode := m.Run() 18 | 19 | fmt.Printf("Tests completed with return code %d\n", exitCode) 20 | 21 | os.Exit(exitCode) 22 | } 23 | -------------------------------------------------------------------------------- /test/e2e/scope/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package scope provides integration tests for the coherence-go-client with scope set. 9 | */ 10 | package scope 11 | -------------------------------------------------------------------------------- /test/e2e/scope/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package scope 8 | 9 | import ( 10 | "github.com/oracle/coherence-go-client/v2/test/utils" 11 | "testing" 12 | ) 13 | 14 | // The entry point for the test suite 15 | func TestMain(m *testing.M) { 16 | utils.RunTest(m, 1408, 30000, 8080, true) 17 | } 18 | -------------------------------------------------------------------------------- /test/e2e/standalone/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package standalone provides integration tests for the coherence-go-client. 9 | */ 10 | package standalone 11 | -------------------------------------------------------------------------------- /test/e2e/standalone/lifecycle_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "github.com/onsi/gomega" 11 | "github.com/oracle/coherence-go-client/v2/coherence" 12 | "github.com/oracle/coherence-go-client/v2/test/utils" 13 | "testing" 14 | ) 15 | 16 | // TestCacheLifecycle runs tests to ensure correct behaviour when destroying or releasing 17 | // NamedMap and NamedCache instances. 18 | func TestCacheLifecycle(t *testing.T) { 19 | g := gomega.NewWithT(t) 20 | session, err := utils.GetSession() 21 | g.Expect(err).ShouldNot(gomega.HaveOccurred()) 22 | defer session.Close() 23 | 24 | testCases := []struct { 25 | testName string 26 | nameMap coherence.NamedMap[int, utils.Person] 27 | test func(t *testing.T, namedCache coherence.NamedMap[int, utils.Person]) 28 | }{ 29 | {"NamedMapRunTestDestroy", utils.GetNamedMap[int, utils.Person](g, session, "destroy-map"), RunTestDestroy}, 30 | {"NamedCacheRunTestDestroy", utils.GetNamedCache[int, utils.Person](g, session, "destroy-cache"), RunTestDestroy}, 31 | {"NamedMapRunTestRelease", utils.GetNamedMap[int, utils.Person](g, session, "release-map"), RunTestRelease}, 32 | {"NamedCacheRunTestRelease", utils.GetNamedCache[int, utils.Person](g, session, "release-cache"), RunTestRelease}, 33 | } 34 | for _, tc := range testCases { 35 | t.Run(tc.testName, func(t *testing.T) { 36 | tc.test(t, tc.nameMap) 37 | }) 38 | } 39 | } 40 | 41 | func RunTestDestroy(t *testing.T, namedMap coherence.NamedMap[int, utils.Person]) { 42 | var ( 43 | g = gomega.NewWithT(t) 44 | err error 45 | ) 46 | 47 | addPerson(g, namedMap) 48 | 49 | // issue destroy against the namedMap 50 | err = namedMap.Destroy(ctx) 51 | g.Expect(err).ShouldNot(gomega.HaveOccurred()) 52 | 53 | // we should no longer be able to perform operations against this namedMap 54 | _, err = namedMap.Size(ctx) 55 | g.Expect(err).To(gomega.Equal(coherence.ErrDestroyed)) 56 | } 57 | 58 | func RunTestRelease(t *testing.T, namedMap coherence.NamedMap[int, utils.Person]) { 59 | var ( 60 | g = gomega.NewWithT(t) 61 | err error 62 | ) 63 | 64 | addPerson(g, namedMap) 65 | 66 | // issue release against the namedMap 67 | namedMap.Release() 68 | 69 | // we should no longer be able to perform operations against this namedMap 70 | // as it is destroyed and released 71 | _, err = namedMap.Size(ctx) 72 | g.Expect(err).To(gomega.Equal(coherence.ErrReleased)) 73 | } 74 | -------------------------------------------------------------------------------- /test/e2e/standalone/session_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "fmt" 11 | "github.com/onsi/gomega" 12 | "github.com/oracle/coherence-go-client/v2/coherence" 13 | "github.com/oracle/coherence-go-client/v2/test/utils" 14 | "sync/atomic" 15 | "testing" 16 | ) 17 | 18 | // TestCacheLifecycle runs tests to ensure correct behaviour when working with session events. 19 | func TestSessionLifecycle(t *testing.T) { 20 | g := gomega.NewWithT(t) 21 | 22 | t.Setenv("COHERENCE_LOG_LEVEL", "DEBUG") 23 | 24 | session, err := utils.GetSession() 25 | g.Expect(err).ShouldNot(gomega.HaveOccurred()) 26 | 27 | listener := NewAllLifecycleEventsListener() 28 | session.AddSessionLifecycleListener(listener.listener) 29 | 30 | utils.Sleep(15) 31 | 32 | // close the session 33 | session.Close() 34 | 35 | f := func() int32 { return listener.getClosedCount() } 36 | 37 | // expected the count to increase 38 | g.Expect(expect[int32](f, 1, 10)).To(gomega.BeNil()) 39 | 40 | // try to use the session, we should not be able to 41 | _, err = coherence.GetNamedMap[int, string](session, "my-map") 42 | g.Expect(err).To(gomega.Equal(coherence.ErrClosed)) 43 | } 44 | 45 | type AllSessionLifecycleEventsListener struct { 46 | listener coherence.SessionLifecycleListener 47 | closedCount int32 48 | } 49 | 50 | func (e *AllSessionLifecycleEventsListener) getClosedCount() int32 { 51 | return e.closedCount 52 | } 53 | 54 | func NewAllLifecycleEventsListener() *AllSessionLifecycleEventsListener { 55 | exampleListener := AllSessionLifecycleEventsListener{ 56 | listener: coherence.NewSessionLifecycleListener(), 57 | } 58 | 59 | exampleListener.listener.OnAny(func(e coherence.SessionLifecycleEvent) { 60 | if e.Type() == coherence.Closed { 61 | atomic.AddInt32(&exampleListener.closedCount, 1) 62 | } 63 | fmt.Printf("**EVENT=%s: source=%v\n", e.Type(), e.Source()) 64 | }) 65 | 66 | return &exampleListener 67 | } 68 | -------------------------------------------------------------------------------- /test/e2e/standalone/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package standalone 8 | 9 | import ( 10 | "github.com/oracle/coherence-go-client/v2/test/utils" 11 | "testing" 12 | ) 13 | 14 | // The entry point for the test suite 15 | func TestMain(m *testing.M) { 16 | utils.RunTest(m, 1408, 30000, 8080, true) 17 | } 18 | -------------------------------------------------------------------------------- /test/e2e/streaming/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package streaming 8 | 9 | import ( 10 | "github.com/oracle/coherence-go-client/v2/test/utils" 11 | "testing" 12 | ) 13 | 14 | // The entry point for the test suite 15 | func TestMain(m *testing.M) { 16 | utils.RunTest(m, 1408, 30000, 8080, true) 17 | } 18 | -------------------------------------------------------------------------------- /test/utils/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package utils provides various utilities for testing the coherence-go-client. 9 | */ 10 | package utils 11 | -------------------------------------------------------------------------------- /test/utils/docker-compose-2-members.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023, 2024 Oracle Corporation and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at 3 | # https://oss.oracle.com/licenses/upl. 4 | 5 | services: 6 | coherence1: 7 | hostname: server1 8 | networks: 9 | coherence: 10 | aliases: 11 | - server1 12 | image: ghcr.io/oracle/coherence-go-test-1:1.0.0 13 | environment: 14 | - COHERENCE_WKA=server1 15 | ports: 16 | - 30000:30000 17 | - 1408:1408 18 | - 9612:9612 19 | - 8080:8080 20 | volumes: 21 | - ./certs:/certs 22 | 23 | coherence2: 24 | hostname: server2 25 | networks: 26 | coherence: 27 | aliases: 28 | - server2 29 | image: ghcr.io/oracle/coherence-go-test-2:1.0.0 30 | environment: 31 | - COHERENCE_WKA=server1 32 | ports: 33 | - 9613:9613 34 | 35 | networks: 36 | coherence: 37 | -------------------------------------------------------------------------------- /test/v1/base/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | /* 8 | Package base provides integration tests for the coherence-go-client got gRPC v1. 9 | */ 10 | package base 11 | -------------------------------------------------------------------------------- /test/v1/base/suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, 2024 Oracle and/or its affiliates. 3 | * Licensed under the Universal Permissive License v 1.0 as shown at 4 | * https://oss.oracle.com/licenses/upl. 5 | */ 6 | 7 | package base 8 | 9 | import ( 10 | "github.com/oracle/coherence-go-client/v2/test/utils" 11 | "testing" 12 | ) 13 | 14 | // The entry point for the test suite 15 | func TestMain(m *testing.M) { 16 | utils.RunTest(m, 1408, 30000, 8080, true) 17 | } 18 | --------------------------------------------------------------------------------