maleo-foundation 0.1.13__py3-none-any.whl → 0.1.15__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.
@@ -8,6 +8,7 @@ class ClientManager:
8
8
  self._logs_dir = logs_dir
9
9
  self._google_cloud_logging = google_cloud_logging
10
10
  self._initialize_logger()
11
+ self._logger.info("Initializing client manager")
11
12
 
12
13
  def _initialize_logger(self) -> None:
13
14
  self._logger = ClientLogger(logs_dir=self._logs_dir, client_key=self._key, google_cloud_logging=self._google_cloud_logging)
@@ -16,6 +16,7 @@ class GoogleSecretManager(GoogleClientManager):
16
16
  credentials_path=credentials_path
17
17
  )
18
18
  self._client = secretmanager.SecretManagerServiceClient(credentials=self._credentials)
19
+ self._logger.info("Client manager initialized successfully")
19
20
 
20
21
  @property
21
22
  def client(self) -> secretmanager.SecretManagerServiceClient:
@@ -23,9 +24,9 @@ class GoogleSecretManager(GoogleClientManager):
23
24
 
24
25
  def dispose(self) -> None:
25
26
  if self._client is not None:
26
- self._logger.info("Disposing Google Secret Manager (GSM) client manager")
27
+ self._logger.info("Disposing client manager")
27
28
  self._client = None
28
- self._logger.info("Google Secret Manager (GCS) client manager disposed successfully")
29
+ self._logger.info("Client manager disposed successfully")
29
30
 
30
31
  @retry.Retry(predicate=retry.if_exception_type(Exception), timeout=5)
31
32
  def get(self, name:str, version:str = "latest") -> Optional[str]:
@@ -24,6 +24,7 @@ class GoogleCloudStorage(GoogleClientManager):
24
24
  if self._bucket is None:
25
25
  self._client.close()
26
26
  raise ValueError(f"Bucket '{self._bucket_name}' does not exist.")
27
+ self._logger.info("Client manager initialized successfully")
27
28
 
28
29
  @property
29
30
  def bucket_name(self) -> str:
@@ -35,10 +36,10 @@ class GoogleCloudStorage(GoogleClientManager):
35
36
 
36
37
  def dispose(self) -> None:
37
38
  if self._client is not None:
38
- self._logger.info("Disposing Google Cloud Storage (GCS) client manager")
39
+ self._logger.info("Disposing client manager")
39
40
  self._client.close()
40
41
  self._client = None
41
- self._logger.info("Google Cloud Storage (GCS) client manager disposed successfully")
42
+ self._logger.info("Client manager disposed successfully")
42
43
 
43
44
  def generate_signed_url(self, location:str) -> str:
44
45
  """
@@ -42,6 +42,9 @@ class ClientHTTPControllerManager:
42
42
  def url(self) -> URL:
43
43
  return self._url
44
44
 
45
+ async def dispose(self) -> None:
46
+ await self._client.aclose()
47
+
45
48
  class ClientControllerManagers(BaseModel):
46
49
  http:ClientHTTPControllerManager = Field(..., description="HTTP Client Controller")
47
50
 
@@ -108,4 +111,9 @@ class MaleoClientManager(ClientManager):
108
111
 
109
112
  @property
110
113
  def services(self) -> ClientServices:
111
- return self._services
114
+ return self._services
115
+
116
+ async def dispose(self) -> None:
117
+ self._logger.info("Disposing client manager")
118
+ await self._controller_managers.http.dispose()
119
+ self._logger.info("Client manager disposed successfully")
@@ -17,9 +17,9 @@ class MetadataManager:
17
17
  class SessionManager:
18
18
  def __init__(self, logger:BaseLogger, engine:Engine):
19
19
  self._logger = logger
20
- self._logger.info("Initializing SessionMaker.")
20
+ self._logger.info("Initializing SessionMaker")
21
21
  self._sessionmaker:sessionmaker[Session] = sessionmaker(bind=engine, expire_on_commit=False)
22
- self._logger.info("SessionMaker initialized successfully.")
22
+ self._logger.info("SessionMaker initialized successfully")
23
23
 
24
24
  def _session_handler(self) -> Generator[Session, None, None]:
25
25
  """Reusable function for managing database sessions."""
@@ -55,7 +55,7 @@ class SessionManager:
55
55
  self._sessionmaker.close_all()
56
56
  self._sessionmaker = None
57
57
 
58
- self._logger.info("SessionManager disposed successfully.")
58
+ self._logger.info("SessionManager disposed successfully")
59
59
  self._logger = None
60
60
 
61
61
  class DatabaseManager:
@@ -74,7 +74,7 @@ class DatabaseManager:
74
74
  raise ValueError("DB_URL environment variable must be set if url is not provided")
75
75
  self._logger.info("Creating SQlAlchemy engine")
76
76
  self._engine = create_engine(url=url, echo=False, pool_pre_ping=True, pool_recycle=3600)
77
- self._logger.info("SQlAlchemy engine created")
77
+ self._logger.info("SQlAlchemy engine created successfully")
78
78
 
79
79
  #* Creating all table from metadata
80
80
  self._logger.info("Creating all tables defined in metadata")
@@ -84,7 +84,7 @@ class DatabaseManager:
84
84
  #* Initializing session manager
85
85
  self._logger.info("Initializing session manager")
86
86
  self._session = SessionManager(logger=self._logger, engine=self._engine) #* Define session
87
- self._logger.info("Session manager initialized")
87
+ self._logger.info("Session manager initialized successfully")
88
88
 
89
89
  @property
90
90
  def metadata(self) -> MetaData:
@@ -313,8 +313,8 @@ class ServiceManager:
313
313
 
314
314
  def _initialize_clients(self) -> None:
315
315
  #* Initialize google clients
316
- secret = GoogleSecretManager(logs_dir=self._logs_dir, google_cloud_logging=self._google_cloud_logging)
317
- storage = GoogleCloudStorage(logs_dir=self._logs_dir, google_cloud_logging=self._google_cloud_logging)
316
+ secret = GoogleSecretManager(**self._log_config.model_dump())
317
+ storage = GoogleCloudStorage(**self._log_config.model_dump())
318
318
  self._google_clients = GoogleClientManagers(secret=secret, storage=storage)
319
319
  #* Initialize http clients
320
320
  self._http_client = HTTPClientManager
@@ -322,9 +322,7 @@ class ServiceManager:
322
322
  #* Initialize maleo clients
323
323
  self._maleo_clients = MaleoClientManagers()
324
324
  if self._maleo_client_manager_classes.metadata is not None and issubclass(self._maleo_client_manager_classes.metadata, MaleoClientManager):
325
- self._loggers.application.info("Initializing %s client manager", self._configs.client.maleo.metadata.key)
326
325
  self._maleo_clients.metadata = self._maleo_client_manager_classes.metadata(**self._configs.client.maleo.metadata.model_dump(), **self._log_config.model_dump())
327
- self._loggers.application.info("%s client manager initialized successfully", self._configs.client.maleo.metadata.key)
328
326
  self._clients = ClientManagers(google=self._google_clients, http=self._http_client, maleo=self._maleo_clients)
329
327
 
330
328
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -29,16 +29,16 @@ maleo_foundation/expanded_types/query.py,sha256=0yUG-JIVsanzB7KAkrRz_OsrhP6J0bRq
29
29
  maleo_foundation/expanded_types/service.py,sha256=q8jpKdbCbLWwH1UPQavKpVE14rC5rveduk2cFWzuhGw,2416
30
30
  maleo_foundation/expanded_types/token.py,sha256=4fRTJw6W5MYq71NksNrWNi7qYHQ4_lQwfu9WxwrMipc,355
31
31
  maleo_foundation/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
- maleo_foundation/managers/db.py,sha256=rbB5W2rSxV2xcexh9j79U4ZKgAuA61t8ZD2IKppg22k,4867
33
- maleo_foundation/managers/service.py,sha256=va8wiU3oImQRo839CxXx2PWJRitsnx-mFPMh1ZGgW88,17833
32
+ maleo_foundation/managers/db.py,sha256=HGvaVe9uCQt8RTeS29F6lZd2s8MzMKP2sFju3wBA0Ck,4890
33
+ maleo_foundation/managers/service.py,sha256=iKHJ8-hAwXgHz5iZFV4d9W8Ta8Ww3Z_xJsMD3TtqAdM,17503
34
34
  maleo_foundation/managers/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- maleo_foundation/managers/client/base.py,sha256=GytrN4WB0oa8Flg6VHJ4oSg7kaWQBjXQ8GTwC4VFleY,965
35
+ maleo_foundation/managers/client/base.py,sha256=K8AFV2MTZrC1jbTqxkx7eedmxodJirNIjoRXGGcppy4,1022
36
36
  maleo_foundation/managers/client/http.py,sha256=dWFZlG1z4TERYBITReR5oSrlzvdhh2EtztVnsU8gCeA,2712
37
- maleo_foundation/managers/client/maleo.py,sha256=2EslsYZyCcCAQyR6j9u2791vfHo1tizhtre2l9zR9vs,3664
37
+ maleo_foundation/managers/client/maleo.py,sha256=f0_znaUjW4m-I55BPi6rtQNphFRVyybq774b7q59TUw,3951
38
38
  maleo_foundation/managers/client/google/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  maleo_foundation/managers/client/google/base.py,sha256=1lrGoyGnYW5Xq05bVXbKqnsqqmFPnsqZCBPK5-DINDA,1037
40
- maleo_foundation/managers/client/google/secret.py,sha256=iKXaF8qNDXRYbmosS9bAXQFYwRdDZ3Kh2yKhBAaOoEI,3061
41
- maleo_foundation/managers/client/google/storage.py,sha256=KaT4XrNpy-p6Bi1TcN0c4BK-vrfzCYxwKzMq4i3saNA,2335
40
+ maleo_foundation/managers/client/google/secret.py,sha256=bWR_3Xl_wUFqj4M48w8ZE692U7PQKX9ap0ndDJviV80,3074
41
+ maleo_foundation/managers/client/google/storage.py,sha256=041iSSaFubnZrP-pS8MiLVtOgeLQ591Iz64JekZ5K7o,2350
42
42
  maleo_foundation/middlewares/__init__.py,sha256=bqE2EIFC3rWcR2AwFPR0fk2kSFfeTRzgA24GbnuT5RA,3697
43
43
  maleo_foundation/middlewares/base.py,sha256=KcpODNs0DQXX8Cwc6T9dC6aiZIqxTLtuJjVAGWXPSKk,11633
44
44
  maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG9iLY7Uc,2288
@@ -79,7 +79,7 @@ maleo_foundation/utils/logging.py,sha256=DuAaKQ1X7lB0y6udR-GF95BRKeluh0JoYN0K_jc
79
79
  maleo_foundation/utils/query.py,sha256=ODQ3adOYQNj5E2cRW9ytbjBz56nEDcnfq8mQ6YZbCCM,4375
80
80
  maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
81
81
  maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
82
- maleo_foundation-0.1.13.dist-info/METADATA,sha256=TegQXAtiKuENhdC46UsHV2wrmqvYJ0uquGEKyj7IPso,3190
83
- maleo_foundation-0.1.13.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
84
- maleo_foundation-0.1.13.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
85
- maleo_foundation-0.1.13.dist-info/RECORD,,
82
+ maleo_foundation-0.1.15.dist-info/METADATA,sha256=_tNoQQD0iptKkB7AuyvaFNUn03MOyRs2W-V7l0o-tM8,3190
83
+ maleo_foundation-0.1.15.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
84
+ maleo_foundation-0.1.15.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
85
+ maleo_foundation-0.1.15.dist-info/RECORD,,