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
AvroEncoder
sync 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=True
keyword is passed in, will automatically register schemas passed in to theencode
method. Otherwise, and by default, will require pre-registering of schemas passed toencode
. Takes agroup_name
argument 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 aMessageType
subtype object, depending on arguments provided.decode
: Decodes bytes content into dict content by automatically retrieving schema from the service.
- constructor: If
MessageContent
TypedDict 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.
MessageType
has 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 aMessageContent
object 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.
InvalidContentError
has been introduced for errors related to invalid content and content types, where__cause__
will contain the underlying exception raised by the Avro library.InvalidSchemaError
has been introduced for errors related to invalid schemas, where__cause__
will contain the underlying exception raised by the Apache Avro library.- The
encode
anddecode
methods onAvroEncoder
support the following message models:azure.eventhub.EventData
inazure-eventhub>=5.9.0
Other Changes
- This package is meant to replace the azure-schemaregistry-avroserializer package, which will no longer be supported.
group_name
is now an optional parameter in the sync and asyncAvroEncoder
constructors.