PolySerializer¶
-
class
kafkit.registry.PolySerializer(*, registry)¶ Bases:
objectAn Avro message serializer that can write messages for multiple schemas in the Confluent Wire Format.
Parameters: - registry :
kafkit.registry.sansio.RegistryApi A registry client.
Methods Summary
serialize(data[, schema, schema_id, subject])Serialize data given a schema. Methods Documentation
-
serialize(data, schema=None, schema_id=None, subject=None)¶ Serialize data given a schema.
Parameters: - data
An Avro-serializable object. The object must conform to the schema.
- schema_id :
int, optional The ID of the schema in the Schema Registry. Even if a
schemais also provided, this method will always obtain the schema through the registry client. If this parameter isn’t set then theschemaparmeter is used.- schema :
dict, optional An Avro schema. This parameter is ignored if the
schema_idparameter is set. If necessary (because the schema isn’t found in the registry) this schema is registered with the schema registry. By default, the schema is registered under a subject named after the fully-qualified name of the schema. This default can be overriden by setting thesubjectparameter.- subject :
str, optional If the
schemaparameter is set and that schema needs to be newly registered with the schema registry, the schema is registered under this subject name. This is optional; by default the schema is registered under a subject named after the fully qualified name of the schema.
Returns: - message :
bytes Message in the Confluent Schema Registry wire format.
- registry :