From 0a07944d25ffb50591e3525e02100265080b0499 Mon Sep 17 00:00:00 2001 From: lgiordano-eb <113450422+lgiordano-eb@users.noreply.github.com> Date: Fri, 28 Oct 2022 17:40:44 -0300 Subject: [PATCH] Revert "Try boto3 to retrieve ElastiCache host and Port" This reverts commit cb9deeec1d898729484bc95e14f2311dcc3ed170. --- .coveragerc | 1 - server/redis.py | 8 ++------ server/redis_services.py | 28 ---------------------------- 3 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 server/redis_services.py diff --git a/.coveragerc b/.coveragerc index 498bccd..6620094 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,7 +5,6 @@ omit = env/* */tests* */__init__.py - */redis_services* [report] exclude_lines = diff --git a/server/redis.py b/server/redis.py index 63f2ee5..cb98b01 100644 --- a/server/redis.py +++ b/server/redis.py @@ -3,23 +3,19 @@ from redis.exceptions import DataError from uvicorn.config import logger -# from .environment import REDIS_HOST, REDIS_LOCAL_PORT +from .environment import REDIS_HOST, REDIS_LOCAL_PORT from typing import Dict - -from server.redis_services import ElastiCache_Api_client from server.constants import ( LOG_EXPIRE, REDIS_ERROR, DEFAULT_EXPIRE, ) -elastiCache_api_client = ElastiCache_Api_client() -REDIS_HOST, REDIS_PORT = elastiCache_api_client.get_host_port() redis_data = redis.Redis( host=REDIS_HOST, - port=REDIS_PORT, + port=REDIS_LOCAL_PORT, db=0, charset="utf-8", decode_responses=True, diff --git a/server/redis_services.py b/server/redis_services.py deleted file mode 100644 index 86cc436..0000000 --- a/server/redis_services.py +++ /dev/null @@ -1,28 +0,0 @@ -import boto3 -from botocore.exceptions import ClientError, NoRegionError - -from uvicorn.config import logger - -from .environment import REDIS_HOST, REDIS_LOCAL_PORT - - -class ElastiCache_Api_client(): - - def get_host_port(self): - try: - client = boto3.client('elasticache') - response = client.describe_cache_clusters( - MaxRecords=10, - ShowCacheNodeInfo=True, - ShowCacheClustersNotInReplicationGroups=True, - ) - url = response.CacheClusters[0].CacheNodes[0].Endpoint.Address - port = response.CacheClusters[0].CacheNodes[0].Endpoint.Port - return (url, port) - except ClientError as e: - logger.error(e) - logger.error(f'Trying local connection - Connecting to HOST: {REDIS_HOST}, PORT: {REDIS_LOCAL_PORT}') - return (REDIS_HOST, REDIS_LOCAL_PORT) - except NoRegionError as e: - logger.error(e) - return (REDIS_HOST, REDIS_LOCAL_PORT)