Skip to content

Commit 561f0a2

Browse files
authored
Integrate V1 Protocol Support, and Near Caching (#180)
Integrate support for Coherence gRPC protocol version 1. The client library continues to work with older Coherence versions. Integrate support for near caching, that is, maintaining a local cache of entries that have been retrieved previously via a gRPC call from a Coherence cluster
1 parent 2de594e commit 561f0a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+7243
-738
lines changed

.coveragerc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ omit =
44
src/coherence/messages_pb2_grpc.py
55
src/coherence/services_pb2.py
66
src/coherence/services_pb2_grpc.py
7+
src/coherence/cache_service_messages_v1_pb2.py
8+
src/coherence/cache_service_messages_v1_pb2_grpc.py
9+
src/coherence/common_messages_v1_pb2.py
10+
src/coherence/common_messages_v1_pb2_grpc.py
11+
src/coherence/proxy_service_messages_v1_pb2.py
12+
src/coherence/proxy_service_messages_v1_pb2_grpc.py
13+
src/coherence/proxy_service_v1_pb2.py
14+
src/coherence/proxy_service_v1_pb2_grpc.py

.github/workflows/validate.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: ["3.8.x", "3.9.x", "3.10.x", "3.11.x"]
21-
poetry-version: ["1.5.0"]
20+
python-version: ["3.9.x", "3.10.x", "3.11.x", "3.12.x", "3.13.x"]
21+
poetry-version: ["1.8.4"]
2222
os: [ubuntu-latest]
2323
coherenceVersion:
24-
- 24.03
24+
- 24.09
2525
- 22.06.10
2626
base-image:
2727
- gcr.io/distroless/java17-debian11
2828
profile:
2929
- ",-jakarta,javax"
3030
- ",jakarta,-javax"
3131
exclude:
32-
- coherenceVersion: 24.03
32+
- coherenceVersion: 24.09
3333
profile: ",-jakarta,javax"
3434
- coherenceVersion: 22.06.10
3535
profile: ",jakarta,-javax"

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ exclude: \w*(_pb2)\w*
88

99
repos:
1010
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v4.6.0
11+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
1212
hooks:
1313
- id: trailing-whitespace
1414
- id: end-of-file-fixer
1515
- id: check-yaml
1616
- id: check-added-large-files
1717

1818
- repo: https://github.com/PyCQA/flake8
19-
rev: 7.1.1
19+
rev: e43806be3607110919eff72939fda031776e885a # frozen: 7.1.1
2020
hooks:
2121
- id: flake8
2222

2323
- repo: https://github.com/psf/black
24-
rev: 24.8.0
24+
rev: 1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # frozen: 24.10.0
2525
hooks:
2626
- id: black
2727

2828
- repo: https://github.com/pre-commit/mirrors-mypy
29-
rev: v1.11.2
29+
rev: f56614daa94d5cd733d3b7004c5df9caad267b4a # frozen: v1.13.0
3030
hooks:
3131
- id: mypy
3232

3333
- repo: https://github.com/PyCQA/isort
34-
rev: 5.13.2
34+
rev: c235f5e450b4b84e58d114ed4c589cbf454175a3 # frozen: 5.13.2
3535
hooks:
3636
- id: isort

Makefile

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ COHERENCE_WKA1 ?= server1
3838
COHERENCE_WKA2 ?= server1
3939
CLUSTER_PORT ?= 7574
4040
# Profiles to include for building
41-
PROFILES ?= ",-jakarta,javax"
42-
COHERENCE_BASE_IMAGE ?= gcr.io/distroless/java17-debian11
41+
PROFILES ?= ",jakarta,-javax"
42+
COHERENCE_BASE_IMAGE ?= gcr.io/distroless/java17-debian12
4343

4444
# ----------------------------------------------------------------------------------------------------------------------
4545
# Set the location of various build tools
@@ -66,6 +66,27 @@ CURRDIR := $(shell pwd)
6666
COMPOSE:=$(shell type -p docker-compose || echo docker compose)
6767
$(info COMPOSE = $(COMPOSE))
6868

69+
# ----------------------------------------------------------------------------------------------------------------------
70+
# List of unit tests
71+
# ----------------------------------------------------------------------------------------------------------------------
72+
UNIT_TESTS := tests/unit/test_cache_options.py \
73+
tests/unit/test_local_cache.py \
74+
tests/unit/test_environment.py \
75+
tests/unit/test_serialization.py \
76+
tests/unit/test_extractors.py
77+
78+
# ----------------------------------------------------------------------------------------------------------------------
79+
# List of E2E tests
80+
# ----------------------------------------------------------------------------------------------------------------------
81+
E2E_TESTS := tests/e2e/test_session.py \
82+
tests/e2e/test_client.py \
83+
tests/e2e/test_events.py \
84+
tests/e2e/test_filters.py \
85+
tests/e2e/test_processors.py \
86+
tests/e2e/test_aggregators.py \
87+
tests/e2e/test_near_caching.py \
88+
# tests/e2e/test_ai.py \
89+
6990
# ----------------------------------------------------------------------------------------------------------------------
7091
# Clean-up all of the build artifacts
7192
# ----------------------------------------------------------------------------------------------------------------------
@@ -116,21 +137,53 @@ generate-proto: ## Generate Proto Files
116137
sed -e 's/import messages_pb2 as messages__pb2/import coherence.messages_pb2 as messages__pb2/' \
117138
< $(CURRDIR)/src/coherence/services_pb2_grpc.py > $(CURRDIR)/src/coherence/services_pb2_grpc.py.out
118139
mv $(CURRDIR)/src/coherence/services_pb2_grpc.py.out $(CURRDIR)/src/coherence/services_pb2_grpc.py
140+
curl -o $(PROTO_DIR)/proxy_service_v1.proto \
141+
https://raw.githubusercontent.com/oracle/coherence/$(COHERENCE_VERSION)/prj/coherence-grpc/src/main/proto/proxy_service_v1.proto
142+
curl -o $(PROTO_DIR)/proxy_service_messages_v1.proto \
143+
https://raw.githubusercontent.com/oracle/coherence/$(COHERENCE_VERSION)/prj/coherence-grpc/src/main/proto/proxy_service_messages_v1.proto
144+
curl -o $(PROTO_DIR)/common_messages_v1.proto \
145+
https://raw.githubusercontent.com/oracle/coherence/$(COHERENCE_VERSION)/prj/coherence-grpc/src/main/proto/common_messages_v1.proto
146+
curl -o $(PROTO_DIR)/cache_service_messages_v1.proto \
147+
https://raw.githubusercontent.com/oracle/coherence/$(COHERENCE_VERSION)/prj/coherence-grpc/src/main/proto/cache_service_messages_v1.proto
148+
python -m grpc_tools.protoc --proto_path=$(CURRDIR)/etc/proto --pyi_out=$(CURRDIR)/src/coherence --python_out=$(CURRDIR)/src/coherence \
149+
--grpc_python_out=$(CURRDIR)/src/coherence \
150+
$(CURRDIR)/etc/proto/proxy_service_v1.proto \
151+
$(CURRDIR)/etc/proto/proxy_service_messages_v1.proto \
152+
$(CURRDIR)/etc/proto/common_messages_v1.proto \
153+
$(CURRDIR)/etc/proto/cache_service_messages_v1.proto
154+
sed -e 's/import proxy_service_messages_v1_pb2 as proxy__service__messages__v1__pb2/import coherence.proxy_service_messages_v1_pb2 as proxy__service__messages__v1__pb2/' \
155+
< $(CURRDIR)/src/coherence/proxy_service_v1_pb2.py > $(CURRDIR)/src/coherence/proxy_service_v1_pb2.py.out
156+
mv $(CURRDIR)/src/coherence/proxy_service_v1_pb2.py.out $(CURRDIR)/src/coherence/proxy_service_v1_pb2.py
157+
sed -e 's/import common_messages_v1_pb2 as common__messages__v1__pb2/import coherence.common_messages_v1_pb2 as common__messages__v1__pb2/' \
158+
< $(CURRDIR)/src/coherence/proxy_service_messages_v1_pb2.py > $(CURRDIR)/src/coherence/proxy_service_messages_v1_pb2.py.out
159+
mv $(CURRDIR)/src/coherence/proxy_service_messages_v1_pb2.py.out $(CURRDIR)/src/coherence/proxy_service_messages_v1_pb2.py
160+
sed -e 's/import proxy_service_messages_v1_pb2 as proxy__service__messages__v1__pb2/import coherence.proxy_service_messages_v1_pb2 as proxy__service__messages__v1__pb2/' \
161+
< $(CURRDIR)/src/coherence/proxy_service_v1_pb2_grpc.py > $(CURRDIR)/src/coherence/proxy_service_v1_pb2_grpc.py.out
162+
mv $(CURRDIR)/src/coherence/proxy_service_v1_pb2_grpc.py.out $(CURRDIR)/src/coherence/proxy_service_v1_pb2_grpc.py
163+
sed -e 's/import common_messages_v1_pb2 as common__messages__v1__pb2/import coherence.common_messages_v1_pb2 as common__messages__v1__pb2/' \
164+
< $(CURRDIR)/src/coherence/cache_service_messages_v1_pb2.py > $(CURRDIR)/src/coherence/cache_service_messages_v1_pb2.py.out
165+
mv $(CURRDIR)/src/coherence/cache_service_messages_v1_pb2.py.out $(CURRDIR)/src/coherence/cache_service_messages_v1_pb2.py
119166

120167
# ----------------------------------------------------------------------------------------------------------------------
121168
# Run tests with code coverage
122169
# ----------------------------------------------------------------------------------------------------------------------
123170
.PHONY: test
124171
test: ##
125-
pytest -W error --cov src/coherence --cov-report=term --cov-report=html \
126-
tests/test_serialization.py \
127-
tests/test_extractors.py \
128-
tests/test_session.py \
129-
tests/test_client.py \
130-
tests/test_events.py \
131-
tests/test_filters.py \
132-
tests/test_processors.py \
133-
tests/test_aggregators.py \
172+
pytest -W error --cov src/coherence --cov-report=term --cov-report=html $(UNIT_TESTS) $(E2E_TESTS)
173+
174+
# ----------------------------------------------------------------------------------------------------------------------
175+
# Run unit tests with code coverage
176+
# ----------------------------------------------------------------------------------------------------------------------
177+
.PHONY: test-unit
178+
test-unit: ##
179+
pytest -W error --cov src/coherence --cov-report=term --cov-report=html $(UNIT_TESTS)
180+
181+
# ----------------------------------------------------------------------------------------------------------------------
182+
# Run e2e tests with code coverage
183+
# ----------------------------------------------------------------------------------------------------------------------
184+
.PHONY: test-e2e
185+
test-e2e: ##
186+
pytest -W error --cov src/coherence --cov-report=term --cov-report=html $(E2E_TESTS)
134187

135188
# ----------------------------------------------------------------------------------------------------------------------
136189
# Run standards validation across project

docs/api_reference.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ Aggregators
1111
.. autoclass:: coherence.Aggregators
1212
:members:
1313

14+
CacheOptions
15+
------------
16+
.. autoclass:: coherence.CacheOptions
17+
:members:
18+
19+
.. automethod:: __init__
20+
21+
CacheStats
22+
------------
23+
.. autoclass:: coherence.CacheStats
24+
:members:
25+
1426
Comparator
1527
----------
1628
.. autoclass:: coherence.Comparator
@@ -58,6 +70,13 @@ NamedMap
5870
:show-inheritance:
5971
:members:
6072

73+
NearCacheOptions
74+
----------------
75+
.. autoclass:: coherence.NearCacheOptions
76+
:members:
77+
78+
.. automethod:: __init__
79+
6180
Options
6281
-------
6382
.. autoclass:: coherence.Options

0 commit comments

Comments
 (0)