https://github.com/flix-tech/kafka-schema-registry
Kafka library with a schema registry integration
https://github.com/flix-tech/kafka-schema-registry
Last synced: over 1 year ago
JSON representation
Kafka library with a schema registry integration
- Host: GitHub
- URL: https://github.com/flix-tech/kafka-schema-registry
- Owner: flix-tech
- License: mit
- Created: 2021-05-18T13:59:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-04T11:47:33.000Z (over 1 year ago)
- Last Synced: 2025-04-06T14:14:33.300Z (over 1 year ago)
- Language: Python
- Size: 47.9 KB
- Stars: 10
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
[kafka-python]: https://github.com/dpkp/kafka-python
## Installing
```sh
pip install kafka-schema-registry
```
## Usage
```python
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