Skip to content

Commit ac8b4b2

Browse files
committed
Remove the dict requirement when serializing AVRO
1 parent b1bf1b0 commit ac8b4b2

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

confluent_kafka/avro/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def produce(self, **kwargs):
8787
"""
8888
Sends message to kafka by encoding with specified avro schema
8989
@:param: topic: topic name
90-
@:param: value: A dictionary object
90+
@:param: value: An object to serialize
9191
@:param: value_schema : Avro schema for value
92-
@:param: key: A dictionary object
92+
@:param: key: An object to serialize
9393
@:param: key_schema : Avro schema for key
9494
@:exception: SerializerError
9595
"""

confluent_kafka/avro/serializer/message_serializer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,10 @@ def encode_record_with_schema(self, topic, schema, record, is_key=False):
8585
The schema is registered with the subject of 'topic-value'
8686
@:param topic : Topic name
8787
@:param schema : Avro Schema
88-
@:param record : A dictionary object
88+
@:param record : An object to serialize
8989
@:param is_key : If the record is a key
9090
@:returns : Encoded record with schema ID as bytes
9191
"""
92-
if not isinstance(record, dict):
93-
raise SerializerError("record must be a dictionary")
9492
serialize_err = KeySerializerError if is_key else ValueSerializerError
9593

9694
subject_suffix = ('-key' if is_key else '-value')
@@ -112,12 +110,10 @@ def encode_record_with_schema_id(self, schema_id, record, is_key=False):
112110
Encode a record with a given schema id. The record must
113111
be a python dictionary.
114112
@:param: schema_id : integer ID
115-
@:param: record : A dictionary object
113+
@:param: record : An object to serialize
116114
@:param is_key : If the record is a key
117115
@:returns: decoder function
118116
"""
119-
if not isinstance(record, dict):
120-
raise SerializerError("record must be a dictionary")
121117
serialize_err = KeySerializerError if is_key else ValueSerializerError
122118

123119
# use slow avro

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy