internal 0.1.84__tar.gz → 0.1.85__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of internal might be problematic. Click here for more details.
- {internal-0.1.84 → internal-0.1.85}/PKG-INFO +1 -1
- {internal-0.1.84 → internal-0.1.85}/pyproject.toml +1 -1
- {internal-0.1.84 → internal-0.1.85}/src/internal/base_config.py +2 -0
- internal-0.1.85/src/internal/database.py +44 -0
- internal-0.1.84/src/internal/database.py +0 -28
- {internal-0.1.84 → internal-0.1.85}/README.md +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/base_factory.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/common_enum/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/common_enum/contact_type.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/common_enum/operator_type.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/const.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/exception/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/exception/base_exception.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/exception/internal_exception.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/ext/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/ext/amazon/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/ext/amazon/aws/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/ext/amazon/aws/const.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/http/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/http/requests.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/http/responses.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/interface/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/interface/base_interface.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/model/__init__.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/model/base_model.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/model/operate.py +0 -0
- {internal-0.1.84 → internal-0.1.85}/src/internal/utils.py +0 -0
|
@@ -30,6 +30,8 @@ class BaseConfig(BaseSettings):
|
|
|
30
30
|
DATABASE_NAME: str = ""
|
|
31
31
|
DATABASE_SSL: bool = True
|
|
32
32
|
DATABASE_SSL_CA_CERTS: str = "/rds-combined-ca-bundle.pem"
|
|
33
|
+
DATABASE_SERVER_SELECTION_TIMEOUT_MS: int = 5000
|
|
34
|
+
DATABASE_CONNECT_TIMEOUT_MS: int = 10000
|
|
33
35
|
|
|
34
36
|
# Micro Service
|
|
35
37
|
AUTH_BASE_URL: str = "http://auth-service-api"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from motor.motor_asyncio import AsyncIOMotorClient
|
|
2
|
+
from pymongo.errors import ServerSelectionTimeoutError
|
|
3
|
+
|
|
4
|
+
from .exception.internal_exception import DatabaseInitializeFailureException, DatabaseConnectFailureException
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MongoDB:
|
|
8
|
+
# def __init__(self, connection_url: str, db_name: str, ssl: bool = False, ssl_ca_certs: str = None):
|
|
9
|
+
# self.client = None
|
|
10
|
+
# self.connection_url = connection_url
|
|
11
|
+
# self.db_name = db_name
|
|
12
|
+
# self.ssl = ssl
|
|
13
|
+
# self.ssl_ca_certs = ssl_ca_certs
|
|
14
|
+
def __init__(self, user_name: str, password: str, host: str, port: int, db_name: str, server_selection_timeout: int,
|
|
15
|
+
connection_timeout: int, ssl: bool = False, ssl_ca_certs: str = None):
|
|
16
|
+
self.client = None
|
|
17
|
+
self.user_name = user_name
|
|
18
|
+
self.password = password
|
|
19
|
+
self.host = host
|
|
20
|
+
self.port = port
|
|
21
|
+
self.db_name = db_name
|
|
22
|
+
self.connection_timeout = connection_timeout
|
|
23
|
+
self.server_selection_timeout = server_selection_timeout
|
|
24
|
+
self.ssl = ssl
|
|
25
|
+
self.ssl_ca_certs = ssl_ca_certs
|
|
26
|
+
|
|
27
|
+
async def connect(self):
|
|
28
|
+
try:
|
|
29
|
+
self.client = AsyncIOMotorClient(username=self.user_name, password=self.password, host=self.host,
|
|
30
|
+
port=self.port, ssl=self.ssl, tlsCAFile=self.ssl_ca_certs,
|
|
31
|
+
connectTimeoutMS=self.connection_timeout,
|
|
32
|
+
serverSelectionTimeoutMS=self.server_selection_timeout,
|
|
33
|
+
retryWrites=False)
|
|
34
|
+
except ServerSelectionTimeoutError:
|
|
35
|
+
raise DatabaseInitializeFailureException()
|
|
36
|
+
|
|
37
|
+
async def close(self):
|
|
38
|
+
if self.client:
|
|
39
|
+
self.client.close()
|
|
40
|
+
|
|
41
|
+
def get_database(self):
|
|
42
|
+
if not self.client:
|
|
43
|
+
raise DatabaseConnectFailureException()
|
|
44
|
+
return self.client[self.db_name]
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from motor.motor_asyncio import AsyncIOMotorClient
|
|
2
|
-
from pymongo.errors import ServerSelectionTimeoutError
|
|
3
|
-
|
|
4
|
-
from .exception.internal_exception import DatabaseInitializeFailureException, DatabaseConnectFailureException
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class MongoDB:
|
|
8
|
-
def __init__(self, connection_url: str, db_name: str, ssl: bool = False, ssl_ca_certs: str = None):
|
|
9
|
-
self.client = None
|
|
10
|
-
self.connection_url = connection_url
|
|
11
|
-
self.db_name = db_name
|
|
12
|
-
self.ssl = ssl
|
|
13
|
-
self.ssl_ca_certs = ssl_ca_certs
|
|
14
|
-
|
|
15
|
-
async def connect(self):
|
|
16
|
-
try:
|
|
17
|
-
self.client = AsyncIOMotorClient(self.connection_url, ssl=self.ssl, tlsCAFile=self.ssl_ca_certs)
|
|
18
|
-
except ServerSelectionTimeoutError:
|
|
19
|
-
raise DatabaseInitializeFailureException()
|
|
20
|
-
|
|
21
|
-
async def close(self):
|
|
22
|
-
if self.client:
|
|
23
|
-
self.client.close()
|
|
24
|
-
|
|
25
|
-
def get_database(self):
|
|
26
|
-
if not self.client:
|
|
27
|
-
raise DatabaseConnectFailureException()
|
|
28
|
-
return self.client[self.db_name]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|