Skip to main content

No project description provided

Project description

faststream-schema-registry

GitHub Actions Workflow Status codecov Python Version PyPI - Version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faststream_schema_registry-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

faststream_schema_registry-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file faststream_schema_registry-0.1.1.tar.gz.

File metadata

File hashes

Hashes for faststream_schema_registry-0.1.1.tar.gz
Algorithm Hash digest
SHA256 223a354c06ef8df67449dc617f0b8f4728536c9dc5fcd69d9e4757b9444a84b7
MD5 5e9815c1cedf418a5693768a41d65614
BLAKE2b-256 328076eaef2d59aa8f5d0c2b20192b0aea348254a4b458b899590f7deb3b10f7

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file faststream_schema_registry-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for faststream_schema_registry-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5569e932e73f3d1cab2110d0ffcc8cc5b6377909ba46e5af72728286e4a5f00
MD5 a2c78df14c532df22da44fb76c168edd
BLAKE2b-256 5ffb8aa699585d08d7ad1f4461d840a64faf6e30a9e6f92c2d2a2712265931d5

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page