class kafkit.registry.PolySerializer(*, registry)#

Bases: object

An Avro message serializer that can write messages for multiple schemas in the Confluent Wire Format.


registry (kafkit.registry.sansio.RegistryApi) – A registry client.

Methods Summary

serialize(data[, schema, schema_id, subject])

Serialize data given a schema.

Methods Documentation

async serialize(data, schema=None, schema_id=None, subject=None)#

Serialize data given a schema.

  • data (Any) – 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 schema is also provided, this method will always obtain the schema through the registry client. If this parameter isn’t set then the schema parmeter is used.

  • schema (dict, optional) – An Avro schema. This parameter is ignored if the schema_id parameter 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 the subject parameter.

  • subject (str, optional) – If the schema parameter 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.


message – Message in the Confluent Schema Registry wire format.

Return type: