AssetProducer#
- class openfactory.kafka.AssetProducer(ksqlClient, bootstrap_servers=None)[source]#
Bases:
ProducerKafka 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:
- __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:
- 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.