atk-common 3.1.0__py3-none-any.whl → 3.2.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.
- atk_common/utils/consumer_retry_handler.py +7 -7
- atk_common/utils/mq_utils.py +4 -4
- {atk_common-3.1.0.dist-info → atk_common-3.2.0.dist-info}/METADATA +1 -1
- {atk_common-3.1.0.dist-info → atk_common-3.2.0.dist-info}/RECORD +7 -7
- {atk_common-3.1.0.dist-info → atk_common-3.2.0.dist-info}/WHEEL +0 -0
- {atk_common-3.1.0.dist-info → atk_common-3.2.0.dist-info}/licenses/license.txt +0 -0
- {atk_common-3.1.0.dist-info → atk_common-3.2.0.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
from kombu import Producer
|
2
|
-
from atk_common.
|
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,
|
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
|
-
|
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
|
-
|
40
|
+
logger.critical("Sending to DLQ...")
|
41
41
|
message.reject(requeue=False)
|
42
42
|
else:
|
43
43
|
if should_retry(process_response):
|
44
|
-
|
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
|
-
|
49
|
+
logger.critical("Discarding message...")
|
50
50
|
message.ack()
|
51
51
|
except Exception as e:
|
52
|
-
|
52
|
+
logger.critical(f"Error during processing: {e}, sending to DLQ...")
|
53
53
|
message.reject(requeue=False)
|
54
54
|
|
55
55
|
return handler
|
atk_common/utils/mq_utils.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import json
|
2
2
|
from http import HTTPStatus
|
3
|
-
from atk_common.
|
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,
|
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
|
-
|
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
|
-
|
29
|
+
logger.critical('Error decoding message: ' + get_message(error))
|
30
30
|
return create_response(ResponseStatusType.INTERNAL, HTTPStatus.INTERNAL_SERVER_ERROR, get_message(error))
|
@@ -70,7 +70,7 @@ atk_common/interfaces/error_handler_interface.py,sha256=H43hSeeThT_7EbNzh-rygAJW
|
|
70
70
|
atk_common/interfaces/http_response_handler_interface.py,sha256=QjDmhVj4AnUyoRtSHk_sfFPI-cto6TV7Mx2_87tiOrs,185
|
71
71
|
atk_common/interfaces/logger_interface.py,sha256=w9bhheJFCQ76qpoO_o0N-F6KVKf4HaHOKLRx_c7Jgsk,315
|
72
72
|
atk_common/utils/__init__.py,sha256=HPqGmoNy6y1Bgu3Um_o1g0R5DnS-UZv1_ueC4i0uP30,1708
|
73
|
-
atk_common/utils/consumer_retry_handler.py,sha256=
|
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=
|
83
|
-
atk_common-3.
|
82
|
+
atk_common/utils/mq_utils.py,sha256=jd3TUzqtS-wHu_Gu7LsrTRjqfEyGCn639nCzV_vzC7s,1841
|
83
|
+
atk_common-3.2.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.
|
97
|
-
atk_common-3.
|
98
|
-
atk_common-3.
|
99
|
-
atk_common-3.
|
96
|
+
atk_common-3.2.0.dist-info/METADATA,sha256=-VP2tolBWHw3W4kMuiIxn_oKXApY3x5V3g26NdAlqvA,1760
|
97
|
+
atk_common-3.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
98
|
+
atk_common-3.2.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
|
99
|
+
atk_common-3.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|