Topic¶
- class kafkaaggregator.topics.Topic(name: str, registry_url: str = 'http://localhost:8081')¶
Bases:
object
Topic schema and interaction with the Schema Registry.
- Parameters:
name (
str
) – Name of a kafka topic.registry_url (
str
) – Schema Registry URL.
Attributes Summary
Methods Summary
Get topic fields.
Retrieve topic schema from the Schema Registry.
register
(schema)Register an Avro schema with the Schema Registry.
Attributes Documentation
- logger = <Logger kafkaaggregator (WARNING)>¶
Methods Documentation
- async get_fields() List[Field] ¶
Get topic fields.
Parses the topic Avro schema and returns a list of fields with Python types.
- Returns:
fields – List of topic fields.
- Return type:
list
[Field
]
- async get_schema() str ¶
Retrieve topic schema from the Schema Registry.
- Returns:
schema – Avro schema.
- Return type:
str
- async register(schema: str) Optional[int] ¶
Register an Avro schema with the Schema Registry.
If the schema is already register for this subject it does nothing.
- Parameters:
subject (
str
) – Name of the topic subject.schema (
str
) – Avro schema.
- Returns:
schema_id – Schema ID from the Schema Registry or
None
if it is already registered.- Return type:
int
orNone