-
-
Notifications
You must be signed in to change notification settings - Fork 0
Generate and emit CloudEvents #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds CloudEvents support, allowing sensor data to be emitted as CloudEvents messages over MQTT. Key changes include:
- Addition of the CloudEventGenerator in cloudevents.py for generating CloudEvents.
- Enhancements to SensorDataEvent to provide CloudEvent data and topic information.
- Updates in app.py to create a CloudEvent generator and emit CloudEvents alongside sensor data, plus corresponding documentation updates in README.md.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sensor_data_event.py | Introduces methods to format sensor data as CloudEvent payloads. |
| cloudevents.py | Adds the CloudEventGenerator class to generate CloudEvents. |
| app.py | Integrates CloudEvents emission into the main loop and adds utility functions. |
| README.md | Updates documentation to include CloudEvents configuration and payload details. |
Comments suppressed due to low confidence (1)
app.py:150
- The json module is used to dump the CloudEvent payload but is not imported in the diff context. Consider adding 'import json' at the beginning of the file.
payload = json.dumps(ce)
4a0aa5e to
5b20163
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request integrates CloudEvents support into the application to allow sensor data to be emitted as CloudEvents messages over MQTT. It updates the documentation, adds the CloudEventGenerator class and helper methods to convert and emit sensor events as CloudEvents, and integrates these changes into the main application loop.
- Added new methods in SensorDataEvent to generate CloudEvents data and retrieve sensor topics.
- Introduced CloudEventGenerator in cloudevents.py and integrated CloudEvent emission in app.py.
- Updated README.md to document new CloudEvents configuration variables and message structure.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sensor_data_event.py | Added methods to generate CloudEvents data and to retrieve topics. |
| cloudevents.py | Introduced CloudEventGenerator for creating CloudEvents messages. |
| app.py | Added functions to create a CloudEventGenerator and emit CloudEvents. |
| README.md | Updated documentation with CloudEvents environment variables and message format. |
Comments suppressed due to low confidence (1)
app.py:51
- [nitpick] The comment refers to 'configuration event_type', but since this dictionary holds provider configuration fields, it could be clearer if the comment mentioned 'configuration type'. Consider changing it back to 'Define required fields for each configuration type'.
# Define required fields for each configuration event_type
5b20163 to
277843a
Compare
This pull request introduces CloudEvents support to the application, enabling sensor data to be emitted as CloudEvents messages over MQTT. The changes include updates to the documentation, new functionality for generating and emitting CloudEvents, and modifications to existing code to integrate this feature.
Documentation Updates:
README.md: Added details about new environment variables (CE_SOURCE,CE_TYPE,CE_MQTT_TOPIC) for CloudEvents configuration, and documented the CloudEvents message structure and attributes. [1] [2]CloudEvents Integration:
cloudevents.py: Introduced theCloudEventGeneratorclass to create CloudEvents messages based on the CloudEvents specification.sensor_data_event.py: Added methods toSensorDataEventfor converting sensor data into CloudEvents format and retrieving the topic.Application Logic Changes:
app.py:CloudEventGeneratorand added a utility functioncreate_cloudevent_generatorto initialize it with environment variables. [1] [2]emit_cloudeventfunction to publish CloudEvents messages to MQTT.mainfunction to handle the new CloudEvents topic (CE_MQTT_TOPIC) and generator.