Apache Avro serialization/deserialization with Confluent Schema Registry framing and Apicurio integration
Project description
AvroCurio
Apache Avro serialization/deserialization with Confluent Schema Registry framing using Apicurio Schema Registry.
Installation
Using uv, poetry, or pip:
uv add avrocurio
poetry add avrocurio
pip install avrocurio
Quick Start
1. Define your schema using dataclasses-avroschema
from dataclasses import dataclass
from dataclasses_avroschema import AvroModel
@dataclass
class User(AvroModel):
name: str
age: int
email: str
2. Serialize and deserialize data
import asyncio
from avrocurio import AvroSerializer, ApicurioClient, ApicurioConfig
async def main():
# Configure connection to Apicurio Registry
config = ApicurioConfig(base_url="http://localhost:8080")
# Create client and serializer
async with ApicurioClient(config) as client:
serializer = AvroSerializer(client)
# Create a user instance
user = User(name="John Doe", age=30, email="john@example.com")
# Serialize the user to an Avro binary with Confluent registry framing.
# Under the hood this will perform a lookup against Apicurio to get the
# artifact ID for the schema, which is then prepended to the Avro binary
# (along with a magic byte).
serialized = await serializer.serialize(user)
# Deserialize the binary back to a User instance.
deserialized_user = await serializer.deserialize(serialized, User)
asyncio.run(main())
Confluent Schema Registry Wire Format
AvroCurio implements the Confluent Schema Registry wire format:
+----------------+------------------+------------------+
| Magic Byte | Schema ID | Avro Payload |
| (1 byte = 0x0) | (4 bytes, BE) | (remaining) |
+----------------+------------------+------------------+
- Magic Byte: Always
0x0to identify Confluent wire format - Schema ID: 4-byte big-endian integer referencing the schema in the registry
- Avro Payload: Standard Avro binary-encoded data
Schema Caching
Schema caching is handled automatically by the ApicurioClient for performance.
Development
Requirements
Integration tests require a running Apicurio Registry. Running it through Docker or Podman using Compose is easiest:
docker compose up
Port 8080 is assumed by default, but you can set APICURIO_URL to point to a different instance.
Running Tests
# Run all tests
uv run pytest
# Run specific test file
uv run pytest tests/test_serializer.py
# Run with verbose output
uv run pytest -v
# Skip integration tests
uv run pytest -m "not integration"
License
AvroCurio is open-source software released under the BSD-2-Clause Plus Patent License. This license is designed to provide: a) a simple permissive license; b) that is compatible with the GNU General Public License (GPL), version 2; and c) which also has an express patent grant included.
Please review the LICENSE file for the full text of the license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file avrocurio-1.1.0.tar.gz.
File metadata
- Download URL: avrocurio-1.1.0.tar.gz
- Upload date:
- Size: 82.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d6d8da3d16c6996d574c1c3dffa0732decf4be39f0a60585742c92d642338aa
|
|
| MD5 |
a349c4f86f08f2925a9c96e2882d3819
|
|
| BLAKE2b-256 |
9805d0c7dc0cf777b3303943371ec7be66e76549bc26d73cb2426b7856931dc2
|
Provenance
The following attestation bundles were made for avrocurio-1.1.0.tar.gz:
Publisher:
release.yml on castoredc/avrocurio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
avrocurio-1.1.0.tar.gz -
Subject digest:
7d6d8da3d16c6996d574c1c3dffa0732decf4be39f0a60585742c92d642338aa - Sigstore transparency entry: 602195123
- Sigstore integration time:
-
Permalink:
castoredc/avrocurio@6c26052aea3af8f1d1015cbb162a8a3f0a49404f -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/castoredc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6c26052aea3af8f1d1015cbb162a8a3f0a49404f -
Trigger Event:
push
-
Statement type:
File details
Details for the file avrocurio-1.1.0-py3-none-any.whl.
File metadata
- Download URL: avrocurio-1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80c79f24425539be0c646d96a7bae56911c40a8ed2515ffba32704ad108d9355
|
|
| MD5 |
b4a337c7d1268e1a41643fd2e47b95cd
|
|
| BLAKE2b-256 |
e1be57acc9bda7ffca1acd51aacd51c65ba1491db76667a857dc8ba7eb638f07
|
Provenance
The following attestation bundles were made for avrocurio-1.1.0-py3-none-any.whl:
Publisher:
release.yml on castoredc/avrocurio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
avrocurio-1.1.0-py3-none-any.whl -
Subject digest:
80c79f24425539be0c646d96a7bae56911c40a8ed2515ffba32704ad108d9355 - Sigstore transparency entry: 602195130
- Sigstore integration time:
-
Permalink:
castoredc/avrocurio@6c26052aea3af8f1d1015cbb162a8a3f0a49404f -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/castoredc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6c26052aea3af8f1d1015cbb162a8a3f0a49404f -
Trigger Event:
push
-
Statement type: