buz 2.13.1rc3__py3-none-any.whl → 2.13.1rc5__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.
- buz/event/infrastructure/buz_kafka/base_buz_aiokafka_async_consumer.py +17 -6
- buz/kafka/infrastructure/aiokafka/aiokafka_consumer.py +2 -3
- {buz-2.13.1rc3.dist-info → buz-2.13.1rc5.dist-info}/METADATA +1 -1
- {buz-2.13.1rc3.dist-info → buz-2.13.1rc5.dist-info}/RECORD +6 -6
- {buz-2.13.1rc3.dist-info → buz-2.13.1rc5.dist-info}/LICENSE +0 -0
- {buz-2.13.1rc3.dist-info → buz-2.13.1rc5.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
2
|
import traceback
|
|
3
|
-
from asyncio import Lock, gather, Semaphore, Event as AsyncIOEvent, sleep
|
|
3
|
+
from asyncio import Lock, create_task, gather, Semaphore, Event as AsyncIOEvent, sleep
|
|
4
4
|
from datetime import timedelta, datetime
|
|
5
5
|
from itertools import cycle
|
|
6
6
|
from logging import Logger
|
|
@@ -89,7 +89,7 @@ class BaseBuzAIOKafkaAsyncConsumer(AsyncConsumer):
|
|
|
89
89
|
start_time = datetime.now()
|
|
90
90
|
await self.__generate_kafka_consumers()
|
|
91
91
|
|
|
92
|
-
if len(self.
|
|
92
|
+
if len(self.__executor_per_consumer_mapper) == 0:
|
|
93
93
|
self._logger.error("There are no valid subscribers to execute, finalizing consumer")
|
|
94
94
|
return
|
|
95
95
|
|
|
@@ -163,13 +163,24 @@ class BaseBuzAIOKafkaAsyncConsumer(AsyncConsumer):
|
|
|
163
163
|
on_partition_revoked=self.__on_partition_revoked,
|
|
164
164
|
)
|
|
165
165
|
|
|
166
|
-
self.__subscriber_per_consumer_mapper[kafka_consumer] = subscriber
|
|
167
|
-
|
|
168
166
|
self.__executor_per_consumer_mapper[kafka_consumer] = executor
|
|
169
167
|
|
|
170
168
|
self.__queue_per_consumer_mapper[kafka_consumer] = InMemoryMultiqueueRepository()
|
|
171
169
|
|
|
172
|
-
|
|
170
|
+
# The purpose of this block is to initialize the consumer without delay the execution of the polling thread
|
|
171
|
+
# If some of the subscribers haven't as many partitions as subscriber they will not be able to be initialized
|
|
172
|
+
# (but maybe they should be initialized in the future)
|
|
173
|
+
create_task(self.__init_consumer(kafka_consumer, subscriber))
|
|
174
|
+
except Exception:
|
|
175
|
+
self._logger.exception(
|
|
176
|
+
f"Unexpected error during Kafka subscriber '{subscriber.fqn()}' creation. Skipping it: {traceback.format_exc()}"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
async def __init_consumer(self, consumer: AIOKafkaConsumer, subscriber: MetaSubscriber) -> None:
|
|
180
|
+
try:
|
|
181
|
+
await consumer.init()
|
|
182
|
+
self.__subscriber_per_consumer_mapper[consumer] = subscriber
|
|
183
|
+
self._logger.info(f"initialized '{subscriber.fqn()}'")
|
|
173
184
|
except Exception:
|
|
174
185
|
self._logger.exception(
|
|
175
186
|
f"Unexpected error during Kafka subscriber '{subscriber.fqn()}' initialization. Skipping it: {traceback.format_exc()}"
|
|
@@ -275,7 +286,7 @@ class BaseBuzAIOKafkaAsyncConsumer(AsyncConsumer):
|
|
|
275
286
|
self._logger.info("Worker stop requested. Waiting for finalize the current task")
|
|
276
287
|
|
|
277
288
|
async def __manage_kafka_consumers_stopping(self) -> None:
|
|
278
|
-
for kafka_consumer in self.
|
|
289
|
+
for kafka_consumer in self.__queue_per_consumer_mapper.keys():
|
|
279
290
|
await kafka_consumer.stop()
|
|
280
291
|
|
|
281
292
|
def __print_statistics(self) -> None:
|
|
@@ -26,8 +26,7 @@ from buz.kafka.infrastructure.aiokafka.translators.consumer_initial_offset_posit
|
|
|
26
26
|
|
|
27
27
|
class AIOKafkaConsumer:
|
|
28
28
|
__DEFAULT_POLL_TIMEOUT_MS = 0
|
|
29
|
-
__DEFAULT_SESSION_TIMEOUT_MS = 1000 *
|
|
30
|
-
__DEFAULT_HEARTBEAT_INTERVAL_MS = 1000 * 15
|
|
29
|
+
__DEFAULT_SESSION_TIMEOUT_MS = 1000 * 120
|
|
31
30
|
__DEFAULT_MAX_POLL_INTERVAL = 30 * 60 * 1000
|
|
32
31
|
|
|
33
32
|
def __init__(
|
|
@@ -90,7 +89,7 @@ class AIOKafkaConsumer:
|
|
|
90
89
|
self.__initial_offset_position
|
|
91
90
|
),
|
|
92
91
|
session_timeout_ms=self.__session_timeout_ms,
|
|
93
|
-
heartbeat_interval_ms=self.
|
|
92
|
+
heartbeat_interval_ms=int(self.__session_timeout_ms / 5),
|
|
94
93
|
partition_assignment_strategy=list(self.__partition_assignors),
|
|
95
94
|
max_poll_interval_ms=self.__DEFAULT_MAX_POLL_INTERVAL,
|
|
96
95
|
rebalance_timeout_ms=self.__DEFAULT_MAX_POLL_INTERVAL,
|
|
@@ -45,7 +45,7 @@ buz/event/exceptions/term_signal_interruption_exception.py,sha256=RkRRF0v_K9Hg48
|
|
|
45
45
|
buz/event/exceptions/worker_execution_exception.py,sha256=6mgztvXOCG_9VZ_Jptkk72kZtNWQ2CPuQ3TjXEWFE14,123
|
|
46
46
|
buz/event/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
47
|
buz/event/infrastructure/buz_kafka/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
|
-
buz/event/infrastructure/buz_kafka/base_buz_aiokafka_async_consumer.py,sha256=
|
|
48
|
+
buz/event/infrastructure/buz_kafka/base_buz_aiokafka_async_consumer.py,sha256=fFIifDvecAyglL81vWPZ8IXZE0RxvKDd6pq6cJYezJI,14625
|
|
49
49
|
buz/event/infrastructure/buz_kafka/buz_aiokafka_async_consumer.py,sha256=dqQDv7taAmINE9G2geMDExbcvSlntP09_rQ0JRbc4Rw,5507
|
|
50
50
|
buz/event/infrastructure/buz_kafka/buz_aiokafka_multi_threaded_consumer.py,sha256=yrEU51OBjvLjCfYJFJPxux1bcIhoTVMw1Jf0HJMWbb0,5449
|
|
51
51
|
buz/event/infrastructure/buz_kafka/buz_kafka_event_bus.py,sha256=f94fmS4AVfb3LQsp49e-4Cqzj00IqxHDzuUvDbN4u2s,4258
|
|
@@ -149,7 +149,7 @@ buz/kafka/domain/services/kafka_admin_test_client.py,sha256=91l_vFIo1yhJLQQCC_Om
|
|
|
149
149
|
buz/kafka/domain/services/kafka_producer.py,sha256=CTiwGYwuzdJY5aeb2WFbJlyCpZ0YyhzcgKQYyogKzUM,401
|
|
150
150
|
buz/kafka/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
151
151
|
buz/kafka/infrastructure/aiokafka/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
152
|
-
buz/kafka/infrastructure/aiokafka/aiokafka_consumer.py,sha256=
|
|
152
|
+
buz/kafka/infrastructure/aiokafka/aiokafka_consumer.py,sha256=zGalbfVPEr-08Uv0weSnkKayr2T76F8luO-UhfMNgx4,8560
|
|
153
153
|
buz/kafka/infrastructure/aiokafka/rebalance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
154
154
|
buz/kafka/infrastructure/aiokafka/rebalance/kafka_callback_rebalancer.py,sha256=3l7NkTrCt3rBktVIS73cTmCOvv6eFguoCbGMYIUfCFc,1774
|
|
155
155
|
buz/kafka/infrastructure/aiokafka/translators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -230,7 +230,7 @@ buz/serializer/message_to_json_bytes_serializer.py,sha256=RGZJ64t4t4Pz2FCASZZCv-
|
|
|
230
230
|
buz/wrapper/__init__.py,sha256=GnRdJFcncn-qp0hzDG9dBHLmTJSbHFVjE_yr-MdW_n4,77
|
|
231
231
|
buz/wrapper/async_to_sync.py,sha256=OfK-vrVUhuN-LLLvekLdMbQYtH0ue5lfbvuasj6ovMI,698
|
|
232
232
|
buz/wrapper/event_loop.py,sha256=pfBJ1g-8A2a3YgW8Gf9Fg0kkewoh3-wgTy2KIFDyfHk,266
|
|
233
|
-
buz-2.13.
|
|
234
|
-
buz-2.13.
|
|
235
|
-
buz-2.13.
|
|
236
|
-
buz-2.13.
|
|
233
|
+
buz-2.13.1rc5.dist-info/LICENSE,sha256=Jytu2S-2SPEgsB0y6BF-_LUxIWY7402fl0JSh36TLZE,1062
|
|
234
|
+
buz-2.13.1rc5.dist-info/METADATA,sha256=HD-JfQW8fjPkxB_hB-bv07tM8IQUtPwhZEPsWFD-TcQ,1620
|
|
235
|
+
buz-2.13.1rc5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
236
|
+
buz-2.13.1rc5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|