No project description provided
Project description
faststream-schema-registry
Middleware to integrate with the confluent schema registry for managing avro/json schemas.
Schemas are generated from python classes using dataclasses-avroschema and registered using python-schema-registry-client.
Requirements
python 3.9+
Installation
pip install faststream-schema-registry
Examples
Serialize objects using either the AvroSchemaRegistry or the JsonSchemaRegistry
AvroSchemaRegistry
from datetime import datetime
from dataclasses_avroschema.pydantic import AvroBaseModel
from faststream import FastStream
from faststream.confluent import KafkaBroker
from faststream_schema_registry.middleware import SchemaRegistryMiddleware
from faststream_schema_registry.registries import AvroSchemaRegistry
schema_registry = AvroSchemaRegistry(url="http://localhost:8081")
broker = KafkaBroker(
"localhost:29092",
middlewares=[
SchemaRegistryMiddleware.make_middleware(schema_registry=schema_registry)
],
)
app = FastStream(broker)
# class for message object
class Message(AvroBaseModel):
timestamp: datetime
message_id: int
payload: str
class Meta:
namespace = "com.test"
@app.after_startup
async def test():
await broker.publish(Message.fake(), topic="messages")
@broker.subscriber("messages")
async def on_messages(msg: Message):
print(msg)
JsonSchemaRegistry
from datetime import datetime
from dataclasses_avroschema.pydantic import AvroBaseModel
from faststream import FastStream
from faststream.confluent import KafkaBroker
from faststream_schema_registry.middleware import SchemaRegistryMiddleware
from faststream_schema_registry.registries import JsonSchemaRegistry
schema_registry = JsonSchemaRegistry(url="http://localhost:8081")
broker = KafkaBroker(
"localhost:29092",
middlewares=[
SchemaRegistryMiddleware.make_middleware(schema_registry=schema_registry)
],
)
...
Project details
Release history Release notifications | RSS feed
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 faststream_schema_registry-0.1.1.tar.gz.
File metadata
- Download URL: faststream_schema_registry-0.1.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
223a354c06ef8df67449dc617f0b8f4728536c9dc5fcd69d9e4757b9444a84b7
|
|
| MD5 |
5e9815c1cedf418a5693768a41d65614
|
|
| BLAKE2b-256 |
328076eaef2d59aa8f5d0c2b20192b0aea348254a4b458b899590f7deb3b10f7
|
Provenance
The following attestation bundles were made for faststream_schema_registry-0.1.1.tar.gz:
Publisher:
publish-package.yml on mlovretovich/faststream-schema-registry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
faststream_schema_registry-0.1.1.tar.gz -
Subject digest:
223a354c06ef8df67449dc617f0b8f4728536c9dc5fcd69d9e4757b9444a84b7 - Sigstore transparency entry: 179770373
- Sigstore integration time:
-
Permalink:
mlovretovich/faststream-schema-registry@1322b7eaff2b11f2796ad2fa638f0ba28dd20789 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mlovretovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@1322b7eaff2b11f2796ad2fa638f0ba28dd20789 -
Trigger Event:
push
-
Statement type:
File details
Details for the file faststream_schema_registry-0.1.1-py3-none-any.whl.
File metadata
- Download URL: faststream_schema_registry-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5569e932e73f3d1cab2110d0ffcc8cc5b6377909ba46e5af72728286e4a5f00
|
|
| MD5 |
a2c78df14c532df22da44fb76c168edd
|
|
| BLAKE2b-256 |
5ffb8aa699585d08d7ad1f4461d840a64faf6e30a9e6f92c2d2a2712265931d5
|
Provenance
The following attestation bundles were made for faststream_schema_registry-0.1.1-py3-none-any.whl:
Publisher:
publish-package.yml on mlovretovich/faststream-schema-registry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
faststream_schema_registry-0.1.1-py3-none-any.whl -
Subject digest:
b5569e932e73f3d1cab2110d0ffcc8cc5b6377909ba46e5af72728286e4a5f00 - Sigstore transparency entry: 179770375
- Sigstore integration time:
-
Permalink:
mlovretovich/faststream-schema-registry@1322b7eaff2b11f2796ad2fa638f0ba28dd20789 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mlovretovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@1322b7eaff2b11f2796ad2fa638f0ba28dd20789 -
Trigger Event:
push
-
Statement type: