@@ -73,20 +73,22 @@ class AvroSerializer(Serializer):
73
73
AvroSerializer serializes objects in the Confluent Schema Registry binary
74
74
format for Avro.
75
75
76
+
76
77
AvroSerializer configuration properties:
77
- +-----------------------+----------+--------------------------------------------------+
78
- | Property Name | Type | Description |
79
- +=======================+==========+==================================================+
80
- | | | Registers schemas automatically if not |
81
- | auto.register.schemas | bool | previously associated with a particular subject. |
82
- | | | Defaults to True. |
83
- +-----------------------|----------+--------------------------------------------------+
84
- | | | Callable(SerializationContext, str) -> str |
85
- | | | |
86
- | subject.name.strategy | callable | Instructs the AvroSerializer on how to construct |
87
- | | | Schema Registry subject names. |
88
- | | | Defaults to topic_subject_name_strategy. |
89
- +-----------------------+----------+--------------------------------------------------+
78
+
79
+ +---------------------------+----------+--------------------------------------------------+
80
+ | Property Name | Type | Description |
81
+ +===========================+==========+==================================================+
82
+ | | | Registers schemas automatically if not |
83
+ | ``auto.register.schemas`` | bool | previously associated with a particular subject. |
84
+ | | | Defaults to True. |
85
+ +---------------------------+----------+--------------------------------------------------+
86
+ | | | Callable(SerializationContext, str) -> str |
87
+ | | | |
88
+ | ``subject.name.strategy`` | callable | Instructs the AvroSerializer on how to construct |
89
+ | | | Schema Registry subject names. |
90
+ | | | Defaults to topic_subject_name_strategy. |
91
+ +---------------------------+----------+--------------------------------------------------+
90
92
91
93
Schemas are registered to namespaces known as Subjects which define how a
92
94
schema may evolve over time. By default the subject name is formed by
@@ -95,9 +97,10 @@ class AvroSerializer(Serializer):
95
97
i.e. {topic name}-{message field}
96
98
97
99
Alternative naming strategies may be configured with the property
98
- `subject.name.strategy`.
100
+ `` subject.name.strategy` `.
99
101
100
102
Supported subject name strategies:
103
+
101
104
+--------------------------------------+------------------------------+
102
105
| Subject Name Strategy | Output Format |
103
106
+======================================+==============================+
@@ -108,7 +111,7 @@ class AvroSerializer(Serializer):
108
111
| record_subject_name_strategy | {record name} |
109
112
+--------------------------------------+------------------------------+
110
113
111
- See `` Subject name strategy`` for additional details.
114
+ See `Subject name strategy <https://docs.confluent.io/current/schema-registry/serializer-formatter.html#subject-name-strategy>`_ for additional details.
112
115
113
116
Note:
114
117
Prior to serialization all ``Complex Types`` must first be converted to
@@ -119,22 +122,14 @@ class AvroSerializer(Serializer):
119
122
See ``avro_producer.py`` in the examples directory for example usage.
120
123
121
124
Args:
122
- schema_str (str): Avro Schema declaration.
125
+ schema_str (str): Avro ` Schema Declaration. <https://avro.apache.org/docs/current/spec.html#schemas>`_
123
126
124
- schema_registry_client (SchemaRegistryClient): Schema Registry
125
- client instance.
127
+ schema_registry_client (SchemaRegistryClient): Schema Registry client instance.
126
128
127
- to_dict (callable, optional): Callable(object, SerializationContext) -> dict.
128
- Converts object to a dict.
129
+ to_dict (callable, optional): Callable(object, SerializationContext) -> dict. Converts object to a dict.
129
130
130
131
conf (dict): AvroSerializer configuration.
131
132
132
- .. _Subject name strategy:
133
- https://docs.confluent.io/current/schema-registry/serializer-formatter.html#subject-name-strategy
134
-
135
- .. _Schema declaration:
136
- https://avro.apache.org/docs/current/spec.html#schemas
137
-
138
133
""" # noqa: E501
139
134
__slots__ = ['_hash' , '_auto_register' , '_known_subjects' , '_parsed_schema' ,
140
135
'_registry' , '_schema' , '_schema_id' , '_schema_name' ,
@@ -196,14 +191,13 @@ def __call__(self, obj, ctx):
196
191
Args:
197
192
obj (object): object instance to serializes.
198
193
199
- ctx (SerializationContext): Metadata pertaining to the serialization
200
- operation.
194
+ ctx (SerializationContext): Metadata pertaining to the serialization operation.
201
195
202
196
Note:
203
197
None objects are represented as Kafka Null.
204
198
205
199
Raises:
206
- SerializerError if any error occurs serializing obj
200
+ SerializerError: if any error occurs serializing obj
207
201
208
202
Returns:
209
203
bytes: Confluent Schema Registry formatted Avro bytes
@@ -264,11 +258,10 @@ class AvroDeserializer(Deserializer):
264
258
from_dict (callable, optional): Callable(dict, SerializationContext) -> object.
265
259
Converts dict to an instance of some object.
266
260
267
- .. _Schema declaration :
268
- https://avro.apache.org/docs/current/spec.html#schemas
261
+ See Also :
262
+ `Apache Avro Schema Declaration < https://avro.apache.org/docs/current/spec.html#schemas>`_
269
263
270
- .. _Schema Resolution
271
- https://avro.apache.org/docs/1.8.2/spec.html#Schema+Resolution
264
+ `Apache Avro Schema Resolution <https://avro.apache.org/docs/1.8.2/spec.html#Schema+Resolution>`_
272
265
273
266
"""
274
267
__slots__ = ['_reader_schema' , '_registry' , '_from_dict' , '_writer_schemas' ]
@@ -295,13 +288,12 @@ def __call__(self, value, ctx):
295
288
operation.
296
289
297
290
Raises:
298
- SerializerError if an error occurs ready data.
291
+ SerializerError: if an error occurs ready data.
299
292
300
293
Returns:
301
- object: if ``from_dict`` is set, otherwise dict.
302
- If no value is supplied None is returned.
294
+ object: object if ``from_dict`` is set, otherwise dict. If no value is supplied None is returned.
303
295
304
- """
296
+ """ # noqa: E501
305
297
if value is None :
306
298
return None
307
299
0 commit comments