Listening to the Kafka stream

You can set up your own Hopskotch client and listen to the messages sent over the corresponding Kafka topic.

There is a lightweight function that does all that for you if you want to offload these 20 lines:

tdemocracy.listen.listen_to_nuclear_stream(start_at=ConsumerDefaultPosition.EARLIEST, until_eos=False, settings=None)[source]

Listen to Nuclear stream, converts older data model versions to current format if possible.

Parameters:
  • start_at (Any) – where to start the stream, either of StartPosition.EARLIEST or StartPosition.LATEST

  • until_eos (bool) – Stop loop when the end of the stream is reached or wait for next message (default)

  • settings (Settings | None) – Settings to use, if not passed reads the corresponding from the environment or a .env file. See tdemocracy.settings.Settings for details.

Return type:

Generator[NuclearTransientReport]

Iterate through the generator to start listening::

for report in listen_to_nuclear_stream():
    # run your classification
    ...