Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 9d470d2

Browse files
authored
Merge pull request #16 from Indicio-tech/update/ACA-Py-0.11.0
Update to ACA-Py 0.11.0
2 parents d48b6f9 + 4d70d32 commit 9d470d2

File tree

9 files changed

+578
-537
lines changed

9 files changed

+578
-537
lines changed

acapy_cache_redis/v0_1/redis_base_cache.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
from aries_cloudagent.core.profile import Profile
77
from aries_cloudagent.core.error import BaseError
88
from redis.asyncio import RedisCluster
9-
from redis.exceptions import RedisError, RedisClusterException, ResponseError
9+
from redis.exceptions import RedisError, RedisClusterException
1010
from typing import Any, Sequence, Text, Union
11-
from uuid import uuid4
1211

1312
LOGGER = logging.getLogger(__name__)
1413

@@ -82,33 +81,26 @@ async def check_for_redis_cluster(self):
8281
reassign redis to redis.asyncio.RedisCluster client.
8382
8483
"""
85-
try:
86-
# Execute a redis SET command on a fake test_key prefix with b""
87-
# value. In case, connection string is that of a single redis
88-
# host then it will return None as it doesn't exists. Otherwise,
89-
# it will raise a MOVED error.
90-
fake_test_key = f"test_key_{str(uuid4())}"
91-
await self.redis.set(fake_test_key, b"", ex=1)
92-
except ResponseError as err:
93-
if "MOVED" in str(err):
94-
self.redis = self.root_profile.inject_or(RedisCluster)
95-
if not self.redis:
96-
self.redis = RedisCluster.from_url(
97-
self.connection,
98-
max_connections=self.max_connections,
99-
username=self.username,
100-
password=self.password,
101-
)
102-
# Binds RedisCluster cluster instance, so that it is
103-
# accessible to redis_queue plugin.
104-
LOGGER.info(
105-
"Found redis connection string correspond to a cluster node,"
106-
" reassigning redis to redis.asyncio.RedisCluster client."
107-
)
108-
self.root_profile.injector.bind_instance(RedisCluster, self.redis)
109-
await self.redis.ping(target_nodes=RedisCluster.PRIMARIES)
110-
else:
111-
LOGGER.info("Using an existing provided instance of RedisCluster.")
84+
cluster_info = await self.redis.info("cluster")
85+
if "cluster_enabled" in cluster_info and cluster_info["cluster_enabled"] == 1:
86+
self.redis = self.root_profile.inject_or(RedisCluster)
87+
if not self.redis:
88+
self.redis = RedisCluster.from_url(
89+
self.connection,
90+
max_connections=self.max_connections,
91+
username=self.username,
92+
password=self.password,
93+
)
94+
# Binds RedisCluster cluster instance, so that it is
95+
# accessible to redis_queue plugin.
96+
LOGGER.info(
97+
"Found redis connection string correspond to a cluster node,"
98+
" reassigning redis to redis.asyncio.RedisCluster client."
99+
)
100+
self.root_profile.injector.bind_instance(RedisCluster, self.redis)
101+
await self.redis.ping(target_nodes=RedisCluster.PRIMARIES)
102+
else:
103+
LOGGER.info("Using an existing provided instance of RedisCluster.")
112104

113105
def _getKey(self, key: Text) -> Text:
114106
return f"{self.prefix}:{key}"

int/poetry.lock

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

int/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "acapy-cache-redis-int-tests"
33
version = "0.1.0"
44
description = "Integration tests for ACA-Py Redis Cache Plugin"
5-
authors = ["Colton Wolkins <[email protected]"]
5+
authors = ["Colton Wolkins <[email protected]>", "Kim Ebert <[email protected]>", "Alex Walker <[email protected]>"]
66

77
[tool.poetry.dependencies]
88
python = "^3.9"

int/tests/cluster/test_connectivity.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ async def test_send_and_receive(echo: EchoClient, connection: ConnectionInfo):
1515
await echo.send_message(
1616
connection,
1717
{
18-
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping",
18+
"@type": "https://didcomm.org/trust_ping/1.0/ping",
1919
"response_resquested": True,
2020
},
2121
)
2222
response = await echo.get_message(connection)
23-
assert response["@type"] == (
24-
"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping_response"
25-
)
23+
assert response["@type"] == ("https://didcomm.org/trust_ping/1.0/ping_response")

int/tests/cluster/test_redis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import json
77

88

9-
109
LOGGER = logging.getLogger(__name__)
1110

1211

int/tests/host/test_connectivity.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ async def test_send_and_receive(echo: EchoClient, connection: ConnectionInfo):
1515
await echo.send_message(
1616
connection,
1717
{
18-
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping",
18+
"@type": "https://didcomm.org/trust_ping/1.0/ping",
1919
"response_resquested": True,
2020
},
2121
)
2222
response = await echo.get_message(connection)
23-
assert response["@type"] == (
24-
"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping_response"
25-
)
23+
assert response["@type"] == ("https://didcomm.org/trust_ping/1.0/ping_response")

int/tests/host/test_redis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import json
77

88

9-
109
LOGGER = logging.getLogger(__name__)
1110

1211

0 commit comments

Comments
 (0)