Kafkit API reference#

kafkit.fastapi.dependencies.aiokafkaproducer Module#

A FastAPI dependency that provides an aiokafka Producer.

Classes#

AioKafkaProducerDependency()

A FastAPI dependency that provides an aiokafka Producer.

Variables#

kafka_producer_dependency

The FastAPI dependency callable that provides an AIOKafkaProducer.

kafkit.fastapi.dependencies.pydanticschemamanager Module#

A FastAPI dependency that provides a Kafkit PydanticSchemaManager for serializing Pydantic models into Avro.

Classes#

PydanticSchemaManagerDependency()

A FastAPI dependency that provides a Kafkit PydanticSchemaManager for serializing Pydantic models into Avro.

Variables#

pydantic_schema_manager_dependency

The FastAPI dependency callable that provides a Kafkit PydanticSchemaManager instance for serializing Pydantic models into Avro.

kafkit.fastapi.dependencies.registryapi Module#

A FastAPI dependency that provides a Kafkit RegistryApi client.

Classes#

RegistryApiDependency()

A FastAPI dependency that provides a Kafkit RegistryApi client.

Variables#

registry_api_dependency

The FastAPI dependency callable that provides a Kafkit RegistryApi client.

kafkit.registry Package#

Serialization and desierialization of Avro messsages using the Confluent Schema Registry.

Classes#

Deserializer(*, registry)

An Avro message deserializer that understands the Confluent Wire Format and obtains schemas on-demand from a Confluent Schema Registry.

MessageInfo(id, schema, message)

A message, along with schema information.

Serializer(*, schema, schema_id)

An Avro message serializer that writes in the Confluent Wire Format.

PolySerializer(*, registry)

An Avro message serializer that can write messages for multiple schemas in the Confluent Wire Format.

RegistryBadRequestError(status_code, *args)

An exception if the request is invalid (4XX errors).

RegistryBrokenError(status_code, *args[, ...])

An excpetion if the server is down (5XX errors).

RegistryError

Base exception for Registry errors.

RegistryHttpError(status_code, *args[, ...])

A base exception that includes metadata about the HTTP response.

RegistryRedirectionError(status_code, *args)

An exception for 3XX responses.

UnmanagedSchemaError

An exception for when a schema is not managed by the Registry, and therefore cannot be deserialized into a native Python object.

kafkit.registry.aiohttp Module#

Aiohttp client for the Confluent Schema Registry.

This code and architecture is based on brettcannon/gidgethub See licenses/gidgethub.txt for info.

Classes#

RegistryApi(*, session, url)

A Confluent Schema Registry client that uses aiohttp.

kafkit.registry.httpx Module#

Httpx client for the Confluent Schema Registry.

This code and architecture is based on brettcannon/gidgethub See licenses/gidgethub.txt for info.

Classes#

RegistryApi(*, http_client, url)

A Confluent Schema Registry client that uses httpx.

kafkit.registry.manager Package#

Schema managers register schemas with the registry and enable conventient serialization and deserialization of messages.

Classes#

RecordNameSchemaManager(*, root, registry[, ...])

A manager for schemas embedded in the application itself in conjunction with a Confluent Schema Registry, for the case of a record name subject name strategy.

PydanticSchemaManager(*, registry[, suffix])

A manager for schemas that are represented as Pydantic models in Python, and translated into Avro for the Confluent Schema Registry.

kafkit.registry.sansio Module#

Code to help use the Confluent Schema Registry that is not specific to a particular http client library.

This code and architecture is inspired by brettcannon/gidgethub and https://sans-io.readthedocs.io. See licenses/gidgethub.txt for license info.

Functions#

make_headers()

Make HTTP headers for the Confluent Schema Registry.

decipher_response(status_code, headers, body)

Process a response.

decode_body(content_type, body)

Decode an HTTP body based on the specified content type.

Classes#

RegistryApi(*, url)

A baseclass for Confluent Schema Registry clients.

MockRegistryApi([url, status_code, headers, ...])

A mock implementation of the RegistryApi client that doensn't do network operations and provides attributes for introspection.

SchemaCache()

A cache of schemas that maintains a mapping of schemas and their IDs in a Schema Registry.

SubjectCache(schema_cache)

A cache of subjects in a schema registry that maps subject and version tuples to an actual schema.

CompatibilityType(value[, names, module, ...])

Compatibility settings available for the Confluent Schema Registry, as an Enum.

kafkit.settings Module#

Pydantic BaseSettings for configuring Kafka clients.

Classes#

KafkaConnectionSettings([_env_file, ...])

Settings for connecting to Kafka.

KafkaSecurityProtocol(value[, names, ...])

Kafka security protocols understood by aiokafka.

KafkaSaslMechanism(value[, names, module, ...])

Kafka SASL mechanisms understood by aiokafka.

kafkit.ssl Module#

Support for connecting to brokers with SSL.

Functions#

create_ssl_context(*, cluster_ca_path, ...)

Create an SSL context for a client connecting to secured Kafka brokers.