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.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

kafka_schema_registry-0.1.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kafka-schema-registry-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.3 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.5

File hashes

Hashes for kafka-schema-registry-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9815efbcacca120aaaad5abcac1444a80d7bcfc86ed748e9d4bb5daa259f91fb
MD5 bd5ebbdfc0f689221c03116c6a46bce7
BLAKE2b-256 814ef84da52ea1fc8e23064b2c4a0b84011a29ad4461f850673471fb4b0d89d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kafka_schema_registry-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.3 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.5

File hashes

Hashes for kafka_schema_registry-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7880e29bc04275f3e485e898baa209bb1244d38cb5f056a94b455aec7da09a75
MD5 3b230f2b463873bda7d47eed3e778594
BLAKE2b-256 691150049352f6782519a224179ed0a7998061d6bb45e50c615104aa1cc57029

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