confluentinc / confluentinc/confluent-kafka-python

Add AggregateSerializer, AggregateDeserializer

Aperta
#1,237 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement priority:low status:help-wanted status:waiting-for-interest
Lingua principale
Python
Stelle
509
Fork
964
Merge medio
2g 2h
PR unite (30g)
14

Descrizione

Description
===========

I had to write a class like the `AggregateSerializer` below recently. It seems like something that would naturally be in the library given producers can produce to multiple topics and considers can subscribe to multiple topics (each with its own format).

See #838
See #1009

How to implement
================

In `/src/confluent_kafka/serialization/__init__.py`, two classes could be added:

```python
class AggregateSerializer(Serializer):
def __init__(self, serializers: Dict[str, Serializer]):
self.serializers = serializers
def __call__(self, obj, ctx: SerializationContext):
return self.serializers[ctx.topic](obj. ctx)

# And basically the same for AggregateDeserializer
```

And basically the same for `AggregateDeserializer`, plus doc comments per other classes in module.

I can do the legwork to integrate this if it increases the chances of it getting in.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.