Aggregator

class kafkaaggregator.aggregator.Aggregator(configfile: Path, aggregated_topic: str)

Bases: object

Create the aggregation model and compute summary statistics.

Given a source topic and a list of field names to exclude from aggregation create the aggregation model and compute summary statistics.

kafka-aggregator adds the aggregation fields time, window_size, and count and computes min, mean, stdev, median, and max statistics for every numeric field in the source topic.

Parameters:
  • aggregated_topic (str) – Name of the aggregated topic.

  • config (AggregatorConfig) – Aggregator configuration

Attributes Summary

logger

Methods Summary

async_create_record()

Sync call to async create_record().

compute(time, messages)

Compute summary statistics for a list of messages.

create_record()

Create a Faust-avro Record class for the aggregation topic.

Attributes Documentation

logger = <Logger kafkaaggregator (WARNING)>

Methods Documentation

async_create_record() Record

Sync call to async create_record().

Get the current event loop and call the async create_record() method.

Returns:

record – Faust-avro Record class for the aggreation topic.

Return type:

Record

compute(time: float, messages: List[Any]) Record

Compute summary statistics for a list of messages.

Parameters:
  • time (float) – The timestamp of the aggregated message, typically the midpoint of the aggregation window.

  • messages (list) – List of messages from which to compute the summary statistics

Returns:

aggregated_message – Aggregated message.

Return type:

Record

async create_record() Record

Create a Faust-avro Record class for the aggregation topic.

Returns:

record – Faust-avro Record class for the aggreated topic.

Return type:

Record