internal 0.1.83__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.

Files changed (28) hide show
  1. {internal-0.1.83 → internal-0.1.85}/PKG-INFO +1 -1
  2. {internal-0.1.83 → internal-0.1.85}/pyproject.toml +1 -1
  3. {internal-0.1.83 → internal-0.1.85}/src/internal/base_config.py +6 -1
  4. internal-0.1.85/src/internal/database.py +44 -0
  5. internal-0.1.83/src/internal/database.py +0 -28
  6. {internal-0.1.83 → internal-0.1.85}/README.md +0 -0
  7. {internal-0.1.83 → internal-0.1.85}/src/internal/__init__.py +0 -0
  8. {internal-0.1.83 → internal-0.1.85}/src/internal/base_factory.py +0 -0
  9. {internal-0.1.83 → internal-0.1.85}/src/internal/common_enum/__init__.py +0 -0
  10. {internal-0.1.83 → internal-0.1.85}/src/internal/common_enum/contact_type.py +0 -0
  11. {internal-0.1.83 → internal-0.1.85}/src/internal/common_enum/operator_type.py +0 -0
  12. {internal-0.1.83 → internal-0.1.85}/src/internal/const.py +0 -0
  13. {internal-0.1.83 → internal-0.1.85}/src/internal/exception/__init__.py +0 -0
  14. {internal-0.1.83 → internal-0.1.85}/src/internal/exception/base_exception.py +0 -0
  15. {internal-0.1.83 → internal-0.1.85}/src/internal/exception/internal_exception.py +0 -0
  16. {internal-0.1.83 → internal-0.1.85}/src/internal/ext/__init__.py +0 -0
  17. {internal-0.1.83 → internal-0.1.85}/src/internal/ext/amazon/__init__.py +0 -0
  18. {internal-0.1.83 → internal-0.1.85}/src/internal/ext/amazon/aws/__init__.py +0 -0
  19. {internal-0.1.83 → internal-0.1.85}/src/internal/ext/amazon/aws/const.py +0 -0
  20. {internal-0.1.83 → internal-0.1.85}/src/internal/http/__init__.py +0 -0
  21. {internal-0.1.83 → internal-0.1.85}/src/internal/http/requests.py +0 -0
  22. {internal-0.1.83 → internal-0.1.85}/src/internal/http/responses.py +0 -0
  23. {internal-0.1.83 → internal-0.1.85}/src/internal/interface/__init__.py +0 -0
  24. {internal-0.1.83 → internal-0.1.85}/src/internal/interface/base_interface.py +0 -0
  25. {internal-0.1.83 → internal-0.1.85}/src/internal/model/__init__.py +0 -0
  26. {internal-0.1.83 → internal-0.1.85}/src/internal/model/base_model.py +0 -0
  27. {internal-0.1.83 → internal-0.1.85}/src/internal/model/operate.py +0 -0
  28. {internal-0.1.83 → internal-0.1.85}/src/internal/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 0.1.83
3
+ Version: 0.1.85
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "internal"
3
- version = "0.1.83"
3
+ version = "0.1.85"
4
4
  description = ""
5
5
  authors = ["Ray <ray@cruisys.com>"]
6
6
  readme = "README.md"
@@ -23,10 +23,15 @@ class BaseConfig(BaseSettings):
23
23
  AWS_LOGGROUP_NAME: str = ""
24
24
 
25
25
  # MongoDB
26
- DATABASE_URL: str = ""
26
+ DATABASE_HOST: str = ''
27
+ DATABASE_USERNAME: str = ''
28
+ DATABASE_PASSWORD: str = ''
29
+ DATABASE_PORT: int = 27017
27
30
  DATABASE_NAME: str = ""
28
31
  DATABASE_SSL: bool = True
29
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
30
35
 
31
36
  # Micro Service
32
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