azure-schemaregistry-avroencoder_1.0.0
1.0.0 (2022-05-10)
Note: This is the first stable release of our efforts to create a user-friendly Pythonic Avro Encoder library that integrates with the Python client library for Azure Schema Registry.
Features Added
AvroEncodersync and async classes provide the functionality to encode and decode content which follows a schema with the RecordSchema format, as defined by the Apache Avro specification. The Apache Avro library is used as the implementation for encoding and decoding.
The encoder will automatically register and retrieve schemas from Azure Schema Registry Service. It provides the following methods:- constructor: If
auto_register=Truekeyword is passed in, will automatically register schemas passed in to theencodemethod. Otherwise, and by default, will require pre-registering of schemas passed toencode. Takes agroup_nameargument that is optional when decoding, but required for encoding. encode: Encodes dict content into bytes according to the given schema and registers schema if needed. Returns either a dict of encoded content and corresponding content type or aMessageTypesubtype object, depending on arguments provided.decode: Decodes bytes content into dict content by automatically retrieving schema from the service.
- constructor: If
MessageContentTypedDict has been introduced with the following required keys:content: The bytes content.content_type: The string content type, which holds the schema ID and the record format indicator.
MessageTypehas been introduced with the following methods:from_message_content: Class method that creates an object with given bytes content and string content type.__message_content__: Returns aMessageContentobject with content and content type values set to their respective properties on the object.
- Schemas and Schema IDs are cached locally, so that multiple calls with the same schema/schema ID will not trigger multiple service calls.
- The number of hits, misses, and total entries for the schema/schema ID caches will be logged at an info level when a new entry is added.
InvalidContentErrorhas been introduced for errors related to invalid content and content types, where__cause__will contain the underlying exception raised by the Avro library.InvalidSchemaErrorhas been introduced for errors related to invalid schemas, where__cause__will contain the underlying exception raised by the Apache Avro library.- The
encodeanddecodemethods onAvroEncodersupport the following message models:azure.eventhub.EventDatainazure-eventhub>=5.9.0
Other Changes
- This package is meant to replace the azure-schemaregistry-avroserializer package, which will no longer be supported.
group_nameis now an optional parameter in the sync and asyncAvroEncoderconstructors.