reach_commons 0.18.24__py3-none-any.whl → 0.18.25__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
|
@@ -146,13 +146,25 @@ class SQSClient(BaseSQSClient):
|
|
|
146
146
|
|
|
147
147
|
return True
|
|
148
148
|
|
|
149
|
-
def
|
|
149
|
+
def get_visible_messages_count(self) -> int:
|
|
150
150
|
try:
|
|
151
151
|
resp = self.client.get_queue_attributes(
|
|
152
152
|
QueueUrl=self.topic_name,
|
|
153
|
-
AttributeNames=[
|
|
153
|
+
AttributeNames=[
|
|
154
|
+
"ApproximateNumberOfMessages",
|
|
155
|
+
"ApproximateNumberOfMessagesNotVisible",
|
|
156
|
+
"ApproximateNumberOfMessagesDelayed",
|
|
157
|
+
],
|
|
154
158
|
)
|
|
155
|
-
|
|
159
|
+
visible = int(resp["Attributes"].get("ApproximateNumberOfMessages", 0))
|
|
160
|
+
in_flight = int(
|
|
161
|
+
resp["Attributes"].get("ApproximateNumberOfMessagesNotVisible", 0)
|
|
162
|
+
)
|
|
163
|
+
delayed = int(
|
|
164
|
+
resp["Attributes"].get("ApproximateNumberOfMessagesDelayed", 0)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
return visible, in_flight, delayed
|
|
156
168
|
except ClientError as exc:
|
|
157
169
|
self.logger.error(
|
|
158
170
|
"error_fetching_queue_attributes, topic_name=%s, error=%s",
|
|
@@ -160,7 +172,7 @@ class SQSClient(BaseSQSClient):
|
|
|
160
172
|
str(exc),
|
|
161
173
|
)
|
|
162
174
|
# If there's an error, return 0 so as not to block the caller.
|
|
163
|
-
return 0
|
|
175
|
+
return 0, 0, 0
|
|
164
176
|
|
|
165
177
|
def publish_with_capacity_guard(
|
|
166
178
|
self,
|
|
@@ -194,7 +206,11 @@ class SQSClient(BaseSQSClient):
|
|
|
194
206
|
if not Result["posted"]:
|
|
195
207
|
print("Queue is over capacity:", Result)
|
|
196
208
|
"""
|
|
197
|
-
|
|
209
|
+
(
|
|
210
|
+
visible_count,
|
|
211
|
+
in_flight_count,
|
|
212
|
+
delayed_count,
|
|
213
|
+
) = self.get_visible_messages_count()
|
|
198
214
|
|
|
199
215
|
if visible_count >= max_capacity:
|
|
200
216
|
self.logger.warning(
|
|
@@ -218,6 +234,8 @@ class SQSClient(BaseSQSClient):
|
|
|
218
234
|
return {
|
|
219
235
|
"posted": True,
|
|
220
236
|
"visible_count": visible_count,
|
|
237
|
+
"in_flight_count": in_flight_count,
|
|
238
|
+
"delayed_count": delayed_count,
|
|
221
239
|
"max_capacity": max_capacity,
|
|
222
240
|
}
|
|
223
241
|
|
|
@@ -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=lxdBzvCZ_cUy29se5LhUrIenPWdJcPHtRtFXazzhg-A,19214
|
|
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.25.dist-info/METADATA,sha256=CBq0zcdO1OOmh8Eq76u6Fa6ECC55JEtU5L3-F5C0Wa8,1965
|
|
31
|
+
reach_commons-0.18.25.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
32
|
+
reach_commons-0.18.25.dist-info/RECORD,,
|
|
File without changes
|