Skip to content

Commit c3674c0

Browse files
Fixing docstring and removing old code
1 parent 0899f68 commit c3674c0

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

aws_lambda_powertools/utilities/idempotency/persistence/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class BasePersistenceLayer(ABC):
116116
def __init__(self):
117117
"""Initialize the defaults"""
118118
self.function_name = ""
119-
self.backend = ""
120119
self.configured = False
121120
self.event_key_jmespath: str = ""
122121
self.event_key_compiled_jmespath = None

aws_lambda_powertools/utilities/idempotency/persistence/redis.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,25 @@ def delete(self, keys: bytes | str | memoryview) -> Any:
4848
class RedisConnection:
4949
def __init__(
5050
self,
51+
url: str = "",
5152
host: str = "",
53+
port: int = 6379,
5254
username: str = "",
5355
password: str = "", # nosec - password for Redis connection
54-
url: str = "",
5556
db_index: int = 0,
56-
port: int = 6379,
5757
mode: Literal["standalone", "cluster"] = "standalone",
5858
ssl: bool = False,
5959
ssl_cert_reqs: Literal["required", "optional", "none"] = "none",
6060
) -> None:
6161
"""
62-
Initialize Redis connection which will be used in redis persistence_store to support idempotency
62+
Initialize Redis connection which will be used in redis persistence_store to support Idempotency
6363
6464
Parameters
6565
----------
6666
host: str, optional
6767
redis host
68+
port: int, optional: default 6379
69+
redis port
6870
username: str, optional
6971
redis username
7072
password: str, optional
@@ -73,10 +75,8 @@ def __init__(
7375
redis connection string, using url will override the host/port in the previous parameters
7476
db_index: str, optional: default 0
7577
redis db index
76-
port: int, optional: default 6379
77-
redis port
7878
mode: str, Literal["standalone","cluster"]
79-
set redis client mode, choose from standalone/cluster
79+
set redis client mode, choose from standalone/cluster. The default is standalone
8080
ssl: bool, optional: default False
8181
set whether to use ssl for Redis connection
8282
ssl_cert_reqs: str, optional: default "none"
@@ -138,7 +138,7 @@ def create_subscription_payment(event: dict) -> Payment:
138138
self.mode = mode
139139

140140
def _init_client(self) -> RedisClientProtocol:
141-
logger.info(f"Trying to connect to Redis: {self.host}")
141+
logger.debug(f"Trying to connect to Redis: {self.host}")
142142
client: type[redis.Redis | redis.cluster.RedisCluster]
143143
if self.mode == "standalone":
144144
client = redis.Redis
@@ -171,12 +171,12 @@ def _init_client(self) -> RedisClientProtocol:
171171
class RedisCachePersistenceLayer(BasePersistenceLayer):
172172
def __init__(
173173
self,
174+
url: str = "",
174175
host: str = "",
176+
port: int = 6379,
175177
username: str = "",
176178
password: str = "", # nosec - password for Redis connection
177-
url: str = "",
178179
db_index: int = 0,
179-
port: int = 6379,
180180
mode: Literal["standalone", "cluster"] = "standalone",
181181
ssl: bool = False,
182182
ssl_cert_reqs: Literal["required", "optional", "none"] = "none",
@@ -193,6 +193,8 @@ def __init__(
193193
----------
194194
host: str, optional
195195
redis host
196+
port: int, optional: default 6379
197+
redis port
196198
username: str, optional
197199
redis username
198200
password: str, optional
@@ -201,8 +203,6 @@ def __init__(
201203
redis connection string, using url will override the host/port in the previous parameters
202204
db_index: str, optional: default 0
203205
redis db index
204-
port: int, optional: default 6379
205-
redis port
206206
mode: str, Literal["standalone","cluster"]
207207
set redis client mode, choose from standalone/cluster
208208
ssl: bool, optional: default False
@@ -231,7 +231,7 @@ def __init__(
231231
from aws_lambda_powertools.utilities.data_class import(
232232
RedisCachePersistenceLayer,
233233
)
234-
from aws_lambda_powertools.utilities.idempotency.idempotency import (
234+
from aws_lambda_powertools.utilities.idempotency import (
235235
idempotent,
236236
)
237237
@@ -271,7 +271,7 @@ def lambda_handler(event: dict, context: LambdaContext):
271271

272272
if not hasattr(self.client, "get_connection_kwargs"):
273273
raise IdempotencyRedisClientConfigError(
274-
"Error configuring the Redis Client. The client must implement get_connection_kwargs function.",
274+
"Error configuring the Redis Client. The Redis library must implement get_connection_kwargs function.",
275275
)
276276
if not self.client.get_connection_kwargs().get("decode_responses", False):
277277
warnings.warn(

0 commit comments

Comments
 (0)