SourceTopic

class kafkaaggregator.topics.SourceTopic(name: str)

Bases: kafkaaggregator.topics.Topic

Represents source topics.

Sets the right Schema Registry URL for source topics.

Parameters:name (str) – Name of the source topic in Kafka.

Attributes Summary

logger

Methods Summary

get_fields() Get topic fields.
get_schema() Retrieve topic schema from the Schema Registry.
names() Return a set of source topic names from Kafka.
register(schema) Register an Avro schema with the Schema Registry.

Attributes Documentation

logger = <Logger kafkaaggregator (WARNING)>

Methods Documentation

get_fields() → List[kafkaaggregator.fields.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]
get_schema() → str

Retrieve topic schema from the Schema Registry.

Returns:schema – Avro schema.
Return type:str
static names() → Set[str]

Return a set of source topic names from Kafka.

Use the topic_regex and excluded_topics configuration settings to select topics from kafka.

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 or None