Использование confluent-kafka-python
from confluent_kafka.avro.cached_schema_registry_client import CachedSchemaRegistryClient
sr = CachedSchemaRegistryClient({
'url': 'http://localhost:8081',
'ssl.certificate.location': '/path/to/cert', # optional
'ssl.key.location': '/path/to/key' # optional
})
value_schema = sr.get_latest_schema("orders-value")[1]
key_schema= sr.get_latest_schema("orders-key")[1]
Использование SchemaRegistryClient
Получение схемы по имени субъекта
from schema_registry.client import SchemaRegistryClient
sr = SchemaRegistryClient('localhost:8081')
my_schema = sr.get_schema(subject='mySubject', version='latest')
Получение схемы по идентификатору
from schema_registry.client import SchemaRegistryClient
sr = SchemaRegistryClient('localhost:8081')
my_schema = sr.get_by_id(schema_id=1)