Skip to main content

Kafka and schema registry integration

Project description

kafka-schema-registry

This library allows you to create topics on Kafka topics, associated with a Confluent Schema Registry, and publish messages on them.

It takes care of:

  • creating the topic
  • publishing the associated schema (or updating an existing one)
  • serializing and publishing messages to Kafka

It works with kafka-python, and extra arguments are forwarded to it.

Installing

pip install kafka-schema-registry

Usage

from kafka_schema_registry import prepare_producer

SAMPLE_SCHEMA = {
    "type": "record",
    "name": "TestType",
    "fields" : [
        {"name": "age", "type": "int"},
        {"name": "name", "type": ["null", "string"]}
    ]
}


producer = prepare_producer(
        ['localhost:9092'],
        f'http://schemaregistry',
        topic_name,
        1,
        1,
        value_schema=SAMPLE_SCHEMA,
)

producer.send(topic_name, {'age': 34})
producer.send(topic_name, {'age': 9000, 'name': 'john'})

Running the tests

The test requires Docker in order to start a local Redpanda instance.

  • make start-redpanda to start the server
  • make test to configure a virtualenv and run the tests

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

kafka-schema-registry-0.0.4.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

kafka_schema_registry-0.0.4-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file kafka-schema-registry-0.0.4.tar.gz.

File metadata

  • Download URL: kafka-schema-registry-0.0.4.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for kafka-schema-registry-0.0.4.tar.gz
Algorithm Hash digest
SHA256 86463c14a1ddf2dc2762acc8cece3a56e4774655859aa129585e9f6f8a2b1bec
MD5 2194cd435520b262dab1a4fc4c4c564c
BLAKE2b-256 687a3683f5379eed6cab1ff62bdce3284d4dbd68a03d2b8702a9dc7da5fe8a19

See more details on using hashes here.

File details

Details for the file kafka_schema_registry-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: kafka_schema_registry-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for kafka_schema_registry-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 79f051d7d1e015279378584a1221cfd03be539c9fa9f7a6873595d9e9fea6eae
MD5 31a5e04f6433b8205224c1c4f7c479cc
BLAKE2b-256 9b835eb42b2ae7fef8a39c2dcf4ccf3917bf4e6565b11a914a82dc586bf3e346

See more details on using hashes here.

Supported by

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