atk-common 3.1.0__py3-none-any.whl → 3.3.0__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.
@@ -28,7 +28,7 @@ class BoLogger(ILogger):
28
28
  def _create_log_json(self, timestamp, level: LogLevel, message: str):
29
29
  log_entry = {
30
30
  "timestamp": timestamp,
31
- "severity": level.name,
31
+ "level": level.name,
32
32
  "message": message,
33
33
  "component": self.component,
34
34
  "version": self.version,
@@ -29,8 +29,8 @@ class RabbitMQConsumer:
29
29
  self.content_type = content_type # Optional content type for message handling
30
30
  self.message_handler = message_handler # Custom message handler
31
31
 
32
- def consume(self):
33
- conn = self.establish_connection()
32
+ def _consume(self):
33
+ conn = self._establish_connection()
34
34
  self.logger.info("Begin consuming messages...")
35
35
 
36
36
  while True:
@@ -47,7 +47,7 @@ class RabbitMQConsumer:
47
47
  self.logger.critical(f"Top-level exception in consume loop: {e}. Restarting after delay...")
48
48
  return
49
49
 
50
- def establish_connection(self):
50
+ def _establish_connection(self):
51
51
  revived_connection = self.connection.clone()
52
52
  revived_connection.ensure_connection(max_retries=3)
53
53
  channel = revived_connection.channel()
@@ -66,7 +66,7 @@ class RabbitMQConsumer:
66
66
  self.logger.info("Starting RabbitMQ consumer run loop...")
67
67
  while True:
68
68
  try:
69
- self.consume()
69
+ self._consume()
70
70
  except Exception as e:
71
71
  self.logger.critical(f"Top-level exception in run loop: {e}. Restarting after delay...")
72
72
  time.sleep(5)
@@ -1,9 +1,12 @@
1
1
  # interfaces/logger_interface.py
2
2
  from typing import Protocol
3
3
 
4
+ from atk_common.enums.log_level_enum import LogLevel
5
+
4
6
  class ILogger(Protocol):
5
7
  def debug(self, msg: str) -> None: ...
6
8
  def info(self, msg: str) -> None: ...
7
9
  def warning(self, msg: str) -> None: ...
8
10
  def error(self, msg: str) -> None: ...
9
11
  def critical(self, msg: str) -> None: ...
12
+ def set_level(self, log_level: LogLevel) -> None: ...
@@ -1,5 +1,5 @@
1
1
  from kombu import Producer
2
- from atk_common.classes.bo_logger import BoLogger
2
+ from atk_common.interfaces import ILogger
3
3
  from atk_common.utils.internal_response_utils import is_response_ok
4
4
 
5
5
  """
@@ -11,7 +11,7 @@ should_retry: function(message_status) -> bool
11
11
  bo_logger: BoLogger instance for logging
12
12
  declare: optional kombu.DeclarativeExchange or Queue to declare before publishing
13
13
  """
14
- def create_retry_handler(process_func, connection, exchange, routing_key, should_retry, bo_logger: BoLogger, declare=None):
14
+ def create_retry_handler(process_func, connection, exchange, routing_key, should_retry, logger: ILogger, declare=None):
15
15
 
16
16
  def handler(body, message):
17
17
  try:
@@ -22,7 +22,7 @@ def create_retry_handler(process_func, connection, exchange, routing_key, should
22
22
  if connection is not None:
23
23
  # Use retry queue
24
24
  if should_retry(process_response):
25
- bo_logger.info("Retrying after delay...")
25
+ logger.info("Retrying after delay...")
26
26
  with connection.Producer() as producer:
27
27
  producer.publish(
28
28
  message.body,
@@ -37,19 +37,19 @@ def create_retry_handler(process_func, connection, exchange, routing_key, should
37
37
  )
38
38
  message.ack()
39
39
  else:
40
- bo_logger.critical("Sending to DLQ...")
40
+ logger.critical("Sending to DLQ...")
41
41
  message.reject(requeue=False)
42
42
  else:
43
43
  if should_retry(process_response):
44
- bo_logger.critical("Sending to DLQ...")
44
+ logger.critical("Sending to DLQ...")
45
45
  message.reject(requeue=False)
46
46
  # bo_logger.critical("Requing...")
47
47
  # message.requeue()
48
48
  else:
49
- bo_logger.critical("Discarding message...")
49
+ logger.critical("Discarding message...")
50
50
  message.ack()
51
51
  except Exception as e:
52
- bo_logger.critical(f"Error during processing: {e}, sending to DLQ...")
52
+ logger.critical(f"Error during processing: {e}, sending to DLQ...")
53
53
  message.reject(requeue=False)
54
54
 
55
55
  return handler
@@ -1,11 +1,11 @@
1
1
  import json
2
2
  from http import HTTPStatus
3
- from atk_common.classes.bo_logger import BoLogger
3
+ from atk_common.interfaces import ILogger
4
4
  from atk_common.enums.response_status_type_enum import ResponseStatusType
5
5
  from atk_common.utils.error_utils import get_message
6
6
  from atk_common.utils.internal_response_utils import create_response
7
7
 
8
- def decode_message(body, message, bo_logger: BoLogger):
8
+ def decode_message(body, message, logger: ILogger):
9
9
  import gzip
10
10
  import msgpack
11
11
  try:
@@ -23,8 +23,8 @@ def decode_message(body, message, bo_logger: BoLogger):
23
23
  elif message.content_type.startswith('text/'):
24
24
  return create_response(ResponseStatusType.OK, HTTPStatus.OK, body.decode('utf-8'))
25
25
  else:
26
- bo_logger.critical(f"Unknown message content type {message.content_type}. Cannot decode message.")
26
+ logger.critical(f"Unknown message content type {message.content_type}. Cannot decode message.")
27
27
  return create_response(ResponseStatusType.INTERNAL, HTTPStatus.INTERNAL_SERVER_ERROR, get_message(error))
28
28
  except Exception as error:
29
- bo_logger.critical('Error decoding message: ' + get_message(error))
29
+ logger.critical('Error decoding message: ' + get_message(error))
30
30
  return create_response(ResponseStatusType.INTERNAL, HTTPStatus.INTERNAL_SERVER_ERROR, get_message(error))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atk_common
3
- Version: 3.1.0
3
+ Version: 3.3.0
4
4
  Summary: ATK common methods
5
5
  Home-page: https://github.com/pypa/atk_common
6
6
  Author: Roger
@@ -17,12 +17,12 @@ atk_common/mq_utils.py,sha256=6z4l7LsZWCzldsCZPsWnCtN4lIQ3gyoSuywQoQOh5Ak,1137
17
17
  atk_common/rabbitmq_consumer.py,sha256=4MhuwZs47Jt1fX4sUxr1MKRe7o2QRbPe9_utXEsa8QE,1907
18
18
  atk_common/response_utils.py,sha256=AxlmwkFoDU5XcFOzBQiuZxAQgswihpKXHSo1T0JJw3Q,556
19
19
  atk_common/classes/__init__.py,sha256=O_VHYxAilmoz3i9L6jkwS-JZ4UaTezdhFiA5liNl1lY,532
20
- atk_common/classes/bo_logger.py,sha256=TvSAeECElnrKmkbvuksxNO9XcqQ64DmX3WftA6iVp3M,2065
20
+ atk_common/classes/bo_logger.py,sha256=WI_6Xyx2H0XSzo_brYDnvs3zo0K5142fPTAHtUGlrCE,2062
21
21
  atk_common/classes/docker_handler.py,sha256=73WiebIT_RwGgwyvIed_Q5p8Tsb1b22JChBDyUmf1IU,2949
22
22
  atk_common/classes/env_handler.py,sha256=XbBPGJZ0n3q5coStHAbmbLnAVqOrFuFcs5JtIdJxUd8,1286
23
23
  atk_common/classes/error_handler.py,sha256=PrQ3njxYrqVCJzwdS2cSyshNktT_AHFMMRaC9vKtjyg,3257
24
24
  atk_common/classes/http_response_handler.py,sha256=B83UW-W6pE5BcUaoYcIb1RS-TzZEeZ22vgWmvB7xT30,2176
25
- atk_common/classes/rabbitmq_consumer.py,sha256=aPMF5H50k__a1HEy8GGwNdhSqu-wjbw2L3TESyd1cEg,2941
25
+ atk_common/classes/rabbitmq_consumer.py,sha256=EHCAZzO2PLugBYSMMd9cshqzZznbkzz0pzc1eNXhw2k,2945
26
26
  atk_common/enums/__init__.py,sha256=hOSoKWIBUpRFaMN2tNJiel6iGI1MHj229OYnU1J8Jg0,2636
27
27
  atk_common/enums/api_error_type_enum.py,sha256=9oW6ZaZ3lhMwR8r2sVNWGliS9C_jV-otiOYdezAuTp0,91
28
28
  atk_common/enums/camera_cabinet_type_enum.py,sha256=U2NVrsTCBgaMRwYJamnjshAW8Y7xlOVjvUzakdgVH9A,90
@@ -68,9 +68,9 @@ atk_common/interfaces/docker_handler_interface.py,sha256=aCJ6cELRlrbZC-sB-RQEpKh
68
68
  atk_common/interfaces/env_handler_interface.py,sha256=yrmtTplH5tnuOAs7CW5RtzLMTE5q9sdzTYjiS2naNQQ,300
69
69
  atk_common/interfaces/error_handler_interface.py,sha256=H43hSeeThT_7EbNzh-rygAJWNAmyzFetodiXdmqKshU,522
70
70
  atk_common/interfaces/http_response_handler_interface.py,sha256=QjDmhVj4AnUyoRtSHk_sfFPI-cto6TV7Mx2_87tiOrs,185
71
- atk_common/interfaces/logger_interface.py,sha256=w9bhheJFCQ76qpoO_o0N-F6KVKf4HaHOKLRx_c7Jgsk,315
71
+ atk_common/interfaces/logger_interface.py,sha256=Jdm3gBHFGAJQinyP4xRW1LcOTZB0uYnJCzYg4vFLsxc,428
72
72
  atk_common/utils/__init__.py,sha256=HPqGmoNy6y1Bgu3Um_o1g0R5DnS-UZv1_ueC4i0uP30,1708
73
- atk_common/utils/consumer_retry_handler.py,sha256=TxlcX7JzU7XBXxGrpWHyisrpouItU0cLisVgTwO0boc,2601
73
+ atk_common/utils/consumer_retry_handler.py,sha256=DvKXDnpkOmVqIfghWnOGMcnI430c39BCJyXSVbIFerE,2574
74
74
  atk_common/utils/datetime_utils.py,sha256=0SC5-Nai4RJH9B0VzvGKUQts_QeRXGb7tJLlsh73LJw,3556
75
75
  atk_common/utils/db_utils.py,sha256=odUtXcS7Mumw5eGyVyVimL_U_lP7TqMX9v8nWO5nMvg,902
76
76
  atk_common/utils/default_should_retry.py,sha256=qghFbU71ygC8ARc0jkbDlxwZtwEPUqO8vGhIhGJX-Ao,838
@@ -79,8 +79,8 @@ atk_common/utils/file_utils.py,sha256=UDwcRquO9IrqRrlUM0t-_g4R1-FKt8ZqQinSEqXOAk
79
79
  atk_common/utils/hash_utils.py,sha256=S_9o89CdI4lUQbVaqc85TDcqyDNuo30_E3VBaOrZKko,1047
80
80
  atk_common/utils/http_utils.py,sha256=eSRuQeDgN0ISQdByZqE6cIGXoorcAXz7PEtVntHUKAo,670
81
81
  atk_common/utils/internal_response_utils.py,sha256=2X9eLFEy1pO3Aesj1IRXg2yprwNcBDM5_dXaA5vfmMI,694
82
- atk_common/utils/mq_utils.py,sha256=W4EVbM9FMPEwk7QJGksTqPN_of3yL1kBIhWpQNi6v_I,1859
83
- atk_common-3.1.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
82
+ atk_common/utils/mq_utils.py,sha256=jd3TUzqtS-wHu_Gu7LsrTRjqfEyGCn639nCzV_vzC7s,1841
83
+ atk_common-3.3.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
84
84
  atk_package/__init__.py,sha256=okIFEefQhQrw6DZg6oCEVWsEdkVCk-57VXBW0IUG_wU,834
85
85
  atk_package/datetime_utils.py,sha256=qsVF7l90P1-xukG2tV_jLqG9J_Yfl5wTpyfrdPBlyMo,239
86
86
  atk_package/env_utils.py,sha256=bXOrxM3fZUslqfmZt75iphbEJHbG4riJa8XOVzPwIII,313
@@ -93,7 +93,7 @@ atk_package/enums/__init__.py,sha256=EtUr_--MQj1Rc_R0sF_ELXIThmhpfmhDWq3YaK9oQMk
93
93
  atk_package/enums/command_status_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087JhkU6Fmard5qVHs,127
94
94
  atk_package/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
95
95
  shared_python_atk_enforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
- atk_common-3.1.0.dist-info/METADATA,sha256=Avy3JWuWbP1Su7TFAGp58xVCgY1U7WjoNy31Y7VqWT4,1760
97
- atk_common-3.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
98
- atk_common-3.1.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
99
- atk_common-3.1.0.dist-info/RECORD,,
96
+ atk_common-3.3.0.dist-info/METADATA,sha256=bT7ov05Kmm1rfg3zHAmT-ZgzGL_rX0DOIBV6pdNTgWU,1760
97
+ atk_common-3.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
98
+ atk_common-3.3.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
99
+ atk_common-3.3.0.dist-info/RECORD,,