buz 2.21.2rc1__py3-none-any.whl → 2.22.1__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/buz_kafka_event_bus.py +5 -1
- buz/kafka/domain/services/kafka_admin_client.py +9 -1
- buz/kafka/infrastructure/kafka_python/kafka_python_admin_client.py +3 -4
- buz/kafka/infrastructure/serializers/implementations/cdc_partition_key_serializer.py +19 -0
- buz/kafka/infrastructure/serializers/partitiion_key_generator.py +9 -0
- {buz-2.21.2rc1.dist-info → buz-2.22.1.dist-info}/METADATA +1 -1
- {buz-2.21.2rc1.dist-info → buz-2.22.1.dist-info}/RECORD +9 -7
- {buz-2.21.2rc1.dist-info → buz-2.22.1.dist-info}/LICENSE +0 -0
- {buz-2.21.2rc1.dist-info → buz-2.22.1.dist-info}/WHEEL +0 -0
|
@@ -16,6 +16,8 @@ from buz.kafka.domain.models.auto_create_topic_configuration import AutoCreateTo
|
|
|
16
16
|
from buz.kafka.domain.models.create_kafka_topic import CreateKafkaTopic
|
|
17
17
|
from buz.kafka.domain.services.kafka_admin_client import KafkaAdminClient
|
|
18
18
|
from buz.kafka.domain.services.kafka_producer import KafkaProducer
|
|
19
|
+
from buz.kafka.infrastructure.serializers.implementations.cdc_partition_key_serializer import CDCPartitionKeySerializer
|
|
20
|
+
from buz.kafka.infrastructure.serializers.partitiion_key_generator import PartitionKeySerializer
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
class BuzKafkaEventBus(EventBus):
|
|
@@ -28,6 +30,7 @@ class BuzKafkaEventBus(EventBus):
|
|
|
28
30
|
kafka_admin_client: Optional[KafkaAdminClient] = None,
|
|
29
31
|
publish_middlewares: Optional[list[PublishMiddleware]] = None,
|
|
30
32
|
auto_create_topic_configuration: Optional[AutoCreateTopicConfiguration] = None,
|
|
33
|
+
partition_key_generator: Optional[PartitionKeySerializer] = None,
|
|
31
34
|
):
|
|
32
35
|
self.__publish_middleware_chain_resolver = PublishMiddlewareChainResolver(publish_middlewares or [])
|
|
33
36
|
self.__publish_strategy = publish_strategy
|
|
@@ -36,6 +39,7 @@ class BuzKafkaEventBus(EventBus):
|
|
|
36
39
|
self.__kafka_admin_client = kafka_admin_client
|
|
37
40
|
self.__auto_create_topic_configuration = auto_create_topic_configuration
|
|
38
41
|
self.__logger = logger
|
|
42
|
+
self.__partition_key_generator: PartitionKeySerializer = partition_key_generator or CDCPartitionKeySerializer()
|
|
39
43
|
self.__check_kafka_admin_client_is_needed()
|
|
40
44
|
|
|
41
45
|
def __check_kafka_admin_client_is_needed(self) -> None:
|
|
@@ -74,7 +78,7 @@ class BuzKafkaEventBus(EventBus):
|
|
|
74
78
|
message=event,
|
|
75
79
|
headers=headers,
|
|
76
80
|
topic=topic,
|
|
77
|
-
partition_key=
|
|
81
|
+
partition_key=self.__partition_key_generator.generate_key(event),
|
|
78
82
|
)
|
|
79
83
|
except Exception as exc:
|
|
80
84
|
raise EventNotPublishedException(event) from exc
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from abc import abstractmethod, ABC
|
|
4
4
|
from datetime import datetime
|
|
5
|
-
from typing import Sequence
|
|
5
|
+
from typing import Sequence, Any
|
|
6
6
|
|
|
7
7
|
from buz.kafka.domain.models.create_kafka_topic import CreateKafkaTopic
|
|
8
8
|
from buz.kafka.infrastructure.interfaces.connection_manager import ConnectionManager
|
|
@@ -66,6 +66,14 @@ class KafkaAdminClient(ConnectionManager, ABC):
|
|
|
66
66
|
) -> None:
|
|
67
67
|
pass
|
|
68
68
|
|
|
69
|
+
@abstractmethod
|
|
70
|
+
def delete_subscription_groups(
|
|
71
|
+
self,
|
|
72
|
+
*,
|
|
73
|
+
subscription_groups: set[str],
|
|
74
|
+
) -> list[tuple[str, Any]]:
|
|
75
|
+
pass
|
|
76
|
+
|
|
69
77
|
@abstractmethod
|
|
70
78
|
def get_consumer_group_offsets(self, *, consumer_group: str, topic: str) -> dict[int, int]:
|
|
71
79
|
"""
|
|
@@ -148,10 +148,9 @@ class KafkaPythonAdminClient(KafkaAdminClient):
|
|
|
148
148
|
self,
|
|
149
149
|
*,
|
|
150
150
|
subscription_groups: set[str],
|
|
151
|
-
) ->
|
|
152
|
-
self._get_kafka_admin().delete_consumer_groups(
|
|
153
|
-
|
|
154
|
-
)
|
|
151
|
+
) -> list[tuple[str, Any]]:
|
|
152
|
+
results = self._get_kafka_admin().delete_consumer_groups(group_ids=subscription_groups)
|
|
153
|
+
return results
|
|
155
154
|
|
|
156
155
|
def get_cluster_consumer_groups(
|
|
157
156
|
self,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from buz.event.event import Event
|
|
4
|
+
from buz.kafka.infrastructure.serializers.implementations.json_byte_serializer import JSONByteSerializer
|
|
5
|
+
from buz.kafka.infrastructure.serializers.partitiion_key_generator import PartitionKeySerializer
|
|
6
|
+
|
|
7
|
+
# This is a static string because the order matters and we can not trust that json encoder libraries are deterministic
|
|
8
|
+
PAYLOAD_CDC_SCHEMA = r"""{"schema":{"type":"string","optional":true},"payload":"[partition_key]"}"""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CDCPartitionKeySerializer(PartitionKeySerializer):
|
|
12
|
+
def __init__(self) -> None:
|
|
13
|
+
self.__json_serializer = JSONByteSerializer()
|
|
14
|
+
|
|
15
|
+
def __generate_payload_schema(self, partition_key: str) -> str:
|
|
16
|
+
return PAYLOAD_CDC_SCHEMA.replace("[partition_key]", partition_key)
|
|
17
|
+
|
|
18
|
+
def generate_key(self, event: Event) -> str:
|
|
19
|
+
return self.__generate_payload_schema(event.partition_key())
|
|
@@ -50,7 +50,7 @@ buz/event/infrastructure/buz_kafka/async_buz_kafka_event_bus.py,sha256=kxqXCf80L
|
|
|
50
50
|
buz/event/infrastructure/buz_kafka/base_buz_aiokafka_async_consumer.py,sha256=7ZhaKaFXBpD3HVkuQMpAJvY8lfy7__1wxftLIwCmnMQ,21284
|
|
51
51
|
buz/event/infrastructure/buz_kafka/buz_aiokafka_async_consumer.py,sha256=GmmuAZboDkrpNOLF8cE_F0t4I7ZnMiGsiGw4SYIvKGc,7303
|
|
52
52
|
buz/event/infrastructure/buz_kafka/buz_aiokafka_multi_threaded_consumer.py,sha256=ZRLRoBRomqrXAiePSMn4gePF59AWPn6VQpQui1UVnyM,7246
|
|
53
|
-
buz/event/infrastructure/buz_kafka/buz_kafka_event_bus.py,sha256=
|
|
53
|
+
buz/event/infrastructure/buz_kafka/buz_kafka_event_bus.py,sha256=bfxdwUh33yFIo0NCm_S_AMrfnLvTCL9dGZZXDaOkKNM,5094
|
|
54
54
|
buz/event/infrastructure/buz_kafka/consume_strategy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
55
|
buz/event/infrastructure/buz_kafka/consume_strategy/consume_strategy.py,sha256=RqlXe5W2S6rH3FTr--tcxzFJTAVLb-Dhl7m6qjgNz2M,331
|
|
56
56
|
buz/event/infrastructure/buz_kafka/consume_strategy/kafka_on_fail_strategy.py,sha256=elNeyTubDuhHsLlTtDA1Nqz2hZe12PUcO9kz8upPby8,136
|
|
@@ -169,7 +169,7 @@ buz/kafka/domain/models/kafka_supported_sasl_mechanisms.py,sha256=ASyDaFgseQRcUJ
|
|
|
169
169
|
buz/kafka/domain/models/kafka_supported_security_protocols.py,sha256=ffY2-9sOj4XIkJTSQVkqeOb4KnuqEYXISDarfDN8r9Q,161
|
|
170
170
|
buz/kafka/domain/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
171
171
|
buz/kafka/domain/services/async_kafka_producer.py,sha256=gSq3WwEVux_gp3EKDAMN1WsM027uklB58E-WnKpyhPs,533
|
|
172
|
-
buz/kafka/domain/services/kafka_admin_client.py,sha256=
|
|
172
|
+
buz/kafka/domain/services/kafka_admin_client.py,sha256=6WJzMPTYSKTUq0Dtxj1rzGAWK-GAYGolW_LFDB_faVU,2042
|
|
173
173
|
buz/kafka/domain/services/kafka_admin_test_client.py,sha256=91l_vFIo1yhJLQQCC_OmeXZ5F429zP7Hx5g4FNllpfE,1625
|
|
174
174
|
buz/kafka/domain/services/kafka_producer.py,sha256=8bLTV328orrPHcARzkc6no4vyJzrArVtCsjmSRXDjos,506
|
|
175
175
|
buz/kafka/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -199,15 +199,17 @@ buz/kafka/infrastructure/interfaces/async_connection_manager.py,sha256=JbaLu5UVV
|
|
|
199
199
|
buz/kafka/infrastructure/interfaces/connection_manager.py,sha256=EWnvShJHOg8QYe6a3ma0urjKjmVMDBi7q8T2cv_i_MQ,200
|
|
200
200
|
buz/kafka/infrastructure/kafka_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
201
201
|
buz/kafka/infrastructure/kafka_python/exception/consumer_interrupted_exception.py,sha256=fqhgV7HILdVdv-p1CsOIaaESKY2ZXBtRGYbrVSdPLg0,164
|
|
202
|
-
buz/kafka/infrastructure/kafka_python/kafka_python_admin_client.py,sha256=
|
|
202
|
+
buz/kafka/infrastructure/kafka_python/kafka_python_admin_client.py,sha256=ikNTLUp3CrLgctvQDEcYTCjz8eRBTffg6cQFP8n0MNY,17571
|
|
203
203
|
buz/kafka/infrastructure/kafka_python/kafka_python_admin_test_client.py,sha256=5xP23dQ7FDuy7dIWNw39C3bMVmaUj9ZQhEEJISRv9ec,2986
|
|
204
204
|
buz/kafka/infrastructure/kafka_python/kafka_python_producer.py,sha256=McH_YNQcte7HzNRvS_4bgaz1ng7v4ESoi4mUkrQFLYw,3627
|
|
205
205
|
buz/kafka/infrastructure/kafka_python/translators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
206
206
|
buz/kafka/infrastructure/kafka_python/translators/consumer_initial_offset_position_translator.py,sha256=hJ48_eyMcnbFL_Y5TOiMbGXrQSryuKk9CvP59MdqNOY,620
|
|
207
207
|
buz/kafka/infrastructure/serializers/byte_serializer.py,sha256=T83sLdX9V5Oh1mzjRwHi_1DsTFI7KefFj7kmnz7JVy4,207
|
|
208
|
+
buz/kafka/infrastructure/serializers/implementations/cdc_partition_key_serializer.py,sha256=TNN1H5AndGvpxkfBTOHGSH94mZocQ4n3JApQnvp7TNw,902
|
|
208
209
|
buz/kafka/infrastructure/serializers/implementations/cdc_record_bytes_to_event_serializer.py,sha256=c5VmnuTOIZJ_tjfOl_BQnPdr7D1OAOxGYVFE4O4X8Tk,1801
|
|
209
210
|
buz/kafka/infrastructure/serializers/implementations/json_byte_serializer.py,sha256=yCPlZ-TNoF5Jh0WUlhseC8rTnHk-IJgmAHmU58ninyA,1523
|
|
210
211
|
buz/kafka/infrastructure/serializers/kafka_header_serializer.py,sha256=ws9xr5lsJF6J-uVIplPym7vboo00KtXHfLJf8JjG0lo,649
|
|
212
|
+
buz/kafka/infrastructure/serializers/partitiion_key_generator.py,sha256=4FQmTuqrLp9xmaYg9qv42x5fPMQFaC4OmDnmuszGf94,190
|
|
211
213
|
buz/locator/__init__.py,sha256=my8qfHL5htIT9RFFjzV4zGIPVW72tu4SMQbKKqBeSKo,293
|
|
212
214
|
buz/locator/handler_fqn_not_found_exception.py,sha256=HfQb8gwqEpG1YfOc_IQlSCjRg0Ete0Aj_z3s7GPC-RM,206
|
|
213
215
|
buz/locator/locator.py,sha256=1RqxXSkTw5PgwSB_AME3gYzYgN8ySV0FrUwW5N_0cAQ,512
|
|
@@ -263,7 +265,7 @@ buz/serializer/message_to_json_bytes_serializer.py,sha256=RGZJ64t4t4Pz2FCASZZCv-
|
|
|
263
265
|
buz/wrapper/__init__.py,sha256=GnRdJFcncn-qp0hzDG9dBHLmTJSbHFVjE_yr-MdW_n4,77
|
|
264
266
|
buz/wrapper/async_to_sync.py,sha256=OfK-vrVUhuN-LLLvekLdMbQYtH0ue5lfbvuasj6ovMI,698
|
|
265
267
|
buz/wrapper/event_loop.py,sha256=pfBJ1g-8A2a3YgW8Gf9Fg0kkewoh3-wgTy2KIFDyfHk,266
|
|
266
|
-
buz-2.
|
|
267
|
-
buz-2.
|
|
268
|
-
buz-2.
|
|
269
|
-
buz-2.
|
|
268
|
+
buz-2.22.1.dist-info/LICENSE,sha256=jcLgcIIVaBqaZNwe0kzGWSU99YgwMcI0IGv142wkYSM,1062
|
|
269
|
+
buz-2.22.1.dist-info/METADATA,sha256=baDIRyxTLM2Z4gKrvVH9War7HIp0V0WFgSlbTR4x6Eo,12580
|
|
270
|
+
buz-2.22.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
271
|
+
buz-2.22.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|