reach_commons 0.18.28__py3-none-any.whl → 0.18.30__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.
reach_commons/reach_aws/sqs.py
CHANGED
|
@@ -164,7 +164,6 @@ class SQSClient(BaseSQSClient):
|
|
|
164
164
|
"ApproximateNumberOfMessages", # visible
|
|
165
165
|
"ApproximateNumberOfMessagesNotVisible", # in-flight
|
|
166
166
|
"ApproximateNumberOfMessagesDelayed", # delayed
|
|
167
|
-
"ApproximateAgeOfOldestMessage",
|
|
168
167
|
],
|
|
169
168
|
)
|
|
170
169
|
|
|
@@ -173,14 +172,8 @@ class SQSClient(BaseSQSClient):
|
|
|
173
172
|
visible = int(attrs.get("ApproximateNumberOfMessages", 0))
|
|
174
173
|
in_flight = int(attrs.get("ApproximateNumberOfMessagesNotVisible", 0))
|
|
175
174
|
delayed = int(attrs.get("ApproximateNumberOfMessagesDelayed", 0))
|
|
176
|
-
oldest_age_seconds = int(attrs.get("ApproximateAgeOfOldestMessage", 0))
|
|
177
175
|
|
|
178
|
-
return {
|
|
179
|
-
"visible": visible,
|
|
180
|
-
"in_flight": in_flight,
|
|
181
|
-
"delayed": delayed,
|
|
182
|
-
"oldest_age_seconds": oldest_age_seconds,
|
|
183
|
-
}
|
|
176
|
+
return {"visible": visible, "in_flight": in_flight, "delayed": delayed}
|
|
184
177
|
|
|
185
178
|
except ClientError as exc:
|
|
186
179
|
self.logger.error(
|
|
@@ -225,7 +218,6 @@ class SQSClient(BaseSQSClient):
|
|
|
225
218
|
visible = metrics["visible"]
|
|
226
219
|
in_flight = metrics["in_flight"]
|
|
227
220
|
delayed = metrics["delayed"]
|
|
228
|
-
oldest_age_seconds = metrics["oldest_age_seconds"]
|
|
229
221
|
|
|
230
222
|
total_active = visible + in_flight
|
|
231
223
|
|
|
@@ -238,14 +230,13 @@ class SQSClient(BaseSQSClient):
|
|
|
238
230
|
self.logger.warning(
|
|
239
231
|
(
|
|
240
232
|
"queue_over_capacity, topic_name=%s, "
|
|
241
|
-
"visible=%s, in_flight=%s, delayed=%s,
|
|
233
|
+
"visible=%s, in_flight=%s, delayed=%s,"
|
|
242
234
|
"total_active=%s, max_visible_capacity=%s, max_total_capacity=%s"
|
|
243
235
|
),
|
|
244
236
|
self.topic_name,
|
|
245
237
|
visible,
|
|
246
238
|
in_flight,
|
|
247
239
|
delayed,
|
|
248
|
-
oldest_age_seconds,
|
|
249
240
|
total_active,
|
|
250
241
|
max_visible_capacity,
|
|
251
242
|
max_total_capacity,
|
|
@@ -255,7 +246,6 @@ class SQSClient(BaseSQSClient):
|
|
|
255
246
|
"visible_count": visible,
|
|
256
247
|
"in_flight_count": in_flight,
|
|
257
248
|
"delayed_count": delayed,
|
|
258
|
-
"oldest_age_seconds": oldest_age_seconds,
|
|
259
249
|
"max_visible_capacity": max_visible_capacity,
|
|
260
250
|
"max_total_capacity": max_total_capacity,
|
|
261
251
|
}
|
|
@@ -657,12 +647,12 @@ class AnomalySQSNotifier(SQSClient):
|
|
|
657
647
|
|
|
658
648
|
DEFAULT_REGION = "us-east-1"
|
|
659
649
|
DEFAULT_TOPIC = "reach-data-bridge-messages-queue"
|
|
650
|
+
SERVICE_NAME = "AnomalySQSNotifier"
|
|
660
651
|
|
|
661
652
|
def __init__(
|
|
662
653
|
self,
|
|
663
654
|
*,
|
|
664
655
|
topic_name: str = None,
|
|
665
|
-
service_name: str = None,
|
|
666
656
|
region_name: str = DEFAULT_REGION,
|
|
667
657
|
logger=None,
|
|
668
658
|
env: str = os.environ.get("ENV", "Staging"),
|
|
@@ -670,13 +660,12 @@ class AnomalySQSNotifier(SQSClient):
|
|
|
670
660
|
"""
|
|
671
661
|
Args:
|
|
672
662
|
topic_name: Nome base da fila (sem prefixo de env). Default: reach-data-bridge-messages-queue
|
|
673
|
-
service_name: Nome do serviço para uso no message_attribute. Default: nome da classe.
|
|
674
663
|
"""
|
|
675
664
|
if logger is None:
|
|
676
665
|
logger = get_reach_logger()
|
|
677
666
|
|
|
678
667
|
self.env = env
|
|
679
|
-
|
|
668
|
+
|
|
680
669
|
base_topic = topic_name or self.DEFAULT_TOPIC
|
|
681
670
|
|
|
682
671
|
super().__init__(
|
|
@@ -684,3 +673,16 @@ class AnomalySQSNotifier(SQSClient):
|
|
|
684
673
|
logger=logger,
|
|
685
674
|
topic_name=f"{env}-{base_topic}",
|
|
686
675
|
)
|
|
676
|
+
|
|
677
|
+
def notify_anomaly(
|
|
678
|
+
self,
|
|
679
|
+
message_data: dict,
|
|
680
|
+
delay_seconds=2,
|
|
681
|
+
):
|
|
682
|
+
message_attributes = {"service_name": self.SERVICE_NAME}
|
|
683
|
+
|
|
684
|
+
return self.publish(
|
|
685
|
+
message_data=message_data,
|
|
686
|
+
message_attributes=message_attributes,
|
|
687
|
+
delay_seconds=delay_seconds,
|
|
688
|
+
)
|
|
@@ -21,12 +21,12 @@ reach_commons/reach_aws/exceptions.py,sha256=x0RL5ktNtzxg0KykhEVWReBq_dEtciK6B2v
|
|
|
21
21
|
reach_commons/reach_aws/firehose.py,sha256=1xFKLWMv3bNo3PPW5gtaL6NqzUDyVil6B768slj2wbY,5674
|
|
22
22
|
reach_commons/reach_aws/kms.py,sha256=ZOfyJMQUgxJEojRoB7-aCxtATpNx1Ig522IUYH11NZ4,4678
|
|
23
23
|
reach_commons/reach_aws/s3.py,sha256=2MLlDNFx0SROJBpE_KjJefyrB7lMqTlrYuRhSZx4iKs,3945
|
|
24
|
-
reach_commons/reach_aws/sqs.py,sha256=
|
|
24
|
+
reach_commons/reach_aws/sqs.py,sha256=FFjQPrsaGvkjNVNf3nLwsuPRAvshFk71Qjci4sBXbSU,21348
|
|
25
25
|
reach_commons/reach_base_model.py,sha256=vgdGDcZr3iXMmyRhmBhOf_LKWB_6QzT3r_Yiyo6OmEk,3009
|
|
26
26
|
reach_commons/redis_manager.py,sha256=SgUtdtt0eV4bUwsWDankIa9Bjfgcm2DKcmVMQT6ptF0,2946
|
|
27
27
|
reach_commons/sms_smart_encoding.py,sha256=92y0RmZ0l4ONHpC9qeO5KfViSNq64yE2rc7lhNDSZqE,1241
|
|
28
28
|
reach_commons/utils.py,sha256=dMgKIGqTgoSItuBI8oz81gKtW3qi21Jkljv9leS_V88,8475
|
|
29
29
|
reach_commons/validations.py,sha256=CJdWg8qc9ILe3rYHYTLdr2upRspsM_8ghhm4IXX4Pg8,1028
|
|
30
|
-
reach_commons-0.18.
|
|
31
|
-
reach_commons-0.18.
|
|
32
|
-
reach_commons-0.18.
|
|
30
|
+
reach_commons-0.18.30.dist-info/METADATA,sha256=Lhs-3FQiZJTYDv97eMpF7YS-I5eD92BbGZrGYBPw3AY,1965
|
|
31
|
+
reach_commons-0.18.30.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
32
|
+
reach_commons-0.18.30.dist-info/RECORD,,
|
|
File without changes
|