pswamp.streaming.kafka_io

Classes

KafkaIO

Online input/output object to be used by applications.

Module Contents

class pswamp.streaming.kafka_io.KafkaIO(kafka_kwargs, input_topic='pmudata', output_topic=None, status_topic='application.status', t_start=None, command_topic='application.commands')

Online input/output object to be used by applications.

TODO: Remove t_start from arguments.

Parameters:
  • kafka_kwargs – Kwargs that will be used in kafka consumers and producers.

  • input_topic – Kafka topic for input data stream.

  • output_topic – Kafka topic for output data stream.

  • status_topic – Kafka topic for status messages.

  • t_start – Not used anymore.

  • command_topic – Kafka topic for application commands.

input_topic = 'pmudata'
kafka_kwargs
kafka_server
command_topic = 'application.commands'
input_stream
output_topic = None
status_topic = 'application.status'
status_producer
command_consumer
get_sample_data_frame()

Get sample data frame from input (without affecting input stream)

Returns:

Data frame

Return type:

_type_

get_sample_pmu_data_frame()

Included for backwards compatibility

Returns:

Data frame

Return type:

_type_

get_config_frame()

Get config frame

Returns:

Config frame

Return type:

_type_

get_next_data_frame()

Get next dataframe

Returns:

Data frame

Return type:

_type_

get_next_command()

Get command frame

Returns:

Command frame

Return type:

_type_

handle_result(result)

Handle result once analysis completes. If result is not None, the result will be sent to the output topic.

Parameters:

result (_type_) – Result

handle_output(topic, output)
handle_status(message)

Sends the satus message to the status topic.

Parameters:

message (_type_) – Status message

seek_relative_input_offset(n_samples)

Changes the offset of the input data consumer according to the specified number of samples.

Parameters:

n_samples (int) – Number of samples to shift