Skip to content
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

feat(capabilities): Add capabilites message type #1049

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lusergit
Copy link
Contributor

@lusergit lusergit commented Jan 21, 2025

Devices can declare to astarte how they will handle future communications by publishing their capabilities on /<realm>/<device_id>/capabilities endpoint. This PR adds both a basic structure for capabilities handling and one capability: purge_properties_compression_format.

Capabilities structure

  • Following feat(capabilities): capabilities topic astarte_vmq_plugin#98 devices can publish on /<realm>/<device_id>/capabilities messages concerning capabilities. Such messages are handled in DUP as a new "capabilities" message type.
  • The capabilities message payload is in BSON format, containing the changes to the current device's capabilities.
  • Capabilities are new columns in the devices table in the database, hence a new migration in astarte house keeping has been added (see 0006_devices_add_purge_properties_compression_format).
  • Capabilities validation is done through Ecto in astarte_core, DUP persists valid changes in the database. Leveraging this, if new capabilities are added in astarte_core, DUP just needs to provide a default value for those capabilities that it needs to use.
  • If the capability message is malformed the device gets forcefully disconnected.

Purge properties compression format

Together with the capabilities structure the purge_properties_compression_format capability have been introduced (see astarte-platform/astarte_core#115). The capability states how astarte should send the purge properties message: if compressed with zlibor in plaintext. The default value for the capability is zlib, which has been chosen for backward compatibility.

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.99%. Comparing base (76adaf5) to head (b0d71bd).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1049      +/-   ##
==========================================
+ Coverage   69.23%   69.99%   +0.76%     
==========================================
  Files         275      253      -22     
  Lines        7193     5599    -1594     
==========================================
- Hits         4980     3919    -1061     
+ Misses       2213     1680     -533     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lusergit lusergit force-pushed the feat/capabilities branch 2 times, most recently from 72bd511 to 92cf9b8 Compare January 22, 2025 11:41
@lusergit lusergit changed the title [WIP] feat(capabilities): Add capabilites endpoint feat(capabilities): Add capabilites message type Jan 22, 2025
@lusergit lusergit changed the title feat(capabilities): Add capabilites message type [WIP] feat(capabilities): Add capabilites message type Jan 22, 2025
@lusergit lusergit force-pushed the feat/capabilities branch 6 times, most recently from 41e59ce to 944f37b Compare January 23, 2025 14:52
@lusergit
Copy link
Contributor Author

lusergit commented Jan 23, 2025

Depends on astarte-platform/astarte_core#115, if merged b0d71bd needs to be updated to just bump up to the latest version of astarte_core

Copy link
Collaborator

@Annopaolo Annopaolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general approach is good! There are however some minor details to iterate on

@lusergit lusergit force-pushed the feat/capabilities branch 3 times, most recently from b57f1c9 to cd7ff67 Compare January 28, 2025 14:55
@lusergit lusergit changed the title [WIP] feat(capabilities): Add capabilites message type feat(capabilities): Add capabilites message type Jan 28, 2025
@lusergit lusergit force-pushed the feat/capabilities branch 2 times, most recently from 5d6ed5d to 790a9f7 Compare January 28, 2025 15:54
@lusergit lusergit requested a review from Annopaolo January 28, 2025 16:06
@lusergit lusergit changed the title feat(capabilities): Add capabilites message type [WIP] feat(capabilities): Add capabilites message type Jan 29, 2025
@lusergit lusergit changed the title [WIP] feat(capabilities): Add capabilites message type feat(capabilities): Add capabilites message type Jan 29, 2025
Copy link
Collaborator

@Annopaolo Annopaolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there!

- Devices can publish on `capabilities` endpoint
- Adds the `purge_properties_compression_format` capability, setting
  whether the device should recive the purge properties compressed with
  zlib or in plain text

Signed-off-by: Luca Zaninotto <[email protected]>
Update astarte core to support `Astarte.Core.Capabilities`

Signed-off-by: Luca Zaninotto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants