buz 2.15.0__py3-none-any.whl → 2.15.2__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/kafka_event_async_subscriber_executor.py +0 -7
- buz/kafka/infrastructure/cdc/__init__.py +0 -0
- buz/kafka/infrastructure/cdc/cdc_message.py +5 -22
- buz/kafka/infrastructure/cdc/cdc_payload.py +24 -0
- buz/kafka/infrastructure/cdc/cdc_schema.py +35 -0
- buz/kafka/infrastructure/deserializers/implementations/cdc/cdc_record_bytes_to_event_deserializer.py +8 -8
- buz/kafka/infrastructure/serializers/implementations/cdc_record_bytes_to_event_serializer.py +3 -1
- {buz-2.15.0.dist-info → buz-2.15.2.dist-info}/METADATA +1 -1
- {buz-2.15.0.dist-info → buz-2.15.2.dist-info}/RECORD +11 -8
- {buz-2.15.0.dist-info → buz-2.15.2.dist-info}/LICENSE +0 -0
- {buz-2.15.0.dist-info → buz-2.15.2.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from asyncio import sleep
|
|
2
2
|
from logging import Logger
|
|
3
|
-
import traceback
|
|
4
3
|
from typing import Optional, Sequence, cast
|
|
5
4
|
|
|
6
5
|
from buz.event import Event
|
|
@@ -68,16 +67,10 @@ class KafkaEventAsyncSubscriberExecutor(KafkaEventSubscriberExecutor):
|
|
|
68
67
|
headers=self.__header_deserializer.deserialize(kafka_poll_record.headers),
|
|
69
68
|
),
|
|
70
69
|
)
|
|
71
|
-
|
|
72
70
|
except NotValidKafkaMessageException:
|
|
73
71
|
self.__logger.error(
|
|
74
72
|
f'The message "{str(kafka_poll_record.value)}" is not valid, it will be consumed but not processed'
|
|
75
73
|
)
|
|
76
|
-
except Exception as exception:
|
|
77
|
-
if self.__on_fail_strategy == KafkaOnFailStrategy.CONSUME_ON_FAIL:
|
|
78
|
-
self.__logger.exception(f"Error consuming event: {traceback.format_exc()}")
|
|
79
|
-
return
|
|
80
|
-
raise exception
|
|
81
74
|
|
|
82
75
|
async def __consumption_callback(self, subscriber: AsyncSubscriber, message: KafkaConsumerRecord[Event]) -> None:
|
|
83
76
|
await self.__consume_middleware_chain_resolver.resolve(
|
|
File without changes
|
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
@dataclass(frozen=True)
|
|
5
|
-
class CDCPayload:
|
|
6
|
-
DATE_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
|
7
|
-
|
|
8
|
-
payload: str # json encoded
|
|
9
|
-
event_id: str # uuid
|
|
10
|
-
created_at: str
|
|
11
|
-
event_fqn: str
|
|
12
|
-
|
|
13
|
-
def validate(self) -> None:
|
|
14
|
-
if not isinstance(self.payload, str):
|
|
15
|
-
raise ValueError("The payload value is not a valid value")
|
|
16
|
-
if not isinstance(self.event_id, str):
|
|
17
|
-
raise ValueError("The event_id value is not a valid value")
|
|
18
|
-
if not isinstance(self.created_at, str):
|
|
19
|
-
raise ValueError("The created_at value is not a value")
|
|
20
|
-
if not isinstance(self.event_fqn, str):
|
|
21
|
-
raise ValueError("The event_fqn value is not a valid value")
|
|
22
|
-
|
|
23
|
-
def __post_init__(self) -> None:
|
|
24
|
-
self.validate()
|
|
4
|
+
from buz.kafka.infrastructure.cdc.cdc_payload import CDCPayload
|
|
25
5
|
|
|
26
6
|
|
|
27
7
|
@dataclass(frozen=True)
|
|
28
8
|
class CDCMessage:
|
|
29
9
|
payload: CDCPayload
|
|
10
|
+
schema: Optional[dict]
|
|
30
11
|
|
|
31
12
|
def validate(self) -> None:
|
|
32
13
|
if not isinstance(self.payload, CDCPayload):
|
|
33
14
|
raise ValueError("The payload value is not a valid value")
|
|
15
|
+
if self.schema is not None and not isinstance(self.schema, dict):
|
|
16
|
+
raise ValueError("The schema value is not a valid value")
|
|
34
17
|
|
|
35
18
|
def __post_init__(self) -> None:
|
|
36
19
|
self.validate()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass(frozen=True)
|
|
5
|
+
class CDCPayload:
|
|
6
|
+
DATE_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
|
7
|
+
|
|
8
|
+
payload: str # json encoded
|
|
9
|
+
event_id: str # uuid
|
|
10
|
+
created_at: str
|
|
11
|
+
event_fqn: str
|
|
12
|
+
|
|
13
|
+
def validate(self) -> None:
|
|
14
|
+
if not isinstance(self.payload, str):
|
|
15
|
+
raise ValueError("The payload value is not a valid value")
|
|
16
|
+
if not isinstance(self.event_id, str):
|
|
17
|
+
raise ValueError("The event_id value is not a valid value")
|
|
18
|
+
if not isinstance(self.created_at, str):
|
|
19
|
+
raise ValueError("The created_at value is not a value")
|
|
20
|
+
if not isinstance(self.event_fqn, str):
|
|
21
|
+
raise ValueError("The event_fqn value is not a valid value")
|
|
22
|
+
|
|
23
|
+
def __post_init__(self) -> None:
|
|
24
|
+
self.validate()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from buz.message import Message
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def generate_cdc_schema(message: Message) -> dict:
|
|
5
|
+
return {
|
|
6
|
+
"type": "struct",
|
|
7
|
+
"fields": [
|
|
8
|
+
{
|
|
9
|
+
"type": "string",
|
|
10
|
+
"optional": False,
|
|
11
|
+
"field": "payload",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"type": "string",
|
|
15
|
+
"optional": False,
|
|
16
|
+
"name": "io.debezium.data.Uuid",
|
|
17
|
+
"version": 1,
|
|
18
|
+
"field": "event_id",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "string",
|
|
22
|
+
"optional": False,
|
|
23
|
+
"field": "event_fqn",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "string",
|
|
27
|
+
"optional": False,
|
|
28
|
+
"name": "io.debezium.time.ZonedTimestamp",
|
|
29
|
+
"version": 1,
|
|
30
|
+
"field": "created_at",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
"optional": False,
|
|
34
|
+
"name": f"{message.fqn()}.Value",
|
|
35
|
+
}
|
buz/kafka/infrastructure/deserializers/implementations/cdc/cdc_record_bytes_to_event_deserializer.py
CHANGED
|
@@ -7,7 +7,7 @@ import orjson
|
|
|
7
7
|
from dacite import from_dict
|
|
8
8
|
|
|
9
9
|
from buz.event import Event
|
|
10
|
-
from buz.kafka.infrastructure.cdc.cdc_message import
|
|
10
|
+
from buz.kafka.infrastructure.cdc.cdc_message import CDCPayload
|
|
11
11
|
from buz.kafka.infrastructure.deserializers.bytes_to_message_deserializer import BytesToMessageDeserializer
|
|
12
12
|
from buz.kafka.infrastructure.deserializers.implementations.cdc.not_valid_cdc_message_exception import (
|
|
13
13
|
NotValidCDCMessageException,
|
|
@@ -25,11 +25,11 @@ class CDCRecordBytesToEventDeserializer(BytesToMessageDeserializer[Event], Gener
|
|
|
25
25
|
def deserialize(self, data: bytes) -> T:
|
|
26
26
|
decoded_string = data.decode(self.__STRING_ENCODING)
|
|
27
27
|
try:
|
|
28
|
-
|
|
28
|
+
cdc_payload = self.__get_outbox_record_as_dict(decoded_string)
|
|
29
29
|
return self.__event_class.restore(
|
|
30
|
-
id=
|
|
31
|
-
created_at=self.__get_created_at_in_event_format(
|
|
32
|
-
**orjson.loads(
|
|
30
|
+
id=cdc_payload.event_id,
|
|
31
|
+
created_at=self.__get_created_at_in_event_format(cdc_payload.created_at),
|
|
32
|
+
**orjson.loads(cdc_payload.payload),
|
|
33
33
|
)
|
|
34
34
|
except Exception as exception:
|
|
35
35
|
raise NotValidCDCMessageException(decoded_string, exception) from exception
|
|
@@ -38,12 +38,12 @@ class CDCRecordBytesToEventDeserializer(BytesToMessageDeserializer[Event], Gener
|
|
|
38
38
|
created_at_datetime = datetime.strptime(cdc_payload_created_at, CDCPayload.DATE_TIME_FORMAT)
|
|
39
39
|
return created_at_datetime.strftime(Event.DATE_TIME_FORMAT)
|
|
40
40
|
|
|
41
|
-
def __get_outbox_record_as_dict(self, decoded_string: str) ->
|
|
41
|
+
def __get_outbox_record_as_dict(self, decoded_string: str) -> CDCPayload:
|
|
42
42
|
decoded_record: dict = orjson.loads(decoded_string)
|
|
43
43
|
|
|
44
44
|
payload = decoded_record.get("payload")
|
|
45
|
+
|
|
45
46
|
if not isinstance(payload, dict):
|
|
46
47
|
raise ValueError("The provided payload value is not valid")
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
return cdc_message
|
|
49
|
+
return from_dict(CDCPayload, payload)
|
buz/kafka/infrastructure/serializers/implementations/cdc_record_bytes_to_event_serializer.py
CHANGED
|
@@ -5,6 +5,7 @@ from datetime import datetime
|
|
|
5
5
|
|
|
6
6
|
from buz.event import Event
|
|
7
7
|
from buz.kafka.infrastructure.cdc.cdc_message import CDCMessage, CDCPayload
|
|
8
|
+
from buz.kafka.infrastructure.cdc.cdc_schema import generate_cdc_schema
|
|
8
9
|
from buz.kafka.infrastructure.serializers.byte_serializer import ByteSerializer
|
|
9
10
|
from buz.kafka.infrastructure.serializers.implementations.json_byte_serializer import JSONByteSerializer
|
|
10
11
|
|
|
@@ -20,7 +21,8 @@ class CDCRecordBytesToEventSerializer(ByteSerializer):
|
|
|
20
21
|
created_at=self.__adapt_created_to_cdc_format(data.created_at),
|
|
21
22
|
event_fqn=data.fqn(),
|
|
22
23
|
payload=self.__serialize_payload(data),
|
|
23
|
-
)
|
|
24
|
+
),
|
|
25
|
+
schema=generate_cdc_schema(data),
|
|
24
26
|
)
|
|
25
27
|
return self.__json_serializer.serialize(asdict(cdc_message))
|
|
26
28
|
|
|
@@ -58,7 +58,7 @@ buz/event/infrastructure/buz_kafka/consume_strategy/topic_and_subscription_group
|
|
|
58
58
|
buz/event/infrastructure/buz_kafka/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
59
|
buz/event/infrastructure/buz_kafka/exceptions/kafka_event_bus_config_not_valid_exception.py,sha256=VUKZXA2ygjg21P4DADFl_Tace6RwSXia1MRYvJypxbM,135
|
|
60
60
|
buz/event/infrastructure/buz_kafka/exceptions/retry_exception.py,sha256=Fq9kvI3DpFsGD3x2icmQ1fYIsuKZAFqI3tCibAuEtSQ,441
|
|
61
|
-
buz/event/infrastructure/buz_kafka/kafka_event_async_subscriber_executor.py,sha256=
|
|
61
|
+
buz/event/infrastructure/buz_kafka/kafka_event_async_subscriber_executor.py,sha256=wJ7hxf5k1YWOkUpkUSmMMWrXLTCt94-QHkIRDfM5YuI,5566
|
|
62
62
|
buz/event/infrastructure/buz_kafka/kafka_event_subscriber_executor.py,sha256=EyG2vsFYErWAyqxdXqSwxx5Zi_y0d6i0h05XavJMnxg,254
|
|
63
63
|
buz/event/infrastructure/buz_kafka/kafka_event_sync_subscriber_executor.py,sha256=S9ECzWpUQm7YKEtOFuzZMZvRVaiAMyMVfNksJ7Jno9A,5600
|
|
64
64
|
buz/event/infrastructure/buz_kafka/publish_strategy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -169,12 +169,15 @@ buz/kafka/infrastructure/aiokafka/rebalance/__init__.py,sha256=47DEQpj8HBSa-_TIm
|
|
|
169
169
|
buz/kafka/infrastructure/aiokafka/rebalance/kafka_callback_rebalancer.py,sha256=3l7NkTrCt3rBktVIS73cTmCOvv6eFguoCbGMYIUfCFc,1774
|
|
170
170
|
buz/kafka/infrastructure/aiokafka/translators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
171
171
|
buz/kafka/infrastructure/aiokafka/translators/consumer_initial_offset_position_translator.py,sha256=WmxkQfoXeTy9mIJtGGhM0eDKeQxhcJczeVAGCbtonVI,617
|
|
172
|
-
buz/kafka/infrastructure/cdc/
|
|
172
|
+
buz/kafka/infrastructure/cdc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
173
|
+
buz/kafka/infrastructure/cdc/cdc_message.py,sha256=Cpv2nA19SG3HZGBLH-wIJbuokzTTZKT_HNFm1VwGSk4,585
|
|
174
|
+
buz/kafka/infrastructure/cdc/cdc_payload.py,sha256=tQ_HdiREkORHlDoQQraj-KQj0x5MRuV8vP-C4x3cgHY,793
|
|
175
|
+
buz/kafka/infrastructure/cdc/cdc_schema.py,sha256=JVSj6MSWNh2aaoWp1LL8UNJtjBvKggoBgMtOOT0vkQQ,940
|
|
173
176
|
buz/kafka/infrastructure/deserializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
174
177
|
buz/kafka/infrastructure/deserializers/byte_deserializer.py,sha256=4fc6t-zvcFx6F5eoyEixH2uN0cM6aB0YRGwowIzz1RA,211
|
|
175
178
|
buz/kafka/infrastructure/deserializers/bytes_to_message_deserializer.py,sha256=r40yq67DIElPi6ClmElbtR3VGrG2grNwgwuflXWOh20,345
|
|
176
179
|
buz/kafka/infrastructure/deserializers/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
177
|
-
buz/kafka/infrastructure/deserializers/implementations/cdc/cdc_record_bytes_to_event_deserializer.py,sha256=
|
|
180
|
+
buz/kafka/infrastructure/deserializers/implementations/cdc/cdc_record_bytes_to_event_deserializer.py,sha256=iMTx9zI_QzHcHvCbpfUkq6Hp67O_LXK5iYE1nzt_mqA,1913
|
|
178
181
|
buz/kafka/infrastructure/deserializers/implementations/cdc/not_valid_cdc_message_exception.py,sha256=hgLLwTcC-C2DuJSOWUhmQsrd1bO9I1469869IqfAPOk,414
|
|
179
182
|
buz/kafka/infrastructure/deserializers/implementations/json_byte_deserializer.py,sha256=L4b164-KweiQUwyRONhTMIGnAz48UPk0btLqjGOTNdk,373
|
|
180
183
|
buz/kafka/infrastructure/deserializers/implementations/json_bytes_to_message_deserializer.py,sha256=YwugXkmOudMNtkVfCC4BFe3pFVpbM8rAL9bT88bZMRk,756
|
|
@@ -189,7 +192,7 @@ buz/kafka/infrastructure/kafka_python/kafka_python_producer.py,sha256=DkqqLSSXHB
|
|
|
189
192
|
buz/kafka/infrastructure/kafka_python/translators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
190
193
|
buz/kafka/infrastructure/kafka_python/translators/consumer_initial_offset_position_translator.py,sha256=hJ48_eyMcnbFL_Y5TOiMbGXrQSryuKk9CvP59MdqNOY,620
|
|
191
194
|
buz/kafka/infrastructure/serializers/byte_serializer.py,sha256=T83sLdX9V5Oh1mzjRwHi_1DsTFI7KefFj7kmnz7JVy4,207
|
|
192
|
-
buz/kafka/infrastructure/serializers/implementations/cdc_record_bytes_to_event_serializer.py,sha256=
|
|
195
|
+
buz/kafka/infrastructure/serializers/implementations/cdc_record_bytes_to_event_serializer.py,sha256=Cw6kbzCMHC2PwHf6DNCIKZB2H-WCEZ-HeIDNxQbkTow,1601
|
|
193
196
|
buz/kafka/infrastructure/serializers/implementations/json_byte_serializer.py,sha256=KGkTQE7lq8VB048zCew_IlYgoWPozkmERYKg0t4DjOA,1510
|
|
194
197
|
buz/kafka/infrastructure/serializers/kafka_header_serializer.py,sha256=ws9xr5lsJF6J-uVIplPym7vboo00KtXHfLJf8JjG0lo,649
|
|
195
198
|
buz/locator/__init__.py,sha256=my8qfHL5htIT9RFFjzV4zGIPVW72tu4SMQbKKqBeSKo,293
|
|
@@ -246,7 +249,7 @@ buz/serializer/message_to_json_bytes_serializer.py,sha256=RGZJ64t4t4Pz2FCASZZCv-
|
|
|
246
249
|
buz/wrapper/__init__.py,sha256=GnRdJFcncn-qp0hzDG9dBHLmTJSbHFVjE_yr-MdW_n4,77
|
|
247
250
|
buz/wrapper/async_to_sync.py,sha256=OfK-vrVUhuN-LLLvekLdMbQYtH0ue5lfbvuasj6ovMI,698
|
|
248
251
|
buz/wrapper/event_loop.py,sha256=pfBJ1g-8A2a3YgW8Gf9Fg0kkewoh3-wgTy2KIFDyfHk,266
|
|
249
|
-
buz-2.15.
|
|
250
|
-
buz-2.15.
|
|
251
|
-
buz-2.15.
|
|
252
|
-
buz-2.15.
|
|
252
|
+
buz-2.15.2.dist-info/LICENSE,sha256=Jytu2S-2SPEgsB0y6BF-_LUxIWY7402fl0JSh36TLZE,1062
|
|
253
|
+
buz-2.15.2.dist-info/METADATA,sha256=vJLWjCrVTn6AdIIQ1IJZv3jUlrPg0Kfp4O05HCaggMc,1659
|
|
254
|
+
buz-2.15.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
255
|
+
buz-2.15.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|