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

refactor: favor WoT.requestThingDescription instead of general fetch #1183

Merged
merged 6 commits into from
Dec 11, 2023

Conversation

danielpeintner
Copy link
Member

@danielpeintner danielpeintner commented Dec 5, 2023

I think we should use requestThingDescription() instead of the generic fetch() everywhere.

Please let me know whether this change makes sense.

fixes #1055

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8761e64) 76.66% compared to head (237b02c) 76.66%.
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1183   +/-   ##
=======================================
  Coverage   76.66%   76.66%           
=======================================
  Files          80       80           
  Lines       16813    16813           
  Branches     1618     1618           
=======================================
  Hits        12890    12890           
  Misses       3893     3893           
  Partials       30       30           

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

@JKRhb
Copy link
Member

JKRhb commented Dec 5, 2023

Thank you, @danielpeintner, that looks pretty good already :) Let us know if we can support you somehow.

@danielpeintner
Copy link
Member Author

598140c adds also the changes/updates w.r.t. documentation.

Something I noticed. We seem to use different import styles.

e.g. HTTP

Servient = require("@node-wot/core").Servient;
HttpClientFactory = require("@node-wot/binding-http").HttpClientFactory;

vs. CoAP

const { Servient, Helpers } = require("@node-wot/core");
const { CoapClientFactory } = require("@node-wot/binding-coap");

I think we should align the style. Any preference?

@danielpeintner
Copy link
Member Author

I think we should align the style. Any preference?

I opened #1187 to tackle this in a follow up PR

Copy link
Member

@JKRhb JKRhb left a comment

Choose a reason for hiding this comment

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

LGTM! :) Maybe one last thing, though: Should we add a @deprecated tag to the fetch method to guide people to the new requestThingDescription method?

@danielpeintner
Copy link
Member Author

danielpeintner commented Dec 7, 2023

LGTM! :) Maybe one last thing, though: Should we add a @deprecated tag to the fetch method to guide people to the new requestThingDescription method?

I tend to think this is a generic helper method that can be used for any other purpose as well.. we are not claiming it is meant to fetch TDs only. Hence I would argue we can/should keep it as is. What do others think?

@relu91
Copy link
Member

relu91 commented Dec 7, 2023

I tend to think this is a generic helper method that can be used for any other purpose as well.. we are not claiming it is meant to fetch TDs only. Hence I would argue we can/should keep it as is. What do others think?

My take is that we have already the fetch function for that. Now it is supported in Node.js too, so no need to define yet another generic fetching function.

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.

Other than the comment above I think we can merge it.

@danielpeintner
Copy link
Member Author

My take is that we have already the fetch function for that. Now it is supported in Node.js too, so no need to define yet another generic fetching function.

Is the fetch in node-wot really yet another fetch? It is about any protocol while the default fetch is about HTTP only?
Anyhow, If someone feels strongly about I can add @deprecated tag ...
Anyhow, we should definitely add a statement that we have a WoT.requestThingDescription() method that is better suited for requesting TDs. Any opinion? As said, I am fine either way ;-)

@relu91
Copy link
Member

relu91 commented Dec 11, 2023

Is the fetch in node-wot really yet another fetch? It is about any protocol while the default fetch is about HTTP only?

yeah good point, but I would argue that the old fetch was actually an early version (or better prototype) of requestThingDescription function. Anyhow we can talk about this in an issue. Let's merge this meanwhile.

@relu91 relu91 merged commit 1db1c11 into eclipse-thingweb:master Dec 11, 2023
12 checks passed
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.

helper class fetch returning unknown ?
3 participants