AssetProducer#

class openfactory.kafka.AssetProducer(ksqlClient, bootstrap_servers=None)[source]#

Bases: Producer

Kafka producer for sending OpenFactory asset data.

This class wraps a Kafka producer and binds it to a specific asset and topic used by OpenFactory.

ksql#

Client used to interact with ksqlDB.

Type:

KSQLDBClient

topic#

Kafka topic to which asset data will be produced.

Type:

str

asset_uuid#

Unique identifier of the asset being tracked.

Type:

str

__init__(ksqlClient, bootstrap_servers=None)[source]#

Initializes the AssetProducer.

Parameters:
  • ksqlClient (KSQLDBClient) – Client to retrieve Kafka topic info, typically a wrapper over ksqlDB.

  • bootstrap_servers (str) – Kafka bootstrap server address, defaults to value from config.

send_asset_attribute(asset_uuid, assetAttribute, attributes=None)[source]#

Sends a Kafka message representing an asset attribute.

Constructs a JSON message from the given asset attribute and sends it to the Kafka ASSETS_STREAM topic.

Return type:

None

Parameters:
  • asset_uuid (str) – UUID of the asset this producer is associated with.

  • assetAttribute (AssetAttribute) – The asset attribute object containing value, type, tag, and timestamp.

  • attributes (dict, optional) – Additional attributes to include under the “attributes” field in the message.