PolySerializer#
- class kafkit.registry.PolySerializer(*, registry)#
Bases:
object
An 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
- async serialize(data, schema=None, schema_id=None, subject=None)#
Serialize data given a schema.
- Parameters:
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 aschema
is also provided, this method will always obtain the schema through the registry client. If this parameter isn’t set then theschema
parmeter is used.schema (
dict
, optional) – An Avro schema. This parameter is ignored if theschema_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 thesubject
parameter.subject (
str
, optional) – If theschema
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.
- Returns:
message – Message in the Confluent Schema Registry wire format.
- Return type: