github Azure/azure-sdk-for-python azure-schemaregistry-avroencoder_1.0.0

latest releases: azure-appconfiguration-provider_2.0.0, azure-ai-ml_1.23.1, azure-mgmt-cosmosdb_10.0.0b5...
2 years ago

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 the encode method. Otherwise, and by default, will require pre-registering of schemas passed to encode. Takes a group_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 a MessageType subtype object, depending on arguments provided.
    • decode: Decodes bytes content into dict content by automatically retrieving schema from the service.
  • 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 a MessageContent 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 and decode methods on AvroEncoder support the following message models:
    • azure.eventhub.EventData in azure-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 async AvroEncoder constructors.

Don't miss a new azure-sdk-for-python release

NewReleases is sending notifications on new releases.