Class StatMsgPackGenerator

Inheritance Relationships

Base Type

Class Documentation

class StatMsgPackGenerator : public ska::pst::stat::StatKafkaMsgGenerator

Abstract class that provides an interface to convert a ‘StatStorage’ to a MsgPack message.

Public Functions

StatMsgPackGenerator(const ska::pst::common::AsciiHeader &_config, std::shared_ptr<StatMsgPackStrategy> _strategy, std::string _dashboard_type)

Create instance of a StatMsgPackGenerator object.

Parameters
  • _config – the configuration for the current scan. This configuration will get values such as EB_ID, SCAN_ID, etc. to be added to the overall message.

  • _strategy – a pointer to a StatMsgPackStrategy that is used to populate the “data_type”, “metadata” and “data” fields of the packed message.

  • _dashboard_type – the name of the dashboard that the generator is for. This is used in logging to give context when multiple generators are being used.

virtual ~StatMsgPackGenerator() = default

Destroy the StatMsgPackGenerator object.

virtual std::string generate_msg(const StatStorage &storage)

generate the MsgPackage message from calculated stats.

This method will pack the common properties of the STAT dashboard MsgPack messages and delegate to the provided strategy for the “data_type”, “metadata”, and “data” values.

The structure of a STAT dashboard message is a map with the following keys:

  • data_type - the value is packed by the provided strategy.

  • beam_id - the ID of the PST beam that is generating this message.

  • eb_id - the execution block ID for the scan.

  • scan_id - the ID of the current scan.

  • metadata - the metadata about the structure of data within the message. The value is packed by the provided strategy.

  • timestamp - the ISO8601 formatted UTC timestamp when this message is created.

  • data - the actual data that will be displayed in the dashboard. The value is packed by the provided strategy.

Parameters

storage – reference to the computed statistics to generate a MsgPack message from.

Returns

a MsgPack message as a string from calculated stats.

inline const std::shared_ptr<StatMsgPackStrategy> &get_strategy()

Get the pointer to the current MsgPack strategy that the generator is using.

Returns

the current strategy the generator is using.

inline const std::string &get_dashboard_type()

Get the dashboard type for the generator.

Returns

the dashboard type for the generator.

Public Static Functions

static std::shared_ptr<StatMsgPackGenerator> create_msg_pack_generator(const ska::pst::common::AsciiHeader &config, const std::string &dashboard_type)

Create a shared pointer to a StatMsgPackGenerator based on configuration and the dashboard type.

This static method is a factory method that creates instances of StatMsgPackGenerator based on the dashboard type. This is allows adding new message pack strategies used by the generator and have it localised to only the generator class and not the overall STAT codebase.

Parameters
  • config – the scan config. This is passed to the StatMsgPackGenerator when it’s constructed.

  • dashboard_type – the type of dashboard the the generator is for. This parameter is used to select the correct strategy to pass through to the constructor of the StatMsgPackGenerator

Returns

std::shared_ptr<StatMsgPackGenerator>

Public Static Attributes

static constexpr uint32_t map_size = 7

The number of entries in the packed message map.