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: add initial requestThingDescription implementation #1166

Merged
merged 7 commits into from
Nov 29, 2023

Conversation

JKRhb
Copy link
Member

@JKRhb JKRhb commented Nov 21, 2023

This PR adds an initial implementation for the requestThingDescription method.

The implementation details probably still need some additional discussion – looking forward to your feedback here :) For now, I extended the ProtocolClient interface with a new requestThingDescription method that is expected to return a Content object that is deserialized and (supposed to be ) validated by the WoT implementation.

I think this latter part also touches #1055 – in my opinion, there should be some validation happening so that library users can be sure that they always receive a valid Thing Description. Maybe the algorithm(s) in the Scripting API would need to be adjusted then as well.

For now, I only implemented the protocol-specific requestThingDescription method for HTTP and CoAP, if the general design works for you more protocols could be added in follow-up PRs.

@JKRhb JKRhb force-pushed the request-thing-description branch from 5a267b6 to cd96956 Compare November 21, 2023 14:52
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Attention: 90 lines in your changes are missing coverage. Please review.

Comparison is base (a494687) 76.67% compared to head (5aeb45d) 76.33%.
Report is 3 commits behind head on master.

Files Patch % Lines
packages/binding-file/src/file-client.ts 18.60% 35 Missing ⚠️
packages/binding-coap/src/coap-client.ts 27.77% 13 Missing ⚠️
packages/core/src/wot-impl.ts 18.75% 13 Missing ⚠️
packages/binding-coap/src/coaps-client.ts 29.41% 12 Missing ⚠️
packages/binding-http/src/http-client-impl.ts 41.66% 7 Missing ⚠️
packages/binding-mbus/src/mbus-client.ts 71.42% 2 Missing ⚠️
packages/binding-modbus/src/modbus-client.ts 71.42% 2 Missing ⚠️
packages/binding-mqtt/src/mqtt-client.ts 71.42% 2 Missing ⚠️
packages/binding-netconf/src/netconf-client.ts 71.42% 2 Missing ⚠️
...ackages/binding-opcua/src/opcua-protocol-client.ts 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1166      +/-   ##
==========================================
- Coverage   76.67%   76.33%   -0.35%     
==========================================
  Files          80       80              
  Lines       16625    16827     +202     
  Branches     1603     1616      +13     
==========================================
+ Hits        12748    12845      +97     
- Misses       3847     3952     +105     
  Partials       30       30              

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

Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

I would fix Ege's point and I left a couple of comments below. Moreover, I wondering if we can somehow track the different TODOs comments before merging. Maybe when we reched two accepts we can create the issues and do a quick update of the comments with a link to the issues? Finally, maybe I missed why there is so much discrepancy between coaps and coap implementation?

packages/core/src/wot-impl.ts Outdated Show resolved Hide resolved
packages/binding-file/src/file-client.ts Outdated Show resolved Hide resolved
@JKRhb JKRhb force-pushed the request-thing-description branch from e4fad1f to 3a7c741 Compare November 23, 2023 07:31
@JKRhb
Copy link
Member Author

JKRhb commented Nov 23, 2023

Finally, maybe I missed why there is so much discrepancy between coaps and coap implementation?

That is actually because we are currently using two different libraries for CoAP (node-coap) and CoAPS (node-coap-client) since node-coap does not support DTLS :/ A mid-term goal for me personally is definitely to arrive at a unified implementation that covers not only CoAP and CoAPS but also CoAP over TCP/TLS and WebSockets. For the time being, though, I think we need to live with this doubled CoAP implementation.

packages/core/src/wot-impl.ts Outdated Show resolved Hide resolved
Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

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

I think for an initial implementation it is fine as is.

I added some comments below

packages/core/src/wot-impl.ts Outdated Show resolved Hide resolved
packages/binding-file/src/file-client.ts Outdated Show resolved Hide resolved
Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Good enough for now. Let's improve it with future iterations!

@relu91 relu91 merged commit 0a6463b into eclipse-thingweb:master Nov 29, 2023
11 checks passed
@JKRhb JKRhb deleted the request-thing-description branch November 29, 2023 10:57
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.

4 participants