internal 1.0.46__py3-none-any.whl → 1.0.48__py3-none-any.whl
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/base_factory.py +27 -10
- internal/common_enum/event_trigger_type.py +7 -1
- internal/database.py +9 -6
- {internal-1.0.46.dist-info → internal-1.0.48.dist-info}/METADATA +1 -1
- {internal-1.0.46.dist-info → internal-1.0.48.dist-info}/RECORD +6 -6
- {internal-1.0.46.dist-info → internal-1.0.48.dist-info}/WHEEL +0 -0
internal/base_factory.py
CHANGED
|
@@ -3,6 +3,7 @@ import logging.handlers
|
|
|
3
3
|
import os
|
|
4
4
|
import traceback
|
|
5
5
|
from abc import ABCMeta, abstractmethod
|
|
6
|
+
from contextlib import asynccontextmanager
|
|
6
7
|
from functools import lru_cache
|
|
7
8
|
|
|
8
9
|
import dotenv
|
|
@@ -44,6 +45,12 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
44
45
|
Each factory should define what model it wants.
|
|
45
46
|
"""
|
|
46
47
|
|
|
48
|
+
async def init_state_scheduler_app(self, app, app_config):
|
|
49
|
+
"""
|
|
50
|
+
Each factory should define what model it wants.
|
|
51
|
+
"""
|
|
52
|
+
pass
|
|
53
|
+
|
|
47
54
|
@abstractmethod
|
|
48
55
|
@lru_cache()
|
|
49
56
|
def get_app_config(self):
|
|
@@ -52,15 +59,31 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
52
59
|
"""
|
|
53
60
|
|
|
54
61
|
def create_app(self, title=None) -> FastAPI:
|
|
62
|
+
|
|
63
|
+
@asynccontextmanager
|
|
64
|
+
async def lifespan(app: FastAPI):
|
|
65
|
+
await mongodb.connect()
|
|
66
|
+
document_model_list = await self.get_document_model_list()
|
|
67
|
+
await init_beanie(database=app.state.db.get_database(), document_models=document_model_list)
|
|
68
|
+
app.state.logger.info("Database connected")
|
|
69
|
+
await self.init_state_cache(app, self.get_app_config())
|
|
70
|
+
app.state.logger.info("Initialization state cache done")
|
|
71
|
+
await self.init_state_scheduler_app(app, self.get_app_config())
|
|
72
|
+
app.state.logger.info("Initialization state scheduler app done")
|
|
73
|
+
yield
|
|
74
|
+
await mongodb.close()
|
|
75
|
+
app.state.logger.info("Database disconnected")
|
|
76
|
+
|
|
55
77
|
if title is None:
|
|
56
78
|
title = self.DEFAULT_APP_NAME
|
|
57
79
|
|
|
58
80
|
if self.get_app_config().DEBUG:
|
|
59
81
|
app = FastAPI(openapi_url=self.get_app_config().OPEN_API_URL, title=title,
|
|
60
|
-
debug=self.get_app_config().DEBUG, version=self.API_VERSION)
|
|
82
|
+
debug=self.get_app_config().DEBUG, version=self.API_VERSION, lifespan=lifespan)
|
|
61
83
|
else:
|
|
62
84
|
app = FastAPI(openapi_url=self.get_app_config().OPEN_API_URL, title=title,
|
|
63
|
-
debug=self.get_app_config().DEBUG, version=self.API_VERSION,
|
|
85
|
+
debug=self.get_app_config().DEBUG, version=self.API_VERSION, lifespan=lifespan, docs_url=None,
|
|
86
|
+
redoc_url=None)
|
|
64
87
|
|
|
65
88
|
origins = ["*"]
|
|
66
89
|
|
|
@@ -92,17 +115,11 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
92
115
|
|
|
93
116
|
@app.on_event("startup")
|
|
94
117
|
async def startup_db_client():
|
|
95
|
-
|
|
96
|
-
document_model_list = await self.get_document_model_list()
|
|
97
|
-
await init_beanie(database=app.state.db.get_database(), document_models=document_model_list)
|
|
98
|
-
app.state.logger.info("Database connected")
|
|
99
|
-
await self.init_state_cache(app, self.get_app_config())
|
|
100
|
-
app.state.logger.info("Initialization state cache done")
|
|
118
|
+
print("startup_db_client================run")
|
|
101
119
|
|
|
102
120
|
@app.on_event("shutdown")
|
|
103
121
|
async def shutdown_db_client():
|
|
104
|
-
|
|
105
|
-
app.state.logger.info("Database disconnected")
|
|
122
|
+
print("shutdown_db_client============run")
|
|
106
123
|
|
|
107
124
|
app.state.db = mongodb
|
|
108
125
|
app.state.config = self.get_app_config()
|
|
@@ -7,6 +7,7 @@ class EventTriggerTypeEnum(str, Enum):
|
|
|
7
7
|
MANUAL_TRACING_STOP_SERVICE_TICKET = "manual_tracking_stop_service_ticket"
|
|
8
8
|
MANUAL_CREATE_SERVICE_TICKET = "manual_create_service_ticket"
|
|
9
9
|
MANUAL_IMPORT_RESERVATION_SMWS = "manual_import_reservation_smws"
|
|
10
|
+
MANUAL_MODIFY_USER_SERVICE_TICKET = "manual_modify_user_service_ticket"
|
|
10
11
|
MANUAL_MODIFY_ESTIMATED_ARRIVAL_TIME_SERVICE_TICKET = "manual_modify_estimated_arrival_time_service_ticket"
|
|
11
12
|
MANUAL_MODIFY_ESTIMATED_DELIVERY_TIME_SERVICE_TICKET = "manual_modify_estimated_delivery_time_service_ticket"
|
|
12
13
|
MANUAL_BOOKING_MESSAGE_SERVICE_TICKET = "manual_booking_message_service_ticket"
|
|
@@ -15,5 +16,10 @@ class EventTriggerTypeEnum(str, Enum):
|
|
|
15
16
|
NOSHOW_SERVICE_TICKET_AUTO_CANCEL = "noshow_service_ticket_auto_cancel"
|
|
16
17
|
IMPORT_RESERVATION_CONFLICT_AUTO_CANCEL = "import_reservation_conflict_auto_cancel"
|
|
17
18
|
BOOKING_REMINDING_SERVICE_TICKET = "booking_reminding_service_ticket"
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
LPNR_IN_ESTABLISHED = "lpnr_in_established"
|
|
21
|
+
LPNR_IN_RECEPTION = "lpnr_in_reception"
|
|
22
|
+
LPNR_IN_WORKING = "lpnr_in_working"
|
|
19
23
|
LPNR_OUT = "lpnr_out"
|
|
24
|
+
LPNR_OUT_GENERAL = "lpnr_out_general"
|
|
25
|
+
LPNR_OUT_NO_SERVE = "lpnr_out_no_serve"
|
internal/database.py
CHANGED
|
@@ -5,12 +5,6 @@ from .exception.internal_exception import DatabaseInitializeFailureException, Da
|
|
|
5
5
|
|
|
6
6
|
|
|
7
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
8
|
def __init__(self, user_name: str, password: str, host: str, port: int, db_name: str, server_selection_timeout: int,
|
|
15
9
|
connection_timeout: int, auth_source: str, ssl: bool = False, ssl_ca_certs: str = None):
|
|
16
10
|
self.client = None
|
|
@@ -49,3 +43,12 @@ class MongoDB:
|
|
|
49
43
|
if not self.client:
|
|
50
44
|
raise DatabaseConnectFailureException()
|
|
51
45
|
return self.client[self.db_name]
|
|
46
|
+
|
|
47
|
+
def get_mongodb_uri(self) -> str:
|
|
48
|
+
uri = f"mongodb://{self.user_name}:{self.password}@{self.host}:{self.port}/{self.db_name}?authSource={self.auth_source}&connectTimeoutMS={self.connection_timeout}&serverSelectionTimeoutMS={self.server_selection_timeout}&retryWrites=false"
|
|
49
|
+
if self.ssl:
|
|
50
|
+
uri += "&ssl=true"
|
|
51
|
+
if self.ssl_ca_certs and self.ssl_ca_certs != "":
|
|
52
|
+
uri += f"&tlsCAFile={self.ssl_ca_certs}"
|
|
53
|
+
|
|
54
|
+
return uri
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
internal/base_config.py,sha256=ZdqvHlPsF6ozELgmV0ZiSpYehSscasIclLp8eAjVE24,1870
|
|
3
|
-
internal/base_factory.py,sha256=
|
|
3
|
+
internal/base_factory.py,sha256=skI4MIFj5XW3Dtxu-Bp5oKoDU1RBEOCx-Sgrjt1aaqU,9115
|
|
4
4
|
internal/common_enum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
internal/common_enum/contact_type.py,sha256=7QkTQ71UxpaT1YHI40FpjmLz3r-UbRU-sd0m5ajH1as,142
|
|
6
6
|
internal/common_enum/description_type.py,sha256=kGwkFQh6dMnjDl6ipWYpA-qbNRrhEpnPq3NleTsNwwk,118
|
|
7
|
-
internal/common_enum/event_trigger_type.py,sha256=
|
|
7
|
+
internal/common_enum/event_trigger_type.py,sha256=Y5V7aHe-9UE2iCbghQJZtHkzLpHNgDUdcL96ztbQwEg,1381
|
|
8
8
|
internal/common_enum/lpnr_direction.py,sha256=Rkzyu3qz4_jwkA8tFsrRUc4L8HLOz9SALfN4K_9Xd1w,90
|
|
9
9
|
internal/common_enum/operator_type.py,sha256=JU4EqloxtrIXzaUbEWuQLDMmAZy6AT8EAX8KIrJH4xs,125
|
|
10
10
|
internal/common_enum/order_type.py,sha256=XwAl5JaZgFLahBQhBKG4VuMJ39Si9KZEhcSS0-DKKzQ,90
|
|
11
11
|
internal/const.py,sha256=U1S9r7bjtHgad2oYQoHO19s8D4V0WDUG-L-haV4UaIw,1025
|
|
12
|
-
internal/database.py,sha256=
|
|
12
|
+
internal/database.py,sha256=HV0F-1HiAo5SAxbgqlMGpBnUsNLY-W7xzc2PtkuAUfA,2310
|
|
13
13
|
internal/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
internal/exception/base_exception.py,sha256=U0ZXx1FOXydAnQQImznkeAdsKVC_YaukPWvJdWqEBfg,363
|
|
15
15
|
internal/exception/internal_exception.py,sha256=rBi70sDFwoYc2NSnxXQ9LY6r2TnxA7ILC64xjpg5h4c,2296
|
|
@@ -28,6 +28,6 @@ internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
28
28
|
internal/model/base_model.py,sha256=NS_GZvw_IqU1aZPHPpyQs6A741O34ybmzVzBPm9nGWU,3014
|
|
29
29
|
internal/model/operate.py,sha256=luEoP_Asvso_11qz1SAE1Kn5KxAnDRptM0VylC5tNik,1493
|
|
30
30
|
internal/utils.py,sha256=0SubS0iUhDvjSX1F4TykasA5-enYJzt2VH-f7_0BnjI,1509
|
|
31
|
-
internal-1.0.
|
|
32
|
-
internal-1.0.
|
|
33
|
-
internal-1.0.
|
|
31
|
+
internal-1.0.48.dist-info/METADATA,sha256=isqwmxO3KxWh3hlIqTcvBOv0eK6D4NJgbwcleHJbCFg,625
|
|
32
|
+
internal-1.0.48.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
33
|
+
internal-1.0.48.dist-info/RECORD,,
|
|
File without changes
|